User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: I2C I/O PORT EXPANDER QUESTION

Fri Mar 08, 2019 9:35 am

tlfong01 wrote:
Fri Mar 08, 2019 4:56 am

How much time would you spend on your I2C I/O PORT Expander Project

Your project of using Rpi to drive 260 devices using an IO expander is a very complex project, for sure not for the faint of heart newbies.

I already have 5 years hobbyist experience in Arudino and another 5 hobbyists years experience in Rpi. I still need 6 months to learn the basic knowledge and skills to do a complex project like yours.

If you are also a hobbyist like me, you might need as much time. Of course it also depends on you basic electronics knowledge, and if you have a home lab with necessary tools.

You might like to visit the following websites to know more.

Electronics Tutorials
https://www.electronics-tutorials.ws/

Free Electronics Text Book
https://www.allaboutcircuits.com/textbook/

Setting Up a Home Lab
https://www.allaboutcircuits.com/textbo ... -home-lab/

The 555 Timer
https://www.allaboutcircuits.com/textbo ... -8/555-ic/

Teardown Tools - Element14 Workbench Wednesday
https://www.youtube.com/watch?time_cont ... 4oVzS4afQ4

Upgrade Your Solder Station (for professionals only) - Element14 Workbench Wednesday
https://www.youtube.com/watch?time_cont ... R0S80xMIuk
Last edited by tlfong01 on Sat Mar 09, 2019 12:53 pm, edited 5 times in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: I2C I/O PORT EXPANDER QUESTION

Fri Mar 08, 2019 12:56 pm

tlfong01 wrote:
Fri Mar 08, 2019 8:59 am
NE555 > ULN2803 > Songle 5V Relay > DC12V Motor Tested OK


NE555 > ULN2803 > Songle 5V Relay > DC12V Motor Schematic
...
Attachments
relay_timer_motor_2019mar0801.jpg
relay_timer_motor_2019mar0801.jpg (179.3 KiB) Viewed 838 times
Last edited by tlfong01 on Mon Mar 11, 2019 7:23 am, edited 3 times in total.
I am an electronics and smart home hobbyist.

Brandon92
Posts: 773
Joined: Wed Jul 25, 2018 9:29 pm
Location: Netherlands

Re: I2C I/O PORT EXPANDER QUESTION

Fri Mar 08, 2019 10:04 pm

mikronauts wrote: You are welcome.

With a bit more software, your project can be immensely simplified.

Just use a string of ws2812 style led's (same as used on neopixels)
I think this is indeed the easiest way to make this project.

The other option would be to multiplexe all the 260 LEDs. As explained in this link. You save a lot of outputs. If you make a matrix of 16*17 you can control 272 leds. But this requires more software to make it work. In this case you only need 33 output pins. But this will also depends on the lay out the product that you are making, if this is useful for you

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: I2C I/O PORT EXPANDER QUESTION

Sat Mar 09, 2019 3:06 am

westwol wrote:
Mon Mar 04, 2019 11:59 pm
1. output must be 5 V...
2. LED as an example but could be RELAY or ACTUATOR ...

Logic Level Converter and Optoisolator

For [1], I would suggest you to use a logical level converter, such as TSX010n, to shift up Rpi GPIO signals from 3V3 to 5V0. This way you also protect Rpi, because TSX010n would be fried first (I have been frying so many chips that now I am very alert to plastic burning smell, and can pull the power plug kung fu lighting fast enough to save the next to fry Rpi!)

For [2] If your project would later entertain relays and actuators, I would suggest you to use an optical isolator now, such as EL817C, which can also be used as a logical level converter.

TSX0104, MCP23017, and EL817C
viewtopic.php?]f=37&t=77158&p=1344493&h ... C#p1344493

EL817C Design Notes
viewtopic.php?f=32&t=219744&p=1349622&h ... C#p1349577

Kung Fu Fighting Fast To Save The Next To Fry Rpi
viewtopic.php?f=32&t=219744&p=1358524&h ... g#p1358524
...
Attachments
el817c_2019mar0901a.jpg
el817c_2019mar0901a.jpg (186.21 KiB) Viewed 801 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: I2C I/O PORT EXPANDER QUESTION

Sat Mar 09, 2019 4:00 am

tlfong01 wrote:
Sat Mar 09, 2019 3:06 am

EL817C Current Limiting Resistor Calculation Notes

My lazy hobbyist quick and dirty calculation is summarized below.

The current limiting resistor value of 1k should be OK.

Update 2019mar11hkt1523

I used an adjustable voltage regulator as a signal source to verify that EL817C is off when signal is larger than 4V, and on when signal is smaller than 1V.

To make it also Rpi 3V logical compatible, I changed the resistor 1k to 6k2 and found that the high trigger off voltage decreases to about 2.6V, and on still less than 1V.



1. EL817C
Ic = 2.5mA at If = 5mA (CTR = 50%, (EL817C CTR = min 200%))
Vce(sat) = max 0.2V at If = 5mA

2. TSX010n
TSX010n High = 4V min
If = 5mA = 4V/R
R = 4V/5mA = 4k/5 ~=5k/5 = 1k

