04-23-2013 10:34 AM
last thing...
from what i can gather pulsein returns a int of microseconds to the serial.write function. im pretty sure that gets turned into binary then goes to matlab and gets deciphered.
similarily, sonar.ping() returns an int of ms to the serial.write function. i have kept everything identical except for where retval gets its data from. Any ideas?
its a bit diff now ps, thought id convert to cm on the arduino and just try and display the value straight out of the serial port.
cheers
04-23-2013 05:11 PM
The changes that I made should fix your original version using that library. I would not recommend using the conversion to distance on the Arduino because retVal is an integer and, IIRC, the return value of ping_cm() is not an integer. So, when you assume it's an integer and then convert it to a double in LabVIEW, it will not interpret the value correctly.
-----------
Serial.write( (retVal & 0xFF) ); // writes the first 8 bits to LabVIEW
Serial.write( (retVal >> 😎 ); // writes the second 8 bits to LabVIEW.
04-23-2013 05:43 PM
ok so i just tried your updated library and just swapped retval from a pulsein to sonar.ping. all the sonar ping functions are unsigned ints, and so is retval, and im guessing pulsein returns an unsigned in as well.
when i run the labview, the tx and rx are constantly blinking very quickly but there isnt anything in the chart. no amplitude at all.
i dont understand why this isnt working?
cheers