CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

3.3V board and 5V switch

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
PrinceNai



Joined: 31 Oct 2016
Posts: 463
Location: Montenegro

View user's profile Send private message

3.3V board and 5V switch
PostPosted: Thu Mar 05, 2020 1:14 pm     Reply with quote

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: 19337

View user's profile Send private message

PostPosted: Thu Mar 05, 2020 2:07 pm     Reply with quote

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: 463
Location: Montenegro

View user's profile Send private message

PostPosted: Thu Mar 05, 2020 2:33 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 05, 2020 2:43 pm     Reply with quote

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: 463
Location: Montenegro

View user's profile Send private message

PostPosted: Thu Mar 05, 2020 2:52 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 05, 2020 2:59 pm     Reply with quote

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: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 05, 2020 3:14 pm     Reply with quote

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: 463
Location: Montenegro

View user's profile Send private message

PostPosted: Thu Mar 05, 2020 3:58 pm     Reply with quote

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: 9163
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Mar 05, 2020 5:49 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group