Making TWI connection to existing hardware... suggestions?

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

Hi. See attached diagram.

I am trying to interface a new AVR device with an existing AVR device via Two-wire Interface (aka twi, i2c). The existing device uses PD0/1 as GPIO but I can re-route the switches that are currently on those lines since they, conveniently, are attached by connector. I realize if I remove the resistors and capacitors and make the connection at "connect points" that I'm in business, but ideally , I'd like to not have to physically modify the existing device at all.

Can you think of any way to do so? Is there any sort of electronic trick I can pull-off in the new device to "negate" the effects of those components? I doubt it, but I know that I know so little that I better ask!

Thanks for any suggestions.

- Steven

ps. I neglected to show it in the ediagram, but the "loose" ends of those caps are connected to GND.

Attachment(s): 

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

Quote:
Can you think of any way to do so?
Bit banged TWI/I2C, then you can use any 2 pins.

Se also

;**** A P P L I C A T I O N   N O T E   A V R 3 0 0 ************************
;*
;* Title		: I2C (Single) Master Implementation

you can find similar code for other strange languages. :)

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Whats with the capacitors? My TWI stuff uses two resistors to pull the lines up to Vcc and thats it.

Curious

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 user

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

Quote:
Whats with the capacitors?
That's his EXISTING switches wiring not what he wants to do with the TWI.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

John... every i/o pin on this device is wired the same way... 200 ohm resistor and 0.1uF cap on either side of the [switch/button/whatever] with the exception of two floating pins connected to nothing... but then I'm still left having to modify the hardware and I'd actually rather remove a cap and resistor than I would solder directly to the pin (note: for a one-off, anything's do-able... but in the long run this is going to be performed on hundreds of devices by people with varying - including none - soldering skills, which is why I want to avoid hardware modification if at all possible. If its not possible, then removal of the two components is the easiest thing to do).

Jim - the device was never designed with TWI in mind. The resistors and caps on the i/o are there as "best practices" for eliminating possible EMI. This is inside a radio transmitter. The point of this thread is interfacing by TWI between an existing avr device (that was designed without consideration for TWI) and a to-be-designed AVR device (that can have any circuitry required for the interface).

- Steven

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

Perhaps I should note: every i/o on the existing chip (save for the two n/c ones) is in use. That's actually part of the point of the new device - to expand upon the i/o of the original.

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

You have to remove those caps, they 100nF is far too large a value to work with TWI.

If those resistors are 200 ohms, I think that is acceptable, as sometimes resistors of small value is there to limit signal fall time on bus which reduces reflections on long buses. But 200 ohms is on the large side, and may limit the pull-up resistor value to be higher than it could be, which in turn would limit communication speed.

So what kind of communication speed you are aiming at (100kHz or 400kHz maximum) and what length (few cm or tens of metres) and over what kind of wiring?

You did not say which device would be the master or the slave, I think your existing device is the master and new device is the slave, but in any case, I recommend the slave uses the real TWI SCL and SDA pins, but the master can use the real TWI pins or just any GPIO pins by bit-banging the TWI protocol in software.

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

Either could be the master/slave - the firmware of both is in our control.

higher speed is better, I suppose... to reduce potential of a bottleneck. Total trace length would be a few cm. no wires.

I guess I was hoping there could be a "negative capacitor" circuit that I could put on the new device that would somehow nullify the cap. The thing of dreams, I suppose :) If I have to have end-users remove the cap its not the end of the world (although I'm sure it increases the number of emails I'll have to handle 10 fold!)

Thanks.

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

Remove caps AND replace resistors with zero ohms links. You are still left with the need to add pullup resistors on BOTH SCL and SDA (3K3-4K7).

If the tracks going to ground for the 2 caps can be easily cut and re-routed to VCC then it may not be too ugly, this only needs to happen on, say, the master board.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

They're 0603 should be easy enough to jump the resistor pads with a solder blob.

Like I said before... doing the mod on a single board isn't a problem at all. The trick here - and why I wanted to avoid 100% of hardware modification if possible - is it needs to be done by 100's of end users with varying degrees of electronics know-how. *IF* it were possible to do it entirely on the interface board, then that would be worth extra design effort and component costs to do so. If its not possible... then so be it. I'll just provide good picture instructions.

Why would I re-route the caps to VCC though? Why not just remove them?

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

Quote:
Why would I re-route the caps to VCC though?
You re-route the cap LOCATIONS AND change the caps to pullup resistors so that you don't have to add them with skyhooks. :-)

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

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

Dumb question(s) time...

CAn you use the USART in the mega 644? If it has a spare maybe use that one to communicate to the new device through it's USART?

Does the comms need to be TWI or can you use SPI?

I can relate to not wanting to have to rely on end users making hardware mods. THAT can be a pain. But the most painless would be to solder onto the txd/rxd pins of the spare usart if it exists, and send a firmware update maybe?

If not then ignore this junk I just posted, and accept my apologies. :)

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 user

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

Quote:
If I have to have end-users remove the cap its not the end of the world (although I'm sure it increases the number of emails I'll have to handle 10 fold!)
Don't know what your PCB look like.
Maybe it's easier for end users to cut a trace on either side of the cap.
The serial resistors might be a problem.
Might help to have pull-up resistors to Vcc on both sides of the serial ones.

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

John - Ahh, I see. I think it would be easier for the end user to just remove the cap, bridge the resistor with a solder blob, and then I'll provide the pull ups on my add-on board's side.

Jim - TWI would be my preference because then the firmware authors for the 64 could communicate directly with the TWI devices that are being added (a specialty IC and some extra EEPROM), however... they'll also have access to the new device's firmware so I suppose SPI could be used between the two AVRs and the new AVR uses TWI to communicate with its onboard devices and then report back to the existing AVR via SPI (can that all happen fast enough?). I should look more into SPI. The new board is going to also be a permanently attached ISP for the existing board, so MISO, MOSI, SCK connections are already there.

I'm not familiar at all with SPI though... reading...

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

HA! As I'm reading the beginning chapter of SPI for dummies... I'm straying to think to myself... "duh" lol

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

Oh.. right... double "duh" :)

Now I remember why SPI wasn't on my radar for this. SCK, MOSI, and MISO are all pulling double-duty. They are all gpio while not actively being programmed. That's also the time I'd need the AVR-AVR communication. Unlike PB0/1, unfortunately, I can't re-route the switches that are on these lines.

I'll have to investigate very carefully what switches are used by these lines, and whether or not we're lucky enough that those switches just aren't needed at the same time the AVR-to-AVR communication is happening, but that sounds ominous.