View previous topic :: View next topic |
Author |
Message |
PrinceNai
Joined: 31 Oct 2016 Posts: 480 Location: Montenegro
|
3.3V board and 5V switch |
Posted: Thu Mar 05, 2020 1:14 pm |
|
|
Dear Sirs,
I made an interface board using 16f15323. It will be used to detect button presses from a card shuffling machine and relay every press wireless to a receiver. It works, as far as software is concerned and if the switch is on 3.3V. My question is hardware. My board is operating on 3.3V and the button on the shuffler is giving me 5V or 0V. Do I need to use a resistor divider or will the pic detect a logic "1" even if the input is 5V? I was a bit to eager to order the board and didn't think "optocoupler" :-).
Regards,
Samo |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19545
|
|
Posted: Thu Mar 05, 2020 2:07 pm |
|
|
Yes, you need a resistive divider.
Some 3.3v PIC's have specific inputs that are '5v tolerant'. This one
doesn't. If the signal tries to go above the PIC's supply it'll raise the
supply voltage of the PIC!. |
|
|
PrinceNai
Joined: 31 Oct 2016 Posts: 480 Location: Montenegro
|
|
Posted: Thu Mar 05, 2020 2:33 pm |
|
|
Mr. Ttelmah,
that is all I needed to know. It is a 5V rated PIC, but I hadn't the foggiest what would happen with that kind of coupling. As usual, thank you.
With kindest regards,
Samo |
|
|
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Thu Mar 05, 2020 2:43 pm |
|
|
Silly question.
What would happen if you have just a series resistor from the 5V to the PIC input?
Wouldn't that limit the current to a safe level without raising the PIC's Vdd. |
|
|
PrinceNai
Joined: 31 Oct 2016 Posts: 480 Location: Montenegro
|
|
Posted: Thu Mar 05, 2020 2:52 pm |
|
|
They mention that method in TIP #10 in 3V Tips ‘n Tricks from Microchip, if there is a diode clamp on that specific pin. I'm interfacing to a 20k€ machine. 20 0.01€ resistors won't make a difference. Luckily that was in a board design :-) |
|
|
alan
Joined: 12 Nov 2012 Posts: 357 Location: South Africa
|
|
Posted: Thu Mar 05, 2020 2:59 pm |
|
|
Agree with that.
Just thought that you can maybe use the current PCB as surely you have a pull up resistor on the switch to 5V, which could then act as your series resistor. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Thu Mar 05, 2020 3:14 pm |
|
|
Use a proper voltage divider ! 5V--2K-PIC-3K--gnd.
Just because you can 'bodge' this combination, maybe, doesn't mean the next version WILL work, let alone reliably for 100s or 1000s of operations.
All too often 'designers' cheap out and eventually the hardware guy gets the blame !!
Steve Ciarcia form Byte magazine and Circuit Cellar Ink, had a GREAT article about a power supply design( OK 30+ years ago) but it's still valid today. Design for reliability, keeping components within spec.....never overstress any part of the system. |
|
|
PrinceNai
Joined: 31 Oct 2016 Posts: 480 Location: Montenegro
|
|
Posted: Thu Mar 05, 2020 3:58 pm |
|
|
Some versions of the shuffler use 24V on the switch, so I did plan for a divider. It was a curiosity question what would happen with 5V, not an attempt to go cheap just because "it could work". On a whole, both Mr. T's are right, of course. It's always better to stay well within specs than stretch them. Especially here. It is not a hobby project, literally millions of € are riding on those machines. And in this case, being both hardware and software designer, there is nowhere to hide if something breaks because of stretching those margins, let alone knowing I was doing that. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Thu Mar 05, 2020 5:49 pm |
|
|
You might want to add a small cap ( .1 - .68) in parallel with the 'lower' resistor. It'll filter or quench the 'arc' that occours when switch is activated. |
|
|
|