Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: ATU on January 17, 2019, 09:59:37 AM

Title: instruction Execution Times
Post by: ATU on January 17, 2019, 09:59:37 AM
Is there a list of instruction execution times? Looked in the manual and help and could not find anything.
Title: Re: instruction Execution Times
Post by: BobO on January 17, 2019, 10:23:43 AM
It's not that simple. Many things affect execution time.

You can figure it out yourself easily though. Use TICKus() in a MATH before and after the instruction. Unless you are talking about contacts, and they are very fast.
Title: Re: instruction Execution Times
Post by: ATU on January 17, 2019, 10:40:07 AM
Two things
Current program trying to make it run as fast as possible. Basic algorithm will be repeated 64 times. If I can shave time, it makes a big difference. Already using stages and separate tasks to get the bare bones logic running when needed.  Need to get a feel for if its worth the extra effort to write logic to avoid using indexed variables, straight out multiple timers versus one timer and comparative contacts. That kind of thing.

Also going to be using interrupts in an upcoming project and literately counting microseconds.
Title: Re: instruction Execution Times
Post by: BobO on January 17, 2019, 10:43:04 AM
Best thing to do is to insert TICKus calls in the code around sections. Works very well for profiling.

How fast are you wanting your interrupts to fire?
Title: Re: instruction Execution Times
Post by: ATU on January 17, 2019, 10:57:06 AM
I have a 16.66 ms window, from the time of the  input to get the calculations done and set the output before the next interrupt occurs. Repeatability under a millisecond  is what I am trying to achieve, so I need to know what all that latency is. I see you have that in the interrupt structure available, which is great. Just trying to decide on the most efficient way to do it. I hope that is achievable.
Title: Re: instruction Execution Times
Post by: BobO on January 17, 2019, 11:12:27 AM
Latency is one of the fields. For a single interrupt, it runs about 6-7us. If you have more than one interrupt, latency can obviously increase to the full execution of the other interrupt(s).
Title: Re: instruction Execution Times
Post by: ATU on January 17, 2019, 11:24:42 AM
I see you can have 32 interrupt routines, but in the configuration, only 4 tied to inputs? On the large BRX, you have 10 HS inputs, but still only limited to 4 interrupts tied to those inputs?
Title: Re: instruction Execution Times
Post by: BobO on January 17, 2019, 11:27:49 AM
32 ISRs. Onboard there are 12 interrupt generators (4 timers, 4 events, and 4 match regs) and those generators can be reconfigured via INCONFIG (even inside an interrupt).

The BX-HSIO will add 12 additional interrupt generators per module.
Title: Re: instruction Execution Times
Post by: ATU on January 17, 2019, 11:29:42 AM
If I used an  Interrupt Timer and scan the HS inputs? How close would that get me? Could I interrupt it every 500us and the PLC still function if the main program was small and coms kept to a minimim?
Title: Re: instruction Execution Times
Post by: BobO on January 17, 2019, 11:34:38 AM
If I used an  Interrupt Timer and scan the HS inputs? How close would that get me?

You can have all 10 HS inputs drive a single interrupt.

You can also do a fast timer. I'd use the event though.
Title: Re: instruction Execution Times
Post by: ATU on January 17, 2019, 11:56:49 AM
You can have all 10 HS inputs drive a single interrupt.

I overlooked that little detail. I see how to do it now.  Should work great. You guys think of everything.
Title: Re: instruction Execution Times
Post by: BobO on January 17, 2019, 12:20:24 PM
I overlooked that little detail. I see how to do it now.  Should work great. You guys think of everything.

You're not the first. Most people come with the simplified view of a one-to-one relationship with a pin and an interrupt, and although our implementation is far more capable, they don't see what they expect and get off track. The struggle is real. ::)
Title: Re: instruction Execution Times
Post by: ATU on January 17, 2019, 01:34:39 PM
Exactly,that was my only experience with interrupts. One input, one interrupt routine for on, maybe one for off. Going through your event configuration, you have a wide variety of conditions to utilize. Lots of possibilities.
Title: Re: instruction Execution Times
Post by: ATU on January 23, 2019, 09:59:19 AM
Best thing to do is to insert TICKus calls in the code around sections. Works very well for profiling.

Good Tool!
Title: Re: instruction Execution Times
Post by: ATU on February 06, 2019, 05:03:31 PM
Those interrupts are just freaking amazing. I never thought the day would come that you would be able to effect control within 50 microseconds on a PLC costing under $400.  Thanks for having the latency and execution time values. Big Help. Good job.
Title: Re: instruction Execution Times
Post by: BobO on February 06, 2019, 05:08:17 PM
Those interrupts are just freaking amazing. I never thought the day would come that you would be able to effect control within 50 microseconds on a PLC costing under $400.  Thanks for having the latency and execution time values. Big Help. Good job.

Thank you, sir. Glad you find them useful.
Title: Re: instruction Execution Times
Post by: ATU on February 18, 2019, 01:25:24 PM
I couldn't find anything in the help to verify this.
I am using a recurrent timed interrupt at 10ms.  Is  that timing done in hardware outside of the PLC OS?  In other words, is there any  accumulative latency for the call or is the periodic execution of the ISR going to be exactly  a 10ms tick + whatever the  call's Latency was at that time?
Title: Re: instruction Execution Times
Post by: BobO on February 18, 2019, 02:14:30 PM
It is timed by dedicated logic in the FPGA and there should be no cumulative error. Not so say that there isn't though...could be bug. The oscillator that drives all of this isn't super-duper accurate though (leading to fairly high clock drift) so that could also taint your view.
Title: Re: instruction Execution Times
Post by: ATU on February 18, 2019, 02:33:30 PM
I was seeing a small shift on the scope and tracked it down to other issues.
However, It got me thinking about the accuracy of the interrupt over longer periods of time (such as duration's lasting days and weeks) and wanted to make sure I would not be getting any major accumulation of error from the timer itself. Might be useful to add that information in the help for the timed interrupt.