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: 

Wait Till Next Millisecond Multiple issue

Solved!
Go to solution

I seem to be having an issue with the Wait Till Next Millisecond VI. I've set it to wait to 1000ms and I have it inside a loop that does a bunch of stuff, yet my charts in the loop updates about 50 times every 60 seconds. I was thinking it perhaps took too long to execute everything in the loop so it "missed" the next millisecond multiple, but if that was the case it would be updating every 2 seconds. It wouldn't make sense for non interger multiples.

My code is a sorta big, so if there any obvious places I should look and see as to why this happening in a general sense, and not specific to my program, I could try that first.

 

Thanks!

0 Kudos
Message 1 of 7
(3,441 Views)

The last two parts of my code.

Download All
0 Kudos
Message 2 of 7
(3,438 Views)
Solution
Accepted by topic author super_strong_dragons_n_stuff

Your loop can only go to the next iteration until all event structures have time out or been triggered by an event AND the 1000ms wait has elapsed.

 

It is hard to troubleshoot, maybe you want to rearchitect the code somewhat first. It seems all event structures are triggerend by the same event. Can't you combine all the code into one? Use a single event structure, not N event structures! 

Keep the diagram to a single screen. Get rid of all these unneeded sequence structures.

Eliminate all that duplicate code. Why have a huge indentical set of property nodes in each case of a case structure? Don't the property nodes belong after the case structure? Only write to properties when the value changes, and not with every iteration of the loop.

Use local variables instead of value property nodes.

 

Can you measure the loop rate with more conventional means to get an exact loop time value?

Message 3 of 7
(3,403 Views)

Danger using 4 event structures! Use ONE event structure to handling the 4 Boolean events.

 

There is no way your while loop is running faster than 1 a sec with 4 event structures with all their time out event set to 1000 ms.

The Wait Till Next Millisecond Multiple is in effect doing nothing. 

Are you sure you are getting 50 update every 60 seconds. That is 

 

Plus I sure it is taking you a while to talk to 4 pumps one at a time or 4 pressure sensor one at a time.

Get rid of the sequences and let the 4 pumps and 4 pressure all run in parallel. Think "DATA FLOW"

Talk to all 8 at the same time in parallel.

 

Get rid of the "Bytes at Port" loops. Read up on "Termination Char" in the VISA help.

Does your pump and pressure return a line feed or charage return at the end of each line?

 

But I can't see how you loop is running faster than 1000 ms due to the Event Structures timeout.

The Wait Till Next Millisecond is coming into play.

Omar
Message 4 of 7
(3,392 Views)

@altenbach

Wow this is a lot of great advice, and will surely take some time to implement all of it. But I will do it!

With the sequence structures, I have so many because I want to avoid trying to reading from the device at the same time. I failed to mention that all the sensors are connected to one device, which I am hooked up to via serial. Not 6 separate sensors necessarily.

But I do understand replacing the value property nodes with local varibles. I will also combine all the event structures together. After this I will measure the loop rate for a exact time value, and maybe that will shed some light on things.

Thanks!

0 Kudos
Message 5 of 7
(3,375 Views)

@Omar_ll

 

The event structures are not in a sequence structure so I intend for them all to time out after 1 second at the same time. But combining them does look like a better idea, so I will do that.

 

I follow on talking to the pumps all at once also. With the sensors, as I mentioned to altenbach, they're all connected to the same device, and I don't think I can send multiple read commands at the same time to the device holding all 4 sensors.

 

I will look into the termination character on VISA help, because my device does use a terminating character. Hopefully that will make everything run quicker!

 

Thanks!

0 Kudos
Message 6 of 7
(3,369 Views)

I follow on talking to the pumps all at once also. With the sensors, as I mentioned to altenbach, they're all connected to the same device, and I don't think I can send multiple read commands at the same time to the device holding all 4 sensors.

 

I will look into the termination character on VISA help, because my device does use a terminating character. Hopefully that will make everything run quicker!

 

Thanks!


We assumed with 4 "Pressure Gauge" VISA references, that you had 4 devices each with their own VISA ref (com port).

 

Termination Character: "Your Sensor On or Off" sub VI does not use the Bytes at Port, but correctly uses the Termination Char.

Just wire in some large number of bytes (more than what you ever expect) and the VISA read will "terminate" on the Termination Char (get it).

Omar
Message 7 of 7
(3,314 Views)