Adds support for a Pololu A4983 stepper motor controller.
This powerful controller can supply up to 2A per coil and contains a chopper circuit with a potentiometer to limit the current. Make sure you read the manual
as to how to use this as its too complex for me to describe here.
You can either power the board from your micro controller regulated supply or you can power it from the same battery as you are using to power the motor.
To power it from your micro controller then attach one of the Vdd pins to the regulated supply on your micro controller. This should be the same voltage that is used by the micro controller. For example: the Axon has both a 5V regulated supply and a 3.3V regulated supply but, since the ATMega640 is powered from the 5V supply then you must connect Vdd to the 5V supply.
To power it from the motor battery then leave Vdd unconnected and instead you will need to short out one of the solder jumpers on the board. For example: the ATMega640 on an Axon uses 5V so you should short out the 5V jumper on the A4983 board.
POLOLU_A4983 MAKE_POLOLU_A4983(inverted, steps, accel, every, direction,pulse,reset,enable)
Create a Pololu A4983 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 micro stepping the motor then don't forget to multiply the actual value for the motor by the number of microsteps you have set up via the three pins
- 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
- direction - The IOPin used to connect to the DIR pin
- pulse - The IOPin used to connect to the STEP pin
- reset - The IOPin used to connect to the RESET pin, or may be 'null' if you don't need that functionality
- enable - The IOPin used to connect to the ENABLE pin, or may be 'null' if you don't need that functionality
Let's assume that we have a stepper motor with 200 steps per revolution and that we have configured the A983 to use half stepping 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 and A1 for direction and pulse and leave the reset and enable unused.
POLOLU_A4983 motor = MAKE_POLOLU_A4983( FALSE, 400, 10, 2, A0, A1, null, null);