3. ULN2803A
ULN2803 Rin = 2k7
h(FE) = 350mA / 500uA ~= (350 * 1000) / 500 ~= 1,000
Ii = 2.5mA, Ic = 2.5mA * 1000 = 2.5A, if no current limiting resistor!

EverBright EL817C Datasheet
http://www.everlight.com/file/ProductFile/EL817.pdf

Sharp PC817 (PC817XNNSZ0F) DataSheet
http://www.sharp-world.com/products/dev ... nnsz_e.pdf

EL817C and EL354 Specification Summary
viewtopic.php?f=32&t=219744&p=1349622&h ... C#p1349577

ULN2803A Datasheet
http://www.ti.com/lit/ds/symlink/uln2803a.pdf
...
Attachments
el817_el354_summary_2019mar0901.jpg
el817_el354_summary_2019mar0901.jpg (179.26 KiB) Viewed 791 times
Last edited by tlfong01 on Mon Mar 11, 2019 7:30 am, edited 2 times in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: I2C I/O PORT EXPANDER QUESTION

Sat Mar 09, 2019 8:09 am

tlfong01 wrote:
Sat Mar 09, 2019 4:00 am

EL817C Assembly and Testing Notes

...
Attachments
el817c_2019mar0904.jpg
el817c_2019mar0904.jpg (184.83 KiB) Viewed 768 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: I2C I/O PORT EXPANDER QUESTION

Sat Mar 09, 2019 11:12 am

tlfong01 wrote:
Sat Mar 09, 2019 8:09 am

EL817C youtube

https://youtu.be/EC-zXCJIfp4 (youtube)
...
Attachments
el817c_2019mar0906.jpg
el817c_2019mar0906.jpg (192.36 KiB) Viewed 749 times
I am an electronics and smart home hobbyist.

User avatar
Burngate
Posts: 5939
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore
Contact: Website

Re: I2C I/O PORT EXPANDER QUESTION

Sat Mar 09, 2019 6:18 pm

