LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event Based: Overwrite default message as soon as user initiated command and send periodically

Hello,

 

Current scenario: I have the code which sends default periodic message every 500ms, but it also acts accept event based  command, so as soon as user initiate command it will send once over the serial port and then gets back to default message.

 

My requirement: i want the user command message to overwrite the default message and sends every 500ms .i.e. for example: 

Default msg: 50 23 01 20 18 33 13 00 07 254 254 00 100 00 00 00 00 02 sends every 500ms

User msg :    50 23 01 80 18 33 13 00 07 254 254 00 100 00 00 00 00 02 sends every 500ms.

 

So, whenever user initiate command that msg is locked and sends over the port periodically.

 

Also, attached is vi which shows my current scenario above.

 

Thanks

 

 

0 Kudos
Message 1 of 11
(3,661 Views)

Hi aniket,

 

whenever user initiate command that msg is locked and sends over the port periodically.

Store the last user message in a shift register of the consumer loop.

Use that stored message for periodic data transfer…

(You need to create two cases in the consumer loop: "user message" and "periodic message"!)

Best regards,
GerdW


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

Hi Gerd,

 

I got what you are trying to explain, i will start with this idea but is there any sample vi from where i can leverage those ideas.

 

"(You need to create two cases in the consumer loop: "user message" and "periodic message"!)"

 

In the attached vi, i have already created 2 cases with periodic & user message. Pls, check if those are align with your ideas. 

 

Thanks

Aniket

0 Kudos
Message 3 of 11
(3,633 Views)

Hi Aniket,

 

in your consumer loop there was only one (default) case handling both types of messages…

Best regards,
GerdW


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

Hi Gerd,

 

Can you pls post the sample code for Consumer loop only, i am finding it hard to implement.

 

 

Thanks a lot

Aniket

0 Kudos
Message 5 of 11
(3,612 Views)

Hi Aniket,

 

what's the problem with changing a case label and adding a shift register?

check.png

Best regards,
GerdW


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

Hi Gerd,

 

Thanks for posting, why i asked because i tried and it's not working as per my expectation.

Pls, find attached code for the reference, and let me know where i get it wrong. 

 

Thanks

Aniket

0 Kudos
Message 7 of 11
(3,601 Views)

Hi Aniket,

 

it's not working as per my expectation.

I don't know your "expectations" nor do I know in which way the VI doesn't meet them…

(Yes, irony! Providing good error descriptions isn't your favorite job, isn't it?)

 

Hint: Well, when you want to store data in shift registers you need to wire all cases, not just one…

 

When you put the VISAClose behind the loop you should NOT leave it in the STOP case too!

 

Best regards,
GerdW


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

Hi Gerd,

 

Sorry for not providing you enough information or good error descriptions.

Required is: simul will keep on sending  periodic message 1, periodic message 2..... so on

but as soon as user initiate commands it should start sending like below :

   periodic message 1

   periodic message 2

   user message 3

   user message 4

   user message 5 .... and so on, 

 

And, what is happening with the code is 

   periodic message 1

   periodic message 2

   user message 3

   periodic message 4, it is not retaining the last value which is "user message".

 

 

I hope this time i am clear 🙂

Again, sorry for not providing you enough description.

Regards

Aniket

0 Kudos
Message 9 of 11
(3,581 Views)

Hi Aniket,

 

in your simple example you always store the "command" ("user message" vs. "periodic message") in the shift register.

In a real-world program you send some data along with the command (like ["user message", "content"]) - and you should store the "content" in the shift register to keep it for the next "periodic message"!

Best regards,
GerdW


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