Assine Faça Login

:: IN24horas - Itamaraju Notícias ::
18 August de 2025
Technology

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

Redação
24 de março de 2023

[ad_1]

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

Hahahaha.

No, of us, no it was not.
IEEESpectrum’s Arms On articles present essentially linear variations of how tasks come collectively. It can provide the impression we’re terribly intelligent, which has about the identical relationship to actuality as an influencer’s curated social-media feed. So now and again I wish to current a story steeped in failure, simply as a reminder that that is what engineering’s like generally.


To ship display information to the Mega, I had a alternative between a number of strategies which can be supported by CircuitPython’s
show driver libraries. I needed to make use of a CircuitPython-powered microcontroller because the Mannequin 100’s new mind as a result of there’s lots of present software program I may port over. Particularly, CircuitPython’s show libraries would vastly simplify creating graphics and textual content and would robotically replace the show. My decisions had been between a parallel interface and two serial interfaces: SPI and I2C.

The parallel interface would require
not less than 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 help I2C, together with storage and sensors of all sorts. One I2C bus can, in principle, help over 100 I2C peripherals. I2C is far 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 occasions earlier than in earlier tasks. I2C was the apparent alternative. However there’s a giant distinction between utilizing a peripheral created by a vendor and constructing one your self.

An illustration of the chips.  The Grand Central controller [bottom] supplies the brand new brains of the Tandy. Though the controller has the identical type 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 traces 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. Units acknowledge when site visitors on the bus is meant for them as a result of every has a singular 7-bit handle. This handle is prepended to any block of information bytes being despatched. In principle, any clock velocity and or logic stage voltage may very well 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 remedy 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 by way of the extent shifter, and put some check code on each microcontrollers. Essentially the most fundamental I2C transaction potential is for the controller to ship a peripheral’s handle over the bus and get an acknowledgement again.

No response. After checking my code and wiring, I attached a logic analyzer to the bus. Out popped a beautiful pulse prepare, which the analyzer software program decoded as a stream of appropriately fashioned 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 principle) 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 subsequent few hours of diagnostic failure, involving a lot gnashing of enamel 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. Finally I attached the logic analyzer once more, and scrolling up and down via the decoded pulses I lastly seen that the bus scan began not at handle 0 or 1, however at 16. Now, once I’d picked an handle for the Mega in my check code, I’d seen many descriptions of I2C in tutorials that stated 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 handle, and bingo! Every little thing labored simply advantageous.

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

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

From Your Website Articles

Associated Articles Across the Net

[ad_2]

Share Article

Other Articles

Previous

Every part We Know So Far – Hollywood Life

Next

California may ban Pink Dye No. 3 and different components utilized in processed meals : NPR

Next
24 de março de 2023

California may ban Pink Dye No. 3 and different components utilized in processed meals : NPR

Previous
24 de março de 2023

Every part We Know So Far – Hollywood Life

No Comment! Be the first one.

Deixe um comentário Cancelar resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

All Right Reserved!