Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: etElMadr on September 20, 2021, 10:29:38 AM

Title: One-Shots & Indirect References to Inputs
Post by: etElMadr on September 20, 2021, 10:29:38 AM
I have a memory structure (data table) with references to particular inputs. Initially, I wrote a Program that using For Loops to increment thru each record, and indirectly reference the input address stored in the record. This worked, until I introduced a trailing edge contact on the input. Do-More doesn't seem to like that. Further, I need to know how long an input is active (timer function). Looking for suggestions as to how to do this.

I'm now trying to MAPIO to bits stored in the active record of the data table. I haven't actually test this yet, but I'm doubt this approach is going to work the way I intended it.
Title: Re: One-Shots & Indirect References to Inputs
Post by: RBPLC on September 20, 2021, 11:07:20 AM
You probably need to supply an example of what you currently have. Doing what I think you're describing is asking for trouble.
Title: Re: One-Shots & Indirect References to Inputs
Post by: franji1 on September 20, 2021, 11:16:33 AM
Don't use edge contacts.  If you are trying to detect that event in a FOR/NEXT loop, emulate a trailing edge using ladder logic.  Add a PreviousScan bit to your UDT record that your FOR/NEXT loop maintains:

FOR V0
// trailing edge looking for "Bit" to be OFF and PreviousScan to be ON
STRN Record[V0].Bit  // .Bit is OFF?
STR Record[V0].PreviousScan  // .PreviousScan is ON?
// all trailing edge output logic

// next rung - move V0 Record's  .Bit state to .PreviousScan for the next PLC SCAN
STR Record[V0].Bit
OUT Record[V0].PreviousScan
NEXT  // V0

You will need to initialize .PreviousScan to OFF on first scan if your records are retentive (which they need to be), otherwise this code may misbehave on first scan since the .PreviousScan state may still be ON from whenever the last the it was set.  Best to do that in $tFirstScan w/FOR/NEXT loop using RST, not RSTR.

Title: Re: One-Shots & Indirect References to Inputs
Post by: etElMadr on September 20, 2021, 11:59:12 AM
That makes sense. Thank you