Thursday, June 22, 2017

Using SD Cards with the TRS-80 Model 100

Most retro-computers have some form of SD or Compact Flash storage options available these days. The TRS-80 Model 100, Tandy 102 and Tandy 200 were no exception, and these micros had such a device not so long ago, the NADSBox. Most unfortunately it appears the NADSBox can no longer be sourced. So what to do now? Well build my own, very cut-down version I suppose is the obvious answer.


Loading files into the Model 100


As an 80's portable computer with limited native storage, the Model 100 came with some nice features for file transfers built right into the standard ROM and hardware. These features allowed for connecting tape drives, a modem, or better for modern needs, a serial RS232 port for computer to computer transfers. The built in TELCOM package allows for some easy ways to transfers files, and nicer still, the built in BASIC also makes it quite easy to load programs directly from the serial port. So all that needs to be done (of course it'll all get much harder later) is to tap into the 100s native abilities and throw some files back and forth over the serial lines.

To start some hardware is needed for some initial testing, I used a Arduino UNO, an SD Card Shield and a MAX232 IC. The MAX232 is required to convert RS232 level signals to TTL serial suitable for interfacing with the Arduino board. There is not much to it, all that needs to be done is to connect the Arduinos TTL lines to the serial port on the Model 100 via the MAX232. There are a load of examples for wiring up the MAX232, this guide at StackExchange is the one I quickly referred to.

On the software side I wrote up a quick program for the Arduino to send some files from an SD card to the Model 100 (Note the SD and SP Atduino libraries are required). The Ardunio waits for the Model 100 to request a transfer and will then upload a file. On the Model 100 side of things a couple of lines of BASIC is need to first OPEN the COM port, send a request, then download / run the files sent by the Arduino.


In the tests I found a baud rate of 1200 is about the best that can be expected when loading BASIC files via the serial connection. The Model 100 tokenises the text being loaded directly into BASIC, and faster baud rates give errors during this process, I guess there is only so much a 2.4 MHz 80C85 CPU can handle.

Content that the serial SD card loading was quite successful, I'll move along with this project further and see how far I can get with it.

Saturday, June 10, 2017

USB Mouse For The ZX81 And ZXpand (Part 2)

It's been a while since the first part of this article, some exciting developments happened to the ZXpand in between and I wanted to test the interfaces functionality out on the brand new ZXpand+ hardware before posting. I've also given the interface a little moniker, "ZeaMouse". Anyway, enough fluffing around, down to the specifics.

As previously mentioned (in Part 1: USB Mouse For The ZX81 And ZXpand), the USB mouse interface relies on normal Atari digital joystick inputs as found on the ZXpand. Since that time, Charlie Robson unleashed the new ZXpand+ into the ZX81 world. With this comes some potential options, in particular a TTL serial port has been included on the ZXpand+ IDC header, this may be of use for sending proportional mouse data, promising true mouse functionality.

For now though, the Mouse interface maintains full compatibility with the original ZXpand while also making allowances for serial connection to the ZXpand+, connections  that will be used at a later date. Of note for those intending to use the interface on other Micro computers, the serial tracks on the ZeaMouse interfaces IDC header may need to be cut (or removed) in order to avoid potential damage to that Micro or the Interface itself.

ZeaMouse Firmware


Some things end up being a lot less complicated than you'd imagined they would be. The coding behind reading the mouse and passing directions to the ZXpands digital joystick port was one of those things. That's definitely a credit to those behind the USB host shield.

There is nothing overly complex in the code. Mouse movement tracked by time, if XY mouse movement is detected the appropriate joystick pin is set to OUTPUT, a debounce timeout then set to 15, milliseconds providing enough time for a 'button press' to be registered by the ZXpand. While mouse movement continues in the same direction the debounce timings are updated. Mouse button 1 and 2 are both setup to work as a standard joystick button press.

