SlotForum banner

Project to Build an Autonomous Slot Car Racing System

6.5K views 22 replies 13 participants last post by  Roguejackal  
#1 ·
Over the last 4+ years part time I have built a fully autonomous slot car racing system. The system is currently in a proof of concept phase with the ability to race up to 6 cars controlled by a PC.

The goal of this project was to build a slot car system whereby cars will race against themselves or against actual people, in a real world race mode. The Carrera Digital Slot Car was selected due to it being a digital slot car system and that significant research with respect to Carrera has been posted on the Web by other people.
This information as to how the Carrera Control Unit (CU) works, along with many electronic recommendations was instrumental in building this project. A big thank you to all of these people.

That being said, this was not an easy project to build as there were many factors that needed to be researched, investigated as to viability and the knowledge of understanding electronics (which I have very little) and multiple programming languages.

The system that is now running is a complete software / hardware solution that incorporates most aspects of real world car racing. It runs on a Windows PC (although the software can be made portable to other OSs) and encompasses a Race Control Module along with various electronics that can be used on any track design. In the 'not too distant future' I will post a You Tube video of the project along with an actual race.

The Race Control Module caters to various

⦁ Race Series
⦁ Race Teams
⦁ Race Cars
⦁ Race Drivers
⦁ Race Tracks
⦁ Race Calendars

Additionally, there are modules that cater to

⦁ Qualification Setup
⦁ Qualification Q1, Q2 and Q3
⦁ Race Setup
⦁ Race Tuning
⦁ Actual Race

Built in functions during an actual race cater to

⦁ Different types of tires
⦁ Tire wear
⦁ Fuel capacity / consumption
⦁ Pit Stops
⦁ Lane Changing
⦁ DRS zones
⦁ Sector timing / lap timing and fastest lap
⦁ Weather conditions
⦁ Dynamic real time car tuning

Electronics
========

The Carrera Digital Slot Car utilizes commands sent to / from the CU using various frequencies. Each controller / car combination utilizes a different frequency which we will use as the starting point of the project. The Carrera track already utilizes IR readers to determine such events as lane change, pit exit, start / finish, etc. Based on these known variables the project was built using this same concept. The electronic portion of this project was built around three phases each utilizing an inexpensive Arduino Nano microcontroller.

The first phase of the electronics was to build IR receivers (Traps) similar to those used by Carrera and place these in strategic locations on the track, in order to capture car information and timing information. This resulted to 2 separated pieces of electronics.

⦁ IR Reader
⦁ Trap Controller

Circuit component Passive circuit component Hardware programmer Electronic component Electrical wiring



The IR reader consists of a set of 2 IR Receivers (one per lane) connected to an electronic component that deciphers the car frequency, which is transmitted to a Trap Controller that sends this data to the PC via a built in RF transmitter. Each Trap Controller can manage up to 4 sets of IR Readers (a total of 8 IR Receivers). Any track design can utilize up to 60 sets of IR Readers, but most tracks only require between 8 and 12 sets.

The second phase of the electronics was to build a Track Decoder that can decipher all signals being sent on each track via the Carrera CU and send this data to the PC via a built in RF transmitter.

The third phase of the electronics was to build a Track Encoder that would receive data from the PC via RF signals and interface this data directly into the Carrera CU. This data takes the form of 2 sets of signals, one set containing timings, speed, lane change, etc and another set containing throttle, brake and fuel settings.

Computer Control Unit (CUU)
=====================


The most complex project phase was to develop the CCU. Since I have a strong understanding of Object Pascal using the Delphi development environment, I decided to take this programming approach. But I was also looking for an Open Source approach and found a solution in utilizing the Lazarus development environment.

The design of this suite of programs had to cover multiple diverse approaches.

Speed Layer

The logic had to be very fast due to timing of Carrera data commands being generated every 75 milli seconds. The only way to achieve this was to create a multi-thread environment and have a CPU that supported a min. of 8 cores.

Communication Layers

The logic had to cater to multiple levels of communication. These levels are as follows:

⦁ Receiving data from Trap Controllers
⦁ Receiving data from the Track Decoder
⦁ Sending data to the Carrera CU Controller
⦁ Internal communications between threads
⦁ Internal communications to the Windows display

Interactive Display

The logic had to display real time simulated vehicle data such as speed, revs, gears, brake wear, tire wear, etc and be able to receive input to make dynamic changes to these data elements.

Diverse Racing Environments

The logic had to be designed to cater to all avenues of real world auto racing from racing series, types of cars, race teams, race circuits and championship events.

Computer Control Race Sequence
========================


The CCU is designed for the user to follow the below sequence of actions.

  1. Setup Series, Teams, Cars and Drivers via their respective modules.
  2. Build required racing circuits using Autorennbahnplaner and import each into the CCU utilizing the Capture module.
  3. Setup Track information via the Tracks module.
  4. Assign IR Traps to the race track via the Controls module.
  5. Setup requirements for Qualifying and the Race utilizing the Qual Prep module.
  6. Perform up to 3 rounds of qualifications for each car, utilizing the Q1 / Q2 / Q3 module.
  7. Perform an analysis of the results of qualifying for each car utilizing the Analysis module.
  8. Perform manual ‘fine tuning’ of the analysis utilizing the Results module. This data is used to race the cars in the autonomous state.
  9. Setup the race utilizing the Race Prep module.
  10. Go racing utilizing the Race Day module.

