Electronics Forum

Electronics Circuits & Projects discussion forum. Get help with electronics.


Ignition-off Timer with ATmega

Discuss about electronic circuits here. Request help for circuits that you couldn't find anywhere else, how a circuit works etc. Discuss anything related to electronic circuits.

Moderator: pebe

Ignition-off Timer with ATmega

Postby xenix » Sat Jun 13, 2015 7:12 pm

I want to replicate the functionality of a 40-year-old timer no longer manufactured for my car. There are alternatives out there, but I want a custom PCB to plug into the original socket. The circuit activates an auxiliary fan to cool the carburetor once the engine is switched off. The fan will only run when the ignition is OFF and the NTC thermistor resistance is below a given threshold. If the fan starts, it will run until the thermistor resistance rises above a threshold, 30 minutes elapses, or the ignition is switched back ON. I designed a circuit that (I believe) is functional but am unsure of the varistor and inductor values to use or if they're even necessary. I could use help with two things.
1. Did I design it correctly, and if not, what would you change?
2. What components from Newark/DigiKey/etc would you select for the relay, varistors, and inductors?
I realize the ATmega is overkill but I would rather program with an Arduino than use a PICAXE. This has been on my to-do list for years. Any help is greatly appreciated.
fantimer.png
fantimer.png (33.05 KiB) Viewed 28155 times
xenix
 
Posts: 13
Joined: Sat Jun 13, 2015 6:14 pm

Re: Ignition-off Timer with ATmega

Postby pebe » Sun Jun 14, 2015 11:11 am

Hi xenix,

Your circuit looks over-engineered for what you want. Points not explained are:-

1. Assuming one side of the fan is grounded and the other is connected to the relay contacts, C6 appears to be blocking the DC path for the fan.
2. What are the connections at the bottom left corner (fan, ground etc) meant to be?
3. No critical temperature is given for switch-off so the thermistor cannot be specified.

The 7805 can power the ATmega all the times and its program can sit waiting for the ‘ignition’ pin to go low when ignition is turned off. But the controller you are using is an overkill, bearing in mind you only need 4 ports, ie.
An A/D input for the thermistor,
An input from the 12V 'ignition' via a potential divider to give 5V,
An output to the relay driver,
An output for the LED indicator.
So a PIC 12F675 PIC could do the job easily.

Let me know if I can help further.
pebe
 
Posts: 1058
Joined: Tue Dec 09, 2003 11:12 pm
Location: Ellon, Scotland

Re: Ignition-off Timer with ATmega

Postby xenix » Sun Jun 14, 2015 1:49 pm

pebe wrote:Hi xenix,
Your circuit looks over-engineered for what you want.

Yes, I agree! I have some PICAXE chips and programming cable already as well as a TI MSP430 LaunchPad with 14-pin MCUs, but after spending a couple hours on the Microchip website, I could certainly go that route though I would need to invest in a PICkit for programming it, correct?

pebe wrote:1. Assuming one side of the fan is grounded and the other is connected to the relay contacts, C6 appears to be blocking the DC path for the fan.
2. What are the connections at the bottom left corner (fan, ground etc) meant to be?
3. No critical temperature is given for switch-off so the thermistor cannot be specified.

1. Yes, it is a single-wire thermistor screwed into a grounded engine mount. I'll delete C6.
2. The controller uses a long-discontinued plug that I will solder onto the new PCB. Rather than create it in Eagle, I just added pads for the connections.
3. I want to use the existing OEM 12V thermistor for now whose only available specification is that the "NTC sensor resistance is 2.0-3.8 kOhms at 90-110C." The fan should start when the engine is switched off if the temp is > 100C. If energized, the fan will switch off when the temp falls below 85C or 30min elapses, whichever occurs first.

pebe wrote:The 7805 can power the ATmega all the times and its program can sit waiting for the ‘ignition’ pin to go low when ignition is turned off. But the controller you are using is an overkill, bearing in mind you only need 4 ports, ie.
An A/D input for the thermistor,
An input from the 12V 'ignition' via a potential divider to give 5V,
An output to the relay driver,
An output for the LED indicator.
So a PIC 12F675 PIC could do the job easily.

Initially, I had incorporated other outputs for a temp gauge or status LEDs and a user-selectable switch to change program parameters, but decided against it.

pebe wrote:Let me know if I can help further.

