LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview with arduino

Solved!
Go to solution

@oathkeeper wrote:
The easiest way is to use your Arduino to read what the PC is sending and send the same thing back on the serial to the PC.

 That is what i am trying to do, and now it is working.PFA and have a look at it.

But that requeres that you program your Arduino to do so. That is why I asked for code.

 It does not need arduino code, it just needs an arduino board, rest is done by labview.

Please look at the code now and now it is working, the reason i have explained in the last post. I need your help to sove the problem which is appering now. Run the program for some time and u will see that the message you writ is not read completely everytime only some part of it displays.


The Arduino need some code to run on it to even function, it can't magicly transmit serial data.

 

There is errors in your code:

Delete the Wait timer and the Bytes at Port. Wire a big number (1000) to the VISA Read byte count.

You have typed a "\n" last in your string, but it is not th right thing. The Line Feed character ( \n )  is a special character, to be able to enter that character correct you need to right-click on the string constant and select  '\' Codes display. Then you can enter \n in the constant.

Or you could have taken the pre-defined constant in the string panel.

 

If you have problems with your code now, you need to show us your Arduino code AND your LabVIEW code.

Message 31 of 49
(2,263 Views)
Solution
Accepted by topic author oathkeeper

I do not how you expect to read data without connecting any device to PC. ( unless you do loopback )

Just go with a simple example , upload this sample sketch to your ardiuno and run the VI.

Message 32 of 49
(2,258 Views)

Serial_echo is in labview13, i have labview 12 so it's not opening and showing error. Instead can i run an example in labview 12 , Basic serial read and write with the same arduino code or else you send me some other file.

0 Kudos
Message 33 of 49
(2,231 Views)

oathkeeper wrote:

Serial_echo is in labview13, i have labview 12 so it's not opening and showing error. Instead can i run an example in labview 12 , Basic serial read and write with the same arduino code or else you send me some other file.


I do not have 2013 now, but you can go ahead and use basic serial read write.

just do not forget to put a wait of atleast 2000 ms after configure VISA.

 

Or use the attached vi in 2009. I have modified it to be simple.

0 Kudos
Message 34 of 49
(2,223 Views)

Hey mann...it is working now..thank you buddy and everyone..

sorry for being rigid and a bit imposy..:P

may be i will get back soon here..:)

0 Kudos
Message 35 of 49
(2,211 Views)

Glad to know thatSmiley Happy

as the topic name and discussion is very basic and generic ,you should mark helpfull post as a solution so that for other users it will be easy to search.

0 Kudos
Message 36 of 49
(2,204 Views)

i want to link these two programs..i am attaching here.

i am trying to figure out the solution to the problem, in the mean time please have a look at these codes and run it and see whats wrong.

 

0 Kudos
Message 37 of 49
(2,185 Views)

One short comment.

In your Arduino program you are missing a Serial.println() after the last Serial.print(...);

 

Do you know why?

0 Kudos
Message 38 of 49
(2,176 Views)
In your Arduino program you are missing a Serial.println() after the last Serial.print(...);
 
Do you know why?

 It is just the result of some hit and trial, if i keep println then labview is not at all showing the values which i am sending, u can try it...also some thing new has happened just run the code i am attaching.

In this one the values are displaying but along with , i mean before and after, a lot of zeros are coming. What i think is, there is synchronization problem, i mean the board and labview are communicating at diff rates and different times, according to the new code, as soon as i upload the arduino code it starts looking for data but it doesn't get anything until the labview code is run, so in that period it is putting all zeros and then as soon as it receives the data it puts it together and displays it, but that too with too many delays.
how can we solve it or how can we make sure that the board starts looking for data only when labview is ready to send data ?

P.S.: when u run the labview code firstly, enter 10000 in 'milliseconds to wait' textbar so that it starts taking values and then u can reduce the value to may be 1000 after which u will start seeing values which we want to see.

0 Kudos
Message 39 of 49
(2,154 Views)

I looked at the vi you attached in your eariler post. ( not able to see this , have 2009 now )

so comments are based on that

1. println will add termination characters to the data so in LabVIEW while reading the port you just need termination character enabled and do not use number of bytes at port.

2. As for as i remember , you are setting the serial buffer size ( and if i recall it correctly flusing the buffer also ) inside a while loop. Please put it outside the loop.

3.while termination character enabled you do not need to put wait between serial read and write in LabVIEW.

4. I could not see the ardiuno sketch properly but i think it will wait for some bytes , upon receiving those bytes it will perform some operation and give you reults. So if you are using same serial setting both side synchronization should not be a problem.

5.(Just a doubt) check that if your indicator is showing data in same format in which device is sending.

  

0 Kudos
Message 40 of 49
(2,140 Views)