Our full technical support staff does not monitor this forum.
Please submit your question from our support page if you don't find an answer here.
Next Page

1

Previous Page

Created on: 04/09/12 04:46 PM

debounce for waitDigTrig() on CR800?

Replies: 2

kirving


Posts: 112
Joined: 09/15/08

debounce for waitDigTrig() on CR800?
04/09/12 4:46 PM

We have a device using a CR800 logger and the waitDigTrig() function to trigger actions via a mechanical push-button switch. The code is similar to:

scan(1,sec,0,0)
waitDigTrig(4,0)
call doStuff
nextscan

I've noticed that the action is also sometimes triggered by static discharge, and was wondering if a 'debounce' option might be possible algorithmically. The second parameter to waitDigTrig() is for an Option argument, but it does not seem to support debounce directly. We could perhaps add a brief delay after the trigger and then check the port again.

I notice that section 4.6.3 in a CR1000.pdf manual recommends a pull-up resistor for connecting switch closures for digital I/O, so maybe that's what we should be doing. That might be a better solution than trying to debounce in the program. Any thoughts on this?

[Report Inappropriate or Erroneous Content]

aps

United Kingdom


Campbell Scientific Ltd. Employee Campbell Scientific Ltd.

Posts: 668
Joined: 09/15/08

RE: debounce for waitDigTrig() on CR800?
04/10/12 4:44 AM

For this to work, I would guess your switch is connected between the control port and 5V, otherwise it would never generate a pulse on closure?

Control ports do have a 100k pull down resistor to hold the port low but if you have long, unshielded cables then big enough transients could trigger the Waitdigtrig input.

There are several ways to solve this.

a) add a lower value resistor across the control port input, e.g. 10k, to pull down the input "harder". This will not solve the problem of switch bounce through.

b) add a small capacitor across the input of the control port, which in combination with the logger's pull down resistor will act both as a simple debounce and noise filter. A 1 microfarad capacitor should do the trick.

c)use a software trick as you say, but you need to be careful as you are not really looking at debounce alone but also noise filtering, so you would need to check the port was held high for a reasonable time (to avoid the spikes) and if not jump around the call to dostuff.

Andrew Sandford, Technical Director, Campbell Scientific Ltd., U.K.

[Report Inappropriate or Erroneous Content]

kirving


Posts: 112
Joined: 09/15/08

RE: debounce for waitDigTrig() on CR800?
04/10/12 8:38 PM

Thanks. That is correct, the switch connects +5V to the control port. The spurious triggers may only be a problem in the lab, but if they persist we'll try the capacitor.

[Report Inappropriate or Erroneous Content]

Next Page

1

Previous Page

Reply

Please login to post a response.