Thanks for your feedback. Before I redraw, are there any obvious advantages of using a Microchip MCU over a PICAXE?
xenix
 
Posts: 13
Joined: Sat Jun 13, 2015 6:14 pm

Re: Ignition-off Timer with ATmega

Postby pebe » Sun Jun 14, 2015 8:56 pm

Thanks for your feedback. Before I redraw, are there any obvious advantages of using a Microchip MCU over a PICAXE?

I am not familiar with PICAXE so I cannot directly answer your question, but I believe that the micros they use are of a family similar to PICs. Perhaps other members could give you their opinions.

I have some PICAXE chips and programming cable already as well as a TI MSP430 LaunchPad with 14-pin MCUs, but after spending a couple hours on the Microchip website, I could certainly go that route though I would need to invest in a PICkit for programming it, correct?

I program PICs in assembler and use Microchip’s own free editor (MPLAB IDE) to write my programs and assemble them in hex. Then I use a cheap Chinese programmer like this to flash the chip. Software for it is downloadable and free, and it has catered for every chip I needed it to.
http://www.ebay.co.uk/itm/K150-ICSP-USB ... 4637b322f9

But if you have used PICAXE and are familiar with it, then you could best stay with it. It looks like their PICAXE-08 chip will do the job. It has these ports:
1 x input
2 x input/output
1 x input/output/ADC
pebe
 
Posts: 1058
Joined: Tue Dec 09, 2003 11:12 pm
Location: Ellon, Scotland

Re: Ignition-off Timer with ATmega

Postby xenix » Mon Jun 15, 2015 11:19 am

Thanks for the Microchip info. I read through a lot of material there and on other sites. The ATmega has been replaced by the 12F675 (with a 4.7k R between VCC and MCLR) and the pads were replaced with a single new part/package. Though not necessary, I added an in-circuit programming header.
Attachments
fantimer.png
fantimer.png (28.19 KiB) Viewed 28121 times
xenix
 
Posts: 13
Joined: Sat Jun 13, 2015 6:14 pm

Re: Ignition-off Timer with ATmega

Postby pebe » Mon Jun 15, 2015 3:35 pm

I still think your circuit is more complex than needed to do the job. Would you be interested in a circuit showing how I would do it?
pebe
 
Posts: 1058
Joined: Tue Dec 09, 2003 11:12 pm
Location: Ellon, Scotland

Re: Ignition-off Timer with ATmega

Postby xenix » Mon Jun 15, 2015 4:46 pm

pebe wrote:I still think your circuit is more complex than needed to do the job. Would you be interested in a circuit showing how I would do it?

Absolutely! I would appreciate a different approach. I'm drawing on my limited experience as a hobby and one class in college in 1982.
xenix
 
Posts: 13
Joined: Sat Jun 13, 2015 6:14 pm

Re: Ignition-off Timer with ATmega

Postby pebe » Wed Jun 17, 2015 1:16 pm

OK. Here is an alternative circuit. It uses a PIC permanently powered from the vehicle battery via a 5V regulator.

As you only need to take action when the ignition is off, then in this circuit the PIC is held in reset while the ignition is on and only needs to run for a short while when the ignition is off. That overcomes the need to use the watchdog timer in the program.

You will need a value for R4 so that at 85ºC GP0 will read somewhere around 2.5V; the actual value you can the set up in your program to compare GP0 with. Alternatively, if you cannot find the value for 85º from the data sheet of the thermistor, you could make R4 a 10k variable, and adjust it on test.

You could also use the PIC’s inbuilt comparator instead of measuring the A/D voltage. In that case you could use a 12F629 in place of the 12F675.

Basically, your program would need to configure the ports – two as outputs and one as an analogue input. You also need to identify which registers you will be using, and set up a timer that will set a flag after 30 minutes. The last instruction of the set-up procedures would be to start the timer. After those set-ups, the program proper begins, starting at a label called ‘Start’.

From that point, the program would check thermistor for 85º. If it’s higher than that it would switch on the fan; if not it would switch off the fan and go to a label called ‘endprog’. There, it would enter a continuous small loop, so effectively doing nothing.

If the fan is on and temp is still above 85ºC, the timer flag would be checked to see if timer has ended. If it had, the fan would be switched off and the program would go to ‘endprog’ and stop. If the timer were still running then the program would loop to ‘Start’ and repeat the checks.

