Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Controls Guy on February 20, 2019, 12:18:55 PM

Title: One shots on indexed addresses within loops
Post by: Controls Guy on February 20, 2019, 12:18:55 PM
DMD is giving me grief about the following code:

Code: [Select]
// Ver(103) PCU(3) Do-more Designer Clip   Source Project: C:\Users\Public\Documents\Do-more\Designer2_3\Projects\~DmD11    Format: Do-more Designer 2.00+  DO-MORE Ladder
PLC BX-DM1-36ER

STRPD T[V0].Done
MATH MHR101 "V0 * LKR_EntrySize"
MATH MHR200 "HMI_AlarmScrnID"

#BEGIN ELEMENT_DOC
"SK","LKR_EntrySize","50",""
"SK","HMI_AlarmScrnID","5",""
#END

I get the error

[Error]   $Main#5(@35)   E128 Array reference parameter T[V0].Done found within Leading Edge One-Shot Contact within a loop (FOR at $Main@14)

Now I'm running the loop non-yielding (timer works for example), and the location is indexed so any given timer and contact are only seen once per scan, so you'd think one-shots should work.  DMD gives me the option to ignore this error for this location.  Will it work as expected?
Title: Re: One shots on indexed addresses within loops
Post by: Controls Guy on February 20, 2019, 12:34:32 PM
Oh, just noticed you can't access Txx.PRE.  How hard would it be to add as an accessible member the structure?
Title: Re: One shots on indexed addresses within loops
Post by: BobO on February 20, 2019, 12:52:28 PM
The preset isn't in the structure, it's only in the instruction. Not hard to do, but a big impact.

The edge isn't going to behave the way you think. If will only be true for the first pass through the loop.
Title: Re: One shots on indexed addresses within loops
Post by: Controls Guy on February 20, 2019, 12:58:57 PM
The preset isn't in the structure, it's only in the instruction. Not hard to do, but a big impact.

Not a big deal then.

Quote
The edge isn't going to behave the way you think. If will only be true for the first pass through the loop.

So even though the reference resolves to a different timer each iteration, the one shot won't track properly?
Title: Re: One shots on indexed addresses within loops
Post by: BobO on February 20, 2019, 01:02:39 PM
So even though the reference resolves to a different timer each iteration, the one shot won't track properly?

There is a single copy of the previous input state, which is associated with the instruction, not with the input. To do what you are wanting, there would have to be a previous state for every possible input bit in the system. Not practical.
Title: Re: One shots on indexed addresses within loops
Post by: Controls Guy on February 20, 2019, 01:07:02 PM
There is a single copy of the previous input state, which is associated with the instruction, not with the input. To do what you are wanting, there would have to be a previous state for every possible input bit in the system. Not practical.

I see.   I ended up doing this to create a one-shot effect to the timer, which works fine:

Code: [Select]
// Ver(103) PCU(3) Do-more Designer Clip   Source Project: C:\Users\Public\Documents\Do-more\Designer2_3\Projects\Monitor 3    Format: Do-more Designer 2.00+  DO-MORE Ladder
PLC BX-DM1-36ER

FOR V0 AlmRangeStart AlmRangeEnd 1

STR X[V0]
ANDN MC[V0]
STRN X[V0]
AND MC[V0]
ORSTR
TMR T[V0] FaultDebounce

STR T[V0].Done
MATH C0 "(T[V0].Acc - FaultDebounce) < 500"

STR T[V0].Done
AND C0
MATH MHR101 "V0 * LKR_EntrySize"
MATH MHR200 "HMI_AlarmScrnID"
MATH V1 "V0"


#BEGIN ELEMENT_DOC
"SK","AlmRangeStart","4",""
"SK","AlmRangeEnd","39",""
"C0","NewFault","",""
"SK","FaultDebounce","5000",""
"SK","LKR_EntrySize","50",""
"SK","HMI_AlarmScrnID","5",""
#END

Title: Re: One shots on indexed addresses within loops
Post by: franji1 on February 20, 2019, 01:08:45 PM
If you want to use the equivalent of a differential contact in a loop, you will have to do it the old-fashioned way (w/o an edge contact).

Create a block of "previous scan bits", say PSB, the same size as your Timer block.  T0.Done previous scan state will be in PSB0, T1.Done will be in PSB1, T255.Done will be in PSB255.

So then your differential behavior inside your FOR/NEXT loop will be

Code: [Select]
PSB[V0]   T[V0].Done
--]/[--------] [------[MATH]

T[V0].Done           PSB[V0]
--] [-----------------(OUT)
Title: Re: One shots on indexed addresses within loops
Post by: Controls Guy on February 20, 2019, 01:11:15 PM
Yup, that's a good approach.  In my case, since it was timers I just checked that it was in the first 500ms post-expiration.  (Didn't need to be a true single-scan one-shot)