This gave me one good idea; What if i could drive the car automatically and fine tune its speed through each corner to win a race? Before and after each corner I would place sensors which would read and decode signal from each car passing.
First I was in the need for an API which would let me communicate with an Advanced Power Base(APB) (Scalextric C7042 APB) and to perform just three simple things - speed up/down and brake the car.
Project is broken into two different parts
- Get control over the car via the APB.
- Create a IR-controller which reads signals from the car decodes it and sends it to the Car-controller
Connection
A key part in this project is the cable which would go from the computer to the base. According to the APB-specifications i would need an RS485 converter of some sort. When i measured voltage between D+ and D- on the base I found that the voltage was around 5 volts, so i decided to try communicating via an Westermo MDW-45 RS232/RS485 converter without any luck. I opened the display which comes along with the APB to see if i could find any information regarding RS485-chips used and next to the PIC was a chip which was named 75176B.After a quick search I ended up with some information about its being a RS485 chip of some sort. Luckily FTDI chips support this and I were able to communicate with the APB using USB-RS485-WE-5000-BT.
Electrical schematics.
Note1: Pin5 on APB is 18VDC, which is the power supply for the display usually connected to AUX-port.
Note2: Be aware of the RJ11 connectors orientation, which is marked on the top by a "tap".
Advanced Power Base-controller
Liek mentioned above i only needed to send some packets to control the car speed, brakes and lane change, but ended up with something that could parse the OutPackets as well. This could be quite handy for future use regarding each cars start / finish time. The packets aren't handled directly but rather through the APB-controller.An APB-instance has several methods implemented such as enable car / track and drive each car ID individually. The APB instance is initialized with 6 Car-instances with ID from 1 to 6, and are available through an readable attribute called #cars.
Communication with the base is initiated with instance-method #start. This will create an communication thread which sends and receives packages until #stop is called. While communication is on-going Car-objects can directly be modified by users and is sent in the next communication cycle. As of writing this blog I set each cycle to be performed each 0,05 secs.
Basic example:
base = APB.new
base.start
base.enable_car(1)
base.disable_red_led
base.run_car(1, 40)
base_run_car(1,20)
Code is available at Github and further documentation is found there.
Next up would be the Sensor-controller which is addressed in part two of this post.
Resource
SNC Protocol SpecificationsScalextric Sport Digital Console
Scalextric Advanced 6-car Power Base (C7042)