Hi,
I have interfaced this RoboPeak Lidar http://www.robopeak.com/blog/?cat=5
with a Teensy 3.2. Teensy is getting data from the Lidar serial port (115200 baud) @ 2000 samples
per sec and then formatting and sending it out on another serial port.
The data format is as follows:
A####R####lf where A = token for angle R = token for range
Feeding the output into a Serial monitor Putty program on my computer clearly shows the
data streaming out correctly.
I want to display the data on a ILI9341 TFT display but at this point I am not even
successful at reading and parsing the incoming data. For this I am also using another Teensy 3.2
interfaced to the TFT display using SPI.
My code in the main loop below is reading the serial data from the port and parsing the incoming
character string. When the line feed is received, the characters arrays are converted to integers.
Currently, nothing is displaying on the monitor.
I have tried with another non-scanning lidar with the same data format and I am successful
at reading and displaying the data.
Questions:
1) What am
2) Is the data rate too much for Teensy?
3) Is there another approach I can take?
As an aside, I sometimes have problems with Teensy serial monitor ports.
Sometimes they work, other times they don't.
Any help or suggestions would be greatly appreciated.
Thanks in advance!
I have interfaced this RoboPeak Lidar http://www.robopeak.com/blog/?cat=5
with a Teensy 3.2. Teensy is getting data from the Lidar serial port (115200 baud) @ 2000 samples
per sec and then formatting and sending it out on another serial port.
The data format is as follows:
A####R####lf where A = token for angle R = token for range
Feeding the output into a Serial monitor Putty program on my computer clearly shows the
data streaming out correctly.
I want to display the data on a ILI9341 TFT display but at this point I am not even
successful at reading and parsing the incoming data. For this I am also using another Teensy 3.2
interfaced to the TFT display using SPI.
My code in the main loop below is reading the serial data from the port and parsing the incoming
character string. When the line feed is received, the characters arrays are converted to integers.
Currently, nothing is displaying on the monitor.
I have tried with another non-scanning lidar with the same data format and I am successful
at reading and displaying the data.
Questions:
1) What am
2) Is the data rate too much for Teensy?
3) Is there another approach I can take?
As an aside, I sometimes have problems with Teensy serial monitor ports.
Sometimes they work, other times they don't.
Any help or suggestions would be greatly appreciated.
Thanks in advance!
Code:
#include <ILI9341_t3.h>
#include <font_Arial.h>
#include <SPI.h>
#define TFT_DC_PIN 9
#define TFT_CS_PIN 10
ILI9341_t3 tft = ILI9341_t3 (TFT_CS_PIN, TFT_DC_PIN);
//-----------------------------------------------------------------------------------------------
void setup()
{
Serial.begin(115200);
//while(!Serial);
delay(3000);
Serial1.begin (115200); // In coming Serial Data from LidarLite
delay(1000);
tft.begin();
tft.setRotation (1);
tft.setTextSize (1);
tft.fillScreen (ILI9341_BLACK);
}
//-----------------------------------------------------------------------------------------------
// Main Loop
// Incoming Serial Data format: A####R####lf
// where A = angle R = Range (deg)
//-----------------------------------------------------------------------------------------------
void loop()
{
int iAng, iRng;
int cnt;
char cChar, cFld;
char cAng[7], cRng[7]; // Max 6 digits plus null string terminator
if (Serial1.available() > 0)
{
while (Serial1.available() > 0)
{
cChar = Serial1.read();
Serial.print(cChar); //NOTHING GETS PRINTED HERE!!!
if (cChar == '\n') // New Line
{
cRng[cnt] = '\0'; // Terminate string for Range
iAng = atoi(cAng); // Output: Angle -90 to +90 deg
iRng = atoi(cRng); // Range 0 to 400 cm
cnt = 0;
}
else if (cChar == 'A') //Field delimiter Angle
{
cFld = cChar;
cnt = 0;
}
else if (cChar == 'R') //Field delimiter Range
{
cAng[cnt] = '\0'; //Terminate string for Angle
cFld = cChar;
cnt = 0;
}
else //Build String with numerical values
{
if (cFld == 'A') cAng[cnt] = cChar; // -90 to +90 degrees
else if (cFld == 'R') cRng[cnt] = cChar; // 0 - 400cm
cnt++;
if (cnt > 6) cnt = 6; //String size - don't overflow
}
}
}
delay (10);
}