LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

program time not stable

Hi,

I try to make a program to create a pulsed voltage with a power supply. To get the pulse I have to enable and disable the output of the power supply. The problem is, that the frequency I get is not stable except the highes frequency. The frequency is limited by the power supply. Due to this I can say, that the instability is caused by LabVIEW. If I set the Wait time (see attached VI) to 0 the frequency is stable. But if I insert a value I get an instability.
Is there any chance to get a stable frequenz?

thanks,
0 Kudos
Message 1 of 17
(3,320 Views)
You will not get precision timing because there is noway of forcing order between the Wait and the command to the instrument.
 
RayR
0 Kudos
Message 2 of 17
(3,315 Views)

I've modified your code and provide explanation with reference to the attached image.

Let's look at a few scenarios:

1.  A1 is first, B1 then B2 followed by A2 repeat.

Sends OFF, 10 ms later Sends ON, 0ms sends OFF 10ms later sends ON... And then it might be 5ms ON then OFF 5ms then ON..  and random after that.

2. B1 first, A1 next, followed by A2 followed by B2, repeat.

Waits 5 ms, then OFF command, 0 ms turn ON waits 10 ms then OFF, etc.

For the other scenarios, just use random possibilities.. which is what was going on..

RayR



Message Edited by JoeLabView on 06-23-2008 07:38 PM
Download All
0 Kudos
Message 3 of 17
(3,310 Views)
Thank you for the fast answere, but the signal I get is still the same. I still get a signal with the variations.
0 Kudos
Message 4 of 17
(3,304 Views)

I suspected that would happen..  😞

It is because there is an element that we omitted from the equation, which is the reponse time from the instrument.

So you need to implement the code in such a way that the time between the ON & OFF times need to be relative to a constant timestamp.

I'll modify the example to illustrate.

RayR

0 Kudos
Message 5 of 17
(3,298 Views)
See attached example.  It uses "Wait Until Next ms Multiple", which will adjust for any deltas in sending the commands.
It also has an improved implementation.
 
Another improvement would be to create a state machine instead of using the Boolean to select the Case.  I did it this way for simplicity...
 
RayR


Message Edited by JoeLabView on 06-23-2008 08:16 PM
0 Kudos
Message 6 of 17
(3,295 Views)
I tried it with your example but no improvement.

Can you give me an example how to create it with a state machine?



0 Kudos
Message 7 of 17
(3,261 Views)

I would be curious if you get error messages.

I changed it to a state machine which will automatically stop if there is an error detected.

I also show the current state.  For both examples (this one and the last one) I suggest changing the delay to something big like 500 ms so that you can see the transitions.  Which is why I changed the constant form 5 to 500 and made it a control.

I suspect that it 5 ms is way to small a value, so we need to find out when it becomes unstable.

Try it out and post feedback

RayR

 

0 Kudos
Message 8 of 17
(3,244 Views)
Hi,

thanks for your efforts, but the signal is still the same.

I tried it with something very simple maybe stupid. I insert an empty for loop to keep the system busy for a short time, but no change. I think that the times of hand the while loop are not stable.
0 Kudos
Message 9 of 17
(3,236 Views)

I may have forgotten to mention that the Windows clock (PC) is not very accurate, especially when dealing with milliseconds. 

I looked at your code and doubt that having a For Loop running 10000 iterations doing nothing will help.

Did you try the last example I posted?  Did it give any error message(s)?  What wait time did you try?  Did you try a range of values?  Did you start with 500ms?

I was thinking of putting an indicator which would show the time deltas between the ON & OFF periods.  This way, you could monitor where the instability resides.

RayR

0 Kudos
Message 10 of 17
(3,230 Views)