Expanding GPIO pins on Arduino Portenta X8

Thread Starter

Rensieboy223

Joined Feb 3, 2024
88
Hello guys,

For my project i want to expand my GPIO pins on my Arduino Portenta X8.
Were gonna use a whole lot of Thermocouples (Adafruit Max31856) and we need to expand our GPIO-pins.
I've done some research and stumbled upon the MCP23017 chip.

Is this one a good option for reading a lot of temperatures with about 40 Thermocouples?
We need to read everything at the same time, so the GPIO pins all need to work parrallell from eachoter.

Thanks already,

Greets,

Rens
 

Attachments

ronsimpson

Joined Oct 7, 2019
4,790
I don't know the X8, or the Max31856.
The Max31856 has a SPI bus. Normally I connect the pins to a micro that has a SPI port. You can do SPI in software from any pin but using the right pins and doing the shifting in hardware is much faster.

It looks like to talk to one Max you need to do 16 clocks. (8 for address and 8 for data)
To connect two Max parts. You connect all clocks together. Connect all CS together. Connect the DO of the first to the DI of the last. Now clock 32 times. The data passes through all the Max parts and back to the CPU. This can be expanded to include 40 parts. You might need to buffer the clock signal.
1715121810667.png
A second way is to connect all the Max parts in parallel. The have 40 different CS pins. You select part 1 and clock 16 times. Then deselect 1 and select 2 and do it again.

The CPU has three SPI ports, the connector has two of them.
1715124422221.png

I have driven large numbers of SPI parts using only these pins on the microcomputer. Clock, DO, DI, CS. CS=is a general purpose IO pin.
 
Last edited:

Thread Starter

Rensieboy223

Joined Feb 3, 2024
88
Hey Ron,

Sorry for my late reply,
I have a few questions about your explanation:

- What is the 'Max' in your tekst? Which device is that since you don't know about the Arduino portenta X8 en the Max31856 thermocouple? The Max31856?
- What is a SPT bus, i cannot find anything on the internet about it?
- Method one cost less pins then method 2 right?
- What do you mean with clocking the pins: 'It looks like to talk to one Max you need to do 16 clocks. (8 for address and 8 for data)'. Right now we connect all the pins to general GPIO pins, define the pins in the Arduino IDE software and where good to go and read temperatures. Is this more complicated?
- How do we program this in the arduino library so the arduino which thermocouple is which?
- Can we read with method 1 all the temperatures at the same time?

Thanks already for the information!

Greets,

Rens
 

ronsimpson

Joined Oct 7, 2019
4,790
Sorry about some typing errors.
- Can we read with method 1 all the temperatures at the same time?
Yes. I don' program in Arduino but I am certain you can chain SPI parts together.

If you connect the pins to any IO pins in your computer, the computer will have to [set clock low, set clock hi, output data, input data, shift data, repeat 16 times] Because of the library you probably can't see what is happening, but it is probably slow.
If you use the SPI that is in hardware in the computer, you will write twice to the SPI. It will clock 8 times and do the read and write without any effort from the computer.

A brief look at Arduino manual suggests the below for two 8 bit writes. To do 40 of these (repeat the middle two commands 40 times)
digitalWrite(chipSelectPin, LOW);
SPI.transfer(address);
SPI.transfer(value);
digitalWrite(chipSelectPin, HIGH);

The picture in post #2 shows three slaves. It could be expanded to 40. This uses the minimum I/O pins.
 

Thread Starter

Rensieboy223

Joined Feb 3, 2024
88
Hey Ron,

Thanks a lot for the information.
If you got any more video's or books or some pages with more information about SPI parts and the SPI bus it uses to read multiple devices at once with low use of gpio that would really be awesome!

On the Breakoutboard in the picture #2 it shows the SPI ports for the Portenta X8 indeed.
I'm not familiar with these COPI and CIPO pins, but I guess it's the same as MISO and MOSI or DI and DO?
And is CK the same as the SCLK on picture number #1?
Maybe some more explanation about these pins would really help me, because these names do seem to differ a lot.

Thanks already man!

Greets,

Rens
 
Top