Continue to Site

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.

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

Relays & PIC18F452

Status
Not open for further replies.

ZERS

New Member
Hi all,

Searching through this foru,I found somme interessting things about controlling relays from a PIC.

To sum up :
1- The relay must have is own PSU instead of sharing its PSU with the PIC one.

3- A NPN transistor should be placed between the trigger and the relay.
:?: How rating this transistor ?

2- The current from the PIC is 5V/25mA. Depending on the chosen transistor, it might be necessary to place a resistor between the PIC and the base of the transistor in order to get the current down to the max of mA accepted by the NPN.

Do Am I wrong ?

I will try to make a schematic later on

Cheers
 
ZERS said:
Hi all,

Searching through this foru,I found somme interessting things about controlling relays from a PIC.

To sum up :
1- The relay must have is own PSU instead of sharing its PSU with the PIC one.

No, a 5V relay can work quite happily from the same supply as the PIC, but commonly you would be using a 12V relay (or something similar), which will need a suitable supply. Often the PIC will be fed from a 5V regulator driven by the same supply as the relay.

3- A NPN transistor should be placed between the trigger and the relay.
:?: How rating this transistor ?

NPN is one way, and the way I'd normally choose, the rating depends on the specific relay. Also, you MUST! place a reverse polarised diode across the relay coil, or the transistor will blow as the relay turns off.

2- The current from the PIC is 5V/25mA. Depending on the chosen transistor, it might be necessary to place a resistor between the PIC and the base of the transistor in order to get the current down to the max of mA accepted by the NPN.

A resistor is ALWAYS required, to limit the current - not using one could damage both PIC and transistor - certainly it would be extremely poor design practice not to include one.

I will try to make a schematic later on

Have a look at my 'Hardware Extras' page in my PIC tutorials, I already discuss this - this page is still 'on going', but I've posted the work so far due to frequent questions about the subject.

I don't specify what transistor to use, but I will be going into more detail later on - when time allows!.
 
thanks, I will look into your website and I'll get back to U

I'm still in the process of choosing the relay before going any further with the PIC...
 
Nigel Goodwin said:
What are you wanting to switch?.
Well to sum up, I'm building my own DIY CD PLAYER.

There are seveal modules in it :

1- The controller board made of the PIC18F452. This board manages the data from/to the the DRIVE (a philips CDPRO2 mechanism), data to be displayed on a LCD, IR data.

2- A dac made of 2 TDA1541A in //, with a tube output stage

3. A PSU board with several voltages :

* 5V for the controller board, the DAC as well as the decoder of the drive

* -21V for the DAC

* 235 V /6.3V for the output stage.

*9V for the drive (mechanism)

The issue is to manage the start of the modules in a good sequence as the CDP is switched off /on

When ON :
1- First the controler board (+5V)
2- Then after a short delay, the DAC (+5V, -21V, 6.3V, 235V)
3- Then the decoder of the drive (+5V)
4- At least, the +9V of drive.

A minimu m of 400ms has to be respected between each modules.

When OFF, take the sequence upside down.

I could manage the delay by inserting RC cells.
But it costs to much and it is less interesting than managing the delay by the PIC. On top of that, I could quickly changed the delay (400ms to 300, 500,...) just by amending the program.

That's why, I attend to control several relays between the PSU board and the other modules. They would switched on/off to enable the flow of current.

Hope it's clear, my english is not as good as expected :oops:
 
Interesting idea, but I'm not sure why you want to switch them on at different times? - I'm also somewhat bemused by you wanting a valve (tube) in the design, but that's your personal preference!.

Depending on the current requirements most of the voltages could be switched by a pair of transistors (one NPN and one PNP for each rail), rather than by relays - which should be smaller and cheaper. Also, depending on the PSU design, you may be able to use the supply regulators as the actual switches.
 
here is the schematic and the board of the psu
 

Attachments

  • psuzers.zip
    122.9 KB · Views: 184
the dac
 

Attachments

  • daczers.zip
    389.6 KB · Views: 191
Nigel Goodwin said:
Interesting idea, but I'm not sure why you want to switch them on at different times?
As far as the fdrive it's concerned, the datasheet explains that it is necessary to start the decoder before the mechanism.

It is written as well that in case of using external DAC, this dac must be started before the decoder..

Nigel Goodwin said:
Depending on the current requirements most of the voltages could be switched by a pair of transistors (one NPN and one PNP for each rail), rather than by relays - which should be smaller and cheaper. Also, depending on the PSU design, you may be able to use the supply regulators as the actual switches.
I would be interesting in this solution...
The requirements are close to 1A for the drive, less than 500mA for other parts except the output stage which requires more.
 
ZERS said:
I would be interesting in this solution...
The requirements are close to 1A for the drive, less than 500mA for other parts except the output stage which requires more.

Here's a simple example, the PNP transistor is the actual switch, with the output from the collector.
 

Attachments

  • tran_sw.gif
    tran_sw.gif
    2.1 KB · Views: 565
Cool ! :D
I've just have to find the good NPN and PNP transistor to rate the resistors.

But how does your schematics works as the input voltage is negative ?
Do I replace the PNP by a NPN, i.e. 2 NPN on a rail ?
 
what do you mean by negative?

negative voltage? this can't be as the signal is coming from the pic and pic's don't run off a negative supply...

if you mean negative logic the you just change it in software
 
Exo said:
what do you mean by negative?

negative voltage? this can't be as the signal is coming from the pic and pic's don't run off a negative supply...

if you mean negative logic the you just change it in software
Yes I mean negative voltage but voltage that is to be "switched" (i/e replace 12V IN by -12V IN in the schematic above) :wink:
 
The easyest way would be to connect the -12V directly to your circuit and switch GND
 
Nigel Goodwin said:
It's not so easy to switch a negative rail using a positive 0-5V output?.
Hello,

sorry I do not understand :oops:
 
ZERS said:
Nigel Goodwin said:
It's not so easy to switch a negative rail using a positive 0-5V output?.
Hello,

sorry I do not understand :oops:

It's fairly simple, you could just make a mirror image of the previous circuit I posted, but to turn it ON would require a -5V signal. The output of the PIC can be either 0V (LOW) or 5V (HIGH), both of these would turn a negative version OFF - you need to find a way of generating a 0V to -5V to switch a circuit in this way.

There are probably many ways of doing it (but not as simple as the positive switch), I suspect a number of people may post suggestions, but one fairly simple way would be to use an opto-isolator.
 
Nigel Goodwin said:
It's fairly simple, you could just make a mirror image of the previous circuit I posted, but to turn it ON would require a -5V signal. The output of the PIC can be either 0V (LOW) or 5V (HIGH), both of these would turn a negative version OFF - you need to find a way of generating a 0V to -5V to switch a circuit in this way.
OK I understand now.
I'm building the whole schematic of the control board and I will post it later on :wink:
 
Here is the schematic of the controller. 8)

There are the IR , the DSA (drive control) , the LCD as well as the button (A/D) interfaces.

There is as well the DB9F connector in order to program the pic "in situ".

You will notice that there is not the "switch" interface we are talking about, I'm still trying to inderstand and find the expected transistors.

Feel free to comment this board.

Regards
 

Attachments

  • schemacontroller.jpg
    schemacontroller.jpg
    100.9 KB · Views: 374
do you think I can use two diodes to provide the negative supply,
something like this ?
 

Attachments

  • switch_780.jpg
    switch_780.jpg
    6 KB · Views: 320
Status
Not open for further replies.

Latest threads

Back
Top