14. Networking and communications

Group assignment

Send a message between two projects (assignments made by different students).

Two projects

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.

Research

Using Neil’s stepper driver code and Neil’s ftdi serail communication library, we managed to connect both boards and make them work as a network.

Code

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[0] == 'x' || buffer[0] == 'X' )

Finally, after the board is assigned, the number of steps is performed

step_ncw(number2);

The commands are sento from a pc using a serial connection

Video