From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

SubVi Reset Data

Solved!
Go to solution

I have a loop that processes a queue with CAN data.
Inside I have a few SubVi's that will process the data.

The problem is, I am only processing the data from one CAN node in the network. In the SubVi I have this comparator if I have the CAN ID that I want to process, with a Switch Case. The problem is when I receive the data, everything is okay in the main loop, otherwise, when I receive a Data that is not processed in this SubVi, this SubVi returns a default value to the main loop. How I prevent this to append? I want to keep the last value in the main loop until a new decoding message is processed in the SubVi.


PMSilva_0-1600852966917.png

 

PMSilva_1-1600853094519.png

 

 

0 Kudos
Message 1 of 9
(1,459 Views)

@PMSilva wrote:

 I want to keep the last value in the main loop until a new decoding message is processed in the SubVi.


Use a shift register. Put the data in it on the right side, and use the left side to get the last value. 

0 Kudos
Message 2 of 9
(1,430 Views)

So put shift register in the main loop, correct?
But why this append? If in the SubVI the Switch Case is not executed, why the value is reset? 

Still don't work...

 

PMSilva_0-1600862295781.png

 

0 Kudos
Message 3 of 9
(1,422 Views)

Hi PMSilva,

 


@PMSilva wrote:

So put shift register in the main loop, correct?
But why this append? If in the SubVI the Switch Case is not executed, why the value is reset? 

Still don't work...


Which "value is reset"?

What means "don't work"?

Mind to attach your VIs instead of pictures of code?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 9
(1,411 Views)

I receive a CAN frame in the Queue.

I have several SubVi's to decode the messages, each one for different messages.

When I receive a message, for example, to decode the Modes of Operation for a given CAN Address, the SubVI will check the message, and if has the same Address and the CAN message is for Modes of Operation, in the SubVi I will execute the Switch Case. Inside this Switch Case I have the decoding algorithm, that send the data out to the main loop.
Everything works fine, when the message is decoded. When the message is not decode, as suppose to... This SubVi puts the value output as a default.

Download All
0 Kudos
Message 5 of 9
(1,403 Views)
Solution
Accepted by topic author PMSilva

Hi PMSilva,

 

due to your LabVIEW version I cannot open your VIs.

 

But the solution should use something like this:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 9
(1,398 Views)

Hi GerdW,
I believe that your suggestion works. I will implement in the other SubVi's this "buffer".
Thank you

 

 

PMSilva_0-1600866995448.png

 

0 Kudos
Message 7 of 9
(1,389 Views)

@PMSilva wrote:

Hi GerdW,
I believe that your suggestion works. I will implement in the other SubVi's this "buffer".
Thank you


If you're going to build it into subVIs, they need to be reentrant. If not, each subVI will really work as a buffer, and that's probably not what you want. The subVI instances will start to communicate with each other.

0 Kudos
Message 8 of 9
(1,383 Views)

Thanks

0 Kudos
Message 9 of 9
(1,364 Views)