Go Down

Topic: Generating 0~3Mhz with pwm (Read 500 times) previous topic - next topic

DrVoid

Hi guys.
I need some help
I want to generate 0~3 Mhz pulse with duty rate 50% for my steppingmotor driver.
And i read "secret of PWM"
I need two parts that generate 0~3Mhz for my steppingmotor driver cause I want the steppingmotor driver to run two motors

ard_newbie

#1
Apr 21, 2018, 11:06 am Last Edit: Apr 21, 2018, 11:39 am by ard_newbie
For full step drive (always 50% duty cycle), you will need 4 synchronized output signals, e.g. PWMH0, PWML0, PWMH1, PWML1. Synchronize your 4 PWM signals by using PWM_SMMR register in 2-bit gray code. PWMH0 frequency will automatically monitor the 3 others, providing PWM channels 0 and 1 have been previously enabled.

Note that you can do the same for PWMH2, PWML2, PWMH3, PWML3 (second stepper motor).

See this thread for some more explanations:
http://forum.arduino.cc/index.php?topic=462272.0

DrVoid

#2
Apr 21, 2018, 12:21 pm Last Edit: Apr 21, 2018, 12:22 pm by DrVoid
Umm thanks to ard_newbie
i think need more explain.
My steppingmotor driver request 0~3Mhz(0~18000Rpm) to setting speed of steppingmotor.
Forexample i send to motordriver 300000hz(duty rate 50%) then motor will spin 1800RPM.
that's why i wrote the question about generating 0~3mhz.
exctually i need 0.3Mhz but if i use 10Microstep then may be i needed.

ard_newbie

You should begin by learning and understanding how works a stepper motor. There are numerous relevant tutorials for that.

Micro stepping is not Full stepping. For micro stepping, you will need the PWM synchro feature and e.g. 16 steps for each period. See this thread, reply 6:

http://forum.arduino.cc/index.php?topic=537904.msg3692270#msg3692270

DrVoid

Ofcourse i know about how microstep moves.
what i want is how to generate 0~3mhz (duty rate50%).
mine only needs pulse to run. also i know about speed profiles.

ard_newbie


DrVoid

Oh assume what i want.
have a question about codes.
in loop i made the function of control hz?
can alloc another pin to generate another hz?
i understand your code generate one pulse.

ard_newbie

in loop i made the function of control hz?
can alloc another pin to generate another hz?
Yes and yes.

DrVoid

Very Thank you to ard_newbie
Really helpful.
Some of my friends say it is hard to write code.

Go Up