View previous topic :: View next topic |
Author |
Message |
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
[SOLVED,Thanks!] Set all ports floating when powering up |
Posted: Sat Dec 08, 2012 2:47 pm |
|
|
Hi,
I have on a board a PIC18F4685 (12mhz xtal) connecting to a 16 relay board module ----> (datasheet)
This module is using a LOW level input (High being off and low ON)
The problem i have is the module is keeping the lines high (normal) and this make the PIC gets power from the module inputs pins to the pic output pins (PORT B & D) (which i don't want!) !!
But then the pic ground the pins at power up and this makes all the relays ON (No good)
1. Is there a way to manage this unwanted power?
2. Is there a way to have all ports in floating mode at power up?
Is that me or i find that counter intuitive to make a relay board driven by low logic?
Thank you very much! _________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy!
Last edited by ELCouz on Sun Dec 09, 2012 3:47 pm; edited 1 time in total |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Sat Dec 08, 2012 2:56 pm |
|
|
Normal mode for the PICs I've used is for ALL I/O pins to be configured as input on power up.
So to get peripherals in the correct state you simply pull in the required direction with a resistor.
Mike |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Sat Dec 08, 2012 3:03 pm |
|
|
Yes, in fact this is one of the guaranteed things in the data sheet of the PIC.
If however the pins are set to output, by setting TRIS, then they will drive high (default for the output latches is '11111111'. So you as a programmer, must set the output latch before changing TRIS.
Best Wishes |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
Posted: Sat Dec 08, 2012 3:06 pm |
|
|
Thank you everybody, i can figured out the power issue...
I need to apply power to the PIC first then relay board after!
Do you have a shorter code which replace:
Code: |
output_float(pin_b0);
output_float(pin_b1);
output_float(pin_b2);
etc...
|
for an entire port?
thanks! _________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Sun Dec 09, 2012 1:47 am |
|
|
set_tris_b(0xFF);
This is the default on power up.
Best Wishes |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Sun Dec 09, 2012 4:56 am |
|
|
Or power at the same time.
All pins on a chip like the PIC, have effectively 'protection diodes', preventing them being taken more than about 0.6v above the supply pin. If power is applied to the relay board first, then with the Vdd of the PIC board at 0v, all the pins will be prevented from going above 0.6v...
This sounds like bad design. If the two boards are powered independently, then there should be an output_inhibit input to the relay board, which if held low, prevents the drivers from coming on.
Best Wishes |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
Posted: Sun Dec 09, 2012 8:09 am |
|
|
Thanks for the instruction Ttelmah !
Quote: | This sounds like bad design. If the two boards are powered independently, then there should be an output_inhibit input to the relay board, which if held low, prevents the drivers from coming on. |
The problem is that is held HIGH (pull-ups) on the relay board (driven by low level) and when i measure from ground to relay board input pins i get 4.5v
If the line is held low the relay will engage... optocouplers are held at 5v with a resistor network
Take a look at the schematic of the board:
The input pins of the relay board are directly wired to the PIC pins.
Should i need another pull ups near the pic but i think its redundant because the optocoupler is already held HIGH.
What would be your solution to prevent power leeching?
Many thanks! _________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy! |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
Posted: Sun Dec 09, 2012 8:11 am |
|
|
Quote: | All pins on a chip like the PIC, have effectively 'protection diodes', preventing them being taken more than about 0.6v above the supply pin. If power is applied to the relay board first, then with the Vdd of the PIC board at 0v, all the pins will be prevented from going above 0.6v... |
Btw, should i put the BROWNOUT (2.1v) fuse to help ? _________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy! |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Sun Dec 09, 2012 1:25 pm |
|
|
Your schematic explains nothing to me.
Your description adds nothing either.
Please, simply show the connections for one channel only.
Mike |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
Posted: Sun Dec 09, 2012 1:35 pm |
|
|
Alright
Here's the chinese 16 relay board complete schematic:
-----> LINK PDF DOWNLOAD <---------
Here's my layout for interfacing with the board:
Code: |
GND ---> Connector ---> Wire ---> Relay Board GND
___ PIN
| 1 |----B7--> Connector ---> Wires ---> Connector---> Relay Board Input #1
| 8 |
| F |
| 4 |
| 6 |
| 8 |
| 5 |
|__|
|
I hope I've cleared any confusions _________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy! |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Sun Dec 09, 2012 1:43 pm |
|
|
No. I said SCHEMATIC for ONE CHANNEL only, please.
Mike |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19506
|
|
Posted: Sun Dec 09, 2012 2:54 pm |
|
|
I think you are missing the point. The PIC _does not_ take it's outputs low when it is switched on. It's outputs _wake up_ floating.
However when the PIC board is switched off, the processor will act as a load to 0v, till it's power appears. You need to power the PIC from the same 5v supply as the relay board. If the PIC is switched off, your relays will be on. No code can affect this.
Best Wishes |
|
|
ELCouz
Joined: 18 Jul 2007 Posts: 427 Location: Montreal,Quebec
|
|
Posted: Sun Dec 09, 2012 3:04 pm |
|
|
Thank you Ttelmah!
You explained the problem easily... i've learned something
Before you posted this i kinda find a (very dirty) way to fix this problem:
- Added BOR46 fuse (because I've noticed the voltage is between 3v and 3.4v when pic power supply is off and the relay board leaks power to the pic)
- Switched the relay board power with a high logic relay
This caused the PIC to reset itself and all the output too so it would cut the high driven relay thus stopping the power going to the 16 relay board!
I will try powering directly from the relay board ... like you said... it should fix the problem! _________________ Regards,
Laurent
-----------
Here's my first visual theme for the CCS C Compiler. Enjoy! |
|
|
Mike Walne
Joined: 19 Feb 2004 Posts: 1785 Location: Boston Spa UK
|
|
Posted: Sun Dec 09, 2012 3:36 pm |
|
|
OK. So you understand I'd like to see a schematic for one channel only.
I think it looks a bit like this for channel 0:- Code: |
OPTO ISOLATOR
--------------------- 12V
Part of PR1 | | |
+5V ----------WWWWW------------ --------5V C
| | |C | C Relay
| ---- | / | C Coil
| \ / |/ | C
| \/ |\ | |
| ---- | \ | |
| | |E | | /C
PIC O/P ----------------------- ---------------|/
| | |\
--------------------- \E
|
|GND
Part of ULN2083 |
As I understand it you have these two states:- Code: |
-------------------------------------------------------------
| PIC O/P | OPTO DIODE | OPTO O/P | ULN2083 Collector | RELAY |
-------------------------------------------------------------
| LOW | ON | ON | LOW | ON |
-------------------------------------------------------------
| HIGH | OFF | OFF | HIGH | OFF |
------------------------------------------------------------- |
I'm assuming the 5V for the Opto is derived on the relay board.
Please confirm that I have the logic correct.
What supplies the 5V for the input side of the opto?
Is it the relay board or the PIC board?
Mike
EDIT
Ttelmah has hit the nail on the head.
You have several options:-
1) Power the PIC from the relay power board (like Ttelmah says).
2) Power the Opto inputs from the same 5V as the PIC.
3) Use open collector/drain devices to drive the optos rather than the PIC directly. |
|
|
|