Sunday, 25 March 2018

Building a awesome VIC20 controlled tank

Updated 05/04/18

I have recently been thinking about building a Commodore VIC20 controlled robot.  Some inspiration came from the classic 1980s Usborne How to Make Computer-Controlled Robots book [3] and the BBC Buggy[4].   





















You will need:


How to build:

First I needed to laser cut the tank chassis.  I downloaded the DXF file and opened it in
Techsoft 2D Design (This is the CAD software we use with our laser cutter).  

















Cutting out the parts from an 5mm perspex sheet on the laser cutter

















Once the parts were cut out, I set about building the tank using the tank building resource instructions.  


Electronics:

Next I built the motor controller board using the supplied instructions.  The board was originally designed to use with a 18 pin PIC microcontroller, I used a programmed PICAXE 18M2 chip[1] to test that the inputs and outputs worked correctly. The board was functioning correctly so I set about building a suitable interface circuit.

I built a prototype circuit on a breadboard to test that I could interface the VIC 20 user port with the FAN8100N motor driver IC on the motor control board. I used a 74HCT244[2]. User port I/O numbers 0 to 3 are connected via the 74HCT244 to the forward and reverse inputs on the FAN8100N motor driver IC.

These tests worked so I went on to add a simple LED display to monitor the status of the user port and added some circuitry to interface the inputs from the existing motor controller board with the VIC 20 user port.  I then verified that the inputs worked correctly.  Now that the circuitry was working correctly I transferred the breadboard layout onto stripboard to make things more permanent.

I removed the existing PIC socket and soldered some Molex headers in place so I could connect the robot to my VIC20 via a 5 meter length of ribbon cable.  


I added some micro switches to the front of the tank and a line following board to the chassis.




























Completed stripboard layout













Schematic






















1 Input circuitry

Input signals from the motor controller PCB (at TTL logic 0 and 1) are applied to the inputs of the 74LS14 Schmitt trigger IC. This is an inverting Schmitt trigger, so that a logic 1 input will cause the associated output to go to logic 0.  The 1KΩ resistors pull the input down to 0V (logic 0) in the absence of input signals.   

A logic 0 out at the Schmitt trigger will cause the cathode of the appropriate LED in the quad opto-isolator IC to go low, so turning the LED on.  This turns on the associated photo-transistor in the opto-isolator and its emitter goes high (due to the p.d across the 1.2kΩ resistors). The logic levels at these emitters are connected directly to the user port PB4-7, which are configured as inputs.   The Schmitt input circuitry ensures precise triggering, whilst the use of opto-isolation obviates the possibility of damage to the microcomputer.

2 User port status LED 

User port signals PB0 -7 are feed through a 74LS540 Octal buffer and line driver IC.  The outputs of this IC are inverted so an logic 1 will turn the LED on in the 10 way light bar LED display.

3 Motor driver

User port signals PB0-3 are feed through a 74LS244 Octal buffers and line driver IC. The outputs of this IC are connected to the FAN8100N Motor driver IC on the existing motor controller PCB.




Mechanical assembly:


I started to assemble the chassis, once this was done I assembled the tracks.












Wiring:

Now the mechanical assembly is complete, I could start wiring things up.  Each motor has a + marking on it, so I made sure the red coloured wire was soldered to that terminal.


























Coding:


With all the wiring in place, I tested motors to make sure they worked correctly.  I need to write some BASIC code to make the tank do something, I'll get onto that later.


Testing the sensors




















This simple program makes the robot move forward until it hits something, then reverse and swivel right or left before setting off again.  I found this in the Usborne Practical Things To Do with a Microcomputer book.

10 POKE 37138,15
20 LET Y=37136
30 POKE Y,5
40 LET Z=PEEK(Y)AND16
50 IF Z<>0 THEN GOTO 70
60 GOTO 40
70 POKE Y,10
80 FOR I=1 TO 10
90 GOSUB 190
100 NEXT I
110 POKE Y,0
120 LET P=6
130 IF RND(1)>0.5 THEN LET P=9
140 POKE Y,P
150 FOR I=1 TO INT (RND(1)*20+10)
160 GOSUB 190
170 NEXT I
180 GOTO 30
190 FOR T=1 TO 100
200 NEXT T
210 RETURN

References


  1.  A PICAXE chip is a standard Microchip PIC microcontroller that has been pre-programmed with the PICAXE bootstrap firmware code. The bootstrap code enables the PICAXE microcontroller to be re-programmed 'in position' directly from a PC.
  2. This is an 8-bit buffer/line driver with 3-state output. The device can be used as two 4-bit buffers or one 8-bit buffer.
  3. These books are now freely available as PDFs from here.
  4. The BBC Buggy is an small robot designed to work with the BBC Microcomputer.

Saturday, 10 March 2018

Deltronics CONTROL IT buffer box


I recently purchased a Deltronics CONTROL IT buffer box from the online tat bazaar eBay, with a view to connecting it to my Commodore VIC 20.  The Control IT buffer box is a general purpose interface that gives you easy and protected access to the computer’s user port.  It was designed to connect to the BBC Micro or other suitable computer.

































The box has a 25 way D-type socket on the back and the connecting cable is terminated with a 25way D-type plug.  I had to make up a lead as the box wasn’t provided with one, luckily I managed to find a pinout for the 25way D-type socket on this website.




















The buffer box contains its own mains power supply which is stabilised and protected internally against overloads and short circuits and the key switch on the front selects either 12 V or 6 V but I don’t have the key.  The full supply voltage of 6 V or 12 V is available between the red and black sockets at all times.  Because of the voltage drop across the buffer box internal circuitry the voltages available at the blue and grey sockets will be less than the supply voltages.  The voltages are blue to black 5.25 V(6 V range) 11.25 V(12V range) and grey to grey 4.5 V (6 V range) 10.5 V (12 V range).

The Control IT buffer box can be used with the following BBC Model B, BBC Plus, BBC Master 128, BBC Master Compact, RML 380Z, RML480Z, RML Nimbus and Sinclair Spectrum although it can be used with any computer that provides access to eight input and eight output lines at TTL levels.

I connected the output lines to the user port on my  VIC 20 and wrote a quick bit of BASIC software to turn the outputs on in sequence.