5 is the value I found by testing, it give me approximately 7 frames/sec (the driver is set to 1/4 steps, I have a smoother move and less vibrations in this mode). I need a range from 2 to 7 fps, I still have to set the higher value, 300 is too slow.
You wrote that there is a rotary switch on the projector. It would be important to know which contact is active in which position. Then you can evaluate it reasonably.
For an acceleration, the moment of switching from STOP → START and vice versa must be recognized.
That' really fast. Even if it's not the real stepping rate, because of loop cycle time.
Anyway, I'm not surprised that the stepper can't do it without a ramp.
I have recognized 3 contacts that are active on the rotary switch on 3 positions : Forward, Stop and Backward (I didn't use Backward in the code, as I could simply use "Else" for the Direction HIGH or LOW). I have a contact active on the ON/OFF switch too.
Could it be problematic somehow? Would you suggest to switch for 1/2 step Mode?
I would create a binary table, which contact is open/closed in which rotary position.
In the sketch you read all contacts and you can see in which position the rotary switch is. And you can see when it was moved to start or stop the motor.
This is much clearer and more concise than that many if / else
Yes, that's true. MobaTools is designed to drive multiple steppers and it limits the speed to not overload the AVR processor. Because you only need one stepper, you can loosen this 'brake' by changing an define in MobaTools.h.
Change this line
#define CYCLETIME 200 // Min. irq-periode in us ( default is 200 ),
to
#define CYCLETIME 80 // Min. irq-periode in us ( default is 200 ),
and you should get the speed of your first sketch.
( There are several similar lines for the different supported processors. You must change the line with default is 200 )
Yes it is. The enable pin is managed by the lib in this case. 'attacheEnable' tells the lib to do so, and it tells the lib which pin and if it's LOW or HIGH active.
it took me some time to find out how to modify the library but I could change this value to 80.
The speed increased indeed but the motor doesn't stop any more once started and the pot is not controlling the speed. I modified back to 200 and went back to the previous situation with limited speed. Is there something I could have done wrong?
I thought I tried it with 80, but maybe I'm wrong. Try with 100 that should do. I'm shure, that I tried it with 100 already. If it still doesn't work I have to see what's wrong.
I didn't have to much modify . Just the speed and the buttons.
I just didn't manage to work on the buttons with MoToButtons and removed this part to go back to what I wrote first for the button. It's probably not the most elegant way to do but it works. All the controls are working like with the original motor.
I am just a bit worried because I start to loose the 12V Power connection on the Driver, the breadboard is getting hot on those points and I had to change the position of the Driver to have a new line on the board. I guess the board can not handle 12V / 1.2A, it's a cheap one I bought on Ebay, without datasheet or mention of the max power.
I think the contacts of your rotatry switch behave different from buttons as the are assumed in the example.
A Breadboard is generally not a good idea fo such currents. Did you place a capacitor of at least 100µF directly at the Vin and Gnd Pins of the driver? This is important too.
Yes, I guess it will better once soldered on a real board. For now I remade the circuit just with wires, the connection is stable.
I have a capacitor yes but only 47µF, I can change it for 100µF .
I also realized that the new sketch using the Mobatool library is giving me some smalls bumps/changes in speed. I initially thought it was because of the bad connection with 12V but I tried again to run my first code and the speeds are totally stable (but no acceleration of course).
Any idea of what could be the problem? I tried to go back to #define CYCLETIME 200 in MobaTools.h just in case but it didn't improve the speed stability.
Audible is normal, since there is - especially at high speeds - an audible jitter on the stepping pulses. This is due to the fact that the pulses are only generated in a grid of 200 - or in your case 100 µs. If you change the speed, the jitter changes too, and that is audible.
Due to the inertia of the motor, this should not lead to an actual jitter in the speed.
But there are some drawbacks in your code. You should not call rotate(1) in every loop. rotate(1) is a command to start the motor. Then it will rotate without any further call of this command.
Remember wether you started it already - forward/backward - or stopped it. And only if you change the state than call the acoording command.
It will probably work anyway, but it's not the way it should be.