TFMini Plus serial interface to RoboRIO

Hi there all!
I was hoping someone out there could help me with interfacing the TFMini Plus to the RoboRIO via rs232 port.
I have successfully tested the sensor with the test program and an FTDI cable on my laptop and all is well. I also wrote simple arduino code to read the 2nd and 3rd bytes as the manual states and displayed them so I know the arduino can do it easily.

I must be doing something terribly wrong because when I run a simple bit of code to pull out the first 4 bytes, I get a stationary 83 on the first two (which are supposed to be headers reading 0x59) and then the data bytes are all over the map. From positives to negatives etc. None of which is logical.

I have disabled the Console Out as suggested on other forums and this enabled me to actually get input data… but again, pretty useless data at that.

Any help is greatly appreciated!! Oh and here are the few crued lines of code I’m using to start with. I’m capturing the data from the first few bytes and sending to the smart dashboard for viewing just to try to make heads or tails of it;

public class TFMini {

private int Distance;

public byte b0, b1, b2, b3, b4;

public byte[] i;

public SerialPort serial1 = new SerialPort(115200, Port.kOnboard,8, Parity.kNone, StopBits.kOne);

public TFMini() {

    

}

public int get() {

    // serial1.setReadBufferSize(9);

  

    i = serial1.read(9);

    

    b0= i[0];

    b1= i[1];

    b2= i[2];

    b3= i[3];

    b4= i[4];

    Distance = (i[2]+i[3])*256;

    serial1.reset();

    return Distance;

    

}

                         

}

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.