A regular Atari Joystick can be attached to the semi-pass-though port. Joystick movement is given priority and should override incidental mouse movements while using a joystick. The exception to this is where a mouse button is pressed as tracking mouse presses relies on the button being released again to clear the OUTPUT.

A large scope exists for future additions to the code. Provisions for USB joysticks and keyboards (with limited functionality) could also be added with some extra effort. As it is possible to attach the USB shield to a USB hub, allowances for multiple devices to be connected at the same time could also be made. Depending on updates to the ZXpand+ itself, and how the TTL serial lines are read, all manner of interfacing options could become available.

The Arduino Code Files can be found here: ZeaMouse_Arduino.tar.gz

ZeaMouse plugged into the ZXpand+ using a (delightful rainbow (thanks Charlie)) IDC cable, with USB mouse and Digital Joystick connected.


Programing the ATmega328P  / Arduino


Ideally it's easiest to purchase an ATmega328P IC with the Arduino boot loader pre-installed, these can be sourced quite easily. I recommend purchasing a kit that comes with the required crystal, such as this kit from Jaycar: ATMEGA328P MCU IC with Arduino UNO Bootloader and 16MHz Crystal (or a cheaper version from your favourite Chinese supplier).

The ATmega328P chip (with boot loader) will require sketch / code / firmware, this must be programmed outside of the USB joystick interface. To do this an Arduino UNO can be used, simply swap out the existing IC in the UNO, insert and program the new one, then transferring that to the interface.

Required Components


All components should be easily obtainable, there is nothing remotely exotic required to build the ZeaMouse. In addition to the construction components listed in the Main Contruction Shopping List, you will also need a USB host Shield.  Along with a 10 pin IDC cable (which may be split from a larger cable), cut to the length you require, proably not shorter that 10cm. 1 or 2 10 pin IDC sockets and or a 9 Pin D-SUB DB9 Female IDC Connector. The configuration of these cables is dependent on variant of ZXpand being used.
IDC Cables: Top Cable for ZXpand+, Bottom Cable for ZXpand.

You may be able to purchase IDC cables pre-made, however if manufacturing at home there is a nice video on how to make IDC (ribbon) cables over on YouTube thanks to The University of Manchester. The main thing to remember when building a cable is that pin 1 on 1 socket should always go to pin 1 on socket 2.

All parts required to build the actual ZeaMouse interface are listed in the table below.

Main Contruction Shopping List (Excluding the PCB & USB Shield)

Amount Part Type Properties
2 Capacitor variant pth2; package cap-pth-small2
1 Ceramic Capacitor package 200 mil [THT, multilayer]; capacitance 100nF; voltage 6.3V
1 Capacitor Polarized variant pth2; package cpol-radial-10uf-25v
1 Capacitor Polarized variant pth1; package cpol-radial-100uf-25v
5 Diode variant pth; package diode-1n4001
1 MICROCONTROLLER variant kit; package dil28-3-simon-kit; chip atmega8
1 AVR ISP 6 Pin variant pth; package 2x3; pins 6
1 10 Pin IDC Header variant variant 2; row double; package THT; pins 10; form ♂ (shrouded male); pin spacing 0.1in (2.54mm); hole size 1.0mm,0.508mm
1 Ardunio_Power_Header_8_Pins variant variant 3; row single; package THT; pins 8; form ♀ (female); pin spacing 0.1in (2.54mm); hole size 1.0mm,0.508mm
1 Ardunio_Analog_Header_6_Pins variant variant 4; row single; package THT; pins 6; form ♀ (female); pin spacing 0.1in (2.54mm); hole size 1.0mm,0.508mm
1 Ardunio_Digital_Header_10_Pins variant variant 5; row single; package THT; pins 10; form ♀ (female); pin spacing 0.1in (2.54mm); hole size 1.0mm,0.508mm
1 Ardunio_Digital_Header_8_Pins variant variant 6; row single; package THT; pins 8; form ♀ (female); pin spacing 0.1in (2.54mm); hole size 1.0mm,0.508mm
1Bucket DB9 Solder Bucket DB9
1 Red (633nm) LED package 3 mm [THT]; color Red (633nm); leg yes
1 10kΩ Resistor package THT; tolerance ±5%; bands 4; pin spacing 400 mil; resistance 10kΩ
1 220Ω Resistor package THT; tolerance ±5%; bands 4; pin spacing 400 mil; resistance 220Ω
1 Voltage Regulator - 3.3V package TO220 [THT]; voltage 3.3V; part # LM2936
1 Crystal package THT; frequency 16 Mhz; pin spacing 5.08mm; type crystal
1 Crystal package THT; frequency 16 Mhz; pin spacing 5.08mm; type crystal


