Question:

I need help using solenoids in a PIC microcontroller circuit !?

by  |  earlier

0 LIKES UnLike

Hi , I'm using PIC as a microcontroller in my circuit and it just make 6 pins continuously turned on, pause ,turned off ,and next one ... and i use this voltage to energise a relay that connect a 24v voltage to a solenoid. and the negetives are connected to each other. the problem occured is that the program is mixing up. the times are changing and the sequence change. please help me, whats wrong ? if i use LED's instead of solenoids every thing is right. ( i'm using bread board and usual adaptors )

I'm really in pressure of time.

thank you

 Tags:

   Report

3 ANSWERS


  1. First off ensure you have the PIC programed for digital only. Some like the 16F family have many pins that default to analog. ( I'd have to look up the command as I have set up a block program for all my basic setup and I've been copying and pasting for ever.)

    Next is to connect an led to any empty pin.  and then write a start up sequence that fires the the led in some pattern. I used something like, on for 500ms off for 250ms. I would have it flash that 3 or 4 times. then pause before it goes into main program. This will show you if the pic is hitting brownout when the relay fires causeing you to think the program is bad, but its really just starting over and over and over.

    I think you'll be needing to add a few power caps into the mix to stop this brown out. You should have like a 250uf at the power source and I think another at relay.

    if you like, email the program and I'll look it over, I spent years programing this things to do everything from flashy lights to high end protocols.

    In the future if you going ask about PICs you should give the device name as there are about a thousand PICs


  2. You are getting spikes from the relays or the solenoids or both and the spikes (which can be hundreds of volts) are getting into the microcontroller and causing the memorys to be changed.

    many things you can do.

    Make sure the ground of the microcontroller is totally isolated from the one used to drive the solenoids. this should be easy as they are driven by relays. The power supplies for the solenoid should also be totally isolated from the microcontroller supplies.

    make sure you have reverse diodes across the relays and every other inductive load.

    Keep the relays and solenoids physically distant from the microcontroller.

    Put large capacitors on each supply that is used for the microcontroller and relays. Put them as close to the controller as possible, and perhaps at the supply end. Use a 100uF in parallel with a 0.1uF ceramic. Put 0.1uF caps on every IC. You can never have too many caps.

    Examine carefully the circuitry you are using to drive the relays, and make sure you are not overloading the microcontroller's outputs. You may want to put a transistor in for isolation.

    for a total fix, you will have to enclose the microcontroller in a metal shielded box. Next stage is to put filters on every signal and supply wire where it enters the shielded box.

    hope this helps.

    electronics with memory are VERY prone to having the memory switch state at the slightest noise pulse, which can come from ground, supplies, signal leads, or through the air.

    I remember a simple 74LS74 FF on a breadboard, with all the inputs pulled up and supplies bypassed. Yet you could wave your hand in the air over the FF and it would change state. Which is why you have to get the controller in a shielded box. But that won't help if you have hundred volt spikes on supplies or ground or signal lines.

    But I remember answering this same question weeks ago.  So you haven't followed my advice that time, and you probably won't this time. But I know spikes are the problem, I have run into this many times. You have to go through it bit by bit.

  3. Key thing you said is relays... The coil of a relay can create a spike and this may be causing the false triggers you are getting. I would take a diode and hook it across the coil to help prevent this from happening. The diode should be a standard silicon diode and should be hooked up so that the cathode is attached to the positive side of the coil and the anode to the negative side of the coil. The LED's don't pose this issue...so I'm thinking the relays are your issue. Each coil should have a diode attached to it.

    Good luck

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.