budryerson / TFMini-Plus

Arduino library for the Benewake TFMini-Plus and TFMini-S LiDAR distance sensors.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

"Status: Checksum" Galore

WeylandKanada opened this issue · comments

Hi Bud,

I am currently using an Arduino Uno meaning that I am trying to use the Software Serial ports. Also, I am very new to Arduino so if you could dumb down the language that would be great!

When I'm running the sample program you created, I am getting plenty of Status: Checksum's instead of readings. Like this image. I'm not sure how to fix this so could you help me out?
image

I saw the post from about two weeks ago talking about using the hardware serial, but I don't know how to do that, so if you think that is the best solution could you please teach me how to use the hardware serial ports?

Here is the code that I am using
TFMP_example2.zip

Thanks in advance,
Weyland Kanada

Hey Weyland,

That is a lot of errors.

It looks like you modified the example code. Your image shows Data-Frame rate: 200Hz. That should be 20Hz. Please check line 73-78 of your copy of the example code to make that it says FRAME_20. Or change line 92 from delay(50); to delay(5);. The getData() loop is running at 20Hz and the mismatch with the data-fame rate could, possibly, account for some of the errors.

Of course, it is always better to use a hardware serial port, but to do that you are going to need a different Arduino with more than one hardware serial port, such as the Mega 2560. The Uno only has one hardware serial port and that is already being used. Have you considered using I2C mode?

Let me know,

Bud Ryerson
San Francisco

Thanks for the response, Bud!

Ok, so I tried it with a Mega 2560 and it worked perfectly! Thank you! But, for my project I would like to get to at least 200 hz. I saw that the UART mode could do 1000 hz instead of 100 hz, which is why I wasn't going to use the I2C mode. Do you know how I can increase the refresh rate?

Thank you,
Weyland Kanada

Weyland,
The sensor chip in the TFMini-Plus is sampling at about 4KHz. The device then averages the data, builds it into frames and transmits the frames serially at the data-frame rate. You command the device to set its data-frame rate. Since data from the chip is being averaged, the lower the frame rate is, the more accurate the data will be and vice versa. Ideally, you will look in your serial read data buffer for a fresh data-frame no faster than they are being transmitted. This is usually controlled by a loop with a delay. A 5ms delay will result in about a 200Hz read rate. If you want, you can set the frame rate to zero and then trigger the device to transmit one serial data-frame at time. They say you can push the data-frame rate up to about 10KHz, but that would be silly because that's faster than the internal chip is working.
Bud Ryerson
San Francisco

Bud,
I didn't know that the TFMini-Plus was doing all that work. Thanks for letting me know. That should be good enough for what I am doing. I will let you know if I have any other questions.

I really appreciate you helping me out,
Weyland Kanada