annulla
Visualizzazione dei risultati per 
Cerca invece 
Intendevi dire: 

How to read Serial Data from Arduino using labview VISA?

Risolto!
Vai alla soluzione

Hi =). Im a beginner working reading serial data from an arduino but im facing... Lets do this step by step

 

I constructed a voltage divider circuit that gives an output ranging from 0 to 5V. The output of this circuit is sent to an analog input pin 0 of an Arduino Duemilanove board.

 

1) Firstly I plugged in the cable connecting my laptop USB to the arduino board.

 

2) I went to start->control panel->system->hardware->device manager. Check out Ports(COM & LPT). In my laptop I can see USB Serial Port (COM4). Now I know in Labview I have to read serial data from COM 4.

 

3) For the arduino side, here is the code to read voltage variations inputted to analog pin 0. The last line 'delay' determines the sampling rate of how we want to sample the voltage divider output:

 

int potPin = 0;    // select the input pin for the voltage divider output
int val = 0;       // variable to store the value coming from the sensor

void setup()
{
  Serial.begin(9600);    // opens serial port, sets data rate to 9600 bps
}

void loop() {
  val = analogRead(potPin); // read the value from the voltage divider
  Serial.println(val);
  delay(10);
}

 

I have slightly modified the basic serial read write VI.. I have attached the block diagram used with comments. Basically I tried to read serial data, divide by 1023 and multiply by 5 in order to graph voltage variations from the voltage divider circuit.  However Im not getting the correct voltage output values . The voltage value just keeps going to 0 and coming again as shown in the pic.

 

Could you guys please guide me on what went wrong?

 

Thanks!

 

Scarica tutti
Messaggio 1 di 141
120.198Visualizzazioni
Soluzione
Accettato da autore argomento Jazlan

- you're reading data, even if there is no data on the port. if 0 bytes are read => ""

- in the false case, you have VISA resource wired to the string output tunnel?

- there is no close VISA resource at the end of the VI

- you're not looping this VI when reading bytes

 

I've added an addaption of your VI which you should give a try maybe 😉

 

 

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
Messaggio 2 di 141
120.160Visualizzazioni

Thanks ABCPrograms. Now I know what I did wrong

0 Kudos
Messaggio 3 di 141
120.154Visualizzazioni

The VISA ref did not pass through the loop so the close VISA might close the port before it read the bytes.

Omar
Messaggio 4 di 141
120.141Visualizzazioni

TRUE Omar, thx for adding this.  BIG ERROR on my behalf.  I should hit myself for missing that 😉

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
Messaggio 5 di 141
120.138Visualizzazioni

I had a similar project. My Arduino continuously sends room temperature readings as part of a text string and I wrote a VI to buffer the text, extract the temp digits, display the value and graph the data.

 

I've attached my VI for your reference.

 

Cheers!

Messaggio 6 di 141
120.123Visualizzazioni

 


@drog wrote:

I had a similar project. My Arduino continuously sends room temperature readings as part of a text string and I wrote a VI to buffer the text, extract the temp digits, display the value and graph the data.

 

I've attached my VI for your reference.

 

Cheers!


Is there a reason why you use "insert into array" in stead of build array (concatenate)???

 

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
Messaggio 7 di 141
120.120Visualizzazioni

No real reason. I probably should have used the Build Array function for consistency.

 

Anyone know if there is an advantage to using the "Build Array" vs. "Insert into Array" functions.

 

Cheers

0 Kudos
Messaggio 8 di 141
120.113Visualizzazioni

Insert into array is normally used to "insert" a value into a array at a certain place.  not at the end, allthough it does work.

Build array is used to add a value (or array) to an array.

Kind regards,

- Bjorn -

Have fun using LabVIEW... and if you like my answer, please pay me back in Kudo's 😉
LabVIEW 5.1 - LabVIEW 2012
0 Kudos
Messaggio 9 di 141
120.093Visualizzazioni

Hey, I am using LabVIEW v 8.6 and would like to view this VI but cannot open it... could you upload a copy saved as an 8.6 file? Thanks

0 Kudos
Messaggio 10 di 141
119.976Visualizzazioni