difu and difdowm

Jeremy Leach

Senior Member
I wonder what the real question is here? Because if you understand what differential means then it's obvious that you will need to monitor the change in the incoming signal, and that's just down to regularly sampling the signal and checking the recent signal value with the last value.

So ...can you expand on exactly what you want to do ?
 
Last edited:

alexthefox

Senior Member
ok sorry.. i want to know when the signal move from 0 to 1, or when the signal return to 0 from 1
 

Attachments

Last edited:

Jeremy Leach

Senior Member
Ok, well I don't think Pulsin would work if you want to know the moment the transition occurs. So my suggestions would be to either 1) repeatedly monitor the logic level until it changes or 2) use interrupt that fires when the logic level changes. The advantage of 2) is that the picaxe can get on with other tasks until there's a change in level.
 

hippy

Ex-Staff (retired)
One thing is to not read the input pin consecutively as that will have problems with transitions between such reads. This would do the job by polling -

Code:
state = pinX
Do
  anyChange = state ^ pinX
  If anyChange <> 0 Then
    state = state ^ 1
    If state = 1 Then
      Gosub RisingEdge
    Else
      Gosub FallingEdge
    End If
  End If
Loop
Interrupts can be used as well as Jeremy suggests.

You could also use a Finite State Machine.

Which is best depends on what you are trying to achieve.
 
Last edited:
Top