Control 5V module using raspberry pi zero - Page 1
Forum section: electronics / projects

author: pandaman
author_rank: Newbie
timestamp: June 30, 2018, 05:07:13 am
content: Hello all,I am working on a custom pcb which uses a raspberry pi as the control unit and I would like to control 15 INPUT pins of a 5V Module.I understand that raspberry pi gpio pins are 3.3v rated and so I need to use an IC between raspberry pi and the module.I tested it without any IC and it worked since raspberry pi pins are output pins but this is not a good practice and will eventually burn the pins.So I used following approach:Raspberry pi -> output gpio -> level shifter -> input of 5V moduleRaspberry pi gpios are output pins but I still need some protection to not burn the 3.3v pins by the current following from inputs of 5v module.I used a SN74LVC24 between raspberry pi gpios and the 5v module's pins and it's working when I run my python code in raspberry pi which makes sure the value of all the pins are high when they are not active.The module is active low.However,the value of pins start to float when I exit the python code.Any recommendations on how to stop the value of pins to float?I obviously don't want to add 15 pull up resistors as they take space.I am using DIP packages and would like to avoid pull up resistors to save space.Please let me know if you know another IC that would work better for this case.Thanks

author: Ian.M
author_rank: Super Contributor
timestamp: June 30, 2018, 06:07:44 am
content: Your pi code is releasing GPIO resources on exit and *something* is setting them back to being inputs (their default mode). However, even if you fix that, they'll still be floating before your pi code runs, which, depending on how you auto-run your script on startup, could be quite a few seconds after power-on.I assume from the partial part number that you are using a couple ofSN74LVC245Abus transceivers between the Pi and the 5V module. These are actually unsuitable for the purpose of providing 5V logic level outputs as they are only specced for operating at Vcc up to 3.6V, so can only provide 3.3V logic level outputs. You are lucky that their logic '1' output level of approx 3.3V is seen as logic '1' by the 5V module. Also, I'm not aware of any CMOS logic family that will guarantee its output statw when its inputs are floating - 74LVC certainly doesn't.Your PDIP constraint makes this a lot more difficult as it rules out most dedicated level translating ICs, and the 'no pullups' constrain makes it near impossible. If you use 74LS bipolar TTL logic powered from 5V, its inputs are 3.3V CMOS compatible, and naturally float at about two Vbe drops above ground, which is seen as logic '1', but that is strongly not recommended as its noise immunity when floating high is very poor.IMHO you should bite the bullet and fit pullups add probably use 74HCT logic powered from 5V for the upwards level translation. If space is a major constraint and you cant go SMD, consider using SIL-9 resistor arrays: eight resistors with one pin common in a nine pin inline package.

author: pandaman
author_rank: Newbie
timestamp: July 01, 2018, 06:26:07 am
content: Great points.I will try both internal pullups and resistor arrays.Which 74HCT model works better? Would 74HCT245N work?Thanks,

author: Ian.M
author_rank: Super Contributor
timestamp: July 01, 2018, 07:46:30 am
content: It depends:Soldered on a PCB, where you can guarantee the DIR pin is strapped so the Pi side can *NEVER* become an output, yes, a 74HCT245 + external pullups will do fine.However if you are breadboarding or the '245 is in a socket, there is a risk of an incorrectly connected or floating DIR pin and that could blow up the Pi. It would be *MUCH* safer to use a unidirectional buffer like 74HCT241 or 74HCT244.Also if you don't have external pullups, any 74HCT buffer is unsuitable as its CMOS floating inputs are going to give essentially random output states even though the thresholds are TTL compatible. For no pullups to work you cant use CMOS 'TTL', so *MUST* use real bipolar TTL (preferably LS family).N.B. the external pullups should be on the 74HCT buffer *INPUTS* and must go to +3.3V not +5V. I recommend 10K. Going lower isn't advisable due to the PI's limited output drive capability and the very limited current you can safely draw from the PI's 3.3V regulator.

author: Siwastaja
author_rank: Super Contributor
timestamp: July 01, 2018, 08:08:33 am
content: 3V3 outputs are OK and will not burn if connected to a 5V input.It's just that most 5V CMOS inputs have a reliable '1' detection level somewhere around 3.5V, which means it may work on the lab table, but won't work in production due to ic-by-ic and temperature differences.Easiest and cheapest level shift component is any 74xxCTx buffer, inverter or logic gate. They have reliable '1' level at 2.4V, but still output 5V when powered from a 5V supply. SN74LVC24 won't work reliably. Add the T.