I/O Expanders

Go To Last Post
17 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I hope that I did not post to the wrong forum. I am designing a project around the ATmega1284. I need more I/O pins, so I will using a Microchip MCP23017 I/O expander. I would like to know how to address the pins on the I/O expander in code. Yes, I have read the data sheet more then once. The answer is probably simple, but it eludes me. Thank you for your help!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It hooks up to the SPI port on the AVR. If you are talking about addressing the pins on the Microchip MCP23017. You are likely to find that information on the Microchip website or any number of forums for their products.

 

Edit: Might be wrong on the SPI.

Last Edited: Mon. Jan 4, 2016 - 05:21 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Most (at least the old ones)  versions are wired on the I2C port; it is often used in RPis  - a nice tutorial is here http://www.raspberrypi-spy.co.uk... , giving the commands you must give to configure a port 's pin as input/output and reading/writing its value- and in Arduino http://tronixstuff.com/2011/08/2...

 

Edited :added the It adress of the nice RPi tutorial....

Last Edited: Mon. Jan 4, 2016 - 05:52 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

Now, there are designs and there are designs.  But after you spend the extra buck for your "I/O expander", and consider board space and dev time, are you really better off than using that extra buck to use a 64-pin or 100-pin AVR model?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, an I2C MCP23017 is about 2.5 E$ at https://hackspark.fr/fr/mcp23017... an arduino uno clone is 8E$, an arduinomega clone is/was  12 E$ at the same shop ... price difference can be neglected . And software is more complicated with I2C.

It makes more sense using it with a RPi, where there is a limited number of pins....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

For reasons I have already described in another post, I need through-the-hole components. If you really want the explanation, please let me know. Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AL7HH wrote:
If you really want the explanation, please let me know.

Yes, please!  It isn't 1970 any more...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well, I see two software issues :

(a) how to drive a I2C (or SPI -MCP23S17, faster- : both can be used as 23017) bus

(b) which specific orders one must send to make part of the port as output/input, and then write/read (and mask them : IIRC, it is almost the same way as a MCU GPIO) them.

and one hardware issue (choosing between SPI -eats more pins: maybe 74HC595 would be enough for output- and I2C). But perhaps AL7HH does not have all of these issues at the time....

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AL7HH, I'll let you into a little secret. For any chip that is half useful, there is usually a Arduino library for it. Whether or not you like/hate the Arduino concept, you'll end up doing the same thing anyways. Since Arduino is just C/C++ you can usually borrow the code with little modification.

You really need to have a go at soldering tqfp packages. They are faster and easier to solder than dip - even when using a standard soldering iron. You'll wonder why you avoided them. I frequently use adapter boards to give me a 0.1" grid.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Australia: It must be nice down under this time of year. One category of users is in Amateur Radio, and they love TTH because it helps them change an IC without soldering. Not to mention that I don't have the equipment to properly solder surface mount components. Although I have had college level classes in C, my C++ is a bit rusty. I may even program in BASCOM, a BASIC style language which has some interesting features, such as using 2 processors with 1 processor being used as an I2C slave. I have BASCOM, Atmel Studio, and even an Arduino installed. I will look into the Arduino's libraries. I hesitate on using Arduino code due to questions about whether the code is open source. Thanks!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AL7HH wrote:
One category of users is in Amateur Radio, and they love TTH because it helps them change an IC without soldering.

I guess.  IME the last thing that is going to fail is the AVR, assuming it is properly protected from the real world.  Probably seven figures of AVR8s over the past 15 years.

 

AL7HH wrote:
Not to mention that I don't have the equipment to properly solder surface mount components.

Carrier boards have already been mentioned.  Schmartboard http://schmartboard.com/smt-to-d... has their "smart" (or is that schmart) system(s) with little grooves for the QFP/SOIC legs to help with the mounting.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Since the code is in the processor, it is also easier to upgrade. And there is a steady flow of upgrades.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

AL, my perception of amateur radio must be different than yours. The only components i remember that were socketted were valves - and unreliable at that. I also remember a curious mix of bleeding edge and obsolete technologies combined. For most of my smt work i just use a normal soldering iron with a chisel tip, 22swg solder, soder wick and a syringe of flux gel. Having a hot air tool is handy, especially for heatshrink.
if you're worried about arduino code being open source, then what about non-arduino code? What about code posted here?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I remember using through hole components...

 

<smirk>

 

Actually, I still use a fair number of them, and have a bunch in my parts bins.

Having made the switch to SMD a few years ago that is now my preferred approach.

 

I recall using an MCP23017 for reading a bunch of push button switches on a front panel.

In the end, it did exactly what I needed it to do, but I recall I had a terrible time with one specific function.

