LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

state machine: two simultanious active states

Hello guys,

 

thanks to your  suggestions i've got an idea that i think it would be the   solution to my problem,

i've simulated reading a serial port  and pass bytes read throught a mecanism and i've observed the  step by step solution, it worked as i wanted exept one thing the first loop(read loop) is faster than the second loop (comapre loop) so there is some bytes which thie second loop doesen't see,, i've tried to queue bytes before using them in my second loop but the same problem remains the same,,

i thought that queue mechanism is supposed to enqueue bytes (keep them temporary in memery) to synchronise passing information from one loop to another and to avoid loosing them,

 

i've attached my new Vi if some one has an idea do not hesitate to suggest it ,, thank you from your interest in my problem

0 Kudos
Message 11 of 16
(735 Views)

Hello all,

i've found a solution to my problem ,,,finally!!! 🙂

so the problem was that the first loop passes rapidly data to the second(which is to slow comparing to the first) so the second loop looses some of the data notified by the first loop,, the solution is to use FIFO: using queues to keep data notified in memory avoiding loosing them

 

thank you all for your help,,that means a lot for me  😉

 

Best regards,

SAmi

0 Kudos
Message 12 of 16
(723 Views)

samiti,

 

You appear to have some misunderstandings about LabVIEW dataflow as well as queues, notifiers, and state machines.

 

You do not need both a queue and a notifier for the same information.  In the Read loop you Enqueue a character to the queue named "sami" then immediately Dequeue it and pass it to the Notifier named "1".  Either pass the data to the Compare loop via the Queue sami or the Notifier 1 but not both.

 

In the Compare loop you have several different enum constants connected to the state wire.  This is why it has coercion dots and why the selector labels are all strings (with " ").  Create an enum control called State and give each state a unique and descriptive name.  Then make the enum control a typedef. Create all the constants from that typedef.  Then the state names will appear in the case selector labels.  And if you need to add a state, you just change the typedef and all the constants automatically change with it.

 

I would also make the extraction a state of the state machine.  Simply go to the Extract state when you have a complete frame. 

 

I think you can do everything you want with two loops (Read and Compare/Extract) and one queue.  No notifiers.  Enqueue the characters to sami in the read loop and dequeue them in the Compare loop.

 

Lynn

0 Kudos
Message 13 of 16
(718 Views)

Hello lynn ,

thank  you for your comments,

i'll try to do some changes on my vi, and post it, if you don't mind taking a look at it 🙂

 

Regards,

sami

0 Kudos
Message 14 of 16
(703 Views)

We are here to help you learn.  When you get to the next point where you do not understand something, please post your code along with your questions.

 

Lynn

0 Kudos
Message 15 of 16
(682 Views)

There's another example in the zip file at the end of this thread:

http://forums.ni.com/t5/LabVIEW/Serial-Packets-how-to-receive-them-correctly/m-p/1812914#M623421

 

 

0 Kudos
Message 16 of 16
(672 Views)