News:

  • August 27, 2026, 08:58:52 PM

Login with username, password and session length

Author Topic: Here is a neat code snippit to play with  (Read 18183 times)

LWgreys

  • Hero Member
  • *****
  • Posts: 117
Here is a neat code snippit to play with
« on: March 06, 2014, 10:31:00 PM »
It's a flip/flop-signal-debounce-timer.
X7 is the input signal and Y15 is the output.
I used V1 and V2 as the time amount values.

OK not a flipflop
« Last Edit: March 06, 2014, 10:33:16 PM by LWgreys »

LWgreys

  • Hero Member
  • *****
  • Posts: 117
Re: Here is a neat code snippit to play with
« Reply #1 on: March 08, 2014, 07:59:58 PM »
Reason I put this here is a "Coil Debounce Function" like the P3000 has would be nice. I use this snippet to prevent signal bounce from the product movement pass the sensors. There are gaps between the product that causes the sensor to change state.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6174
  • Yes Pinky, Do-more will control the world!
Re: Here is a neat code snippit to play with
« Reply #2 on: March 10, 2014, 10:46:36 PM »
Ok, now you're just playin' dirty, tellin' me P3K has a useful instruction that Do-more lacks. ;) Probably need to add this one to the to-do list...
"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

LWgreys

  • Hero Member
  • *****
  • Posts: 117
Re: Here is a neat code snippit to play with
« Reply #3 on: March 10, 2014, 11:37:40 PM »
With the faster scan time the Do-more has over the DL, it amplified the signal bouncing. About 10 time more. Had to work out something simple to handle the problem. Then I remembered reviewing the P3K that it had a Coil Debounce function. I thought it would be great if the Do-more had it also.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: Here is a neat code snippit to play with
« Reply #4 on: March 11, 2014, 01:07:57 AM »
My feeling about this is like the idea of having device-specific com boxes.  Rather than that, I'd rather have the generic boxes like Modbus just work really well.  If you were going to so something beyond what's there now, I'd rather have individual definable filters on the inputs, so more of a config thing than a new ladder box.

This is what I typically do, which does (I think) the same thing and is a little simpler.

I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: Here is a neat code snippit to play with
« Reply #5 on: March 11, 2014, 01:13:04 AM »
You could also create a periodic task and run it every 50ms or whatever, and in it copy the inputs you want to debounce to some proxy bits.  It's not as good as a true debounce, where the new state must be maintained for some set amount of time before it's accepted, but it would simulate the effect of DL Classic scan times with almost no effort.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: Here is a neat code snippit to play with
« Reply #6 on: March 11, 2014, 10:29:32 PM »
Wouldn't this be better addressed in some type of programmable input filtering? I never really understood the specs on the input modules, there are such wide ranges. Some are 1-8ms, others are 3-9ms. 

LWgreys

  • Hero Member
  • *****
  • Posts: 117
Re: Here is a neat code snippit to play with
« Reply #7 on: March 12, 2014, 11:47:47 PM »
does (I think) the same thing and is a little simpler.


Yes it does the same thing.
Look what I did. Shrunk it down to 2 rungs with two output Y14 & Y15, no Cs.

Really would like it on one rung.

plcnut

  • Hero Member
  • *****
  • Posts: 815
    • premiersi.com
Re: Here is a neat code snippit to play with
« Reply #8 on: March 14, 2014, 09:16:50 AM »
If Host decides to add an instruction/config...
I would prefer the instruction based debouncer to the config based. This would allow me to use the input for multiple purposes ie: Count transitions for 1 purpose, and the filtered input for another.
Circumstances don't determine who we are, they only reveal it.

~Jason Wolthuis
Premier Systems Integration, LLC
https://premiersi.com

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6174
  • Yes Pinky, Do-more will control the world!
Re: Here is a neat code snippit to play with
« Reply #9 on: March 14, 2014, 01:01:25 PM »
We'll support both. For brick I/O I am adding configuration based filtering in lieu of physical caps and resistors, but we are planning to add an instruction as well.
"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: Here is a neat code snippit to play with
« Reply #10 on: March 15, 2014, 10:16:46 AM »
 :)