Arduino Best expander Input/Output | GPIO Expansion module | MCP23017, MCP23S17
HTML-код
- Опубликовано: 20 фев 2022
- You will certainly learn something new from this video!
Here I go with a new DIY breakout module, and this time I axplained how to design and use a GPIO expansion module that could be used by any microcontroller like #Arduino, Raspberry Pico, STM32, NodeMCU or any other MCU dev board as long as it has a I²C bus
This MCP23017 Module board has been designed under Altium Designer and you can start a FREE TRIAL of this EDA software through this link :
www.altium.com/yt/DIYGUYChris
★☆★ Trusted sources ★☆★
PCB designing tool : www.altium.com/yt/DIYGUYChris
PCB manufacturing : jlcpcb.com/PCH
Arduino Portenta : store.arduino.cc/products/por...
★☆★ DOWNLOAD PCB GERBER FILES ★☆★
GERBER files : www.mediafire.com/file/kf17oc...
★☆★ DOWNLOAD SCHEMATICS ★☆★
Download PDF : www.mediafire.com/file/8eei5h...
★☆★ ARDUINO CODES ★☆★
★☆★ My Video filming tools ★☆★
Main Camera Canon Rebel T7 : www.amazon.com/gp/product/B07...
Macro Camera lens : www.amazon.com/gp/product/B06...
Secondary camera Gopro Hero 8 : www.amazon.com/gp/product/B08...
LED Video lighting : www.amazon.com/gp/product/B08...
★☆★ 💻 FOLLOW ME BELOW 💻 ★☆★
Instructables: www.instructables.com/member/...
Hackaday : hackaday.io/DIYGUYChris
Facebook : / diyguychris
Twitter : / chris_diy
Hackster : www.hackster.io/diyguyChris
TikTok : vm.tiktok.com/ZMRAvhK9u/
Keywords
#ArduinoProject #MCP23017 #Electronics #Maker #diy #howToDiy #HowToDesignPCB #Altium # #PCBAssembly #SMD #EasyTutorial #STEM #circuitDesign Наука
We need more videos like this 👏 🙏 keep up the good work 👏
Thanks 🙈
ohhh ça déchiiiire 😍gooood joob Chris
Merci 🙈
As always in the top 🎩
As always continued support 🙈
Great work, good continuation 👏
Thanks 🙏
I have followed all stages on your Instagram too it's seems so cool good job👏
Thanks 🙈
In a project, altera max ii fpga ic and mcu atmega328p are installed, altera max ii was used to expand io pins. Only the MCU must be programmed. Or both the Altera Max II and the MCU will be programmed.
Thanks, useful project.
Thanks
very good M'ester belkhir
Top project
Good work ✌️🇨🇦
Good job 🎖️
Thanks 🙈
Good job 😉
Thanks 🙏
Excellent project Chris. Any plans for an analogue version of the multiplexer?
Do you have any suggestions about some AD devices? I'm doing digital all the time but I have some interest to make some analog modules so any recommendations from you will be very appreciated
Nice to see your new video, I wonder how long you spent on hand solder, the board is small, but you did a fantastic job.
Yeah, soldering was challenging because of the tiny components size 🙈
how is the pin state at startup of the expander? high or low?
Can we use ic 7219 mux
For conneting more relay in case of attiny mcu
Do you mean the TMUX7219? That's a switch not an MCU.
Is it possible to use audio input (e.g. inmp441 i2s) or audio output (e.g. max98357A i2s) via this port expander? If yes how is it done, especially the pin config? Thanks for any advice. I only got buttons, leds, encoders to work.
I²S is an audio communication protocal that requires an I²S data line which is not existing in MCP expander not even in other GPIO Expander because these will provide General Purpose IO but I²S is specific IO for sound.
I hope you can distinguish these two terms (I²S and GPIO) !
In your example sketches, one demonstrated OUTPUT and the second demonstrated INPUT.
Can this expander have some
pins set to OUTPUT and different pins set to INPUT (within the same sketch)?
Sure thing, it is as same as you set the arduino pin I/O
Hi , like your project, can you pls do Nodmcu with water tank Level indicator IoT.?
its exactly the same just use the i2c pins on the nodemcu
top borject
👍🎉👏👏👏👏
Sooo, could you make a 3d printer with raspberry pi pico now that you can expand its IO pins?
You can make 3D printer without any need of expansion : )
@@DIYGUYChris But for a 3d printer usually you have to have at least one stepper per axis and an extra for the extruder, i think the pico doesn't have that much IO pins
@@luizpollo you will not get the steppers powered directly from Pico, there you will have stepper motor drivers, A4988 is one of these drivers.
In this case no need for extra GPIOs
Hello, great video 😄.
I'm a beginner and I have a question :
Can you use the MCP23017 with the TCA9548A multiplexer?
Thank you in advance for your precious support 😁.
Cordially.
Indeed
@@DIYGUYChris Hello, thank you very much for your feedback 😁.
Have a nice weekend 😄.
Cordially.
does that adafruit library handle the debouncing of the switch or did you add a 5ms piece of logic in there yourself? I noticed you got precisely only one message per push down and one for release. Normally momentary switches (especially ones that are not top quality) will "bounce" as the mechanical plate causes a bounce (you can see on the o scope) when you get close to closing. debouncing usually removes this or putting in about a 5ms logic to handle it. Very cool video. I have used a dozens of PCA9685 modules and love anything i2c
That's a good point to highlight, I got the inputs to interpret the clicks through logic edge because edges appear one time but logic level is continuous so I suggest you add a boolean variable as a flag for each input reading and add it to the input read if() statement so for example instead of writing if(digitalRead(input))
{
Serial.println("message");
}
You write
if(digitalRead(input)&&flagInput)
{
Serial.println("message");
flagInput=0;
}
if(!digitalRead(input))
{
flagInput=1;
}
This way the flagInput variable will ensure that we get the message one time only once the input is high.
This will cost you some of the dynamic memory of your MCU due to variables use.
Instead you could add a short delay of around 200 ms just inside the "if" statement so it becomes like this
if(digitalRead(input))
{
delay(200);
Serial.println("message");
}
But this will keep you getting the message on the serial as long as the button is clicked.
I hope this is clear
@@DIYGUYChris that is how I handle "Button Presses" too
@DIYGUYChris well, except the delay, I despise delay in microcontroller code. I either use Millis or interrupts with a simple Finite State Machine logic to give the illusion of "pauses or delays" but still have processor "free" to provide a multi task feel. This becomes VERY important when you want to react quickly to things like button presses, especially of you have a bunch of them
Can you please help me to find an gpio extension upto 2600 output
shift registers is an option
I have used mcp23s17 in a project to extend the io pins.but the speed is getting with 16-bit remote bidirectional 10mhz. What can i use instead of mcp23s17 to increase capacity. Can i connect mcp23s17 in parrallel to solve my problem? The problem in this project is that ic above 128kb is not being read,i want to read 192kb ic.
Application need more io pin because of laptop keyboard connector is 32 pin connect to my pcb.
I used mcu atmega88 in my project.
This my programmer is only able to read io ic 128kb of laptop. Cannot read 192kb ic.
How to solve this problem. Please help or make video on this topic.
Thank you
You are already using the MCP23S17 in parrallel because it uses SPI communication which is already the fastest communication port for MCPs, maybe you need more software solution rather than hardware, try to read/write ports instead of reading or writing one bit at a time, it helped me to speed up the outputs writing for my MCP23017 once.
program SPI_Communication;
{$APPTYPE CONSOLE}
uses
SysUtils, Windows;
const
FT232RL_VENDOR_ID = $0403;
FT232RL_PRODUCT_ID = $6001;
SPI_MODE_0 = 0;
SPI_MODE_1 = 1;
SPI_MODE_2 = 2;
SPI_MODE_3 = 3;
type
TTransferOptions = record
Pin: byte;
Mode: byte;
BitsPerWord: byte;
Speed: DWORD;
end;
var
hDevice: THandle;
TransferOptions: TTransferOptions;
MCP23S17_ADDRESS: byte;
IODIRA: byte;
IODIRB: byte;
GPIOA: byte;
GPIOB: byte;
procedure SpiInit;
begin
// set SPI mode 0
TransferOptions.Mode := SPI_MODE_0;
// set SPI clock speed to 1 MHz
TransferOptions.Speed := 1000000;
// set bits per word to 8
TransferOptions.BitsPerWord := 8;
end;
procedure SpiTransfer(address, registerAddress, data: byte);
var
Buffer: array[0..2] of byte;
BytesTransferred: DWORD;
begin
Buffer[0] := address or $80; // set MSB to 1 for write operation
Buffer[1] := registerAddress;
Buffer[2] := data;
// perform SPI transfer
if not DeviceIoControl(hDevice, $22200b, @TransferOptions, SizeOf(TransferOptions), @Buffer, SizeOf(Buffer), BytesTransferred, nil) then
Writeln('Error: ', SysErrorMessage(GetLastError));
end;
procedure MCP23S17Init;
begin
// set IO direction of Port B as output
SpiTransfer(MCP23S17_ADDRESS, IODIRB, 0);
end;
procedure MCP23S17Write(data: byte);
begin
// write data to Port B
SpiTransfer(MCP23S17_ADDRESS, GPIOB, data);
end;
begin
// initialize FT232RL USB to serial converter
hDevice := CreateFile('\\.\FTDIBUS0', GENERIC_READ or GENERIC_WRITE, 0, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL or FILE_FLAG_OVERLAPPED, 0);
if hDevice = INVALID_HANDLE_VALUE then
begin
Writeln('Error: Unable to open device!');
Exit;
end;
// set vendor and product IDs for FT232RL
if not DeviceIoControl(hDevice, $A2320001, @FT232RL_VENDOR_ID, SizeOf(FT232RL_VENDOR_ID), nil, 0, DWORD(nil^), nil) then
begin
Writeln('Error: Unable to set vendor ID!');
CloseHandle(hDevice);
Exit;
end;
if not DeviceIoControl(hDevice, $A2320002, @FT232RL_PRODUCT_ID, SizeOf(FT232RL_PRODUCT_ID), nil, 0, DWORD(nil^), nil) then
begin
Writeln('Error: Unable to set product ID!');
CloseHandle(hDevice);
Exit;
end;
// set up SPI communication
SpiInit;
// set up MCP23S17
MCP23S17_ADDRESS := $40;
IODIRA := $00
Please suggest what is the mistak in delphy code.
Does it work with esp32 ?
Indeed, it works with all MCUs
You can make robot dog
What is that
MCP23017 Breakout board
I will need your help
Okay
@@DIYGUYChris I would like a hat that can hold up to 96 GPIO pin hat. With its own power supply from a 12v -24V DC BATTERY THAT 🔋 and cand a Automatically be controlled with the raspberry pie depending on load
@@DIYGUYChris I want to use R GB W on my 2005 theater Sequoia I'll be able to control it from a raspberry pie app inside the car
@@DIYGUYChris I need if I can make another GPL or USB HATt that could control all the 4k cameras on the S UV and store in a external SSD, like tasla camara blind spot camaras. I would like to know if there's a 3-D program that I could use for my vehicle to select toggle switches for my LED light on my car display inside the car
@@DIYGUYChris I want the raspberry pie depending on my command to tell if the door is open and if I can turn on the light what color will it be and what color can I change it to or if the Ignition switches on or off when till start loading data into it is hard drive