Newer
Older
# Arduino code
The code was written to be as fast as possible, mimizing useless operations and using conditionnal compilation (optimises the code on the PREPROCESSOR level).
When using the code, just provide the PORT you use (PORTA or PORTB by adapting the appropriate registers in the #define section), and provide the right pin number on that port for OUT_STEP_PIN. OUT_DIR_PIN is implicitely the next pin (this is to save time).
Make sure the proper RX/TX pin are selected in the arduino environnement for your board. (5/4 or 8/9 for TX/RX respectively).
Then select the proper BAUDRATE by adapting it in the #define section too.
# Worst case scenario testing
We tried to communicate through UART as fan as we can, by using the 'T' motor (a fourth motor, the 2 MSB of the UART signal) and PORTB0 as the OUTPUT step pin. This will require the maximum shifting (6 steps) and will thus be the worst case scenario.
With this configuration. We got the maximum standard baudrate at 460800 without getting troubles. You can then see that the LEDs react about at the third bit of the next message, meaning you are close to half period. Nearly dubbling the frequency by butting it at 1MHz works nearly all the time but some steps are missed. (aout 1/25 ratio).
Using the X motor (2 LSB) doesn't change the reaction time that much so probably the worst case scenario we just exposed can be considered as standard scenario.