LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Visa Write data type

Hi everyone,

I am new with LabView and I am trying to solve a problem. I would really appreciate any type of help.

 

I am acquiring a signal with a DAQ at 1000Hz sampling rate, I am doing some simple processing of the signal in LabView and now I want to send these value to arduino through a serial communication using the Visa Write function.

 

I want to send an average value of 100 samples, so that every 100ms ( I was acquiring at 1kHz) a new value is calculated and sent to Arduino.

 

I've got problems in understanding how to send these values every 100ms and read them properly in arduino. I've seen that the write buffer of the Visa Write accepts only strings while I was working with double float values. 

Is there an easy way to transform these values in string. How would be possible to reconvert them in float in arduino?

 

 

Thank you in advance for your help!

0 Kudos
Message 1 of 5
(3,075 Views)

Hi bla,

 


@bla1234 wrote:

I've got problems in understanding how to send these values every 100ms and read them properly in arduino. I've seen that the write buffer of the Visa Write accepts only strings while I was working with double float values. 

Is there an easy way to transform these values in string. How would be possible to reconvert them in float in arduino?


An easy way to convert a numeric to a string is to use FormatIntoString (or any of the other NumericToString) function(s)!

I'm no expert for Arduino but I guess the command is called "serial.read(ln)" (in cooperation with the serial.write(ln) command). I also guess you can read the Arduino help to get more information on this topic…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(3,024 Views)

What format do you want the data to be in?  For simplicity, I would use an ASCII format.  Use the Format Into String using "%f\n" for the format.  You need the "\n" to append the end of line character.

 

If you decide to go the raw/binary/hex format, then use the Flatten Into String.  You will then want to add a frame around the data with a start byte (typically 0x02) at the beginning and then a checksum of some type at the end.  This way, you can verify you have the right block of data.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 5
(3,009 Views)

I change a little bit my goal to semplify the code. But I am still having problems.. Now basing on the value that I have obtained I want to send different characters to arduino. It should be very easy but the only things that my arduino read in the serial monitor is "-1" and I really don't get why..

 

 

char val;

void setup() {
Serial.begin(9600);
}


void loop() {

 if(Serial.available()>=0) 
 val=Serial.read();


 Serial.print(val);

}

0 Kudos
Message 4 of 5
(2,978 Views)

Hi bla,

 


@bla1234 wrote:

char val;
void setup() {
Serial.begin(9600);
}


void loop() {
 if(Serial.available()>=0) 
 val=Serial.read();

 Serial.print(val);
}


Does this Arduino code even runs? In case it does it will be finished very fast because I don't see any loop to repeatedly read from serial port…

 


@bla1234 wrote:

I change a little bit my goal to semplify the code.


Well, then you should have used atleast AutoCleanup! (I guess you want to "simplify"…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 5
(2,964 Views)