Author Topic: "Button" Sensor circuit  (Read 2688 times)

0 Members and 1 Guest are viewing this topic.

Offline GertlexTopic starter

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
"Button" Sensor circuit
« on: July 14, 2008, 12:38:31 PM »
I'm implementing a simple button sensor in a grabber.  I've gotten it to work fine, but I have a few questions:
http://www.societyofrobots.com/sensors_tactbumpswitch.shtml

Using either of the first two circuit diagrams, should I be expecting to get values of 0 or 255 depending on whether button is pressed?

Hmmmm...

I guess what I'm asking is should I be seeing an indicator of the resistor's size in the values?  AKA, as long as I put a large enough resistor in the circuit, I can subsequently forget about the size of the resistor when it comes to programming, etc.?

I also seemed to have damaged the first ADC port on my axon XD  (It works, but it's got a bit of a fuzz factor on it)
I

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: "Button" Sensor circuit
« Reply #1 on: July 14, 2008, 01:33:12 PM »
fuzz factor is noise. it will never, ever be dead as long electronics are around :P
if you are simply using a switch, make it a digital input, and add a pull-up/pull-down. you will see 0/1 instead. The switch doesn't have any more states than this, so it doesn't justify using an ADC. You added a pullup/pulldown to the switch even if you are using ADC reading, right?
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline paulstreats

  • Supreme Robot
  • *****
  • Posts: 1,381
  • Helpful? 21
Re: "Button" Sensor circuit
« Reply #2 on: July 14, 2008, 01:34:55 PM »
Why not just use a digital i/o port to register a simple button press?

A single resistor would not vary the adc reading it only changes the current and not the volts. You can use a voltage divider circuit with 2 resistors to measure voltage differences.

Has the suspect adc port being used with a push button? if so, are you using a debouncing circuit with the button? you might not have a damaged adc pin at all. It might even be as simple as changing the sampling rate in software.

Offline GertlexTopic starter

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
Re: "Button" Sensor circuit
« Reply #3 on: July 14, 2008, 02:01:13 PM »
Well of course i'm not using digital... I'm a newb here and Admin makes no mention of doing such in his placeholder guide for button type triggers.  I'll certainly look into that, though.

Am I correct in inferring that the onboard button's state is observed in code already using digital input?

Will look into it... but I do have my grabber/sensor combo working, that is it doesn't try to crush my finger ;)

As for the ADC0 port itself, well since it's not behaving like the other 11 working ADC ports, I'll consider it slightly damaged. I can still use it, though.

Example of output from adc0: 126_7_0_7_0_8_0_6_
Example of output from all the others: 131_0_0_0_0_0_1_0_1_0_1_0_1_0_0_0_0_0
Those are outputs when the pins are read each time i press the button, and with nothing connecting any of a set of three adc pins.
(I'm not sure why it always throws some weird first reading as the first value, e.g. 126 and 131 and other values around there, but I'm not concerned with that)
« Last Edit: July 14, 2008, 02:06:39 PM by Gertlex »
I

Offline Asellith

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 648
  • Helpful? 9
  • "I'm a leaf on the wind. Watch how I soar"
Re: "Button" Sensor circuit
« Reply #4 on: July 14, 2008, 05:30:28 PM »
What about debounce? When the switch is pressed but does not settle on a value for a few seconds. Hmm actually now that I think about it for a bit I remembered why my last project had that problem I was using the switch to trigger an interrupt in code and was firing the interrupt to many times.
Jonathan Bowen
CorSec Engineering
www.corseceng.com

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: "Button" Sensor circuit
« Reply #5 on: July 14, 2008, 06:21:48 PM »
You are not actually expecting 8 different channels to behave identically, are you? :P
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline GertlexTopic starter

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
Re: "Button" Sensor circuit
« Reply #6 on: July 14, 2008, 06:44:23 PM »
You are not actually expecting 8 different channels to behave identically, are you? :P

It behaved like the other 11 of them earlier... if you're again referring to the ADC pins/port.
I

Offline izua

  • Supreme Robot
  • *****
  • Posts: 682
  • Helpful? 0
Re: "Button" Sensor circuit
« Reply #7 on: July 14, 2008, 08:13:56 PM »
Nothing, ever, in digital electronics, behaves identically at such a low level. There are always impurities, the channels are positioned differently on silicium (and hence, influenced by different fields which are the result of what happens in the mcu), and then, there's noise. Lots of it, when it comes to clocked circuits.

Now, here's a simple test to see if your channel is really broken. Set up uart, and write some small code to change the channel on button presses (so you can select what channel you see). Hook up several pots as voltage dividers to each adc channel. Graph (using bray's terminal, for example) incoming data and turn the pot. Switch the channel, play with its respective pot. If you notice huge differences, the channel might be broken (if the pot is set up correctly, you have a low noise reference, etc). I'd recommend to send (and sample) your data in 8 bits (1 byte = 1 sample). Bray's terminal can only graph this, and it just makes everything easier.
Check out my homepage for in depth tutorials on microcontrollers and electronics.

