Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library work well with TF mini but error for TF mini Plus #9

Open
VaAndCob opened this issue Mar 6, 2019 · 8 comments
Open

Library work well with TF mini but error for TF mini Plus #9

VaAndCob opened this issue Mar 6, 2019 · 8 comments

Comments

@VaAndCob
Copy link

VaAndCob commented Mar 6, 2019

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

@PeterAJansen
Copy link
Contributor

That's interesting... can you point me to a datasheet for the TF mini plus?

@VaAndCob
Copy link
Author

VaAndCob commented Mar 6, 2019

@PeterAJansen
Copy link
Contributor

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.

@VaAndCob
Copy link
Author

VaAndCob commented Mar 6, 2019

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

@VaAndCob
Copy link
Author

VaAndCob commented Mar 6, 2019

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...

@VaAndCob
Copy link
Author

VaAndCob commented Mar 6, 2019

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.

@sfambach
Copy link

sfambach commented May 1, 2020

Thanks thats worked for me to.

@DaveDixon
Copy link

DaveDixon commented May 29, 2020

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];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants