Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
Hardwyre
PostPosted: Dec 17, 2011 - 10:32 AM
Newbie


Joined: Dec 15, 2011
Posts: 12


Hi AVRF!

So this is my first adventure into microprocessor (uC) controlled devices. I've spent the last week designing a circuit and I think I've got it finished. Because it is an amalgamation of various tutorials and different sites, I may have missed something, or I have gone over board.. I'm not entirely sure.

What the circuit for is a blinker control for my Datsun 280Z. The dual-filament bulbs have a common ground for the parking and blinker functions of the lights. Looking at this wiring diagram, I'm pretty sure the blinker switch toggles the positive/power side of the blinker.

http://www.4moores.com/280z/files/test_ ... 20copy.jpg

What I'm trying to do with my design is get main power for the uC from the parking lamp side, ground from the common ground or chassis ground, and use the left and right blinkers as signals for a pair of inputs on the uC for the code.

What I am trying to emulate is Audi's blinker/running light arrangement. When the parking/head lights are on, a pair of LED bars are turned on as marker lights. However, when the left or right blinker is turned on, the selected side obviously begins blinking while the opposite side turns off until the blinker switch is returned to is neutral position.

I have a 5 volt regulator on the main power to run the uC, and I'm using 4.7+v zener diodes with 390ohm resistors on the two blinker inputs to bring the power down to a safe level for the inputs.

I have the reset pin of the AtTiny85 tied high with a 10k resistor and linked to the reset pin of the IPS header.

The two output pins are tied to each of their own MOSFETs on the logic level gate pins though 1k resistors. The MOSFETs' source pins are both linked to a solder select jumper to source either 12+ (or whatever the battery is charging at) or ground, depending on where in series with the LED bars I'll be using the circuit is placed.

I would like to figure out some way to be able to change on inputs to be pulled high and use a low signal as the trigger in the case another vehicle switches the ground for the blinkers instead.


I just realized that this won't turn on and the blinkers won't work unless the parking lights and/or headlights are on. I think I can resolve that by passing the power from the blinkers themselves through a few diodes to the main power input of the 5v power supply circuit. Or maybe just the main line to the accessory/switched power in the car so they're always on and function are real running lights.

Anyways. All that stuff is secondary. I hope I've explained what I'm trying to do and that someone might be able to look over what I'm put together and provide any feed back, suggestions, criticisms, etc.

Thank you.

I've attached the Eagle files.
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: Dec 17, 2011 - 10:41 AM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia

Quote:
The MOSFETs' source pins are both linked to a solder select jumper to source either 12+ (or whatever the battery is charging at) or ground
Totally wrong. You can't reverse the MOSFETs' source terminals to +12V, only GND is allowed.

Quote:
I've attached the Eagle files.
Who's that Eagle? Reattach the .jpg/.png/.pdf instead.

P.S. this should have been posted to a General Electronics instead.
 
 View user's profile Send private message  
Reply with quote Back to top
Hardwyre
PostPosted: Dec 17, 2011 - 11:10 AM
Newbie


Joined: Dec 15, 2011
Posts: 12


Ahh... now I see the problem. MOSFETs reference their gate to the source. So the way I have it now, I would have to drive the gate way higher than I can source from the micro. Thank you. Luckily it's an easy fix at the moment. I can remove the selector and run the trace to ground.

Eagle is a shareware PCB design program. It's got a free "light" version that lets you make 2 layer 80mm x 100mm boards.

Here's the jpegs of the board and schematic:



Click for full size:


I'll remember to post things like this in the GE forum in the future. I was just thinking because I'm using an 8-bit micro, it went here. Thank you for the correction.
 
 View user's profile Send private message  
Reply with quote Back to top
Kartman
PostPosted: Dec 17, 2011 - 11:26 AM
Raving lunatic


Joined: Dec 30, 2004
Posts: 8789
Location: Melbourne,Australia

The regulator probably wont appreciate the auto electrics, nor will the inputs with no protection or filtering.
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: Dec 17, 2011 - 11:30 AM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia

I do know what Eagle is - I just wanted to show you that many of us do not have (and want) it readily installed.

Make the D2 and D3 zeners to shunt PB3/PB4 inputs to GND instead of being connected in series, and increase R1 and R2 values to ~20k - otherwise you will easily fry your Tiny.

