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.

Interfacing 12v signals to a microcontroller

Status
Not open for further replies.

MalcolmT

New Member
Hi Folks,

I'd appreciate a little help with a problem which I really should be able to answer myself.
I'm designing some microcontroller based alarm systems for very small houses. They're 3 or 4 room dwellings in our townships.
The PCB's will be assembled by semiskilled folk, so I need to keep the component count to a minimum,

I need to interface 12v signals to the microcontroller, whilst I have no problem doing a bullet proof design with discrete component's, it would be great if a can achieve something similar with one or two low cost ic's.

Quad or hex channel ic's would be good, maybe 74 or CD series chips could be used.

Can anyone suggest anything suitable.

Regards
Malcolm
Parys, South Africa
 
If you want it idiot proof, then fit opto-isolators to the inputs. I suggest something like this:-https://uk.rs-online.com/web/p/optocoupler-ics/6998253/

The input from 12 V will need a resistor in series. A second resistor in parallel with the opto-isolator input is a good idea to reduce the chance of it being triggered by a low voltage. I suggest 1 k in parallel with the opto-isolator and 4k7 in series with the combination.
 
I'd use a two resistor divider at each input to reduce the 12V to around 5V.
2k2 from MCU input to ground and either 2k7 or 3k3 MCU input to the 12V signal should work as a basic setup.

Or you can add debounce & noise filtering by connecting eg. a 100K resistor from that divider output to the MCU input pin, plus a 0.1uF cap to ground from the MCU pin.

The input should be in schmitt trigger mode for that, as the signal can change relatively slowly.

Edit. re. another answer - Optos are pretty much essential if the signal source and MCU are using different ground or 0V connections, as there could be voltage offsets.

If everything is sharing the same ground, they are totally pointless and just add complications & expense.


Edit 2 - To keep the component count to a minimum, consider using resistor arrays, rather than discrete resistors.

You can get ones with eg. four or eight separate resistors in SIL or DIL format for the series resistors, and commoned SIL ones with eg. eight resistors commoned to the 9th pin for the pulldowns.
(Or pullups, in other applications).
 
Last edited:
Another thought as it's a security system:

Most newer ones use terminating resistors at the sensors, so a wiring fault or tampering can be detected; quite a few PIRs etc. include a 1K terminator resistor selectable by a jumper.
That is very easy to implement with an MCU, just use a resistive divider and analog inputs.

eg. For your 12V system, a fixed divider with three resistors from 12V to 0V; two 470 Ohms and a 220 Ohm, in that sequence.

The top of the 220R goes to the MCU ADC pin and the external alarm sensor connects between the junction of the two 470R resistors and 0V.

With a good circuit and 1K loop termination to 0V, you should get roughly 1.8V
If the loop is broken, that will go up to ~2.28, while if the loop is shorted it will be near 0V.
(And if the input is shorted to 12V, it does not do any harm; around 4V at the ADC input).
 
Another thought as it's a security system:

Most newer ones use terminating resistors at the sensors, so a wiring fault or tampering can be detected; quite a few PIRs etc. include a 1K terminator resistor selectable by a jumper.
That is very easy to implement with an MCU, just use a resistive divider and analog inputs.

eg. For your 12V system, a fixed divider with three resistors from 12V to 0V; two 470 Ohms and a 220 Ohm, in that sequence.

The top of the 220R goes to the MCU ADC pin and the external alarm sensor connects between the junction of the two 470R resistors and 0V.

With a good circuit and 1K loop termination to 0V, you should get roughly 1.8V
If the loop is broken, that will go up to ~2.28, while if the loop is shorted it will be near 0V.
(And if the input is shorted to 12V, it does not do any harm; around 4V at the ADC input).

Its a good idea, I plan to use the small PIR's used in Arduino kits etc. Their range is less than the usual types, but then the rooms are far smaller, also they are far cheaper. Being inside the protected area I wasn't too concerned about tampering.
They system will have inputs for PIR's, panic switches, a dedicated door entry switch, and the option of window switches.

I'll take a slightly different approach to the strobe light and siren, again because houses are far closer together than in the regular developed areas. The siren and strobe led will have tamper protection.

Nothing like this is sold by the usual security system suppliers, there are a few companies selling low cost systems from china. The specs are good, the price is excellent, but the suppliers offer zero support. My system will be repairable, not a single SMD in sight.

Cheers
Malcolm
 
I have always favored the approach used in this EDN article:

**broken link removed**. It uses old-school MC1489 quad RS232 interface chips and will handle a wide input range of up to 30v. Unlike voltage divider inputs or optically-coupled signals, it handles a wide input range without any adjustments being required.

Screenshot_20201201-050945_Edge.jpg
 
I have always favored the approach used in this EDN article:

**broken link removed**. It uses old-school MC1489 quad RS232 interface chips and will handle a wide input range of up to 30v. Unlike voltage divider inputs or optically-coupled signals, it handles a wide input range without any adjustments being required.

View attachment 128260
Something much like this will do the trick.
Thanks for the ideas, now to get cracking.

Thanks Again.
MalcolmT
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top