Offline krich

  • Robot Overlord
  • ****
  • Posts: 165
  • Helpful? 0
Re: "Button" Sensor circuit
« Reply #8 on: July 15, 2008, 11:48:44 AM »
I do have my grabber/sensor combo working, that is it doesn't try to crush my finger ;)

Take a look at the recent thread on FSR, Force Sensitive Resistor.  This  might give you much better control over "finger crushing" and will better use the ADC setup that you have already developed.

Also, there's some good YouTube videos on FSR and how they work with regards to grabbers, so search for those if you need to nail down the concept.


Offline bulkhead

  • Full Member
  • ***
  • Posts: 102
  • Helpful? 0
Re: "Button" Sensor circuit
« Reply #9 on: July 16, 2008, 01:15:09 AM »
I'm surprised the tactile switch mini-tutorial doesn't mention anything about debouncing and rejecting noise.  Switch debouncing is extremely important so that 1) some noise doesn't cause a false trigger and 2)a single press is just that--a single press and not 20 "presses" occuring within the span of a few milliseconds.

Debouncing in hardware: there are IC's that will do this, or you can set up some type of RC circuit to make sure that the switch must be down for X milliseconds before it counts as a "switch pressed".

Debouncing in software: sample the switch 5 times, and if the switch is pressed for 4/5 times, then register it as a switch press; otherwise, it's either just noise or the switch is still settling (bouncing back and forth between the threshold, a good time to give it is ~30ms to settle).  If it is a time sensitive thing the 5 samples can be decreased; if it is something important (like a kill switch) the number of samples can be increased to guarantee no false triggers.

Offline BANE

  • Supreme Robot
  • *****
  • Posts: 639
  • Helpful? 4
  • E=roboticsC^2
Re: "Button" Sensor circuit
« Reply #10 on: July 16, 2008, 04:52:30 AM »
Couldn't you just filter data in the program?  Thats what i had to do with my ps2 controller
Bane

Offline GertlexTopic starter

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer · Roboticist
Re: "Button" Sensor circuit
« Reply #11 on: July 17, 2008, 09:40:50 AM »
I do have my grabber/sensor combo working, that is it doesn't try to crush my finger ;)

Take a look at the recent thread on FSR, Force Sensitive Resistor.  This  might give you much better control over "finger crushing" and will better use the ADC setup that you have already developed.

Also, there's some good YouTube videos on FSR and how they work with regards to grabbers, so search for those if you need to nail down the concept.



I saw that.

And if I ran around after each new project like that that I see, I'd never finish anything :P.
I

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,696
  • Helpful? 173
    • Society of Robots
Re: "Button" Sensor circuit
« Reply #12 on: July 17, 2008, 03:16:01 PM »
Have you seen this?
http://www.societyofrobots.com/robotforum/index.php?topic=4536.0

If I were to use ADC without bothering with configuring digital ports, I'd do something like:

Code: [Select]
if(button_port > 128)
   do something;
else // below 129
   ignore;


Quote
I'm surprised the tactile switch mini-tutorial doesn't mention anything about debouncing and rejecting noise.
That tutorial was never really written, just a quickie placeholder. Some day I'll find time to fix it up . . .

For debouncing, the easiest way is just to do:
delay_ms(100);//assume bouncing stops after 100ms


edit: Also, instructions can be found here:
http://www.societyofrobots.com/axon/axon_function_list.shtml#digital_input
« Last Edit: July 17, 2008, 03:22:12 PM by Admin »

 


Get Your Ad Here

data_list