The R4 and R5 resistor values also should be increased to ~10k. You do not need any extreme speed in turning your FETs on/off, and your 1k gate resistors may damage your Tiny in case of the FET gate-drain breakdown.

As Kartman said, you have to replace your 1117 regulator with an automotive grade one (did you know that the car's +12V may have spikes at least from -10 to +50V?), and add the 1 nF caps from PB3/PB4 inputs to GND to filter the EMI.
 
 View user's profile Send private message  
Reply with quote Back to top
DocJC
PostPosted: Dec 17, 2011 - 08:55 PM
Raving lunatic


Joined: Dec 11, 2007
Posts: 6856
Location: Cleveland, OH

I think you are off to a good start.

Power your micro from either an always on source, or from an accessory on source, your choice for when you want the lights to be operational.

Be sure to put a small fuse in the V+ line to your micro, and perhaps in the power drive lines.

Use an automotive grade voltage regulator, and put a heat sink on it.

An LM2940 is an example of a linear regulator designed for vehicular applications.

Google "Load Dump" for lots of info on the electrically very noisy and spiky power bus encountered in vehicles.

Every input should be protected from over voltage spikes. A resistor-Zener is adequate, adding a small cap across the resistor is even better. Better designs exist, but this will work.

The circuit you are describing has the load connected to ground, and you are supply the power to the V+ side of the load. You are also using a logic level signal to control this. There are several examples of "High Side Drivers" on the forum, and via Google. One can also purchase a High Side Driver which incorporates the FET and the logic level driver interface, which then makes it easy.

I've used IR3310 High Side Drivers before, but used 2N2222 transistors to drive them. If you look around you should be able to find a HSD with logic level inputs and an adequate maximum current rating. Note that cold filament light bulbs will look almost like a short circuit at turn on, until the filament heats up.

As you review your design, and the various voltage sources, be sure that when your vehicle is off, and you want the lights to be off, they will be off. You do not want a floating or incorrectly pulled line turning the lights on when they should not be on.

The diagram has a couple of sections cut & pasted here to give you some further ideas.

You might want to consider mounting holes for your PCB. Vehicles are a very bumpy environment with lots of vibration.

You might want to put a Version number and date on your PCB.

You might want to put an additional marker for the programming header, Pin #1, and perhaps for the Pin #1 for other chips.

JC
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
indianajones11
PostPosted: Dec 18, 2011 - 12:24 AM
Raving lunatic


Joined: Nov 28, 2004
Posts: 3552
Location: San Diego, Ca

Hardwyre you can make a pdf file of your *.sch or *.brd by going File -> print -> at the top hit "Output File" and *.pdf will be one of the auto. extensions available .

Printer field will change to "Print to File" and it will save to a file and WON'T print . If you have a recent enough version .

If the MCU had more pins and were UNUSED, what's the safest practice for them, to keep the bad stuff out ? Inputs tied to ground, outputs with low value, whatever and should they have any components to protect against EMI creeping in and causing trouble... ?

_________________
1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1
 
 View user's profile Send private message  
Reply with quote Back to top
LDEVRIES
PostPosted: Dec 18, 2011 - 06:04 AM
Raving lunatic


Joined: May 04, 2007
Posts: 3529
Location: Geelong Australia, Home of the "Cats"

IMHO, the Eagle schematics are much easier to read when the background is white, instead of the default black.

_________________
Charles Darwin, Lord Kelvin & Murphy are always lurking about!
Lee -.-
(If you haven't already done so, edit your PostNuke profile and let let us know where you are, what you do & what your interests are.)
 
 View user's profile Send private message Visit poster's website 
Reply with quote Back to top
Hardwyre
PostPosted: Dec 19, 2011 - 11:47 AM
Newbie


Joined: Dec 15, 2011
Posts: 12


Wow. Thank you everyone. I am in the process of incorporating all your pieces of advice into the circuit.

The regulator is now an LM2940CT-5.0/NOPB. I see what you mean by it being specifically built for dirty automotive sources. Has integrated circuitry that shuts it down entirely if large voltage spikes are detected. Very nice.

I've added 1nf caps to all the inputs, as well as rearranged their protection circuits using the example DocJC posted.

V+ is going to be to a switched source, while VPARK will go to the parking lights and one of the inputs to trigger bilateral running lights.

V_IN_Right(or Left) will be used to start the appropriate blinking on either side with the opposite side turning off for a moment.

Thank you for describing that the circuit I had in my head was a high side driver. The appropriate "lower side driver?" with the MOSFETs should work just fine. I just didn't understand the importance of placement at the moment I was bumbling through everything.

I am curious what I should use for overcurrent protection. I like the idea of PTCs, and I'm thinking 30V at 200mA lhold and 400mA ltrip on each of the four power inputs should work... but I'm also wonder if the three pin inputs should be something smaller since I think the micro's inputs only soak 20mA safely (50mA max), so should I use something with an lhold of 20mA and 40mA ltrip?

On the input to the power supply, should I use a standard inline ATO/ATC/ATM fuse instead of a PTC? If so, what amperage? 1? 2? I really do appreciate the information. I'm an RN by trade, so this is all just study for me.

Here is the updated schematic (in white on a PDF!)
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: Dec 19, 2011 - 12:11 PM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia

1. Never add a diode (D4 in your case) to the GND rail, the D1 in a +12V rail is enough for reverse polarity protection.

2. Your N-FETs will not work at all. To switch the positive rail you need to use the P-channel MOSFETs with another low power NPN- or N-channel FET transistor to provide the full 0..+12V gate voltage trip. Your AVR can give only 0..+5V trip.

3. The F2 is useless.

4. The C4 may screw up your ICSP.

So far, so bad Laughing
 
 View user's profile Send private message  
Reply with quote Back to top
Hardwyre
PostPosted: Dec 19, 2011 - 12:40 PM
Newbie


Joined: Dec 15, 2011
Posts: 12


VLED is on the GND rail with the FETs. I moved them off of the positive rail after you told me they can only source ground. I should probably rename them LED_GND or something more clear.

The FETs themselves are listed as being logic level design in the data sheet (http://search.digikey.com/us/en/products/IRF7401TRPBF/IRF7401PBFCT-ND/812582)

Series
HEXFET®

FET Type
MOSFET N-Channel, Metal Oxide

FET Feature
Logic Level Gate

Rds On (Max) @ Id, Vgs
22 mOhm @ 4.1A, 4.5V

Drain to Source Voltage (Vdss)
20V

Current - Continuous Drain (Id) @ 25° C
8.7A

Vgs(th) (Max) @ Id
700mV @ 250µA

Gate Charge (Qg) @ Vgs 48nC @
4.5V

Input Capacitance (Ciss) @ Vds
1600pF @ 15V

My understand of the logic level FETs is that they didn't need +12 on the gate to get a complete switching. Am I wrong on this?

F2 on VPARK is a positive rail coming from the parking lights. It's not going to provide any protection at all?

Should I switch over to a micro with more i/o pins so I'm not sharing the IPS header with inputs and outputs?

So far, so bad, but my knowledge is expanding. Smile
 
 View user's profile Send private message  
Reply with quote Back to top
Jepael
PostPosted: Dec 19, 2011 - 01:05 PM
Raving lunatic


Joined: May 24, 2004
Posts: 6002
Location: Tampere, Finland

What on earth are those FETs supposed to drive?

Yes they are logic level N-channel FETs, when Gate has about 4.5V or more compared to Source (Vgs) then it is on. It means Source must be connected to GND or near it.

Besides you drive the FETs through 10kohms resistance. While it is true that FETs are controlled by gate voltage, the gate is capacitive in nature. It means large resistance will charge the gate slowly and the FET spends a lot of time between fully on and fully off state, so the FET dissipates power. Depending on how often you change the state and how big load you are driving, the FET may not survive even the first turn-on cycle.

Besides if the AVR is in reset state or being programmed, there is nothing defining the FET gate state so it may happily float at some halfway on voltage and the FET is constantly heating.
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: Dec 19, 2011 - 01:07 PM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia

OK, then for the low side switching your FETs are fine - I hope now you learned to give your nets meaningful names. Add the ~10k pulldown resistors to their gates to avoid gates floating.

The F2 is connected in series with a 20k resistor which provides all necessary protection itself. Since the F2 resistance is only few Ohms, it will never ever trip in any circumstances, that's why it's useless.
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: Dec 19, 2011 - 01:15 PM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia

Jepael wrote:
you drive the FETs through 10kohms resistance.
His switching target is just a car turning light LED strip which doesn't require to be switched any fast. In this case the 10k resistors are fine because they do provide a necessary AVR port protection in case of a FET's G-D breakdown. Moreover, 10kOhm * 1 nF * 2.2 = ~ 20 uS only.
 
 View user's profile Send private message  
Reply with quote Back to top
indianajones11
PostPosted: Dec 19, 2011 - 08:33 PM
Raving lunatic


Joined: Nov 28, 2004
Posts: 3552
Location: San Diego, Ca

Quote:
My understand of the logic level FETs is that they didn't need +12 on the gate to get a complete switching.
You better make sure the FETs even turn on at all because of gate capacitance, B 4 making a board ! If they won't, you'll need FET driver chips .

I once had a resistive load that had to be switched with an N-channel Fet and it was good that I tested B 4 making my *.brd, 'cause it needed the driver .

_________________
1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: Dec 19, 2011 - 08:39 PM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia

indianajones11 wrote:
You better make sure the FETs even turn on at all because of gate capacitance, B 4 making a board ! If they won't, you'll need FET driver chips .
Why on Earth wouldn't they turn on? Is the 1..2 nF G-S capacity any terrible?
 
 View user's profile Send private message  
Reply with quote Back to top
Hardwyre
PostPosted: Dec 20, 2011 - 02:36 AM
Newbie


Joined: Dec 15, 2011
Posts: 12


I was reading another tutorial on FETs and it brought up gate threshold.

http://www.electronics-tutorials.ws/transistor/tran_7.html

Quote:
Because of the extremely high input or gate resistance that the MOSFET has, its very fast switching speeds and the ease at which they can be driven makes them ideal to interface with op-amps or standard logic gates. However, care must be taken to ensure that the gate-source input voltage is correctly chosen because when using the MOSFET as a switch the device must obtain a low RDS(on) channel resistance in proportion to this input gate voltage. Low threshold type MOSFETs may not switch "ON" until a least 3V or 4V has been applied to its gate and if the output from the logic gate is only +5V logic it may be insufficient to fully drive the MOSFET into saturation. Using lower threshold MOSFETs designed for interfacing with TTL and CMOS logic gates that have thresholds as low as 1.5V to 2.0V are available.


The Vgs(th) of the chips I've picked is a minimum of 0.7V. I'm making a calculated effort that this is where the chip begins to turn on, and 4.5v is when it is fully turned on.

Speaking of the draining issues with the gate capacitance, I keep seeing some diagrams that show a resistor to ground between the output pin resistor and the gate pin, but I can't find the equation for calculating the resistor value. Would this be something I could use to ensure the gate drains entirely? I'm assuming the resistance would have to be less than the output pin's resistor, but high enough that current will flow into the gate when it's being switched.

Learning learning learning. Smile

MBedder, with the F2, wouldn't it provide protection in the case there's a short to ground somewhere? Or is the resistor already doing plenty?
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: Dec 20, 2011 - 05:41 AM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia

The resistor is more than enough.

_________________
Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.
 
 View user's profile Send private message  
Reply with quote Back to top
Hardwyre
PostPosted: Dec 20, 2011 - 10:12 AM
Newbie


Joined: Dec 15, 2011
Posts: 12


Okay. So I removed the PTCs from the inputs, but left one on the main power in before the voltage regulator.

Some research suggested adding a 20k resistor on the output pins just before the FETs' gates to help prevent floating.

More reading came up with 4k7 resistors on the SPI pins after the ISP header connections, so I've added those. The filtering caps at 1nf as suggested, but more reading states these might cause problems, especially with the SCK input, but under 10nf, the problem clears up. Should I go with a sub-nanofared cap for the SCK?

I also re-arranged the pin arrangements. Both the FETs are now on non-IPS pins (in this case, PB3 and PB4) and the inputs are on the MISO, MOSI, and SCK pins. My thought being is that removing the FETs from the programming pins, I reduce the chance of having them interfere with the programming.

How am I doing? Moving forward or backwards? Revision attached.
 
 View user's profile Send private message  
Reply with quote Back to top
MBedder
PostPosted: Dec 20, 2011 - 11:09 AM
Raving lunatic


Joined: Nov 02, 2009
Posts: 3239
Location: Zelenograd, Russia

You're almost there. Just increase the R13/R14 values up to 100k or move'm one step left - to the AVR ports, which is better because in this case you will not loose the gate voltage amplitude.

_________________
Warning: Grumpy Old Chuff. Reading this post may severely damage your mental health.
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits