i2c GPIO expansion IC advice

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

Hi All

 

I got a little issue.

 

I need to control 5 latching relays, via a H-Bridge IC. This would mean, i would need about 7 GPIO, which are the 5 enables and 2 H-bridge control lines for the DRV8837C. My AVR does not have any spare.

 

My main PCB has a spare port, which has only VCC(5V),GND, and UART TX and UART RX.

 

I am thinking of using the tca9534a and controlling it using a software i2c libary. If i am correct there are i2s software based libaries for AVR?

 

The other option is using a UART to GPIO IC, if there is any?

 

Would there be any issue with this, as i would like to avoid using another AVR just to control extra GPIO for my relays.

 

Please advice

Thanks

Regards

DJ

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

djoshi wrote:
If i am correct there are i2s software based libaries for AVR?
not an answer as the following was for a mega32U4 with an I2C port expander in the Arduino IDE.

ControLeo/ControLeo at master · engineertype/ControLeo · GitHub

MCP23008 - Interface - Interface- Serial Peripherals - 8-Bit I2C I/O Expander with Serial Interface

via Whizoo.com (reflow oven controller)

 

"Dare to be naïve." - Buckminster Fuller

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

Google Peter Fleury. He has what i consider the finest I2C library on the net

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

 

"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

What AVR are you using?   You may be able to use the USART in master spi mode if supported. 

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
stack gold/silver https://www.onegold.com/join/713...

 

 

 

 

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

jgmdesign wrote:

Google Peter Fleury. He has what i consider the finest I2C library on the net

Jim

 

Thanks I will

Thanks

Regards

DJ

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

ki0bk wrote:

What AVR are you using?   You may be able to use the USART in master spi mode if supported. 

 

 

I am using Atxmega256a3bu, pins PC2 and 3.

 

 

Thanks

Regards

DJ

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

Scratch Peter Fleury if you are using an XMEGA

 

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

 

"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

djoshi wrote:

I am thinking of using the tca9534a and controlling it using a software i2c libary. If i am correct there are i2s software based libaries for AVR?

 

The other option is using a UART to GPIO IC, if there is any?

 

Would there be any issue with this, as i would like to avoid using another AVR just to control extra GPIO for my relays.

Keep in mind that small MCUs these days can cost less than an i2c expander  (yes, that's nuts but is shows what volumes can do...)

 

Digikey has search engine that lets you scan   

Interface - I/O Expanders  with choice of  IO count

and 

Embedded - Microcontrollers with choice of  IO count

 

 

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

Thanks i will use Peter Fleury's library.

 

I could use another AVR, but want to avoid programming multiple devices especially for simple operations.

 

Thanks

Regards

DJ

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

I have downloaded the  Peter Fleury's library from  http://homepage.hispeed.ch/peterfleury/avr-software.html

 

Is this meant to be a software(bit-bash) library?  As it seems that it is trying to read certain AVR registers such as TWCR.

 

Thanks

Thanks

Regards

DJ

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

The Fleury software has two libs, one is bit bang to any two i/o pins, the other uses the TWI, but will not work on xmega!

 

An alternative to I2C, the USARTs on the xmega support master spi operation, so use a shift register or spi i/0 expander ic for your i/o expansion, very easy to do and fast too.

 

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
stack gold/silver https://www.onegold.com/join/713...

 

 

 

 

Last Edited: Thu. Apr 25, 2019 - 06:06 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks

 

I am using the atxmega256a3bu and my i2c device is connected to port c pin 2 and 3. SDA connects to the TX pin and SCL connects to SCL pin.

 

Is there any example of how to make this port SPI? I have never used an UART as a SPI

Thanks

Regards

DJ

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

That device does not have an SPI engine? I thought all Xmegas have one.

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

 

"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

ki0bk wrote:

The Fleury software has two libs, one is bit bang to any two i/o pins, the other uses the TWI, but will not work on xmega!

 

An alternative to I2C, the USARTs on the xmega support master spi operation, so use a shift register or spi i/0 expander ic for your i/o expansion, very easy to do and fast too.

 

 

Jim

 

 

When you mention it will not work in XMEGA , is that for both libraries or just TWI?

Thanks

Regards

DJ

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

jgmdesign wrote:

That device does not have an SPI engine? I thought all Xmegas have one.

Jim

 

SO i guess bitbashing i2c is the only option.

Thanks

Regards

DJ

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

If you read the datasheet for the xmega you called out you will see that the device has tqo spi engines built in

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

 

"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

Yes, but the only pin i have access to the uart pins and the PCB already made. We need to control that device , or at least setting the output pins

Thanks

Regards

DJ

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

Read the DS USART section on master spi mode.

For that to work, you will need one pin for SS, perhaps the RXD pin can be used for that.

 

Jim

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
stack gold/silver https://www.onegold.com/join/713...

 

 

 

 

Last Edited: Thu. Apr 25, 2019 - 08:05 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Well that certainly sucks for you doesn't it? Ouch
Are the two sets of spi pins being used already?

I wpuld think it easier to implement bit bashed spi. Over i2c. A freak did it for me years ago in assembler i think. I would think it also easy to do in c as well.

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

 

"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


 

 

No sweat, here it is!

Jim

 

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
stack gold/silver https://www.onegold.com/join/713...

 

 

 

 

Last Edited: Thu. Apr 25, 2019 - 08:10 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So is my only option the bitbash of i2c?

Thanks

Regards

DJ

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

I found the following example of getting it to work with XMEGA, by using virtual ports.

http://nickdademo.blogspot.com/2011/03/how-to-peter-fleury-i2c-driver-and-avr.html

 

Has anyone tried this?

Thanks

Regards

DJ

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

Just use a tiny102  or tiny 104 as an expander...it has a uart built in to rcv your commands  & transmit any responses....just hook rx to tx, & tx to rx  & away you go with io, and even other measurements.

 

 

 

 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

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

djoshi wrote:

I am using the atxmega256a3bu and my i2c device is connected to port c pin 2 and 3. SDA connects to the TX pin and SCL connects to SCL pin.

Is there any example of how to make this port SPI? I have never used an UART as a SPI

djoshi wrote:

So is my only option the bitbash of i2c?

 

I'm confused, do you want i2c (2 wires open drain) or SPI (3-4 wires, MISO/MOSI/SCK/CS)

 

i2c in software should be fairly portable, if you can configure the pins to open-drain.

If the MCU cannot manage open-drain, but has data-direction,  you can modulate the data direction to emulate open drain.

 

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

Hi. Thanks 

 

i have manged to get a quick solution, instead of bit bashing with the the gpio pins. 

 

I simply made , the GPIO input and shorted them to i2c pin on the same board.

 

I think the next revision of the PCB, will now have a extra i2c header connector.

 

I wanted the PCB to look neat with not wire modes, but i guess this was required.

 

Thanks

Thanks

Regards

DJ