Clear Filters
Clear Filters

slrt USB data stream from Arduino to speedgoat

8 views (last 30 days)
Hello everyone,
I have some issues with the implementation of a simple data stream from an external device via USB to the Speedgoat.
Setup:
Arduino Nicla Voice
Speedgoat Baseline M
The task is pretty simple. I would like to stream sensor data (IMU) from Arduino to my target machine. My current implementation does not work properly. I am pretty sure something is wrong with my FIFO buffer configuration of the target machine. The stream does not work every time. I have to plug off the Arduino and restart the system until I get the stream. In other cases I just see a stream of zeros (acc_x/y/Z, gyr_x/y/z) on the target.
Code on Arduino (loop):
// code above
int16_t acc_x_raw, acc_y_raw, acc_z_raw, gyr_x_raw, gyr_y_raw, gyr_z_raw;
//
...
Serial.print(acc_x_raw);
Serial.print(",");
Serial.print(acc_y_raw);
Serial.print(",");
Serial.print(acc_z_raw);
Serial.print(",");
Serial.print(gyr_x_raw);
Serial.print(",");
Serial.print(gyr_y_raw);
Serial.print(",");
Serial.println(gyr_z_raw);
delay(10);
The Arduino sends the data with round about 100 Hz (Baudrate 115200). Currently, I use a comma separation. It should be a constant IMU data stream. It works properly in the Arduino IDE. Plug in USB, stream starts...
Target runs with 500 Hz. As I understood, it is not that bad to read faster than write. At least the buffer cannot overflow this way. Is that correct?
I am not that familiar with FIFOs, that is why I didn't get it to work on the target. This is how my target configuration looks like:
This is the configuration menu of each block:
I started to read the reference manual but do not understand all the steps like: FIFO size/8-bit unit null termination etc. That is my problem. AFAIK, the general serial port is configured properly. (Baud/Number of bits/Parity). The above configuration works (after a few plugs in/off, restart model on target, which is very annoying), but honestly I do not know why. Does someone have initial tips for this streaming problem? What would be the simplest/efficient (data size) implementation. My naive approach would be to send a binary data stream of 16 bit * 6 signals = 96 bits.
My undestanding of the blocks:
Baseboard Serial F1:
Receive FIFO size is a FIFO with 1024 bits (my interpretation, if tranfered data is > 1024 -> overflow)
Transmit Data Type ??
FIFO read:
Reads all the FIFO buffer in one call (here 500 Hz). Reads until delimiter (CR/LF)
8-bit unit null terminated ??
ASCII Decode:
How to interpret data stream
For me, the first line make sense. But why do I need the number of variables, it is implicitly included in "Format string".
Thank you very much.

Answers (1)

UDAYA PEDDIRAJU
UDAYA PEDDIRAJU on 25 Jan 2024
Hello dundan,
It sounds like you're encountering issues with consistent data streaming from an Arduino to a “Speedgoat Baseline M system” via USB. Here are some tips and clarifications that might help you troubleshoot the problem:
  • The Receive FIFO size should be large enough to accommodate the burst of data you expect to receive. If your Arduino sends data at around 100 Hz and your “Speedgoat” target machine is running at 500 Hz, the FIFO size needs to handle at least 5 times the data packet size you send from the Arduino to avoid overflows. In your case I would suggest you double the FIFO size for safety.
  • Transmit Data Type: This is typically the data type that the “Speedgoat” will use to send data out. Since you're focusing on receiving data from the Arduino, this may not be critical for your current setup.
  • The FIFO read block should be configured to read the data at an appropriate rate. If you're reading faster than the Arduino sends data, you need to handle cases where the FIFO might be empty. The delimiter should match the end-of-line character that the Arduino sends (“Serial.println” by default sends a newline character).
  • 8-bit Unit Null Terminated: This setting is relevant when dealing with ASCII strings. If your data is sent as ASCII text, each value will be a null-terminated string, which means the end of the text string is marked by a null character (0x00). This is not applicable if you're sending raw binary data.
  • Implement a mechanism to ensure that the data stream is synchronized between the Arduino and “Speedgoat”. This may involve sending a header or a specific byte sequence that the “Speedgoat” can recognize as the start of a new data packet.
  • Debugging: Use tools like LEDs on the Arduino or logging on the “Speedgoat” to indicate the status of the data stream and help identify where the process is failing.
I hope with these you’ll be able to figure out the issue!

Categories

Find more on Arduino Hardware in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!