ZeaMouse Board Assembly


ZeaMouse PCB Layout
All the files required files for ordering a PCB from a fabrication house, or for rolling your own board are contained in the ZeaMouse_Fritzing.tar.gz file. 

As mentioned in Part 1 of the USB Mouse For The ZX81 And ZXpand blog post, the mouse interface PCB is designed to allow easy one sided home fabrication, as well as double sided construction for the more adventurous, or ordering from fabrication houses.

The underside of the PCB is all that needs to be printed, with the top side consisting of only straight tracks and vias that can be linked with copper wire if you choose the one sided method. Linking wires are highlighted in red on the PCB layout figure / image.

All components are of the through hole variety for easy assembly, and there are not a great many of them. The only really tricky part in the whole process is attaching the solder bucket DB9 joystick socket. I used this particular part to save space and keep the interface an acceptable size. In attaching the DB9 connector to the PCB, I first soldered pin cutoffs from the long Ardunio Headers to the solder pads / buckets of the DB9, then inserted the pins through the PCB for soldering to the board. You could also use Generic male header pins in a similar fashion.

Assembly List

Label Part Type Properties
C1 Capacitor variant pth2; package cap-pth-small2
C2 Capacitor variant pth2; package cap-pth-small2
C3 Ceramic Capacitor package 200 mil [THT, multilayer]; capacitance 100nF; voltage 6.3V
C4 Capacitor Polarized variant pth2; package cpol-radial-10uf-25v
C5 Capacitor Polarized variant pth1; package cpol-radial-100uf-25v
D1 Diode variant pth; package diode-1n4001
D2 Diode variant pth; package diode-1n4001
D3 Diode variant pth; package diode-1n4001
D4 Diode variant pth; package diode-1n4001
D5 Diode variant pth; package diode-1n4001
IC1 MICROCONTROLLER variant kit; package dil28-3-simon-kit; chip atmega8
J1 AVR ISP 6 Pin variant pth; package 2x3; pins 6
J2 Atari Joystick IDC variant variant 2; row double; package THT; pins 10; form ♂ (shrouded male); pin spacing 0.1in (2.54mm); hole size 1.0mm,0.508mm
J3 Ardunio_Power_Header_8_Pins variant variant 3; row single; package THT; pins 8; form ♀ (female); pin spacing 0.1in (2.54mm); hole size 1.0mm,0.508mm
J5 Ardunio_Analog_Header_6_Pins variant variant 4; row single; package THT; pins 6; form ♀ (female); pin spacing 0.1in (2.54mm); hole size 1.0mm,0.508mm
J6 Ardunio_Digital_Header_10_Pins variant variant 5; row single; package THT; pins 10; form ♀ (female); pin spacing 0.1in (2.54mm); hole size 1.0mm,0.508mm
J7 Ardunio_Digital_Header_8_Pins variant variant 6; row single; package THT; pins 8; form ♀ (female); pin spacing 0.1in (2.54mm); hole size 1.0mm,0.508mm
J8 Generic male header - 5 pins Solder Bucket DB9, top row: See article for attachment guide
J9 Generic male header - 4 pins Solder Bucket DB9, bottom row: See article for attachment guide
LED1 Red (633nm) LED package 3 mm [THT]; color Red (633nm); leg yes
R1 10kΩ Resistor package THT; tolerance ±5%; bands 4; pin spacing 400 mil; resistance 10kΩ
R2 220Ω Resistor package THT; tolerance ±5%; bands 4; pin spacing 400 mil; resistance 220Ω
U1 Voltage Regulator - 3.3V package TO220 [THT]; voltage 3.3V; part # LM2936
XTAL1 Crystal package THT; frequency 16 Mhz; pin spacing 5.08mm; type crystal


