This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

HOW TO IMPLEMENT DEALY IN CODING

I have written code for sensing input and then output port to respond. I want to add delay between the two actions. Can any one help me out.

Parents
  • Have you no ideas of your own?

    Like time-stamping the change of the input and in your loop decide if enough time have passed for the output to toggle too?

    Or implementing a "delay chain" where you sample the input at a fixed speed and store in an n step long ring-buffer and every time you insert a new input sample into the ring buffer you take out an old sample and use to control the output - multiple pulses in the input will then repeat as the same number of pulses on the output, but delayed based on the length of this delay chain.

    Or change the "delay chain" to only store actual changes of the input with state+time and constantly peek the tail of the chain to see if it's time to extract and execute a change to the output.

Reply
  • Have you no ideas of your own?

    Like time-stamping the change of the input and in your loop decide if enough time have passed for the output to toggle too?

    Or implementing a "delay chain" where you sample the input at a fixed speed and store in an n step long ring-buffer and every time you insert a new input sample into the ring buffer you take out an old sample and use to control the output - multiple pulses in the input will then repeat as the same number of pulses on the output, but delayed based on the length of this delay chain.

    Or change the "delay chain" to only store actual changes of the input with state+time and constantly peek the tail of the chain to see if it's time to extract and execute a change to the output.

Children
No data