HomeTechnologyUpcycling a Tandy Mannequin 100, Half II: I2C Strikes Again

Upcycling a Tandy Mannequin 100, Half II: I2C Strikes Again


Final yr for Palms On, I gutted a defunct TRS-80 Mannequin 100. The purpose was to improve its 24 kilobytes of RAM and a pair of.4-megahertz, 8-bit CPU however
maintain the pocket book laptop’s pretty keyboard and LCD display. That article was nearly fully about determining the right way to drive its squirrely Eighties-era LCD display. I left the remainder, as they are saying, as an train for the reader. In spite of everything, sending a stream of knowledge from a brand new CPU to the Arduino Mega controlling the display can be a trivial train, proper?

Hahahaha.

No, people, no it was not.
IEEESpectrum’s Palms On articles present essentially linear variations of how tasks come collectively. It may give the impression we’re terribly intelligent, which has about the identical relationship to actuality as an influencer’s curated social-media feed. So once in a while I prefer to current a story steeped in failure, simply as a reminder that that is what engineering’s like typically.


To ship display information to the Mega, I had a selection between a number of strategies which are supported by CircuitPython’s
show driver libraries. I wished to make use of a CircuitPython-powered microcontroller because the Mannequin 100’s new mind as a result of there’s a variety of current software program I may port over. Specifically, CircuitPython’s show libraries would drastically simplify creating graphics and textual content and would robotically replace the show. My selections had been between a parallel interface and two serial interfaces: SPI and I2C.

The parallel interface would require
at the very least 12 wires. SPI was higher, being a four-wire interface. However I2C was better of all, requiring solely two wires! Moreover, there are many breakout boards that assist I2C, together with storage and sensors of every type. One I2C bus can, in concept, assist over 100 I2C peripherals. I2C is way slower than SPI, however the Mannequin 100’s delightfully chunky 240-by-64-pixel show is slower nonetheless. And I’d used I2C-based peripherals many instances earlier than in earlier tasks. I2C was the plain selection. However there’s an enormous distinction between utilizing a peripheral created by a vendor and constructing one your self.

An illustration of the chips.  The Grand Central controller [bottom] offers the brand new brains of the Tandy. Though the controller has the identical kind issue because the Arduino Mega, it has vastly extra compute energy.. A custom-built defend holds a supporting voltage-level shifter [top left] that converts the three.3- and 5-volt logic ranges utilized by the controllers appropriately.James Provost

On the circuit stage, I
2C is constructed round an “open drain” precept. When the bus is idle, or when a
1 is being transmitted, pull-up resistors maintain the strains on the voltage stage indicating a logical excessive. Connecting a line to floor pulls it low. One line transmits pulses from the central controller as a clock sign. The opposite line handles information, with one bit transmitted per clock cycle. Gadgets acknowledge when visitors on the bus is meant for them as a result of every has a novel 7-bit deal with. This deal with is prepended to any block of knowledge bytes being despatched. In concept, any clock velocity and or logic stage voltage might be used, so long as each the controller and peripheral settle for them.

And there was my first and, I believed, solely downside: The microcontrollers that ran CircuitPython and had been computationally hefty sufficient for my wants ran on 3.3 volts, whereas the Arduino Mega makes use of the 5 V required to drive the LCD. A straightforward clear up although—I’d simply use a US $4 off-the-shelf logical stage shifter, albeit
a particular kind that’s appropriate with I2C’s open-drain setup.

Utilizing a $40
Adafruit Grand Central board as my central controller, I related it to the Mega through the extent shifter, and put some take a look at code on each microcontrollers. Essentially the most fundamental I2C transaction potential is for the controller to ship a peripheral’s deal with over the bus and get an acknowledgement again.

No response. After checking my code and wiring, I connected a logic analyzer to the bus. Out popped a beautiful pulse practice, which the analyzer software program decoded as a stream of accurately shaped addresses being despatched out by the Grand Central controller because it scanned for peripherals, however with no acknowledgement from the Mega.

A diagram showing the arrangement of the I2C bus and how logic levels are altered between high and low when the clock signal is high to transmit 1 and 0s.An I2C is a comparatively low-speed bus that gives bidirectional communications between a controller and (in concept) over 100 peripherals. An information and clock line are saved at a excessive voltage by pullup resistors The frequency of a clock line is managed by the controller, whereas each the management and peripheral units can have an effect on the info line by connecting it to floor. A peripheral will take management of the info line solely after it has been commanded to take action by the controller to keep away from communication collisions. James Provost

I’ll skip over the following few hours of diagnostic failure, involving a lot gnashing of tooth and a useless finish involving a quirk in how the SAMD chip on the coronary heart of the Grand Central controller (and lots of others) has a hardware-accelerated I
2C interface that reportedly can’t go
slower than a clock velocity of 100 kilohertz. Ultimately I connected the logic analyzer once more, and scrolling up and down by means of the decoded pulses I lastly seen that the bus scan began not at deal with 0 or 1, however at 16. Now, once I’d picked an deal with for the Mega in my take a look at code, I’d seen many descriptions of I2C in tutorials that mentioned the potential vary of addresses ran from 0 to 127. Once I’d checked out what appeared like a fairly complete description by Texas Devices of how the I2C bus labored right down to {the electrical} stage, addresses had been merely described as being 7-bit—that’s, 0 to 127. So I’d picked 4, kind of at random.

However with the outcomes of my logic scan in hand, I found that,
oh, by the way in which, addresses 0 to 7 are literally unusable as a result of they’re reserved for numerous bus-management capabilities. So I went again to my unique {hardware} setup, plugged in a pleasant two-digit deal with, and bingo! All the things labored simply positive.

True, this headache was attributable to my very own lack of expertise of how I
2C works. The caveat that reserved addresses exist
can be present in some tutorials, in addition to extra detailed documentation from people like Texas Devices. However in my protection, even in the perfect tutorials it’s normally fairly buried and straightforward to overlook. (The overwhelming majority of I2C instruction issues the vastly extra widespread state of affairs the place a grown-up has constructed the peripheral and hardwired it with a wise deal with.) And even then, nothing would have instructed me that CircuitPython’s heartbeat scan would begin at 16.

Oh nicely, time to press on with the improve. The remaining must be fairly straightforward, although!

From Your Website Articles

Associated Articles Across the Internet

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments