News:

  • September 24, 2026, 01:37:17 PM

Login with username, password and session length

Author Topic: Precise Delay ON  (Read 16052 times)

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Precise Delay ON
« on: April 13, 2020, 08:26:29 AM »
Is there anyway to do a pulse triggered programmable time delay latch ON with the high speed counter module? The delay would be 0 to 30ms and looking for a repeatability of 100us or less.  One high speed input  pulse, software enable and reset and one high speed output. I am doing it now with interrupt routines on 8 channels, but best repeatability is +/- 200us with all else going on in the program and diminished Ethernet traffic. I could measure the delays with the module, but don't see a way to do anything like that with the outputs. Or perhaps some combination of an interrupt and a high speed out?
« Last Edit: April 13, 2020, 08:43:43 AM by ATU »

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Precise Delay ON
« Reply #1 on: April 13, 2020, 09:59:43 AM »
Is there anyway to do a pulse triggered programmable time delay latch ON with the high speed counter module? The delay would be 0 to 30ms and looking for a repeatability of 100us or less.  One high speed input  pulse, software enable and reset and one high speed output. I am doing it now with interrupt routines on 8 channels, but best repeatability is +/- 200us with all else going on in the program and diminished Ethernet traffic. I could measure the delays with the module, but don't see a way to do anything like that with the outputs. Or perhaps some combination of an interrupt and a high speed out?

It's a tiny bit of a hack, but you can use a TDOPRESET. Counter in, TDO preset of 1. You should be able to get repeatability to +-1us.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Precise Delay ON
« Reply #2 on: April 13, 2020, 10:06:36 AM »
Thanks, I'll take a look at it.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Precise Delay ON
« Reply #3 on: April 13, 2020, 10:17:11 AM »
You'll then have to reset the counter to rearm. I'd put the whole kit into a program block.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Precise Delay ON
« Reply #4 on: April 13, 2020, 11:32:56 AM »
I am missing something or I didn't  define this well enough.  How do I get a 1us pulse input to the counter to drive the table? I want to start timing when I receive a pulse then at the end of that time latch on a high speed output.  I could initiate that from an interrupt routine. I need the time delay to be as exact as possible. 1us would be fantastic.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Precise Delay ON
« Reply #5 on: April 13, 2020, 11:35:56 AM »
I am missing something or I didn't  define this well enough.  How do I get a 1us pulse input to the counter to drive the table? I want to start timing when I receive a pulse then at the end of that time latch on a high speed output.  I could initiate that from an interrupt routine. I need the time delay to be as exact as possible. 1us would be fantastic.

I guess I didn't understand what you wanted.

1us pulse? You can't (officially). Max input freq is 250k.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Precise Delay ON
« Reply #6 on: April 13, 2020, 11:50:28 AM »
I have a single 1 ms pulse input. This will start a timer that I want to be at least 100us repeatable. The length of time is programmable from 0 to 30 ms.  I have up to 8 of these going at one time.  Could be all simultaneous or at different start times.  I can do all of this in interrupt routines, but only to 200 us repeatability. Its the timing part that I want to improve on.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Precise Delay ON
« Reply #7 on: April 13, 2020, 12:02:23 PM »
I have a single 1 ms pulse input. This will start a timer that I want to be at least 100us repeatable. The length of time is programmable from 0 to 30 ms.  I have up to 8 of these going at one time.  Could be all simultaneous or at different start times.  I can do all of this in interrupt routines, but only to 200 us repeatability. Its the timing part that I want to improve on.

You said 1us.

Use the input on a counter. Rising or falling edge of input counter from 0 to 1.

TDOPRESET is configured on that counter. At a preset of 1, trigger a pulse output set for the required time. It will be precise to 1us.

You can only do 3 internally or 4 on an HSIO, but any of these that you moved from the interrupt would improve the performance of things remaining on the interrupt.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Precise Delay ON
« Reply #8 on: April 13, 2020, 12:54:29 PM »
Sorry, I meant 1 ms.   :-\
 So I would use the table Pulse-On Preset Function to set my time delay? Can you change that on the fly?

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Precise Delay ON
« Reply #9 on: April 13, 2020, 01:50:27 PM »
Sorry, I meant 1 ms.   :-\
 So I would use the table Pulse-On Preset Function to set my time delay? Can you change that on the fly?

You can reprogram the table as often as you like.

It appears that the pulse time cannot be a variable from the instruction based table, but you can use a D memory based table and change the source data. Presets can be variable.

Another approach would be to use a timer instead of counter. Rising edge to start timing, then use presets to turn on and turn off at the times you want. You can use the table completion bit ($TableOutx.Done) to reset the timer.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Precise Delay ON
« Reply #10 on: April 13, 2020, 02:15:26 PM »
Sounds doable. I was planning to use 2 high speed modules to time the devices. Might be able to incorporate this in that timer function. Need to read up on it, looks like a lot of functionality.  Never used it before. 

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6176
  • Yes Pinky, Do-more will control the world!
Re: Precise Delay ON
« Reply #11 on: April 13, 2020, 02:18:26 PM »
Counter/timers and TDO are both fully hardware based. Their underlying cycle time is 1us. Anything you build on those functions will be accurate to 1us.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO