Using the PCA9544 MUX (RPI)

Post Reply
Richard-TX
Posts: 1320
Joined: 10.07.2012, 04:00
Location: Texas, USA
Contact:

Using the PCA9544 MUX (RPI)

Post by Richard-TX » 16.12.2013, 02:12

Here is how to use the PCA9544 I2C multiplexer (mux) on the Raspberry Pi (Rpi)

First find what address the MUX is at.

Code: Select all

# i2cdetect -y 1 

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: 40 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: 70 -- -- -- 74 -- -- --

Mine is at 0x74. The Rpi has one built in at 0x70 so avoid that address.

To select bus #0:

Code: Select all

# i2cset -y 1 0x74 0x04 0x04

I have a device at 0x48 on multiplexed bus #0 so it shows up now.

Code: Select all

# i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: 40 -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: 70 -- -- -- 74 -- -- --

To select mux bus #1

Code: Select all

# i2cset -y 1 0x74 0x04 0x05 
Select mux bus #2

Code: Select all

# i2cset -y 1 0x74 0x04 0x06
Select mux bus #3

Code: Select all

# i2cset -y 1 0x74 0x04 0x07
To set the MUX so that all mux buses are shut off.

Code: Select all

#i2cset -y 1 0x74 0x04 0x00
PCA9544a datasheet at http://www.nxp.com/documents/data_sheet/PCA9544A.pdf
Last edited by Richard-TX on 16.12.2013, 02:56, edited 1 time in total.

Richard-TX
Posts: 1320
Joined: 10.07.2012, 04:00
Location: Texas, USA
Contact:

Post by Richard-TX » 16.12.2013, 02:38

The layout of the I2C bus is as follows:

RPI I2Cbus -> LED ctrlr @ 0x40 > mux @ 0x77 -> mux bus 0 -> adc @ 0x48

My previous post should now make more sense.

Why a MUX? For those cases where the devices to be attached just don't have enough address lines.

Take the 4 channel adc PCF8591. Without the mux the maximum channels available are 8*4 or 32. With the addition of one mux, the maximum number of adc channels is 128. (4*8*4)

rjversluis
Site Admin
Posts: 40996
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Post by rjversluis » 16.12.2013, 10:03

Richard-TX wrote:Take the 4 channel adc PCF8591.
For what purpose should you use an ADC on a model railroad?
An electronic circuit for a steady and correct signal is not easy.
To control LED you should use PWM. (GCA-Pi03).
The ADC is useless as occupation detection.

Richard-TX
Posts: 1320
Joined: 10.07.2012, 04:00
Location: Texas, USA
Contact:

Post by Richard-TX » 17.12.2013, 15:32

Rob,

The whole point of the ADC is so that signal amplification to TTL levels can be mostly dispensed with. Want to build a turntable? A pot and a ADC could provide all the positional info needed. A 10 bit adc would provide up to 1024 steps for 360 degrees of rotation.

I am still waiting for the parts for the zero insertion loss current detector. Shipping is slow due to the holidays.

A light sensor could also provide train positional info. Parts are one adc chip, 4 sensors and 4 resistors and a source.

rjversluis
Site Admin
Posts: 40996
Joined: 10.04.2006, 08:48
Location: Speyer, Germany
Contact:

Post by rjversluis » 17.12.2013, 17:10

Hi Rich,

we already have a very good turntable/fiddleyard controller:
http://wiki.rocrail.net/doku.php?id=gca145-en

Richard-TX
Posts: 1320
Joined: 10.07.2012, 04:00
Location: Texas, USA
Contact:

Post by Richard-TX » 18.12.2013, 05:11

I will just amuse myself as I am still recovering from neck and shoulder surgery.

The nice part about the ADC is that I can read all manner of voltage levels., not just TTL high or low levels.

Richard-TX
Posts: 1320
Joined: 10.07.2012, 04:00
Location: Texas, USA
Contact:

Post by Richard-TX » 18.12.2013, 05:17

THe mux is pretty good for those times where you want a use many chips that have a small address range.

peter&basti
Moderator
Posts: 6413
Joined: 09.01.2012, 22:09
Location: Vienna, Austria

Post by peter&basti » 18.12.2013, 19:49

Hi Rich,


How do you mean the Steps?

1024 steps for a H0 turntable will be too less for a 360 Turn. Calculate the circumference of a 25 cm turntable divided by 1024 - will be around .8 mm per step - too much.

Without mechanic gear not useful

Actually i work on my turntable to refit it with a steppermotor, GCA145 and mechanical Reduction 1:30, what results in 6000 Steps or .1 mm accuracy

Regards,

Peter

Richard-TX
Posts: 1320
Joined: 10.07.2012, 04:00
Location: Texas, USA
Contact:

Post by Richard-TX » 19.12.2013, 00:09

Peter,

You are correct. 10 bits is not enough.

I have found a few solutions that should work.

From the Overkill Department is the NAU7802 ADC. It has the following features:

Low cost - $2.20 each in single lot quantities
24 bits - Over 16 million steps from 0 to V-Ref.
VDD range - 2.0-5.5 volts
4 channel
16 pin DIP package
2.7-5.5v supply
I2C Streaming mode capable.
Built in PGA
Only 1 chip allowed per i2c bus.

https://download.nuvoton.com/NuvotonMOS ... 00-NAU7802

Resolution too high? Drop bits to fit your needs.

-----------------------------

The Second candidate is the Adafruit ADS1115 16-Bit ADC
Features:
moderate cost - $15
built in PGA
4 channel
4 chips per I2C bus
16 bits - 65535 steps from 0 to Vref.
860 samples per second
http://www.ti.com/lit/ds/symlink/ads1115.pdf

Image

I would pick the second option.

Richard

RainerK
Moderator
Posts: 3947
Joined: 29.04.2009, 09:31
Location: Sprockhövel (zwischen BO u. W)
Contact:

Post by RainerK » 19.12.2013, 07:14

Hi Richard,

the "Position of a turn table bridge" with it's fine steps to feedback and control with a analog measurement :?: :roll:

That is definitely Not State Of The Art :thumb_down: :!:

That You can knocking into the ton (in german You say: in die Tonne kloppen), because otherwise annoying faults are guaranteed :evil:

Use a digital coded information and You feel fine. :)

Best Regards
RainerK

Richard-TX
Posts: 1320
Joined: 10.07.2012, 04:00
Location: Texas, USA
Contact:

Post by Richard-TX » 19.12.2013, 08:07

I am not sure what you mean for certain, but I am likely guilty as charged. :wink:

A digital location sensor for a turntable is pretty easy. Interfacing the digital world to the analog world we live in can be a bit tricky at times.

Some of my ideas may not work, other ideas work only for me, and yet others actually prove to be good. That is up to the reader to decide. Even a blind pig finds an acorn once in a while and I am that pig.

I believe we need to share ideas. Here in the states we call that a "Think Tank".

If someone looks at one of my ideas and creates a cool product, then I have done my job. :thumb_up:

Richard - Doing all he can to help the Rocrail project.

Post Reply

Return to “DIY Hardware”