Adds support for a generic bipolar stepper motor controller such as the L293D.
This uses 4 output pins to control the two coils as well as an optional output pin which is set high to enable the motor.
If you are using an L293D then here is the schematic:-
The enable pins are pulled high using a 10k resistor just in case you choose not to use the enable logic. If you wish to be able to disconnect the motor (ie turn off the supplied current) then specify an enable output pin from your board and connect it to pins 1 and 9.
BIPOLAR MAKE_BIPOLAR(inverted,steps, accel, every, coil1A,coil1B, coil2A,coil2B, enable, mode)
Create a bipolar stepper motor controller.
The parameters are as follows:
- inverted - TRUE or FALSE - if the motor is turning in the wrong direction then flip this parameter value
- steps - The number of steps per revolution. If you are half stepping the motor then don't forget to multiply the actual value for the motor by 2
- accel - A number from 0 to DRIVE_SPEED_MAX. When the motor is changing speed it will limit the acceleration to this value
- every -The number of timer ticks between accelerating by the 'accel' value above
- coil1A - The IOPin used to connect to one end of coil 1
- coil1B - The IOPin used to connect to the other end of coil 1
- coil2A - The IOPin used to connect to one end of coil 2
- coil2B - The IOPin used to connect to the other end of coil 2
- enable - The IOPin used to connect to the ENABLE pin, or may be 'null' if you don't need that functionality
- mode - this sets the stepping mode and must be either FULL_STEP or HALF_STEP
Let's assume that we have a stepper motor with 200 steps per revolution and that we choose to use half stepping mode to achieve 400 steps per revolution. Also assume we configure the driver to produce a maximum of 300 pulses per second. This means that the maximum speed of the motor will be 0.75 revolutions per second (ie 45 rpm).
If we used 'accel = 10' and 'every = 2' then this means the motor speed will increase by 10 units every 150th of a second (300 pulses per second divided by 2) until it reaches the requested speed. Note that values of 'accel = DRIVE_SPEED_MAX' and 'every = 1' will effectively give infinite acceleration.
We will use pins A0 to A3 for the coils and leave the enable unused.
BIPOLAR motor = MAKE_BIPOLAR( FALSE, 200, 10, 2, A0, A1, A2, A3, null, HALF_STEP);