Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: WhomBom on September 07, 2009, 02:54:08 PM

Title: probably a dumb question...
Post by: WhomBom on September 07, 2009, 02:54:08 PM
I want to use some switches to sense if something is in my robot's claw. If any of the switches is pressed i want a digital input pin to go high (5V), 5V is supplied by the arduino regulated output. Should i use a resistor? if yes how much Ohm should it be?

My guess is i have to use a resistor and the bigger the Ohm rating the better, but i really dont want to frie anything again  ::)

(http://img267.imageshack.us/img267/1783/schakelingtactswitch.jpg)

here's a graphic example of what i mean

Also: how important is it to have regulated power? Right now i just hook everything up to a 6V NiCad (7V when fully charged) but every servo has it's own cap, plus there's another one attached to the battery.
Title: Re: probably a dumb question...
Post by: SmAsH on September 08, 2009, 12:33:58 AM
For microcontrollers, never use unregulated power, bad things will happen.

For use of a resistor, if you want to, you can use a pull down resistor to stop the input from floating while the button is not pressed. The resistance should be somewhere between 4K7 and 10K or 10k and 47k.

as for switches, i assume you are using momentary switches?
Title: Re: probably a dumb question...
Post by: airman00 on September 08, 2009, 05:19:18 PM
You're going to need a really sensitive switch, I would personally go with a rangefinder of some sort.

But if you want to do switch then:
1. Use the internal pullups that are available on the ATmega168 - aka the Arduino "chip" . This will eliminate the need for external resistors.
2. Connect the switch to ground (also known as negative). This means the pin will go LOW when its pressed. This is necessary for the Internal Pullups to work.


Quoted from the Arduino website:
Quote
Pullup Resistors

Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pullup resistor (to +5V), or pulldown resistor (resistor to ground) on the input, with 10K being a common value.

There are also convenient 20K pullup resistors built into the Atmega chip that can be accessed from software. These built-in pullup resistors are accessed in the following manner.

pinMode(pin, INPUT);           // set pin to input
digitalWrite(pin, HIGH);       // turn on pullup resistors


Note that the pullup resistors provide enough current to dimly light an LED connected to a pin that has been configured as an input. If LED's in a project seem to be working, but very dimly, this is likely what is going on, and the programmer has forgotten to use pinMode() to set the pins to outputs.

Note also that the pullup resistors are controlled by the same registers (internal chip memory locations) that control whether a pin is HIGH or LOW. Consequently a pin that is configured to have pullup resistors turned on when the pin is an INPUT, will have the pin configured as HIGH if the pin is then swtiched to an OUTPUT with pinMode(). This works in the other direction as well, and an output pin that is left in a HIGH state will have the pullup resistors set if switched to an input with pinMode().
Title: Re: probably a dumb question...
Post by: WhomBom on September 09, 2009, 04:17:45 PM
Thanks for the answers!

I found out that the duemilanove has it's ow power regulater and may receive an input voltage of 6V-20V, so i wouldn't need an external one right? I don't care if my servo's receive noisy current.
Still if the battery start's to approach 6V the arduino tends to reset if motors start sucking power,  with a relatively full battery it has no problems. To tackle this problem if found an old 10.000 microFarad elko, it has no date on it but it looks old.. Right now i have a 2200microF and three 220's. That doesn't seem to cut it if battery's start running low.

As for the switches, they are crude. I don't know what momentary means, but if they are pressed a contact is established, when released the contact is broken again. I ripped them from the control panel of a cd player. I already thought of using a led and a ldr with color lens to make a sort of sensor, but didn't like it and decided to go switches.
 But then i read about seeker II a mini sumo bot and saw it uses an ir led and detector to make a close range sensor.. but i already started on the switchess o for now i think i'll use the switches and see if it works. And thanks again for the tip's!
Title: Re: probably a dumb question...
Post by: SmAsH on September 10, 2009, 06:12:39 AM
Just chuck a big cap in there and it should help heaps, i mean 400-1000uf!
Make sure you take the switch power from the regulated pin!

Those switches you listed are momentary, momentary means only on while pushed down (moment).
They are most likely tactile switches, they are very common in small electronics like cd players, vcrs, dvd etc...