Go Forth and Build


That's it for the moment, so go forth and build the ZeaMouse. I'll be updating and adding features to the firmware over the coming months, and hopefully some specifically ZXpand+ only enhancements that take advantage of the new hardware, so come back every now and again to check for that. As always feedback and suggestions are more than welcomed.

Friday, June 09, 2017

Think Different, the TRS-80 Model 100

And now for something completely different, the first articles (along side the usual stuff) based around the portable computing powers of the TRS-80 Model 100. Yes I'm jumping to the right for a look into something not Sinclair related, though not I think not without some correlation. On first glance there is not a lot to connect the cheep yet stylish Sinclair home micros to what could best be described as an 'American Design' (baring that internals are all Japanese) beige business mans machine.

TRS-80 Model 100 With the Full Kit.

Yet, initial target audience aside, the Model 100 seems to be something outside the a strict business box, it feels more like a portable home computer, with its Micosoft Basic interpreter and built in rudimentary applications. This is not a computer designed to run CPM and Visicalc, not straight from the factory at least, this is a computer that if one ignores initial hefty sales price tag, would have appealed to any home enthusiast of the period. One just has to glance at the included manuals to see that, in particular the Technical Reference Manual.

Yes the Technical Reference Manual, a 127 page thesis on the entire design and construction of the Model-100, this is an 80's hardware hackers dream. The guide presents the full schematics, lists every single part used in construction (with catalogue numbers) and even goes right down to LCD screen design.

The hardware itself is by no means shabby, the Model 100 packs in a modem, full serial and parallel ports, a very clear LCD display and a fantastic full sized mechanical ALPS keyboard. All these features of course contributed to the high price point of the little portable back in 1983. Equally, these features make the model 100 a very interesting and usable(?) machine today. The Model 100 is the perfect kind of micro for some modern experimentation.

All good stuff, however I need to get down to some quickly required (non business) business.


A little Leaking Battery Work Required


I picked a Model 100 very recently, one in excellent condition, this machine seemed well loved (and used) by its former single owner, and included where all the original manuals and documentation. What it did need was a good clean and a new internal battery. Yes is the old leaky soldered-in NiCd battery curse of old computers. 

The Model 100 uses a NiCd battery to keep 32K of static RAM juiced up when the computer is powered down. The battery is rather important as the static RAM is the internal storage medium, there are no flash drives in thid machine. While the battery was still holding charge, it had began it's decay, and had started leaking ever so slightly. Time for a replacement.

Leaking NiCd Battery


A little googling revealed an interesting replacement idea for the battery, suggesting the use of a super-capacitor. This seemed like a perfectly reasonable proposition, and so I took the advice and installed and 1 Frand super-capacitor. If doing this mod yourself, As noted in the original source, insure the 1 Frand super-capacitor used is rated 5 VDC or better.

1 Frand Super-Capacitor Battery Replacement

The replacement procedure it simple, remove the old NiCd battery, solder some wires to the circuit board and attach the capacitor. With Super-capacitors, polarity matters, so be careful to attach the negative anode to the negative wire / solder pad and positive anode to the positive pad. I bent the pins of the capacitor over horizontally before attaching wires, and hot glued (generously) the capacitor to the circuit board to keep it secure.

After putting the case back together I left the capacitor to change for a while, tested that if all external power was removed that yes the 32K static RAM would stay active. No more leaking battery and no more memory worries.

Now it's time to see what else we can do with this beast.