LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Syncing Labview and multiple arduino visa read

Good evening,

 

I was able to successfully create a vi that does what I need, after some long hours messing with labview and modifying my needs.

 

Right now, my issue is syncing the rate of read.

Basically, I have one arduino which outputs a serial write of both rpm and torque.

I wanted to now add a second arduino which outputs information such as temperatures, fuel flow and air-fuel ratio. However, both arduinos have different output speeds. As such, when I run the vi, it seems that labview doesn't skip any read but refreshes all the information as quickly as the slowest arduino outputs. (For example, if one arduino outputs 4 times per second and the other one only 2 times per second, then labview will refresh only 2 times per second and quickly the quickest one will be presented later and later).

 

Could someone help me displaying everything as soon as it is read and, when saving to the file, make sure that each save iteration will save the latest values read?

 

PS: I was able to do that, apart from saving, if I create two while loops separately and without any flat sequence, however, I can't then find a way of saving the information.

 

The V1 vi, I can display the values as they are read but I can't find a way fo saving the values.

The V2 vi, I can save the values but the slower read stalls the faster one.

 

My alternative is trying to using only one arduino. However, this is last resort.

 

Could someone please help me?

 

Best regards,

Alexandre

Download All
0 Kudos
Message 1 of 8
(187 Views)

I finally found out the issue. I didn't know about the channel write and read. Using those tools and configuring as tags, I was able to do what I needed.

Now, the only thing I would like to do is select the range of the charts, but other than that, it's working as I wanted. I leave my vi if someone needs it.

 

Cheers

0 Kudos
Message 2 of 8
(120 Views)

Instead of using four separate channels per loop, build an array of the four measurements in each loop and send the array in one channel wire.

 

Also you can remove the Flat Sequence structure as it is superfluous... (Think Data Flow) 

-------------------------------------------------------------------
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
Message 3 of 8
(115 Views)

Thank you for the advice. I tried building the array inside each loop and sending it to the save loop. However, what channel write/read should I use? I thought I should use the accumulator tag since the tag only can't send arrays, only single values. Stream doesn't seem like the correct channel to use since it doesn't replace the latest array. Can you please give me some advice?

EDIT: Nevermind. Somehow, in the beggining it was giving me an error when I tried keeping the tag as before. I tried using lossy stream but the save loop was as slow as the slowest while loop (in my case, the second/bottom while loop). I reverted to tag and it is still working without any issue, apparently.

 

I'm uploading the vi with the changes you suggested. I think now it's fine but if you see any strange thing, please let me know.

 

Also, do you, by any chance, know a way of changing the range of the charts, ie, changing the x-axis to display the latest 10 values, for example?

 

Thanks

0 Kudos
Message 4 of 8
(110 Views)

@alexbigmac wrote:

Thank you for the advice. I tried building the array inside each loop and sending it to the save loop. However, what channel write/read should I use? I thought I should use the accumulator tag since the tag only can't send arrays, only single values. Stream doesn't seem like the correct channel to use since it doesn't replace the latest array. Can you please give me some advice?

EDIT: Nevermind. Somehow, in the beggining it was giving me an error when I tried keeping the tag as before. I tried using lossy stream but the save loop was as slow as the slowest while loop (in my case, the second/bottom while loop). I reverted to tag and it is still working without any issue, apparently.

 

I'm uploading the vi with the changes you suggested. I think now it's fine but if you see any strange thing, please let me know.

 

Also, do you, by any chance, know a way of changing the range of the charts, ie, changing the x-axis to display the latest 10 values, for example?

 

Thanks


 

As for your X-Axis you can set the "Chart History Length", caveat being you can't change the history length during runtime. 

-------------------------------------------------------------------
Unfortunately, most readers of this Forum, including some real Experts, have not mastered the skill of being able to read the code that Posters fail to post. If we cannot see "what you did wrong", we are unable to tell you how to fix it. (Bob Schor 28 August 2018)
0 Kudos
Message 5 of 8
(100 Views)

What I mean is, as you can see from the pictures, I can't change the x-axis range. In this case, it always displays the last 105 values or so. Can't I change it so that it displays the last 10 or something like that?

 

Cheers

 

EDIT: I found out. All I have to do is change the minimum and maximum scale to, say, 0 and 10 respectively and it will display the last 10 values!

 

Thanks for all the advice.

0 Kudos
Message 6 of 8
(95 Views)

Hi Alex,

 

another suggestion for code improvement:

To create additional indicators to show the current value of each chart is also considered Rube-Goldberg!

All you need to do is to enable the "Digital display" of each chart in its context menu (aka right-click menu)!

 


@alexbigmac wrote:

However, what channel write/read should I use? I thought I should use the accumulator tag since the tag only can't send arrays, only single values.


Why do you think the tag channel wire can't handle arrays? You just need to create a tag channel from the BuildArray output…

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 7 of 8
(67 Views)

@GerdW  escreveu:

Hi Alex,

 

another suggestion for code improvement:

To create additional indicators to show the current value of each chart is also considered Rube-Goldberg!

All you need to do is to enable the "Digital display" of each chart in its context menu (aka right-click menu)!

 


@alexbigmac wrote:

However, what channel write/read should I use? I thought I should use the accumulator tag since the tag only can't send arrays, only single values.


Why do you think the tag channel wire can't handle arrays? You just need to create a tag channel from the BuildArray output…


I was only testing the vi to make sure that it worked the way I wanted/needed. Now I'm optimizing the dials and charts and all that to make sure that I keep it simple. But thanks for the advice! That reference was great ahah

 

I thought it could. But when I made the changes, it gave me an error. But then I deleted and created the tag channel again from the build array and it worked fine. Now I only need to make the vi look pretty!

0 Kudos
Message 8 of 8
(48 Views)