Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

how do I detect this switch 20 to 30 meters away?

Status
Not open for further replies.

j3Riks

New Member
if i connect a switch to a microcontroller 20 to 30 meters from each other.

how do i detect if the switch has changed state? considering the distance.

someone presses the switch(on state) then it is released after(off state).

in that very fast sequence how will i be able to know that it was even pressed?!

should i increase the voltage or current? how do i do this?

any suggestions would be appreciated. thanks.
 
The problem not the switching speed. The long cable working as aerial, and can receive strange signals. Use optocoupler on processor side.
 
so after putting an optocoupler what else should i do about the fast switching?

do i need to use transistors from where the switch is connected to the microcontroller? to pull up some voltage or current?

i really don't know what to do.
 
You could connect an optocoupler like this. R1 gives about 8mA thru the opto's LED and R2 gives about 5mA thru the opto's transistor. Your output will be inverted (i.e. switch on=output low). Motorola's databook says switching time will be on the order of microseconds.
 

Attachments

  • opto.gif
    opto.gif
    1.4 KB · Views: 538
well i have no experience in using optocouplers.

so optocouplers protects the microcontroller/filters the signal? is this what it does?

@jbeng
in your circuit you just used 5 volts. is this enough? considering the distance?

will the microcontroller be able to sense the fast switching just by using an optocoupler and using a very small voltage?
 
opto very good and all. But distance a problem here. It could work but line-drivers will be best here. teh 422 is very good and easy to interface to
 
Styx said:
opto very good and all. But distance a problem here. It could work but line-drivers will be best here. teh 422 is very good and easy to interface to

There's no need for it, an opto-coupler as shown would be ideal, basically because it's current driven, rather than voltage driven - if the resistance of the wire was as high as 470 ohms, there's still plenty of current to feed the LED.
 
j3Riks said:
@jbeng
in your circuit you just used 5 volts. is this enough? considering the distance?

You could use a higher LED voltage, say 12VDC if you want, but you will need to adjust the value of R1 so that you don't put too much current thru the LED and burn it out. Motorola says the LED in the 4N37 can handle a max forward current of 60mA(!), but they recommend about 10mA for normal operation ...
 
really?! using an optocoupler will solve my problem?

thanks guys!

i'll try jbeng's circuit.

so setting aside the problem. what's the best optocoupler to use? are there different kinds of optocouplers?

should i only use the Phototransistor type?
 
The opto type depend from desired speed. If You really use a push-button, enough the poor PC817, 4N25 or similar. Don't forget the debouncing.
 
well the image device below is the one connected to the microcontroller. it detects something that passes through it.

as you can see it just functions like a switch, does it need debouncing(program code debouncing)?

**broken link removed**

i'm planning also to use many of these sensors and connect it to the microcontroller just like in a key matrix.

what circuitry(circuit design) should i make to properly implement it?
 
are multiplexers used to increase the number of possible key switches in a key matrix? i mean over a hundred of switches.

the column of the matrix is connected to the output of the microcontroller and the row is connected to the multiplexers, while the outputs of the mulitplexers are the ones that are connected to the inputs of the microcontroller.

thus by increasing the multiplexers the number of rows are multiplied.

so if i use 8 ports as outputs(column) and for example 5pcs of 16X1 MUX. my switches can reach up to 8 * (5*16) = 640 switches.

and only utilizing 5 input ports of the microcontroller.

is this correct and functional? or are there other ways?
 
is it a parallel-in serial-out shift register? how do i cascade these registers and how will i read the serial data?
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top