Steps 1 through 4 above should only be required to be performed once for any overall Championship.

Computer Control Unit Overview
=======================


Below is a quick overview of the CCU. This is an initial design with additional functions being added as the system evolves. The development has been simplified and is not built around sophisticated ‘look and feel’ beautification. All of the below is in active working condition unless indicated by (Not yet implemented).

Master Menu

Rectangle Font Brand Circle Paper product



The main menu comprises of 4 major sections:

⦁ Team Setup
⦁ Track Setup
⦁ Qualifying
⦁ Race

Team Setup


Rectangle Font Brand Circle Paper product



The Team Setup menu comprises of 5 sections:

⦁ Series - Setup for the various Race Series that exist.
⦁ Teams - Setup for the various Teams that exist.
⦁ Cars - Setup for the various Cars that exist.
⦁ Drivers - Setup for the various Drivers
⦁ Championship - (Not yet implemented)

Product Rectangle Font Screenshot Parallel



Track Set Up

Rectangle Window Font Parallel Circle



The Track Setup comprises of 3 major sections:

⦁ Capture
⦁ Tracks
⦁ Controls

Capture

One of the best Carrera Track layout design software on the market is from Autorennbahnplaner. (...the ultimate Carrera track designer (autorennbahnplaner.de). I purchased this software in order to aid my CCU as I was not in the market to design my own track design software. This track design software is very good and allows you to design any practical layout you desire to build. For me it lacked a couple of features that I was specifically looking for to help integrate into my software, but I used simple work arounds that proved to be quite workable. (A nice piece of software.)

The 1st step is to build your track layout using Autorennbahnplaner. Once you have finalized this design, you need to indicate where the new IR Traps are to be placed on the circuit. Since Autorennbahnplaner does not have the ability to use User design elements, I used the ‘PowerFeedIn’ tool to represent these traps.
Once completed, the capture module is used to import the track as a JPG into the CCU system.

Tracks

The Tracks module is used to record all of the tracks that one wishes to build and use in a series of races.

Controls

Product Rectangle Font Parallel Screenshot



The Controls module is a complex program that reads the Autorennbahnplaner data file for the selected track and with additional input assigns appropriate data to each IR Trap on the track. This information is used for lane changing, pit stops, start / finish, timing information, etc. and is required to assist in the car automation process.

Qualifying

Rectangle Font Parallel Number Brand



Qual Prep

The Qual Prep module is used to setup the track for race qualification and race day and to assign cars to the race along with various settings that each car will use during the race. These settings have direct bearings on the speed and handling of each car and are used to setup the CU controller.

Q1 /Q2 /Q3

Each car that will race will be required manually to complete a number of laps to record controller (Speed) settings and Trap timings. The number of qualifying laps can be pre-determined for each car and each driver can use either lane and the lane changing facilities.

The data collected during Q1, Q2 and Q3 qualifications will be further analysed to create the actual data used during the race to drive the cars around the track. The fastest lap for each car will determine the grid position for that car.

Analysis

This module will take the fastest time between each set of IR Traps for each car and use this for Race Day automation setup. This data displays appropriate timing and speed data that one can modify later either before the actual race or dynamically during the race to achieve better lap results.

Results

This module will display the best timings between each trap for each car over the Q1, Q2 and Q3 qualifications. These timings will normally be better than the quickest qualifying lap as it takes the best results from each trap pair rather than a full lap. This data is then used in the actual race to achieve the best results.

Rectangle Font Parallel Technology Facade



Race

Rectangle Font Parallel Number Circle



Race Prep

This module is used to set up the parameters for the actual race. It takes into consideration data for both the track and cars. Track actions include Championship year, weather, distance, no of laps or race time duration and DRS availability. Car actions include throttle, brakes, fuel, and DRS availability. Tire management is built into the actual Race Day module below. Each of these parameters have a dynamic bearing on the cars actual actions during the race.

Race Day

This module controls the actual race. The module displays 6 steering wheels with real time feedback of racing data. (Future improvements are planned to split out each steering wheel to execute on individual computers and additionally to be able to display different types of steering wheels).

Feedback to each wheel during the actual race includes revs, speed, throttle settings, gear, tire performance, fuel, current lap times and fastest lap time. There is also the ability to pit and refuel and change tires.

In addition to the above dynamic feedback, timings are recorded for up to 3 race sectors and the main straight, displaying current timings, previous timings and fastest timings per sector.

Results

Open (NYI)

Championship

Open (NYI)

Product Font Rectangle Engineering Technology




Notes
====

  1. Pit Lane uses program to calculate fuel and NOT the Carrera Control Unit
  2. 4 lane track is currently not supported
  3. Race Day module currently displays F1 steering wheels. Other steering wheels to be added
  4. Race Day module currently displays all 6 cars. Individual displays to be added
  5. Tire wear is based on the type of tire and adjusts the Carrera throttle value in real time
  6. Fuel usage is based on distance travelled and adjusts the Carrera throttle value in real time
  7. DRS utilizes rules from F1 and adds 2 levels of throttle while activated
  8. Real time race fine tuning of speed and timings to be added
  9. Pit Stop functions to be added
  10. Following modules to be programmed
    • Calendar
    • Record Results
    • Championship Standings
    • History / Backup
    • Sound

Summary
=======


As September 2023 the system is approx. 95% built (without the additional NYI modules). Proof of concept of autonomous racing of 3 cars has already been successfully executed using the CUU module. The 5% remaining includes a voluminous amount of testing of the overall system, including actual controlled races, Lane Change, Pit Stops, DRS, etc. Since this is a part time hobby that has already exceeded 4 years of overall investigating, planning, experimenting, programming and building, it is anticipated that it will take many more months before it is in a 'finalized' state. After which additional functionality will be incorporated as I see this as a 'living' project.
 
#3 ·
Thank you Bill_586
Yattr was actually a big help is solving my last hurdle and that was the correct electronic connection to the Carrera CU port. (My 1st attempt blew the CU)
We have had numerous e-Mails over Carrera timings and I am hoping that he has gained some insight from these also.
I still owe him a Nano Decoder
 
#4 ·
Working with dafrgo was instrumental in finally correctly documenting the Carrera Digital Controller interface for ports 1 and 2 of the Carrera Control Unit. His understanding of the old IR tower protocols was key. This protocol evolved over time and therefore was a bit strange as compared to other Manchester protocols used by Carrera.

Dafrgo found my autonomous thread on this forum and PMed me. With numerous phone chats, emails and especially FaceTime sessions (oscilloscope sessions), we were able to developed a mutual understanding of the signals and protocol.

What dafrgo has accomplished is a great demonstration of what can be done with digital slots.

Congratulations dafrgo!
 
#5 · (Edited)
I have now posted 3 videos on YouTube showing some test results of 3 cars racing each other. They are not very competitive yet but the videos display that the Proof of Concept works. The biggest problem is manipulating the database table of time/speed entries to get the maximum out of each car without crashing off of the track.
To this end I am now developing a real time program to visualize each car on the track with the time/speed database entries and being able to modify these to get a better understanding of performance. Not an easy program to develop but will be invaluable when completed.

Autonomous Carrera Race PC Control Screen - YouTube
(1) Autonomous Carrera Race Start - YouTube
(1) Autonomous Carrera Slots Race long view - YouTube
 
#11 ·
Hi XENON,

I am a long way off from releasing any of this to the general public as I am still building and improving the concept.
The software is about 80-90% complete and requires some solid testing to eliminate bugs and I need to add a few new modules to manage Championships and storing of history. I am also looking at adding a module to display real time graphics of the cars navigating the track. There are also some 'nice to have' pieces that I wish to add (like different steering wheels and individual computers controlling individual car displays as this is all covered in one screen at present)
But the biggest changes that I am in the process of making is improving the response time of each gate back to the CU microprocessor. I have a 2 step plan in place and I am in the process of executing the 1st step which I hope to have operational by the end of January. This should significantly help in being more accurate as to where each car is on the track at any point in time.
My goal is to have a production system in place later this year.
I will keep this post updated as I make progress.
 
#15 ·

Not sure what you mean by "episode", but I am the author and I am in the last phase of testing, adding additional functionality and in a short period of time will post a new document outlining all functionality.
It will contain the basic Race Management functions (Tracks, Cars, Race Series, Drivers and Teams) but also includes Racing Calendars and Championship Results, real live Qualifying, Time / Speed Analysis, Simulation, Performance Graphs and computer automation where the computer will race up to 6 cars racing against the computer or against people.
This is a large project and the end is very near, so please stay tuned.
 
#17 ·
@dafrgo wow!! what you have done is Huge for the slot hobby.
I'm fading out and losing interests for this hobby since I dont fund much peoples to race with me at home
and race with a Ghost car are very limited to progress
but this extra layer and difficulty to race against AI or computer give me hope :)this is so great! thank you to bring it this idea where Carrera dont give a sh...t

do you have a roughs idea where this is going to be ready for beta testing? or when do you think you have a first release? this year or it's more next year?
thanks a lots and I can't wait to see the progress
 
#19 ·
special to read, great project, which takes a lot of time and work, congratulations.
I watched the videos and I don't see any digital overtakes, in other words I didn't see any use of lane changer?.
Software-wise you could see through the traps where another ID is located and drive the best running line and realize an overtake as used with BLST. or is this the next phase?
 
#22 ·
There is now a web site that covers the release of this system in Spring of this year.

The Autonomous Race Management System© represents a sophisticated ‘Real World’ approach to motor racing utilizing the Carrera© 1/32 Digital Slot Cars, including real time race feedback, computer simulations, graphic lap comparisons and autonomous / computer-controlled racing. The autonomous / computer-controlled module can race up to 6 cars against themself or race up to 4 cars with 2 additional cars being controlled by racing enthusiasts.

autonomousracemanagement.com