Library work well with TF mini but error for TF mini Plus
my controller is Arduino Pro mini the library works well with TFmini model
36 cm sigstr: 119 36 cm sigstr: 120 36 cm sigstr: 120 36 cm sigstr: 119 36 cm sigstr: 120
but when I connect to TFmini plus (a model come with IP56 enclosure) the error occurred repeatly.
Last error: ERROR_SERIAL_BADCHECKSUM 65535 cm sigstr: 65535
Remark: TFmini plus work well with Benewake TF test software
That's interesting... can you point me to a datasheet for the TF mini plus?
http://en.benewake.com/res/wuliu/docs/15487893679657874SJ-GU-TFmini%20Plus-01-A02-Datasheet_EN.pdf
here is the page for datasheet download
Here's a datasheet from Sparkfun: https://cdn.sparkfun.com/assets/2/b/0/3/8/TFmini_Plus-01-A02-Datasheet_EN.pdf
It looks like it's using very different commands than the TF mini. Feel free to update the driver (I would make a second class, TFMiniPlus). Or if someone sends one my way, I can try to do this update in between things.
thank Peter, I have tried to skip checksum byte comparison in the library. the output with some error as shown below:
204 cm sigstr: 1354 204 cm sigstr: 1351 204 cm sigstr: 1350 52569 cm sigstr: 17408 (error) 22873 cm sigstr: 204 (error) 204 cm sigstr: 22855 205 cm sigstr: 1354 204 cm sigstr: 1347 205 cm sigstr: 1356 52313 cm sigstr: 17152 (error) 22988 cm sigstr: 52057 (error) 204 cm sigstr: 1360 203 cm sigstr: 1356
I notice that no matter the output distance is correct or not, checksum byte comparison will always be different.
checksum : checksumByte 0x69 : 0x59 44 cm sigstr: 5598 0x67 : 0x9C 22828 cm sigstr: 2390 (error) 0x62 : 0x6B 44 cm sigstr: 5591 0x68 : 0x0 44 cm sigstr: 23000 0xBC : 0x15 22828 cm sigstr: 11353 (error) 0x9B : 0xFB 2390 cm sigstr: 5593 (error) 0x68 : 0x59 44 cm sigstr: 5597 0x74 : 0x98 22873 cm sigstr: 44 (error) // I don't know why...
I found the cause that make checksum error.
// Store running checksum if (i < TFMINI_FRAME_SIZE-2) { checksum += frame[i]; }
code in file TFmini.cpp Line No. 140
I replace 2 with 1
// Store running checksum if (i < TFMINI_FRAME_SIZE-1) { checksum += frame[i]; } it works normally now.
Thanks thats worked for me to.
In addition to Ratthanin's check sum change, I found I had to change takeMeasurement() also.
From
uint16_t dist = (frame[1] << 8) + frame[0]; uint16_t st = (frame[3] << 8) + frame[2];
To
uint16_t dist = (frame[1] << 7) + frame[0]; uint16_t st = (frame[3] << 7) + frame[2];