• 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.

Driving Relays using PIC 16F88

Status
Not open for further replies.

Tom81

Member
Hi guys,

I'm building a circuit which controls the wing mirrors on my car. Essentially, I want the mirrors to retract and extend using 4 x relays (1A, 5V coil).

Details of the project:
- Measured resistance across the existing mirror motor to be around 180kΩ. They run off 12V.
- I'm using a 16F88 to control the relay switching sequence and timing. The signals from the micro are sent to a UDN2981 High-source driver, which then in turn drive the coils of each relay. Coil resistance of each relay = 167Ω.
- A 7805 regulator is used as voltage source for the micro and the source driver.
- A switch is used to simulate the car's accessory voltage. Conventionally, this comes on when the car is turned on.
- The circuit is simulated on a breadboard, with a separate relay board and a 1.5A/12V power supply.

See attached schematic. For simplicity I omitted two of the relays which are used in conjunction with the other relays to control the function of the motor.

During testing, I experienced some erratic behaviour from the circuit. The micro would reset and occasionally the relays would oscillate on/off rapidly. I did a quick search and found that this was common so I took the following measures to remedy the problem.

- placed resistors in between outputs from the micro and the inputs to the source driver. [made no difference]
- programmed the micro to have MCLR internally tied to Vdd. [made no difference]
- Added a 100n across 12V Rail and Gnd. [some improvement]
- Added a 100µF between 5V and GND pins on Source Driver [some improvement]

The circuit now works about 90% of the time. But occasionally the micro will reset, usually when the mirror retracts all the way in, reaches the end of its rotation, and stops suddenly, causing the motor to stall momentarily and presumably drawing maximum current. This should not exceed the circuit’s current limitations though.

Any thoughts on how to make the circuit 100% effective? More filtering capacitors? What size and where?
Would the breadboard be likely to be the cause of the problem?

Sorry for the long winded explanation! I didn’t want to omit too much detail.

Any help or suggestions would be much appreciated.

Cheers -Tom
 

Attachments

Pommie

Well-Known Member
Most Helpful Member
It's probably hitting the limit of your power supply. Try putting a diode from 12V to the input of the 7805 and a larger capacitor in parallel with the 330nF.

Mike.
 

Pommie

Well-Known Member
Most Helpful Member
10uF should be OK. However, I just noticed you are powering the UDN from the 5V supply, in which case I would add a bigger capacitors (as well as the 100nF) after the 7805 as well. It would be better if you switched to 12V relays and powered the UDN from 12V.

Edit, keep the 100nF as close to the pic as possible.

Mike.
 
Last edited:

mvs sarma

Well-Known Member
better to have seperate path for the motor current than use any path used by the Micro including relay drive current.
 

Tom81

Member
10uF should be OK. However, I just noticed you are powering the UDN from the 5V supply, in which case I would add a bigger capacitors (as well as the 100nF) after the 7805 as well. It would be better if you switched to 12V relays and powered the UDN from 12V.

Edit, keep the 100nF as close to the pic as possible.

Mike.
I added a 10µF Cap to both sides of the Regulator. Seems to have fixed the problem. Originally i wanted to run the source driver with 12V, but unfortunately the coils in the relays were rated to 5V. Next time I'll get some 12V relays.

better to have seperate path for the motor current than use any path used by the Micro including relay drive current.
Agreed. That would have been my first choice, but the circuit is designed to integrate with the existing mirror/switch assembly in my car and run off the car's battery voltage, so the 12V source is used to power the mirrors AND the micro/driver circuit (via the regulator).

Thanks Mike and mvs sarma for your comments. Most helpful!

-Tom
 
Status
Not open for further replies.

EE World Online Articles

Loading
Top