If i drive the relay by a PNP if the pic goes down the relay will switch on and may cause a fire??? I would rather a positive output.
The PIC could do the 1.5second output to directly switch the transistor for the relay but to be honest the PIC has enough to do and I don't want to write another inturrupt to switch it off,
Possible I could get 25 556's I just wanted to know was there a cheaper and easier way. Obviously if I have to buy the 556 timer I also need all the surrounding components aswell.
I'm using about 12 PIC's all on a CAN network, The PIC that will be controlling this function will have limited i/o so the less I can use for each relay will be great.
Yeah I could use the PIC to directly control the 1.5 delay but I have limited inturrupts and to be honest I'm struggerling with the inturrupts I have (not enough) so having to make another one for the 1.5 seconds delay will be a bit of a problem. Also the other problem I have is cos I'll be controlling over 50 relays some relays might switch on together and then I have to control which one I need to switch off .... etc....
It just seems a hell of alot easier to do this function by hardware.
So does one PIC control 4 relays, ie. 4 * 12 = 48 relays?
Or does each PIC control 50 relays?
Does the PIC ever have to operate 2 or more relays at the same moment?
Have you considered using a mux to reduce the number of i/o? Note that a MUX can only be used to operate one relay at a time, but several could be operated in rapid succession.
I assume one PIC controls 25 relays and the other the other 25?
Are both PICs on the same PCB?
A Shift Register would be an alternative to the MUX.
If you operate one or more relays at once, is it likely that you will have to operate another relay within the next 1.5 Sec?
What I have in mind is that you may only need one hardware timer (or possibly one per PIC) so the PIC would operate one or more relays and then, if it has to operate more, check whether the timer is still active, and if so, wait until it expires. You would of course need one more i/o line to monitor the timer.
This is a very good idea but I'll be controlling relays as the same time, i.e. I might switch a relay on, then 10 seconds later I might switch another, 750mS later I'll switch another 50mS I'll switch another and so on.
If there was gonna be a 1.5S gap between each Relay being active this would work a treat. The problem is the Relay switching will be completly random.
hi jason,
quote: If i drive the relay by a PNP if the pic goes down the relay will switch on and may cause a fire??? I would rather a positive output.
Regarding PIC failure, it is also possible that the PIC output could fail in the +V output state as well as the 0v state.
If the failure of the PIC could cause a fire, your basic system is flawed.
You should re-examine the relays rating, if its continously rated and run at the correct voltage,
within its specified operating temperature, it should NOT catch fire.
Any idea why it gets hot???
Are using a relay with only an 'intermittent use' rating??
Jason,
I've been thinking further about your project.
Correct me if I'm wrong, but I assume the reason why you have 2 PICs is because one PIC does not have enough i/o to drive the 50 relays.
If so, then it should be possible to drive the relays and do the timing in one PIC and do everything else in the other.
How? Use 8 bit serial in/parallel out Shift Registers (such as the 4015) to drive some of the relays.
For example, 3 SR would drive 24 relays leaving 26 to be driven directly by the PIC.
Alternatively, 4 SR would drive 32 relays leaving 18 to be driven directly by the PIC.
etc.
You need 2 i/o for the data and clock signals.
The SR can be reset either by a simple sub routine which is called during the PIC initialisation phase, or by using another i/o to do a hardware reset.
Since relays take several milliseconds to operate or release, then they will not "chatter" if the data is clocked into the SRs quickly. For example, if you use 4 SRs and a 100 kHz clock rate, then the SRs will be loaded in about 320 :mu: s.
Remember that the clock does not have to be regular. In other words, the time between clock pulses can vary when the PIC has extra functions to perform such as moving data from the storage register to the output register.
This is a very good idea but I'll be controlling relays as the same time, i.e. I might switch a relay on, then 10 seconds later I might switch another, 750mS later I'll switch another 50mS I'll switch another and so on.
If there was gonna be a 1.5S gap between each Relay being active this would work a treat. The problem is the Relay switching will be completly random.
Jason,
If it is possible to operate only one relay at a time, then there is a solution that will significantly reduce the hardware and you probably don't need 2 PICs.
You could arrange the relay coils in a matrix.
49 relays could be arranged in a 7 * 7 matrix and the 50th would be driven directly.
Thus you would only need 15 i/o.
There would be 7 PNP (or P channel MOSFETs) driving the +12V side and 7 NPN (or N channel MOSFETs) driving the gnd side, plus one transistor driving the 50th relay.
Regarding PIC failure, it is also possible that the PIC output could fail in the +V output state as well as the 0v state.
If the failure of the PIC could cause a fire, your basic system is flawed.
You should re-examine the relays rating, if its continously rated and run at the correct voltage, within its specified operating temperature, it should NOT catch fire.
Any idea why it gets hot???
Are using a relay with only an 'intermittent use' rating??
There seems like you all have a concern about the heat of the relay. I'll explain more, the relay isn't a relay, but it works like a relay so this is why I said this as it was easier to explain.
The component is a Model Railway Point switching module, it has 2 coils and if you energise the one coil the point moves left, if you energise the second the point moves right.
Obviously you only need to activate the coil enough time for the bar to switch from the one side to the other, if you energise the coil for long periods of time it does get hot.
I agree what you say about the shift reg's but I'm not sure how one works so this why I've shyed away from this idea. I should really look into it and learn how they work.
A Shift Register works like the shift left / shift right instructions in a PIC.
You apply data to the input and at the positive edge of the clock pulse, the data bit is shifted into the first register and all of the bits in the reg shift one place and the last is lost.
I suggest you download the data sheet of the 4015. It is 2 4 bit SRs in one package so it can be configured as an 8 bit SR by paralleling the clock inputs (pins 1 & 7) and by connecting the output of one (eg. pin 10) to the input of the next (pin 15). If you don't use the reset inputs (pins 6 & 14), connect them to gnd.
There is also an 8 bit SR but I don't know the number of it. It would be a bit easier to use since you don't have to connect the output to the input and parallel the clocks and resets.
Yes, the operate and release times of relays and other electromagnetic devices is in the millisecond region due to physical initeria and the inductive time constant.
If the SR clock rate was say 100 kHz, then the bits are being shifted every 10 :mu:s. So the relays won't have time to respond.