14. Networking and communications¶
Send a message between two projects (assignments made by different students).
Stepper motor drivers¶
Since two of us worked on sterpper motor drivers, and we need to work for machine design assignment, we created a wired network with the two drivers, and used serial communication to drive both boards.
Serial communication requires Rx and Tx pins:
#define RX PA6 // *** rx pin on the 44 #define TX PA5 // *** tx pin on the 44
We also changed the variable bit_delay_time to 102 for 9600 baud communication
#define bit_delay_time 102 // bit delay for 9600 with overhead
Then, set the boards to listen to the serial pins and store the incoming data
get_char(&serial_pins, serial_pin_in, &chr); buffer[index++] = chr;
Each board’s address is given by the axis they ara driving, one is ‘x’ and the other is ‘y’, so an if statement is used to find which board is addressed.
if ( buffer == 'x' || buffer == 'X' )
Finally, after the board is assigned, the number of steps is performed
The commands are sento from a pc using a serial connection