Jump to content

Timing question...need help!


Recommended Posts

Alright, so I have a timed sequence that turns a boolean off, and then on, repeatedly, by an amount of time set by the user. I am also writing to a DAQmx device. When I monitor the line with an oscilloscope and both times set to 2ms, everything is fine. When I set them both to 0ms, it seems to stay high for about 130us, and then low for about the same, which is fine.

The problem comes when I set the times to 1ms. It seems to still do 2ms. It does 2ms very accurately, even when I choose 1ms. Is there any way to get 1ms, or is 2ms the best I'm going to get?

I have tried using Create Timing Source VI, and using DAQmx timing, and the results are identical. :headbang: Maybe I don't quite know what I'm doing :question: . Any help is appreciated. :worship:

I have attached the test code.Download File:post-5227-1165601085.vi

Thanks,

Nicholas

Link to comment

Nicholas,

why do you mix two timing types?

You have a timed sequence, which is the correct item for your application. And you use the wait function based on the OS time.

I suggest you use the timing of the timed sequence (I have never used it, but think this is what you need):

post-2399-1165671687.png?width=400

In the first frame, I read the start time of the frame, add the wait time and then set the start time of the next frame. You should do this for the third frame as well

I think you can limit your sequence to two frames, one where you make the output high, and one where you make the output low. The timing of the frame will set the speed correct.

Ton

Link to comment

Hi Nicholas,

what happened is that your second frame executer during a very short amount of time, so you don't see the light comming on.

I added a third fram just for timing issues:

post-2399-1166041299.png?width=400

Another way to get this is using a timed loop that runs at 2 ms, so the timed sequence is launched every 2 ms, but there are other ways.

Ton

Link to comment
There must be someone out there who has used precise LabView timing (w/o using RealTime). I have access to timing signals from DAQmx cards if that helps.

Thanks

Unfortunately the computer clock can't always be counted on, but i modified your vi so that it should work for you now.

If it looks like it slows down or speeds up, that is just your system's ability to keep up, it may actually be running properly, but

the screen updates happen too slow.

but i modified your vi so that it should work for you now.

By the way, i forgot to mention that i changed the clock from 1KHz to 1KHz®, which resets for every iteration. you could use a shift register and the output node to get the second frame's ending time and add that to the off time and keep looping that into the 't0", but that gets messy and it is possible for the timed loop to get farther ahead while your doing the math and then it misses.

I also removed your extra local variable and have your high (T) wired directly to the terminal for the indicator. Minimize the use of variables to keep memory/processor overhead down.

Hope all this helps. Good Luck!!! :D

Download File:post-3482-1166042884.vi

Link to comment

So I hooked 'er back up to the scope, and it seems almost perfect! I can now get timing very accurate to the ms, however, the off time always seems to be twice as long as what is entered on the front panel. This can be seen by entering 1000 for both values. When doing this, the light is on for 1 second, but off for 2.

I will investigate this further, and hopefully find the problem.

P.S. Dividing the Off time by 2 before putting it into the start frame does not solve the problem.

So it turns out that the Off Time has to be wired directly into the Start of the next frame, and not added to the Actual Start of the sequence. Strange, as I thought since the first frame started at say 1000, that you would want the start of the next frame to be at 2000. But I guess the Start option for the right data node is relative to the previous frame.

Download File:post-5227-1166123023.vi

Link to comment
So I hooked 'er back up to the scope, and it seems almost perfect! I can now get timing very accurate to the ms, however, the off time always seems to be twice as long as what is entered on the front panel. This can be seen by entering 1000 for both values. When doing this, the light is on for 1 second, but off for 2.

I will investigate this further, and hopefully find the problem.

P.S. Dividing the Off time by 2 before putting it into the start frame does not solve the problem.

So it turns out that the Off Time has to be wired directly into the Start of the next frame, and not added to the Actual Start of the sequence. Strange, as I thought since the first frame started at say 1000, that you would want the start of the next frame to be at 2000. But I guess the Start option for the right data node is relative to the previous frame.

This maybe due to the timer resetting itself. try changing the off value to 0 and see if this works. if it does, you can either leave it like that, or we can go the messier route of using shift registers to carry around the current timer value.

Link to comment
Alright, so I have a timed sequence that turns a boolean off, and then on, repeatedly, by an amount of time set by the user. I am also writing to a DAQmx device. When I monitor the line with an oscilloscope and both times set to 2ms, everything is fine. When I set them both to 0ms, it seems to stay high for about 130us, and then low for about the same, which is fine.

Hi,

Just a thought, if it is accurate timing on the digital line you want, why don't you use a counter output?

Search the LabVIEW examples for the counter/timer examples, try one of the "Gen Dig Pulse..." VIs.

/J

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.