so today i'm going to be building this little kit that harold sent me uh in a
mail bag a few weeks ago and since harold's ontario i decided to choose an ontario beer
this is cobblestone nitro stout from mill street brewing in toronto
so this little kit if you remember from the mailbag is a gpio extender board based on
the mcp23017 chip which is this one it takes i squared c seo and sda from a microcontroller and
breaks it out into 16 extra gpio pins which can be really handy if you're working either with a
small microcontroller or with a ridiculously huge number of pins and you've just exceeded what your
board can do let's take a quick peek at the chip itself it is part of a family of uh of chips that
uh do this some are i squared c summer spi this particular one is i squared c uh 23017 comes in
a variety of packages of course it'll operate down to 1.8 volts which means you can use this
for the 3.3 volt microcontroller families or it'll operate up to 5 volts which
means you can use it for the more traditional arduino stuff there's the basic block diagram
serial data comes in there address decode if you happen to be using i squared c which we are
it has a couple of interrupts that it can send to the microcontroller so that the microcontroller
doesn't have to constantly scan this thing it can just uh ignore it until something changes out here
and that flips in interrupt and then there are the 16 gpio out there they are just as far as i know
just a standard gpao they're not pwm or anything like that they're not anal and onto digital
converters but just for standard handy enough chip so included in his little kit there is the chip
and the socket the board itself nice solid board a bunch of pin headers a whole bunch
a little sill resistor array so this is a 103 or 10k resistor array so it's got nine pins uh
it contains eight resistors these pins here and each one has the common side coming back to this
first pin at this end handy way to get a whole bunch of resistors into a fairly small footprint
and then there are three just standard resistors which i assume are pull-ups or something similar
they'll be going in there now in this note harold pointed out that he missed putting in
some pull-up resistors on the i2c lines so that will be something that i will add out of my
selection of uh parts i should be able to do that there'll be header pins going in there
and five volts is conveniently located there so i should be able to barge that on on the back
fairly easily i would think so let's get started i think we'll start with these three
loose resistors that came with it and just out of curiosity we'll see what they are
looks like they're 10k are they all the same i assume so
yeah they are okay so those three go in these positions down in the corner here
so those three appear to be associated with the address pins and they are all common to
there which is to there which is the plus five so those are pull up resistors so the address
for this board is one one one i should have looked at the data sheet to find out what that
translates to what the base address is do you know what i think i'm just going to use the uh
arduino sketch that snoops the i squared c bus and identifies the addresses that it finds
which is also a useful way of telling me if this circuit is working or not
a nice blob of blue tack on there and
get busy on the socket pins looks like not all of them are in use that particular corner one isn't
nice how they got all the gpio pins lined up
in a nice convenient row it makes breaking them out a whole lot easier well done people at some
microchip corporation mcp when you designed this board however long ago as you did did that
i guess i will put the sill resistors in as i mentioned earlier that that end little arrow
indicates the common side of them and he has conveniently put a dot where the common side goes
so that one goes that way up and this one the dot goes at the other end
like that and i guess i will throw some blue tack on here
just to hold them from falling out when i flip the board over i'll put them straight ish too
for some people neatness counts i am less concerned
the rest of it is just putting in pin headers so what he's done on here and
i commented on it in the mail bag is he has for each gpo he has three pins
one is the ground which appears to be the outside one on that and how does the ground get over to
here yeah so ground is on the outside plus five volts is on the middle the gpio is on the inside
so rather than using the black headers that he is supplied with that i'm going to dive into my stash
and i am going to use red and green for the positive and negative voltage
and then i'll use the black ones that he sent me for the uh for the actual signals
yeah just about like that now the hard part comes in soldering them all in place because
i probably shouldn't have done it like that make this work easily with some painters tape just to
hold them in place i don't know if it will or not or if it's just going to make it even uglier but
they'll give it a shot i think i'm just going to do one pin at the end of each strip for now
and then straighten them up and then go from there
that's better
let's do the power pins and uh data pins here before i get too carried away as well
those are all leaning a bit but
it's a quick reflow and push on them with my finger from the other side
and it's got the leaning the other way
that's not bad
that's not perfect but i'll live with it
okay those are all nice and straight those are the ones i'm more concerned about
now i'll just solder the whole shooting match down again
i'm just going to take a second here to make up the pull-up resistors that i need to put on the i
squared c so just twist a couple of those together and on the common side and start them together
so there's the two i squared c lines the clock and data and there is five volts um on that
pin and that pin and these pins down here so i think what i'm going to do is put that like that
and then run those in some heat shrink down to approximately there i know i often say neatness
doesn't count in a lot of this stuff but this is more preventing damage than literal neatness
splooge it into that pad
that went into there and
that went into there i don't think that took but i'm going to shorten them up anyway
just because they're getting a little bit ugly here that's still not as short as it needs to be
okay that's connected that's connected and
that little tail
that should do so before we get too carried away and put the chip
in let's just put the power supply on it and see what happens power supply shows zero current draw
which is approximately right these pull ups aren't doing any significant amount of uh
of current because they're not supposed to they're just a gentle pull-up so that's good i don't have
any shorts on the board so notch indicates the pin one end there's the notch there's
a dot indicating pin one so put that in like that being careful to get all the pins aligned
you can usually get away with gently straightening them a time or two before you
are in real trouble here try this again
okay i think i've got them all started
that looks right now let's see if it draws a little bit of current
it should draw a little tiny bit but not too much
nothing to speak of okay chip's not getting warm that's a good start well
i guess all that's left now is to hook it up to an arduino or something and test it out
so the next step i guess is to see if we can talk to it and for that we will start with this
i squared c detect sketch which just scans through all the possible addresses until
it finds something that responds in this case this one is responding on address 27.
so now i have installed a couple of different libraries for the mcp23017
this particular one i think i'm going to try and use it has both a digital read example
and a digital write example so here is the digital write example code it sets up a serial
it pulls in a couple of libraries it defines the i squared c address sets up a serial print
begins everything
does a little bit of initial configuration here and then it throws some stuff onto the serial
monitor creates a little loop here uh 16 times it looks like it alternates between a high and a low
digital right onto pin zero and then do a so it looks like it's blinking that one for 16 times
while printing some stuff and then it uh throw something else at the serial monitor
creates a little loop here looks like it's each time through the loop
it either sets the uh pin from the loop high or low so turns every second one on i guess
and then reads them back okay
blinky blinky blinky and then turn every second led on so that's kind of what we expected um
and that shows just the basics of controlling it so you can control them
the outputs that's fairly straightforward i guess i should test or demonstrate the
input as well just for uh just for funsies but i don't think i'm going to wire up all 16 of them
just because that's an awful lot of wiring and an awful lot of push buttons and i probably can't fit
them all onto a breadboard anyway and here's the digital read version of the example code
again start stuff same as before set the address same as before most of this is very similar
here is the the business we serial print the header we run a loop we digital read all the pins
and we print them as we've read them and go back do that 16 times that is
in the setup part i've just copied and pasted that down into the loop just to keep it running
and added a delay after it and there is what it looks like running now that if i push
some buttons i only have the first eight buttons connected so that's the only ones you're going to
see come active but there's uh i don't have enough fingers anyways there you go you can
see it inputting them so we should be able to uh use those libraries and uh and just very standard
digital read and digital write type commands to generate whatever we want on all of these pins
and as i was mentioning earlier if we have multiple of these there are three address lines we
could we could address up to seven of these chips with one arduino with one you know i squared c
so you could get a ridiculous number of uh gpio out of uh out of your arduino fairly easily i
think that's a pretty cool little chip and a nice little board that that harold designed and shared
with me thank you very much for that oh i know i learned something tonight i hope you did too uh
comments and questions down below thanks for watching i'll talk to you later