LabVIEW Interface for Arduino Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Back to basics...

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

0 Kudos
Message 11 of 13
(810 Views)

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.

0 Kudos
Message 12 of 13
(810 Views)

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

0 Kudos
Message 13 of 13
(810 Views)