I use a ULN2803A darlington array to drive relays. The chip has surpressor diodes to absorb the energy in the relay magnetic field when it is shut off and will sink 500ma per darlington. The processor should not be used to drive relays directly as the current requirement is likely to exceed the output rating of the chip and the "spike" when the relay is shut off may damage the processor output or cause a "noise crash" - and require a reset.
Data sheet:
http://www.tranzistoare.ro/datasheets/105/366825_DS.pdfThe common (surpressor diode) is connected to the +5 rail. The relay coil is connected between the +5 rail and the chip "out" terminal. A one (+5) at the input will then energise the relay. The relay is selected to have a contact rating suitable to the heater load and for high power applications the relay might pick up a power contactor. A solid state relay can also be driven by the darlington and this method will provide optical isolation of the heater power circuit. Jameco part 481001is a triac output solid state relay rated 240V at 10 amps and it provides 4000V isolation between the AC power and your delicate 5V electronics.
----- Original Message -----
From: Jefferson Smith
To:
68HC12@...
Sent: Tuesday, April 17, 2007 9:07 AM
Subject: [68HC12] Re: Please Help...Programming Assitance Needed with Dragon12
--- In
68HC12@..., "b_scheibe" <b_scheibe@...> wrote:
> I am very new to programming/HC12 so please bare with me. The code i
> am currently dealing with is something my professor made available
> so that i can modify it. I am trying to run a heater using the
> Dragon 12 with a relay hooked up between the two. I already have a
> thermistor set up on the board with temperature being displayed to
> the LCD. I am wanting the heater to turn on when the temp is below
> 270 and turn off when the temp is above 280. I currently have the
> relay hooked up to PB2 and ground. This is where my programming
> knowledge ends. I am assuming it is just a matter of turning the
> relay either high or low according to my previously mentioned
> criteria. What i am wanting to know is what i need to add to my
> Freescale CodeWarrior C code to cause these things to happen. If
> there is any other information you need, let me know. Thanks for
> your help.
>
> -Bryan
Well, Dragon12 is so far the best setup for my projects (and just
keeps getting better), but I see that you need more info about the
hardware you are interfacing with, and how it looks inside the MCU.
Actually from what you've said so far, you did not even indicate that
you know what "if/else" means in C. There's no way we could tell you
*everything* you need to know, so let us know in more detail, what you
have. If your professor just gave you source code to get you started,
I suppose a sort of framework, have you even figured out what *that*
does? We certainly cannot guess what the code does so far.
Do you have the relay coil directly connected to the MCU pin? will
that cause a problem? How much current can the pin drive? Will counter
EMF burn out the MCU? Has all this been already tested by someone with
the same hardware? All this research will help you, but has nothing
really to do with this 68HC12 group unless you have specific questions
about what it says in spec sheets for the MC9S12DP256 or DP512.
Also, you would need to know how to read in a variable that represents
a temperature from your sensor. Maybe you know that number is not
necessarily '270' when the actual temperature is 270 degrees (F? C?
K?). Well I suppose you already can get the actual temperature value
because you say it is displayed on the LCD, but sure will hepl if you
can read the code and know how it does it.
------------------------------------------------------------------------------
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.446 / Virus Database: 269.5.1/764 - Release Date: 4/17/2007 4:43 AM
[Non-text portions of this message have been removed]