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.

microcontroller in automotive environment

Status
Not open for further replies.

alex

New Member
Hello everyone,

This is my first post here. Hopefully somebody can point me in the right direction. I am building a few circuits to control various things in a car (lights, etc.) and am having trouble figuring out how to protect my microcontroller (pic12F683). Basically there are 3 things I need to do:
1. create a good 5V supply
2. inputs are 12V/GND lines
3. outputs need to be 12V to trigger relays

1. I know that "12v" in a car is not really 12V... it can range from 7V (while cranking engine) to 14.x volts (while running), and have large (I'm told 300V) spikes after cranking. So my power supply needs to handle all of that. Should I use a zener diode? A 7805? Something with zeners and transistors? It would be nice to keep it small (SMD) too, and efficient (if possible).

2. To get my inputs converted to 5V I suppose I could use a similar technique as #1, but it needs to have a sharper transition than the power supply. Could I use an optoisolator to route my existing 5V from #1 to an input pin? I've never worked with optoisolators before.

3. I know how to wire an output pin to a transistor to turn on/off a 12V line (through a resistor to limit current) but what happens if the 12V on that line spikes, could it bleed through the base and damage the transistor or microcontroller? Would an optoisolator be useful here as well?

I hope I have given enough details!
Thanks,
Alex
 
1) You can use a 7805 if you precede it with a Low Pass Filter to cutout the voltage spikes. There are also regulators specifically designed for the automotive environment.
2) You could simply use a resistor, zener and capacitor to limit the input voltage and spikes. An Opto-isolator is the 100% safe method. Both methods will affect maximum "speeds" or data rates.
3) Use a higher voltage rated transistor to drive the relay if you are worried about this. Putting the relays behind the LC Low Pass Filter used to protect the 7805 will also work.
 
Last edited:
Alex,

For item 1, I would use a DC-DC converter such as the LM2672 or equivalent for the 5V supply. Since it's a DC-DC type, it's more efficient (less heat and less battery drain compared to a 7805). It has a wide voltage input (made for automotive environment).

For item 2, I'll just use a 44k and 22k resistor voltage divider circuit, tap it from the middle for 4+ V when active high, add a 0.1 cap for filtering, a Schottky diode for backflow protection, and a 5.1V zener diode for overflow protection. All these will take up very little board space if you're using SMD components

For item 3, I'd use something like a VN750 or equivalent for high current requirement, or maybe a MIC2981 or equivalent to trigger some ~low power relays. It depend on the current requirement of the relay's coil. Look for this "highside" keyword when you're searching for this component.

(Maybe select a larger PIC with more I/O pins to do ICSP but the 12F683 may work.)

Good luck.
 
For the power supply look at +5V output .

■ Very low dropout voltage (0.15V typ. at 10mA
load)
■ Low quiescent current (typ. 2.5mA, at 100mA
load)
■ Output current up to 100mA
■ Adjustable (from VOUT = 2.5V only SO-8) and
fixed (3.3V & 5V) output voltage version
■ Internal current and thermal limit
■ Load dump protection up to 60V
■ Reverse transient protection up to -50V
■ Temperature range: -40 to 125°C
■ Package available: TO-92, DPAK, TO-220,
SO-8 (with inhibit control)​

If this does not have enough current there may be similar units out there that do.

3v0
 
Thanks for the quick replies! That is definitely helpful. I like that the LM2672 is efficient, although it's not all that critical for this application since the engine will be running. I didn't see any efficiency figures listed for the LM2931AZ50R, but it looks like it uses fewer external components - am I right in thinking that all I will need is a .1µF cap between Vin and ground, and a 100µF cap between Vo and ground? That's the sample they give in the datasheet.

phil7890, if I use the MIC2981, I assume I don't need any sort of protection on that? Either overvoltage/transient protection for the source voltage (straight car battery line), or reverse current protection for the output pin for when the relay closes? The datasheet says it's suitable for switching inductive loads, and the internal diagram shows a diode between IN and GND.

On tuesday I should have time to create my schematic, can I post that up here for you guys to look at?

Thanks again everyone,
Alex
 
Also keep in mind that most micro-controller manufactures sell their chips with optional grades for certain types of service, normally differentiated by temperature extremes that the device will run in. Automotive service is considered a pretty wide temperature environment so if you live in vary cold or hot climates you might consider that.
 
schematic

Hi everyone,

I created a schematic for my circuit... however there are some components that I don't know how to pick values for. I know that none of them are critical, but it would be nice to know how I can pick components that will not drain unnecessary power but still allow everything to work (like resistors, etc). The components hilighted in orange are the ones I'm not sure about.

Other than that, does this schematic look feasible?

**broken link removed**

Alex
 
Ok I posted this twice before but for some reason it didn't make it past moderation :confused:

Anyways, here is the schematic I came up with - anyone see any glaring errors? Also, the components highlighted in orange are ones that I don't know how to pick values for. I know none of them are critical, but could someone explain how you'd go about selecting those values, instead of just guessing?

Thanks everyone,
Alex

**broken link removed**
**broken link removed**
 
Last edited:
Hi Alex, regarding the voltage divider circuit... I think the shottky diode should be in parallel with the 0.1uF cap (not in series towards the PIC).

The switch in there will probably bounce and requires some software debouncing... or maybe add a small cap for hardware debouncing. There are various other fancy ways to debounce a switch, but an extra tiny cap along with that resistor is probably sufficient.

There's a cap near the /MCLR pin. I don't remember PICs that well but I think maybe this cap is not recommended for ICSP (if you're using ICSP).
 
Hi Alex, regarding the voltage divider circuit... I think the shottky diode should be in parallel with the 0.1uF cap (not in series towards the PIC).

The switch in there will probably bounce and requires some software debouncing... or maybe add a small cap for hardware debouncing. There are various other fancy ways to debounce a switch, but an extra tiny cap along with that resistor is probably sufficient.

There's a cap near the /MCLR pin. I don't remember PICs that well but I think maybe this cap is not recommended for ICSP (if you're using ICSP).



Hmm, so the schottky diode is oriented so + goes to ground and - goes to the MCU pin? I can see how that would allow a negative input to get grounded, but wouldn't it still present a - voltage to the MCU pin? Whereas if you put the schottky diode in series with the MCU pin, it would protect the MCU while grounding through the resistor at the left. Is that right?

I will pull the cap from the /MCLR pin, I saw that in the datasheet for the 16F876A but they didn't say what value cap to use. I suppose if I pull that out I don't need the resistors either.

And yes, the switch will be software debounced, thanks for reminding me :)
 
Hi Alex, if we put the schotkky diode in series I think that pin/line may float but I could be wrong. Anyways in the Microchip AN728 app note
https://www.electro-tech-online.com/custompdfs/2008/12/00728a.pdf
on page 8, near the "top left" side (after printing and rotating this page 90-degrees), they have this PNK / IGNition example for the wiring. They use a regular diode (labeled D7) here instead of a schotkky type. (They don't show a zener there - this is an extra component here for extra precaution.)

Regarding the /MCLR pin, there's this AN829 app note
https://www.electro-tech-online.com/custompdfs/2008/12/00910a.pdf
...on page 20, they have an example of this /MCLR ICSP connection. Just remove/short the 470 ohm and remove the 0.1 cap (but we do need that <40k resistor... it can be 10k or 22k if you're doing ICSP).
Have fun...
 
Status
Not open for further replies.

Latest threads

Back
Top