News:

  • May 15, 2025, 03:28:54 PM

Login with username, password and session length

Author Topic: One-Shot rising edge and Math Instruction  (Read 794 times)

scottsutton

  • Full Member
  • ***
  • Posts: 38
One-Shot rising edge and Math Instruction
« on: April 22, 2025, 08:59:00 AM »
Just curious if I put as expression in a Math Box Instruction, example (D34 - 1 = D34) and enable that Math Box with a one-shot rising edge contact will it always only execute on time per rising edge? I am doing this in a code and it appears to be stable 99% of the time. But every now and then it seems to execute more than once per rising edge contact. This could be another issue in the code but I just wanted to make sure that this logic usage is valid.

Thanks,
Scott

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3745
    • Host Engineering
Re: One-Shot rising edge and Math Instruction
« Reply #1 on: April 22, 2025, 10:33:29 AM »
Yes.  It will only execute once.

put an INC V99 below your MATH box.  V99 will increment whenever the MATH box has power flow.  Trend V99 and see if it also "misbehaves".  If so, that means that your issue is on the edge contact.

If V99 is NOT misbehaving like D34, that means that something else is writing to your D34 - check cross reference (anything else writing to D34?), array references (something writing to D[V42] with V42 set to 34), external comm writing to D34, ...

scottsutton

  • Full Member
  • ***
  • Posts: 38
Re: One-Shot rising edge and Math Instruction
« Reply #2 on: April 28, 2025, 03:27:29 PM »
Thanks for the help. Yes, I did verify that as you say it will only execute once per rising edge. I had another section of the code that was also writing to this variable causing the intermittent problem.

Scott

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3745
    • Host Engineering
Re: One-Shot rising edge and Math Instruction
« Reply #3 on: April 28, 2025, 04:07:00 PM »
Thanks for the help. Yes, I did verify that as you say it will only execute once per rising edge. I had another section of the code that was also writing to this variable causing the intermittent problem.

Scott
Great!  Glad you figured it out.  INC is a great debug tool (better than just setting a bit on an edge event or delta event)