westwol wrote:
Sat Mar 02, 2019 9:01 pm
I'm working on a project where a Raspberry PI must have up to 260 outputs.
westwol wrote:
Sun Mar 03, 2019 11:53 pm
I must be able to output 5 V on each of the 230 GPIO ports (just one port at a time will be outputting the voltage)
westwol wrote:
Mon Mar 04, 2019 11:59 pm
I used a LED as an example but could be a RELAY, or anything that with the logic to enable something such as an ACTUATOR.
westwol wrote:
Tue Mar 05, 2019 5:11 am
I should able to control 260 ports that must output 5V (HIGH) when active not necessarily a LED, it could be a wire to a relay that activates something. (Just one output will be enabled at a time, so I don't worry about overloading the chip)
Brandon92 wrote:
Fri Mar 08, 2019 10:04 pm
The other option would be to multiplexe all the 260 LEDs. As explained in this link. You save a lot of outputs. If you make a matrix of 16*17 you can control 272 leds. But this requires more software to make it work. In this case you only need 33 output pins. But this will also depends on the lay out the product that you are making, if this is useful for you
From these I'm getting the impression you need to tell us more about what you want to drive.
For example, 260 LEDs would take less current and be more tolerant of voltage than 260 relays, and be easier to drive.

If I were to consider only LEDs, I would turn to my right and look at a 32 x 16 LED panel from AdaFruit, with 512 LEDs ready-wired and ready to go.
For relays, I'd be looking round my old workplace - they had row upon row of uniselectors, gathering dust but ready to go.

User avatar
mikronauts
Posts: 2709
Joined: Sat Jan 05, 2013 7:28 pm
Contact: Website

Re: I2C I/O PORT EXPANDER QUESTION

Sun Mar 10, 2019 12:56 am

The OP does not want to provide details, when I asked he said led's, when I proposed a simple solution for led's he said it was not led's.

In my experience, when a poster is not willing to give details, they want to get free design work for their commercial project.
Burngate wrote:
Sat Mar 09, 2019 6:18 pm
westwol wrote:
Sat Mar 02, 2019 9:01 pm
I'm working on a project where a Raspberry PI must have up to 260 outputs.
westwol wrote:
Sun Mar 03, 2019 11:53 pm
I must be able to output 5 V on each of the 230 GPIO ports (just one port at a time will be outputting the voltage)
westwol wrote:
Mon Mar 04, 2019 11:59 pm
I used a LED as an example but could be a RELAY, or anything that with the logic to enable something such as an ACTUATOR.
westwol wrote:
Tue Mar 05, 2019 5:11 am
I should able to control 260 ports that must output 5V (HIGH) when active not necessarily a LED, it could be a wire to a relay that activates something. (Just one output will be enabled at a time, so I don't worry about overloading the chip)
Brandon92 wrote:
Fri Mar 08, 2019 10:04 pm
The other option would be to multiplexe all the 260 LEDs. As explained in this link. You save a lot of outputs. If you make a matrix of 16*17 you can control 272 leds. But this requires more software to make it work. In this case you only need 33 output pins. But this will also depends on the lay out the product that you are making, if this is useful for you
From these I'm getting the impression you need to tell us more about what you want to drive.
For example, 260 LEDs would take less current and be more tolerant of voltage than 260 relays, and be easier to drive.

If I were to consider only LEDs, I would turn to my right and look at a 32 x 16 LED panel from AdaFruit, with 512 LEDs ready-wired and ready to go.
For relays, I'd be looking round my old workplace - they had row upon row of uniselectors, gathering dust but ready to go.
http://Mikronauts.com - home of EZasPi, RoboPi, Pi Rtc Dio and Pi Jumper @Mikronauts on Twitter
Advanced Robotics, I/O expansion and prototyping boards for the Raspberry Pi

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: I2C I/O PORT EXPANDER QUESTION

Sun Mar 10, 2019 1:53 am

mikronauts wrote:
Sun Mar 10, 2019 12:56 am
The OP does not want to provide details, when I asked he said led's, when I proposed a simple solution for led's he said it was not led's.
In my experience, when a poster is not willing to give details, they want to get free design work for their commercial project.

Free Design Work For Commercial Project

Yes, free ideas for unicorn startups.

Or he is just like my girl friend, doesn't know what she really wants, or changes her mind as frequently as changing her designer bags. I bring her fake LV bags but she pushes them away, and says she will cut me, ... :( So I beg her pardon everyday, ... :mrgreen:


Lynn Anderson - I Beg Your Pardon (BBC Top Of The Pops) - 17,249,101 views
https://www.youtube.com/watch?v=2-eclUz-RYI

Bon Qui Qui - I will cut you - 64,211 views
https://www.youtube.com/watch?v=sS2q6xIDRUc
...
Attachments
unicorn_startup_company_2019mar1001.jpg
unicorn_startup_company_2019mar1001.jpg (149.11 KiB) Viewed 700 times
Last edited by tlfong01 on Mon Mar 11, 2019 5:08 am, edited 4 times in total.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: I2C I/O PORT EXPANDER QUESTION

Sun Mar 10, 2019 7:09 am

tlfong01 wrote:
Wed Mar 06, 2019 7:40 am
(2) Rpi GPIO is only 3V logic. You might need to consider using logical level shifter to convert the signals to 5V.

Rpi 3V GPIO Compatible Opto Isolator/Level Converter and Power MOSFET Switch

Actually you don't need all things 5V TTL compatible. For example the EL817C optoisolater current limiting resistance value of 1k is designed to be 5V TTL compatible. You can change it to 6k, so that it is <1V on and >2.5V off, in other words, both Rpi 3V3 and TTL 5V compatible.

And if you worry that electromagnetic relays too bulky to squeeze into your small case, you can instead use power MOSFET, such as IRL540N, which can handle big currents and also has very small size SMD versions. They are also Rpi 3V GPIO compatible.

You don't need to worry that SMD devices are too small to handle. You can use feed through versions for your prototyping, and when ready for startup mass production, you can ask the cheap, open hardware, hobbyist friendly, purple PCB guy OshPark to do the SMD assembly for you.


OshPark PCB Services
https://oshpark.com/
...
Attachments
relay_vs_power_mosfet_2019mar1002.jpg
relay_vs_power_mosfet_2019mar1002.jpg (184.83 KiB) Viewed 695 times
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: I2C I/O PORT EXPANDER QUESTION

Sun Mar 10, 2019 12:28 pm

tlfong01 wrote:
Sun Mar 10, 2019 1:53 am

Duplicated post by mistake. My apologies.
I am an electronics and smart home hobbyist.

User avatar
tlfong01
Posts: 1312
Joined: Sat Jun 02, 2018 1:43 pm
Location: Hong Kong

Re: I2C I/O PORT EXPANDER QUESTION

Mon Mar 11, 2019 7:15 am

tlfong01 wrote:
Sun Mar 10, 2019 7:09 am
the EL817C optoisolater current limiting resistance value of 1k is designed to be 5V TTL compatible. You can change it to 6k, so that it is < 1V on and > 2.5V off, in other words, now both Rpi 3V3 and TTL 5V compatible.

Getting around Rpi 3V GPIO signal not high enough to switch off EL817C opto isolator


Actually this get around of changing EL817C (total) current limiting resistor (and LED) value from 1k to 6k to make 5V Logic also 3V3 compatible is a general trick that applies to opto or direct, high trigger or low trigger relay, or power MOSFET or BJT as a sinking source driver.

An example is the following SainSmart opto low trig relay. The original in1 is Arduino compatible but NOT Rpi compatible. By adding an external 4k7 to in1, the other end of 4k7 in2 is now Rpi compatible. Of course 4k7 is not a magic number, you need to use Ohm's law and do a bit of trial and errors to find an appropriate value.

...
Attachments
ss_opto_low_trig_relay_getaround_2019mar1101.jpg
ss_opto_low_trig_relay_getaround_2019mar1101.jpg (189.28 KiB) Viewed 634 times
I am an electronics and smart home hobbyist.

Return to “HATs and other add-ons”