12-16-2011 08:25 AM
I was able to send and recieve "Hello World".
Thank you for your help.
How would I go about sending and recieving a string array of unknown size? i.e. I do not know how many bytes I am going to recieve.
Maybe I could count the bytes in arduino and then send that as a precursor to the array.
12-16-2011 10:10 AM
ADrexelDragon,
You could send a string of an unknown size but then there is no way to guarantee that you received the entire string. For example In LabVIEW you could use a VISA read VI to read 1 byte in a loop with a timeout of 5 seconds. If the VI times out you can exit the loop, if the read is successful you could read again until you time out. This assume that you will never go more than 5 seconds without new data on the serial line. This may work most of the time, but there is no guarantee that you are getting all the data.
I you would be better off doing something like you said and packetizing the data to include a header with the number of bytes to follow. This is a very common method of data transmission (TCP/IP for example).
-Sam K
LIFA Developer
12-19-2011 08:23 AM
I think the LabVIEW code is not reading all of the data.
I am using the same code as the arduino.
With regards to LabVIEW, I am not sure how many bytes to read at a time and also not sure what the timeout should be.
I think I should read the serial port for data until there is no more data coming in but I am not sure how to so that. Do I read 1 byte at a time until no more are available, in this case a short timeout?
Any help would be appreciated.
12-21-2011 09:22 AM
AdrexelDragon,
You can use the VISA Bytes at Serial Port.vi to determine how many bytes are available and the VISA Read VI to read the bytes.
In LabVIEW click Help>>Find Examples and serach for serial to see how serial communication should be done in LabVIEW.
-Sam K
LIFA Developer
02-14-2016 03:05 AM
Hello, I'm having the same goal as you (read an InfraRed sensor through LabView) and I don't understand how to get this done.. I thought I could simply use the Digital Read but it seems to be too slow (binary output differs from each loop). As said in the tutorial mentioned above, I should use Digital Read PIN but on LINX I don't find any VI to do that.
I tried to compile the firmware that ADrexelDragon posted and then to run his VI to read the digital code of my IR remote, but I cannot open his VI because it needs subVIs and TypeDefs that I don't have.
I am very new to LINX (but not to LabView).
I hope you can help me! Thank you very much in advance,
Dario
02-14-2016 11:38 AM
The existing LINX software does not have the capability to decode a hand held IR remote control signal. Two suggestions. A better place for getting help for this problem is the LINX forum Or you could use Arduino code that is available on the Internet to decode the IR signal and develop a Labview VI for interfacing with your Arduino board. This second suggestion does not use LIFA or LINX.
A good source of information for learning how to decode an IR signal Is:
<https://learn.adafruit.com/ir-sensor>
hrh212
02-14-2016 12:00 PM
I was able to get it to work by loading the IR signal into the Arduino and passing it to LabVIEW, storing the signals in LabVIEW and replaying them out via IR LED. It took a while to figure out but it is possible using the serial read.
02-16-2016 02:00 AM
So if I understang correct I could use the IR decode Arduino code (the one posted in the previous page) and then through visa serial read I could capture the detected signal on Labview.
What is not clear to me now is the second part: how do I make labview send an IR code through Arduino?
Here http://www.ladyada.net/wiki/tutorials/learn/sensors/ir.html in the middle of the page there's a
sketch which will pulse pin #13 on and off very fast in the proper code sequence
How can I programmatically (through labview) send the IR code that I want?
Thank you again for your help!
02-16-2016 08:30 AM
Take a look at this reference: http://www.righto.com/2009/08/multi-protocol-infrared-remote-library.html
It shows an example of the Arduino code that was needed to read and decode the IR signal. Once the decoded signal was read (I wasn't able to receive and send the signal to LabVIEW at the same time), I had to send it out after the signal was completely recieved on the Arduino.
You can send the signal to LabVIEW by printing out on the serial port.
02-16-2016 04:27 PM
For transmitting you need additional Arduino code to drive a transmitting IR LED. To transmit you could store all of the different bit sequence commands you need to control an external device in Labvierw. Then when you want an external device to perform a particular action download the required bit sequence command to the Arduino board . The Arduino code should be set up so that whenever it receives a bit sequence command it automatically transmit the command .
Another approach is store all of the bit sequence commands on your Arduino board. Then when you want the external device to perform a particular action send a command from Labview specifying the required bit sequence command to transmit. On receiving the command the Arduino code should automatically transmit the command.
Another good source of information is Sparkfun, See:
<s://learn.sparkfun.com/tutorials/ir-communication>
hrh212