TR1 gives an inversion of the signal from the IGN feed. When the ignition pin is high (engine on) TR1 turns on and takes the master reset of the PIC low, and so stopping it from operating. When the IGN is switched off, the reset is removed and the PIC can start its program. It will always end up looping in the ‘endprog’ loop, waiting for the ignition to be turned on; when it will reset.

I hope that may help.
Attachments
Vehicle Fan.GIF
Vehicle Fan.GIF (7.35 KiB) Viewed 28042 times
pebe
 
Posts: 1058
Joined: Tue Dec 09, 2003 11:12 pm
Location: Ellon, Scotland

Re: Ignition-off Timer with ATmega

Postby xenix » Thu Jun 18, 2015 2:52 pm

pebe wrote:OK. Here is an alternative circuit. It uses a PIC permanently powered from the vehicle battery via a 5V regulator.

That's a very elegant solution. Thank you.

pebe wrote:You will need a value for R4 so that at 85ºC GP0 will read somewhere around 2.5V; the actual value you can the set up in your program to compare GP0 with. Alternatively, if you cannot find the value for 85º from the data sheet of the thermistor, you could make R4 a 10k variable, and adjust it on test.

I've never been able to find a data sheet. I suppose I could construct a resistance/temp curve by measuring both while idling in the driveway?

pebe wrote:You could also use the PIC’s inbuilt comparator instead of measuring the A/D voltage. In that case you could use a 12F629 in place of the 12F675.

I'll have to read up on this but this would mean that the PIC is comparing the voltage into GP0 with a Vref (for example GP3)? The circuit would stay the same but the program would, of course, change?

pebe wrote:I hope that may help.

Huge understatement! A couple thoughts/questions...
I could replace the 7805 with a 2931 (using appropriate resistors per the data sheet)?
The thermistor is simply creating a voltage divider, so it makes no difference in functionality sending 5V to it versus 12V as in the original design?
Any automotive (12V) relay with a 15A or greater load capacity should work? For example: http://media.digikey.com/pdf/Data%20Sheets/Panasonic%20Electric%20Works%20PDFs/JS-M%20Relays.pdf
xenix
 
Posts: 13
Joined: Sat Jun 13, 2015 6:14 pm

Re: Ignition-off Timer with ATmega

Postby pebe » Thu Jun 18, 2015 4:37 pm

The thermistor is simply creating a voltage divider, so it makes no difference in functionality sending 5V to it versus 12V as in the original design?

Yes, all you need to do is input a voltage from the thermistor that is somewhere between 0V and 5V.
I'll have to read up on this but this would mean that the PIC is comparing the voltage into GP0 with a Vref (for example GP3)? The circuit would stay the same but the program would, of course, change?

Figure 6.2 of the 12F629 datasheet shows 8 modes of use for the comparator.
If you wanted to make the temperature adjustable, you could use the mode CM2:CM0 = 010. You could use a pot that would give 0 to 5V for comparison and input that to GP1.Then input the thermistor voltage to GP0. The comparator would output to bit COUT (bit6 of the CMCOM register), which the program would test.
I've never been able to find a data sheet. I suppose I could construct a resistance/temp curve by measuring both while idling in the driveway?

You could go that route, and use the mode CM2:CM0 = 100, but Cvref can only be provided in 16 steps so would probably not be accurate enough.

On reflection I think the comparator mode 010 would be preferable to using the A/D converter in this application.
A couple thoughts/questions...
I could replace the 7805 with a 2931 (using appropriate resistors per the data sheet)?

The 5V part of the circuit only uses a few milliamps, so yes, no problem.
Any automotive (12V) relay with a 15A or greater load capacity should work? For example: http://media.digikey.com/pdf/Data%20She ... Relays.pdf

Yes, the relay is only specified for a resistive load, but there should be no high back-EMF when it switches off so it should be OK.
pebe
 
Posts: 1058
Joined: Tue Dec 09, 2003 11:12 pm
Location: Ellon, Scotland

Re: Ignition-off Timer with ATmega

Postby xenix » Fri Jun 19, 2015 5:47 pm

I redrew the circuit into functional groupings, if for nothing else, to help me better visualize what I'm trying to do. After reading more on the comparator, I gave R4 a value of 3k3 because the R of interest from the thermistor is 2k-3k8 Ohms. Ideally, I want the value of R4 to be similar to the value of the other R in the divider, correct? (Besides those numbers, all I know about the thermistor is that the hotter it gets, the smaller the R and after a day in the freezer it showed 129k at 0º C.) CIN- uses a 10k trimpot.

