Figure 2.
Data1. To recapitulate, then, Data0 always transmits a
zero while Data1 always transmits a one, with the
alternate port line covering the hardware handshaking.
Yes, it seems a trifle convoluted at first but the
choreography is actually fairly straightforward and reliable.
To receive a zero from the calculator, just follow these
next steps. As usual, Data0 and Data1 are idling as inputs
and in a high state. When the TI- 83 Plus is ready to send a
zero, it will bring Data0 low. This alerts the PIC to make
Data1 an output which it sets low as an acknowledgment.
The calculator responds by making Data0 high again.
Finally, when the PIC is content with how things have
gone, it sets Data1 as an input. Once more, both port
lines are idling in a high input condition. Receiving a one
is very similar, with the roles of Data0 and Data1 reversed.
So, we know how to transmit and receive a single bit
between the PIC16F88 and the TI- 83 Plus calculator. All
that’s required now is a pair of software routines to bag
up everything and allow entire eight-bit bytes to be
communicated. To save you the travail involved in that
task, I’ve written a collection of library routines which
takes care of all of the messiness for you. You can get it
(called TI-LIBRARY.GCB) in the download files for this
article.
For now, take a moment to spy the two low level
routines of interest: GETBYTE and SENDBYTE. These
46 August 2013
superintend the details for you. Just pass in or receive byte
parameters and away you go. The source code (written for
the free Great Cow Basic compiler) has been heavily
commented, so understanding how it all works is
straightforward. Remember, the syntax of Great Cow Basic
is very similar to commercial compilers or, for that matter,
the interpreted Basic of the PICAXE line of
microcontrollers. Porting it to some other chip shouldn’t
be much of a botheration at all.
Time For A Test
We really should pause to test the essential send and
receive functions before moving on to the more
complicated business of transmitting entire commands. So,
compile and burn the demonstration program
DEMO1.GCB into a PIC16F88. You’ll note that this
program leans upon the library routines just mentioned.
Then, wire up the circuit shown in Figure 1 and plug it
into the TI- 83 Plus calculator. For this simple test, we don’t
really need the LCD, so you can leave that portion off if
desired.
Here’s the plan. The calculator will be running
terminal software. When you press a key on it — say the
letter A — that will be transmitted to the PIC, which then
turns right around and sends it back to the TI- 83 Plus.