Pulse counter - Is this correct settings for the signal?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
stin88
Normal user
Posts: 16
Joined: 29 Jul 2019, 18:36

Pulse counter - Is this correct settings for the signal?

#1 Post by stin88 » 02 Feb 2020, 18:07

not sure about the settings... read some over here..
viewtopic.php?t=3476
i thought i could use the log to determinate how fast its going high between and low but thats not how the web-logging interface works..

but heres the signal i like to count (and seems to count but not sure if its correct counting) :)
Image

Im not able to find any wiki about this plugin but im using the almost the same settings as
viewtopic.php?t=5284
but instead om 100ms, i use 10ms with falling... its around 50-100ms between low and high, forgot to check.. but what does mode type "change" mean? :?:

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Pulse counter - Is this correct settings for the signal?

#2 Post by TD-er » 03 Feb 2020, 15:23

I am not entirely sure what you try to measure here.
Are you trying to count events and failing because some pulses are too short?
Or you you want to measure the pulse width?

If it is about counting pulses with a relative long interval and short pulse width, then you could add a flipflop in front of the GPIO pin and then count each change (rise and falling edge).
The flipflop will be much faster in reacting to a pulse and will keep the changed state until it changes again.
So it will also clean up the signal for you.

GravityRZ
Normal user
Posts: 206
Joined: 23 Dec 2019, 21:24

Re: Pulse counter - Is this correct settings for the signal?

#3 Post by GravityRZ » 03 Feb 2020, 18:23

change means it counts a pulse when the signal goes from 0-1 and also when going from 1-0
in your case you want to count the pulse so it needs to be either falling or rising

falling counts when signal goes from 1-0
rising when signal goes from 0-1

you state your pulse is 50-100ms
what you need to know is when you can expect another pulse(is it also 50-100ms or longer)


the debounce time is to avoid jitter(eg counting distortion)

if the fastest time between pulses is 1 second the debounce time should be below 1 second(500ms)
however if the time between pulses is 50ms then the debounce time should be lower than that

if debounce is to long it will miss pulses, if to short it might count a disturbance as a pulse

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Pulse counter - Is this correct settings for the signal?

#4 Post by TD-er » 03 Feb 2020, 19:58

Please note that the debouncer should not be needed if the pulse comes from something that does not give bounces like a digital output of some chip.
It should have strong enough pull-up or -down resistors to make sure the signal will not pick up noise from some other source.

stin88
Normal user
Posts: 16
Joined: 29 Jul 2019, 18:36

Re: Pulse counter - Is this correct settings for the signal?

#5 Post by stin88 » 08 Feb 2020, 11:13

thanks for all replies, i will use RISING with debounce of 56ms.
Image

the counter works perfect.. now i need to read some more about using rules... I am not really comfortable using the rules but here you get a preview of what I am trying to achieve if there is someone who knows to point me in the right direction. :oops:

Code: Select all

if (GPIO(7) == HIGH && GPIO(1) == LOW) {
//read pulse counter value to dummy1
}
else if (GPIO(7) == LOW && GPIO(1) == HIGH) {
//read pulse counter value to dummy2
}
else {
  // reset pulse counter value to 0 
  // send notification that high/low values are set
}

Code: Select all

//Reset pulse counter.. when going to high/low state. 
on MOTOR-A#position=0 do
  if [MOTOR-B#position]=0
    TaskValueSet 12,1,0 // Empty the value of pulse counter (this is not finished)
  endif
endon

// IF motor-A not running but motor-B does, then save values from pulse counter to dummy 1 (high state)
on MOTOR-A#position=0 do
  if [MOTOR-B#position]=1
    TaskValueSet 12,1,0 // Save var1 to dummy1 (this is not finished)
  endif
endon

// IF motor-A running but motor B does not, then save value from pulse counter to dummy 2 (low state)
on MOTOR-A#position=1 do
  if [MOTOR-B#position]=0
    TaskValueSet 12,1,0 // Save var1 to dummy2 (this is not finished)
  endif
endon

Post Reply

Who is online

Users browsing this forum: No registered users and 31 guests