01-30-2018 05:48 AM
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
01-30-2018 06:51 AM - edited 01-30-2018 06:52 AM
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"!)
01-30-2018 09:14 AM
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
01-30-2018 09:50 AM
01-31-2018 03:06 AM
Hi Gerd,
Can you pls post the sample code for Consumer loop only, i am finding it hard to implement.
Thanks a lot
Aniket
01-31-2018 03:27 AM
01-31-2018 05:19 AM
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
01-31-2018 06:01 AM
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!
02-01-2018 02:26 AM
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
02-01-2018 03:12 AM
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"!