I don't recall what that was, and I ended up using a work around, (maybe an interrupt issue?).

(Interrupt issue with the I/O expander, not with the Mega running the project.)

 

Anyway, interesting that the I/O Expander chip and SMD should come up in the same Thread.

The project in which I used the I/O Expander chip was also my first SMD PCB, (for a DDS chip that didn't come in a through hole version).

Not a great layout, but one has to start somewhere.

 

Everything else was through hole.

 

I started the transition to SMD using 1206 sized parts.

Those are EASY to hand solder with a normal soldering iron.

I don't own a hot air station.

 

I also have some solder paste and an old frying pad.

I've cooked up a few PCB's, also.

I use a syringe and short stubbed needle to put the paste on the pads, add the components, and then fry it up until the paste re-flows, (melts).

Easy, works, my preferred approach if I have several boards to do, or a fair number of components on them.

 

I'll add a link to my fry pad Thread if I can find it.  Here.

 

The DDS Signal Generator with the I.O Expander chip and my first SMD PCB is shown below.

 

JC

 

 

JC

 

 

 

 

Last Edited: Tue. Jan 5, 2016 - 01:59 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

it is also easier to upgrade

Not sure I understand that one.

I think you are implying that you pull the DIP chip and put it in a programmer, and then reinsert it back onto the project's PCB.

 

I did that for years.

 

And then I switched to using AVR's.

 

Even with my DIP AVR's, as I like to breadboard projects when it is reasonable to do so, I don't remove them to program them.

 

The AVR's use In System Programming, and as it's name implies, you leave the uC in the circuit while updating the code.

 

None of my projects are super small, so adding a 2x3 male header for programming is no big deal.

Attach the ribbon cabled programming connector when doing software development, otherwise ignore it.

There are lots of Threads about non-"Standard" programming connectors for space constrained designs, if that matters.

 

You should consider putting a programming header on your PCB's for the original software installation, and for debugging and software development, and for occasional upgrades, regardless of whether you use through hole or SMD design for your projects.

 

The following photo is another project, two uC's, two red push button reset switches, two 2x3 male programming headers.

(One below the red PB switch in the middle of the board, one above the red PB switch in the right lower corner of the board.)

 

Truly, give SMD a try, you will be glad you made the transition.

And, start adding a programming header to your boards, regardless of TH or SMD.

It is MUCH easier, pins don't get bent, connections don't loosen, and it is soooooo much faster and pulling, inserting, pulling, and inserting a chip for each change in software.

 

The Atmel "Standard" programming layouts, compatible with most AVR programmers, is found in Atmel Application Note AVR042: AVR Hardware Design Considerations,  found here.

 

JC

 

 

Edit: Typo

 

Last Edited: Tue. Jan 5, 2016 - 02:24 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have exchanged PM's with the OP on his project and I understand the reasoning behind the desire to use through hole devices as many of the HAM products he uses still are made with through hole and "if it ain't broke don't fix it" is the theory.  Also the OP as he has mentioned is a couple of notches above a hobbyist, but just is not ready, or knowledgeable enough regarding the SMD adapters and other goodies we all may take for granted because we work with them all the time. 

 

While I do use SMD to DIP adapters quite frequently I have noticed that I am having difficulty soldering TSSOP and MSOP parts to the adapters lately.... It was inevitable, hopefully my six year old will pick up the slack soon wink

 

Great to see some great links to adapters like Schmartboards and Doc's link on how to fry a circuit board without frying it.

 

Jim

 

 

 

 

I would rather attempt something great and fail, than attempt nothing and succeed - Fortune Cookie

 

"The critical shortage here is not stuff, but time." - Johan Ekdahl

 

"Step N is required before you can do step N+1!" - ka7ehk

 

"If you want a career with a known path - become an undertaker. Dead people don't sue!" - Kartman

"Why is there a "Highway to Hell" and only a "Stairway to Heaven"? A prediction of the expected traffic load?"  - Lee "theusch"

 

Speak sweetly. It makes your words easier to digest when at a later date you have to eat them ;-)  - Source Unknown

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB, RSLogix user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

" I hesitate on using Arduino code due to questions about whether the code is open source."

https://github.com/adafruit/Adaf... : it is opensource (bsd licence) and the source is easy to deduce  (BTW "BASIC style language which has some interesting features, such as using 2 processors with 1 processor being used as an I2C slave"  arduino can do it, too :  gammon  explains how to use two avrs/arduini  , one being an I2C slave http://www.gammon.com.au/i2c ; and  this is more complicated -I tested it and was satisfied -with  a SPI slave http://www.gammon.com.au/forum/?...)

 

* i2c url corrected. Ross*

 

 

Last Edited: Wed. Jan 6, 2016 - 12:09 PM