Host Engineering Forum

General Category => Do-more CPUs and Do-more Designer Software => Topic started by: Controls Guy on May 26, 2018, 02:41:20 PM

Title: Increase and decrease contacts
Post by: Controls Guy on May 26, 2018, 02:41:20 PM
I love that delta contact to death.  Use it all the time, plus impress my friends who program other brands that don't have it.

Once in a while, I want to detect changes in a numerical register only in a single direction, so you might create delta/increase and delta/decrease contacts.  It'd be like leading and trailing edge contacts on a bit.  What you have to do now in ladder is slightly cumbersome (remember the previous value and compare each scan).  Not sure if users in general would find value in this.
Title: Re: Increase and decrease contacts
Post by: BobO on May 26, 2018, 02:52:15 PM
The rising/falling edge equivalent of delta. Wouldn't be hard.
Title: Re: Increase and decrease contacts
Post by: Controls Guy on May 26, 2018, 04:24:48 PM
How does delta work on a float, even the current bidirectional one?  Look for any change in the exponent or past some threshold in mantissa?
Title: Re: Increase and decrease contacts
Post by: BobO on May 26, 2018, 04:44:38 PM
How does delta work on a float, even the current bidirectional one?  Look for any change in the exponent or past some threshold in mantissa?

Simple integer compare of the raw bits. A directional version would require int/float awareness, but it isn't hard. The hardest part would be the 27 things that have to happen in DmD.
Title: Re: Increase and decrease contacts
Post by: Controls Guy on May 26, 2018, 06:14:42 PM
Well, the inc/dec thing isn't a huge deal.  Nice to have, whenever it floats to the top of the list.

As a separate idea, though, you might think about upgrading the float implementation of delta.  Any change in exponent, or a significant change in mantissa*, or a sign change with a mantissa above a certain threshold. Could that be done entirely in DM firmware without changing DMD?  I guess the issue is that the compare still has to know it's looking at a float to invoke those rules.

*This implicitly makes the threshold relative to the magnitude so a larger number has to change more to kick the delta, plus still allowing an integer comparison rather than having to convert to a float and apply a comparison rule.
Title: Re: Increase and decrease contacts
Post by: BobO on May 26, 2018, 06:18:32 PM
It would be controller only, but we are very reluctant to change behavior in an instruction that isn't explicitly broken.
Title: Re: Increase and decrease contacts
Post by: Controls Guy on May 26, 2018, 06:40:35 PM
Good point.  There may be people out there depending on it the way it is.
Title: Re: Increase and decrease contacts
Post by: Controls Guy on May 26, 2018, 06:46:33 PM
Maybe throw up a poll, and see what percentage would prefer which way.
Title: Re: Increase and decrease contacts
Post by: LWgreys on June 02, 2018, 02:36:44 AM
I say leave it alone. I do not want it changed. Because then I would have to modify my programs.

Now if you want to add a new contact then that's all right.