04-06-2017 06:08 AM
Hi
I want to control speed of bipolar stepper motor with micro stepping driver and arduino board,
I have already written a code for it in just one speed,I need 3 pulse , first one is true pulse for enabling driver , second one is for direction and third one is pwm pulse ( but duty cycle isn't important) as I realized for changing the speed of this stepper I only need to change the pwm frequency (frequency of pulse) , what should I do to change the frequency?? do I need to change arduino board frequency?
is there any other way to change the frequency without changing board freqcuency??
note that my code is working well without error I wanna improve it .
I will attach my code
tnx.
04-21-2017 10:53 AM - edited 04-21-2017 11:16 AM
I've done this sort of thing with LabVIEW, arduino and a stepper motor.
I would recommend that instead of using PWM to control the frequency, you just use a digital output pin (like you are doing for the "Dir") and then:
The frequency of the pulse cycle will be approximately 1000/(2n). You can then set the value of n using a control or a calculation.
The attached snippet shows how I would do this in the 'clockwise' case. Ideally, I would break this out so that clockwise and counterclockwise use the same code to do the step High, step Low, and differ only in the direction bit.... but since your code is working, I don't want to disrupt it too much.
04-21-2017 11:52 AM - edited 04-21-2017 12:02 PM
Just for fun, I took a stab at rewriting the whole thing.
I removed the redundant code and the local variables. I hope this looks simpler.
If it were me, I'd also take out the sequence structure because it just takes up space and the wires between Set Direction and Step High, Step Low ensure that these will operate in the correct order. I left it in because I thought it makes it a little more readable to separate these two.
04-26-2017 10:37 AM
@LandJBelenky wrote:
Just for fun, I took a stab at rewriting the whole thing.
I removed the redundant code and the local variables. I hope this looks simpler.
If it were me, I'd also take out the sequence structure because it just takes up space and the wires between Set Direction and Step High, Step Low ensure that these will operate in the correct order. I left it in because I thought it makes it a little more readable to separate these two.
Thank you for your reply, I really appreciate it.
I have solved my problem and controlled the speed of stepper.
as you mentioned we need to set high and low with some frequency , for this purpose I have used "Digital write square wave" block and its working correctly. this block produce square wave with 50% duty cycle , and we can set frequency as input, so we can change speed of stepper as well.
digital write square wave address: makerhub>>Linx>>Peripherals>>Digital>> digital write square wave.
04-28-2017 09:37 AM - edited 04-28-2017 09:40 AM
From a programming point of view, I think your solution makes a lot of sense because it involves less activity in LabView and just lets the arduino do all the work of managing the pulse HIGH, pulse LOW repetition. The solution I suggested would require that the LabVIEW program keep running to generate those pulses one at a time.
The one thing I worried about is what would happen if the LabView program stops before it sends a DISABLE or turns off the square wave. Or, if the connection between the computer and the arduino is lost. The arduino might keep pulsing, and the motor would keep moving, with no easy way to regain control. Depending on your application, that could be bad, or even dangerous.
03-27-2018 04:27 AM
Hello guys,
Sorry to reply to this post after a long time.
I am currently working on a project controlling linear actuators powered by stepper motors.
Even though I can control the direction and speed of the motor I cannot control the steps it will do.
I remember on LIFA there was StepsToMove function?
How can I specify the exact steps? Which block should I use?
The duration should be an answer to that. (calculating frequency x time to get distance) but it does not work. The motor continues after the specified time.??
01-21-2019 08:19 AM
Hi,
Could you please send me the vi file? tnx in advance
@Alirezap30 wrote:
@LandJBelenky wrote:
Just for fun, I took a stab at rewriting the whole thing.
I removed the redundant code and the local variables. I hope this looks simpler.
If it were me, I'd also take out the sequence structure because it just takes up space and the wires between Set Direction and Step High, Step Low ensure that these will operate in the correct order. I left it in because I thought it makes it a little more readable to separate these two.
Thank you for your reply, I really appreciate it.
I have solved my problem and controlled the speed of stepper.as you mentioned we need to set high and low with some frequency , for this purpose I have used "Digital write square wave" block and its working correctly. this block produce square wave with 50% duty cycle , and we can set frequency as input, so we can change speed of stepper as well.
digital write square wave address: makerhub>>Linx>>Peripherals>>Digital>> digital write square wave.
01-21-2019 01:18 PM
@asatarsh wrote:
Hi,
Could you please send me the vi file? tnx in advance
The above image is a LabVIEW snippet, and is for all practical purpose very close to the VI (except for VI options, connector pane assignments, etc.). See if that works for you.