This has been a back-burner project for a couple of years. You've been a tremendous help so far.

[attachment=Fan Timer]fantimer5.png[/attachment]
Attachments
fantimer5.png
fantimer5.png (29.89 KiB) Viewed 27995 times
xenix
 
Posts: 13
Joined: Sat Jun 13, 2015 6:14 pm

Re: Ignition-off Timer with ATmega

Postby pebe » Fri Jun 19, 2015 7:16 pm

You have shown the LED wired backwards. Its anode should go to Vdd.
Other than that it's great. Congratulations.

BTW, GP5 is not used. So you can either set it up as an output when it will automatically take up a 5V or 0V position (so don't connect it), or you can set it as an input and hard-wire it high or low (as an input it must not be allowed it to float).
pebe
 
Posts: 1058
Joined: Tue Dec 09, 2003 11:12 pm
Location: Ellon, Scotland

Re: Ignition-off Timer with ATmega

Postby xenix » Fri Jun 19, 2015 7:55 pm

pebe wrote:You have shown the LED wired backwards. Its anode should go to Vdd.
Other than that it's great. Congratulations.

BTW, GP5 is not used. So you can either set it up as an output when it will automatically take up a 5V or 0V position (so don't connect it), or you can set it as an input and hard-wire it high or low (as an input it must not be allowed it to float).


Great, thanks again!
xenix
 
Posts: 13
Joined: Sat Jun 13, 2015 6:14 pm

Re: Ignition-off Timer with ATmega

Postby xenix » Sun Jun 21, 2015 12:34 am

pebe,
Now that I've had some time to read through some data sheets, maybe you help me with a few questions.

1. The LM2931 data sheet illustrates a polarized cap for C3. I swapped it but from what I've read, either a polarized or non-polarized cap would work for that application. For a DC application like this, is it a matter of cap size and/or cost, or is there an inherent requirement for an electrolytic cap?
2. The TO-92 package for the VR is more than adequate for this circuit. Would there be any reason to use a TO-220 for such a low-current requirement?
3. I selected an inexpensive, 12V/20A, automotive relay. The centrifugal fan it will control is on a 10A circuit. It looks like a suitable relay but it is so small that I'm doubting my selection. The data sheet is here.

I feel like I'm understanding it much better now after getting through the circuit and poring over the data sheets to select appropriate components.
Thanks.
xenix
 
Posts: 13
Joined: Sat Jun 13, 2015 6:14 pm

Re: Ignition-off Timer with ATmega

Postby pebe » Sun Jun 21, 2015 11:22 am

xenix,
1. The cap at the output is there to stabilize the internal circuitry of the regulator. Without it, the circuit would oscillate at high frequency and give the wrong output voltage. The impedance of a capacitor equals the reactance of the capacitor plus its ESR. As reactance would be low at high frequencies, I would think that ESR would be more important than the capacity. That said, you couldn’t get such a large capacity in the non-polarised types.

I note the data sheet specifies a tantalum (in preference to an aluminium electrolytic). I normally use the tantalum bead type because it’s compact.

2. You will be drawing no more than a few (10 max?) milliamps at 5V, so the power dissipated in the regulator is (12V – 6V) x 0.01A = 6mW and so the TO-92 is OK, assuming you are using the fixed 5V type. The only reason for using the T0-220 would be when the dissipation was at the maximum specified = (30V – 5V) x 100mA = 2.5W

3. The fan is on a 10A circuit so will be drawing less than 10A, so your selected relay should be OK. Furthermore, the data sheet states that is suitable for switching automotive motors.

The max current is specified as DC with a resistive load. If your fan has a permanent magnet for the field, or has a field winding in parallel with the armature, then it will appear as a resistive load to the relay. The only possible problem I see is if the motor has its armature and a wound field in series. Switching off would then leave the field open-circuit and the energy left in it by its magnetic field would dissipate as an arc at the relay contacts and possibly destroy them. Adding a reverse biased diode across the contacts as a suppressor would prevent that.
pebe
 
Posts: 1058
Joined: Tue Dec 09, 2003 11:12 pm
Location: Ellon, Scotland

Next

Return to Electronic Circuits Help



Who is online

Users browsing this forum: No registered users and 10 guests



cron