Looking for help with TCT40 Sparkfun Ultrasonic Sensor custom driver

Hi -

We are working on a custom driver for the TCT40 Ultrasonic Sensor using the FTC SDK’s I2c interface. We actually got it working, but:

  1. It never reads more than 200 or so (shouldn’t it go to 400?)
  2. After a while it locks and we get an orange message saying the device can’t be found that persists until we power cycle the control hub. I don’t have the exact error on me, but it appears to be a no acknowledge sort of error, which seems odd since we are just reading a register.

We are a bit frustrated by the lack of documentation. From the Arduino code, we pieced together that we need to read 2 bytes at register 0x01. But that code has a return value that implies the length of data that’s returned, which implies that the data we receive may be dynamic and maybe that’s part of our problem. Or maybe not. But the fact that the value never exceeds 200 makes me wonder if we are only getting one byte (or if my java conversion of the arduino bitwise code is wrong - can I use bytearraytoshort?).

Finally, we are going to test using readWindow with repeated reads with the hope that this helps, but any input would be much appreciated.

For anyone following, I think we solved it. We start a timer in the driver and only perform a read if 500ms has elapsed since the last one (we were reading every 100ms or less in our test opmode). This a) got rid of the error (it appears) and b) stopped us getting noisy readings (random 0 readings, for example). We will tune the wait to find the min that works consistently.

Now we are finding the error grows with distance - we plan to test that systematically.

2 Likes