# Slot car computer control with a TI 99/4A computer

Posted by Vorticon, 14 October 2016 · 1,379 views

TI 99/4A Slot car computer control

Slot car racing sets have always fascinated me, and I have owned a few over the years. Unfortunately, it was always difficult to find opponents to race against beyond just a few runs. I have dabbled many times with the idea of a computer controlled opponent over the years, and finally decided to tackle it as a demo project for the 2016 Chicago International TI Faire in October 2016.

I have a lot of experience under my belt interfacing the TI computer to the real world, using the PIO, joystick and cassette port as interfaces, and therefore it was only natural for me to attempt doing this using my good old TI 99/4A computer.

The first idea I came up with was outfitting one of the slot cars with a centrifugal force sensor that could send a wireless signal to the TI equipped with a compatible wireless receiver, and thus allow the computer to adjust the speed of the car in order to keep the centrifugal force under a certain limit that would keep the car on the track. The obvious advantage here is that this would be track independent regardless of how tough and twisted the track was. I may still do that at some point, but it required a fairly large scale car and track in order to be able to accommodate the needed electronics and power supply, and I did not want to invest in a large slot car race track at this time.

The alternative idea required a different approach, with 2 problems to solve:

• How to sense the location of the car on the track
• How to control the speed of the car
The sensing part was solved by strategically positioning photoresistors on the track which will sense when the car is over them and thus report back a location to the computer. One only needs to know where a particular type of track starts, whether a curve or a straight, and adjust the speed of the car accordingly. These track sections will be labeled as sectors with a fixed car speed for each optimized by trial and error.

Here's the basic circuit diagram:

When the photoresistor is fully lit, i.e. there is no overlying car, then its resistance is very low and the PIO line is connected to the positive pole of the battery, and so is in a high state or 1. When the car is on top of the photoresistor, then the latter's resistance becomes very high, therefore the PIO line goes to ground or 0. From there, it's just a matter of masking in software the appropriate bit in the PIO data lines (there are 8 of them) to find out whether it is high or low and thus figure out which photoresistor got triggered. Since there are 8 available PIO lines, it's possible to detect up to 8 sectors on the track.

As for speed control, I decided to use the cassette port motor control plug for the purpose. Earlier on, I had experimented with that method to ignite a rocket motor igniter at the request of a fellow TIer (Omega) as seen in the video below:

Here, I replace the igniter with the connection to the track hand controller which is nothing but a variable resistor. The problem here is that when the relay is activated, then the slot car will get full power and will very likely fly off the track in an instant. One way I came up with to mitigate that problem was to use what I call Pulse Frequency Modulation, where full power is applied for a very brief amount of time, but then repeated frequently. The frequency of the on/off cycles will then determine the speed of the car. The frequency can be easily controlled in software and again I relied on a previous project where I control a robotic arm with the TI as detailed below (skip to 14:11 for the relevant part):

And here's the basic control circuit. I will be using a solid state relay instead of a mechanical one for durability, speed of actuation and lack of bounce.

So now we have solved both problems, and it's just a matter of experimentation and putting it all together. I created a small PCB which incorporates both the sensing and motor components as discussed above. The slot car racing set I'm using is a cheap small one which only requires 5 photoresistors. The PCB layout was designed using Circuit Wizard and the PCB was produced using a homebrew process.

And the finished product. It won't win any design awards, but hey it's functional

Here's the source code for the control program:

Spoiler

Below is the video of the experimentation and the completed project:

That was a fun one

Freaking Awesome!
• Report

Oh yes, I totally enjoyed your video and blog entry.  In  fact I never remember enjoying one more than this.

I hope you take another video at the Chicago get-together of this in head to head matches with other TI'ers.  I'm betting the TI will win most matches.  Sorry guys.

Pulse modulation, was an elegant solution to the problem.  I bet some model railroaders will be looking into this with keen interest as well.

So far, how many digital inputs is the TI capable of tracking in total?  Could the software be modified (at a future point) to accept strength values (high / low) to double the amount of input capability?

Great job Walid!

• Report

Oh yes, I totally enjoyed your video and blog entry.  In  fact I never remember enjoying one more than this.

I hope you take another video at the Chicago get-together of this in head to head matches with other TI'ers.  I'm betting the TI will win most matches.  Sorry guys.

Pulse modulation, was an elegant solution to the problem.  I bet some model railroaders will be looking into this with keen interest as well.

So far, how many digital inputs is the TI capable of tracking in total?  Could the software be modified (at a future point) to accept strength values (high / low) to double the amount of input capability?

Great job Walid!

Thanks  It was really fun to develop, but I have to say that the project would not have come to fruition were it not for your initial suggestion to use the cassette motor port to power a relay for the rocket engine igniter test. I had never thought of that previously!

There are only 8 inputs on the PIO port, although we could add a couple more if we use the handshake in and the spare in lines as well. So 10 total. That said however, if you wire external inputs to trigger more than one pin on the PIO port, you could differentiate these kinds of input discreetly through masking in software, so theoretically several 2^8 inputs could be accommodated...

• Report
Nicely done. I got to try making my own PCBs.
• Report

Nicely done. I got to try making my own PCBs.

Here's where I learned how to do it. I think making one's own PCB really makes a project truly homebrew  Back in the early 90's, I used an etching pen and hand drawn circuits, which worked but only for the crudest of circuits!

http://quinndunki.co...ndihacks/?p=351

• Report

When I did my slot car racing controller some years ago, I had a speed control consisting of a few outputs, driving relays which bridged a resistor each in a resistor ladder. This kind of gave me a functionality corresponding to different gears in a car.

I also had a photo cell at the start of each track segment, after which I first ran one "gear" for a certain time, then another "gear" forever. The last gear was slow enough to allow the car to run around the track without de-railing. This allowed putting the car back on track anywhere. It would just run at medium speed until it was picked up by some photo cell, then continued at optimized speed from there.

• Report

S M T W T F S
123
45678910
11121314151617
1819 20 21222324
25262728293031