Circular Buffers

In order for our code to function properly, we need to have different data streams that are able to run independently. For this we need to use circular FIFO(first in first out) buffers to compensate for the continuous inputs and outputs. Using these buffers in our code allows us to simultaniously perform these input and output operations when the mbed has to send data to another computer and to another source (in our case, motors). This process avoids stall time and doesn't call any interrupts on either individual stream when the program is running.

A basic demonstration can be viewed here: /media/uploads/avbotz/circularbuffers.cpp

In the sample code we can see that two serial ports are set up, A and B which are sending signals at different rates. When running the code, characters a, b, and c are constantly sent within Serial B and it can be observed that Serial A is performing its own operations by adding input commands from a computer to a buffer.

Code implemented in our project:

Code for computer communication (pc.cpp): /media/uploads/avbotz/pc.cpp

(pc.h): /media/uploads/avbotz/pc.h

Code for motor communication (motor.cpp): /media/uploads/avbotz/motor.cpp

(motor.h): /media/uploads/avbotz/motor.h


Please log in to post comments.