LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

synchronize while loops for CAN applications

Hello

 

i have two while loops with each containint a case structure. i am using one while loop to transmit data over CAN and the other to recieve the CAN data.

 

i would like to sychronise the two loops so that the transmit and recieve while loops start at the same time

 

the reason i want this is because sometimes i see errors in the data transmitted due to an offset in time between the two loops operating. to me it seems like a slight time offeset builds up over time?

 

thanks

Brendan

0 Kudos
Message 1 of 5
(2,570 Views)

Hi,

to synchronize 2 while loops you can use the "Rendezvous" functions (see attached picture). However, you might need to use a small delay in the receive loop in order to read the reply for the sent message.

Lucian
CLA
0 Kudos
Message 2 of 5
(2,518 Views)

I can't envision what you are trying to do.  In a case statement, only one loop will be running at a time because a case won't exit until the while loop inside has completed.  How can you start them at the same time?  Show us what you have.  I'm not sure it's an optimal architecture?  It sounds like an inside out state machine.

 

[edit]

Or maybe you meant they are in separate case structures?  At any rate I'd like to see the code.  Or at least a gutted version so I can see what you are trying to do.

[/edit]

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 3 of 5
(2,501 Views)

Hi,

I think that "Master/Slave" or "Producer/Consumer" structure should be good for you. Idea with two while loops won't be work.

Try File -> New.. From templates to create the base structure for you.

 

Simyfren

0 Kudos
Message 4 of 5
(2,461 Views)

So if you use wait until next ms multiple with a sufficiently long multiple, I don't think you'll see a ton of drift. However, to pull up a level -- what dyou want to do? I can't think of why you would ever want to synchronize an RX and TX loop, so it might help us help you if you give us a better explanation as to why the offset time is a bad thing.

0 Kudos
Message 5 of 5
(2,434 Views)