SlotForum banner
1 - 20 of 30 Posts

·
Registered
Joined
·
636 Posts
Discussion Starter · #1 ·
Hi all,

I want an autonomous slotcar that outdrives me on my track. To my knowledge, currently there is no intelligent slotcar that can learn a track and drive it as fast as possible.

Once there was the Challenger by Scalextric, which seemed really fine, but it is not available any more.

Also there was a thread on Slotforum about DASC Uno which was exactly what I wanted, but it never came to see the light of day.

Anybody out there with knowledge of something like that?

Anyhow, I finally decided to try it my own, may be there are some guys with hints around...

Reuirements:

  • Scale 1:24
  • Woodtrack, no magnets
  • Usage of stock components (I can solder, but there is no electronics know-how)
  • Minimum changes to existing track (a magnet for lap detection would be ok)
  • Electronics have to fit into the car, 124 Scale
  • Chassis shall be a stock metal chassis
  • Taylor made components to hold sensors and other electronics will be 3D designed and printed.
  • Arduino Nano shall perform car control
  • Following sensors shall be used:
    • LM393 for speed detection
    • Analog hall sensor for detecting drift angle
    • Digital hall sensor for lap detection
  • Power Supply:
    • Arduino: 12V battery or USB-Power Pack
    • Motor: Track power (constant from 6V to 18V)
  • The car shall learn the track automatically
  • Car synchronizes each time it passes S/F-line

Basically, the car will be controlled by a so-called PID-Controller. Besides, breaking before curves has to happen in advance, that is where learning will come into play.

Cheers
Diegu
 

·
Registered
Joined
·
636 Posts
Discussion Starter · #2 ·
First basic and partial setup on a 1:24 brass chassis "DoSlot OBG"

Sensors, magnetholder and index disc for speed meter have been fit into place:

DSC02226.JPG

Motor controller can be seen on the right hand side, not yet mounted. Arduino is not in the pic.
Also there has been an all wheel drive installed, for speed measurement in the testbed.
The green and purple spur gears at the top are only used for fixing the axels.

DSC02227.JPG
 

Attachments

·
Registered
Joined
·
636 Posts
Discussion Starter · #3 ·
This is the first full install using a small 12V battery for the arduino.

20210101_234400.jpg

With a bit of tweaking, the car did in fact go around the track on its own.

The car still has no knowledge of the track, so it cannot break before the curves, but it uses a PID-algorithm to go through the curves.

Due to the fact, that the car does not know, when to break before the curves, I had to reduce voltage to a very low value.


The first laps already showed some design flaws to be fixed later on.

Major problem was, that the car stopped repeatedly without any reason after about 45 seconds. Eventually it showed that it's not a good idea to use such a small 12V battery. This one ist not designed to power an arduino with several modules attached.

Hope you enjoy.

Cheers,
Diegu
 

Attachments

·
Registered
Joined
·
1,204 Posts
Cool project.
thumbsup.gif


Watching with interest.

Can you power the Nano from the track power? (via the onboard voltage reg or an external one or a buck converter )

How do you propose to trigger the car to brake before a corner if not using magnets etc.?

What is the round black part between the motor and battery?
 

·
Registered
Joined
·
636 Posts
Discussion Starter · #5 ·
Hi Drifter2,

glad you like it
smile.png
.

You're right, I could power the Nano from track power. Motor is an SRP25, which runs optimally at 12V, and so is good for the Arduino. (Voltage from 6V up to 20V should do the trick)

Anyhow, for now, I want to exclude power issues like spikes, dead spots,... from the equation. So there is the battery.

"How do you propose to trigger the car to brake before a corner if not using magnets etc.?"

Idea is to have a learning phase with increasing voltage. There will be situations, when the tail swings out "too far".

The Arduino will store each such position with the adjacent speed. This will be - more or less - the target entry speed for that curve.

My son-in-law works on (real) autonomous cars and provided me - after some thinking - with an equation, when to start braking at a given speed and a given deceleration, to reach a target speed at a given position.

Anyhow, in the early versions, I will program fixed braking point positions for my track.

"What is between the motor and battery?

It's just a buzzer. There are no debug logs when driving on the track, so currently, there is only acoustic feedback.
Currently, this works better than expected. If need be, I may switch to an RF Nano, like in one of the posts of Dr_C.

Currently, the biggest problem is, that the digital hall sensor detects laps every some centimeters. Hope I can fix this by using capacitors, but the won't arrive until next Thursday.

Cheers,
Diegu
 

·
novice jazz player &
Joined
·
6,257 Posts
Yepp... cool project :)

c
 
  • Like
Reactions: diegu

·
Registered
Joined
·
636 Posts
Discussion Starter · #7 ·
While waiting for the capacitors to arrive, there is enough time to fiddle around.

First thing was to optimize measuring the angle of the guide flag. Given the impression of the first test drive, I came to think that the initial setup with one magnet as shown in the pics that the measuring range was too narrow.

So I did two other designs for the magnet holder and did some measuring:

Guide_Statistics.jpg

As expect, design one yields poor results.

Designs two and three have a wider effective range and allow to distinguish between left and right curves. I currently do not use this, but this might be helpful in the future.

Design three outperforms design two in terms of effective range, so I will go for this.

Hope you enjoy.

Diegu
 

Attachments

·
Registered
Joined
·
1,204 Posts
With my project I found that extending the guide flag rearwards (so it is effectively is 2x longer than standard) gave more consistent and accurate readings.

( this also meant the IR Led had to be relocated rearward as well )

Also the guide pivot on mine had a lot of free-play, again improving this gave better results.
 

·
Registered
Joined
·
636 Posts
Discussion Starter · #9 ·
Drifter2 - thanks for pointing me to your project! Very inspiring and instructional.
Thanks also for the hint on the guide flag. The one I use is 28mm in length, my slot is 4mm in width and the guide is only 2mm wide, so this gives room for an error of about 4° on the straights. May be worth thinking of.
thumbsup2.gif


Next thing to fiddle around is control algorithm. I noticed, that the car accelerates very hesitantly. This was, due to the controller starting to regulate at 0V
wacko.png
.

So, the first idea is never to go below the minimum voltage suitable for the slowest curve. For now I measured this to be 5.3V on my current track for this specific car. Later-on this shall be computed in the learning phase.

Second idea is to have the increased or reduced voltage in each control cycle somewhat proportional to the deviation from the optimal drift angle.

And now I wonder how to test this, without lap detection and thus no braking
sad.png


Cheers,
Diegu
 

·
Registered
Joined
·
636 Posts
Discussion Starter · #10 ·
OK, sometimes it's not the electronics, sometimes one simply is too stupid
wacko.png
.

May be there is a "spikes problem" regarding the hall sensor, but using the interrupt not as stupidly as I did, did the trick for now.

So: Lap detection works and as the positioning algorithm is also already in place I was able to do a mock-up of the "learning car" by simply defining break points and (currently one) target speed to be reached after braking.

I then had to fiddle a lot, with the parameters of the PID-Controller (just reduced to the "P"-part of the controller - "I" and "D" are just set to zero), which resulted in some nice autonomous laps.

Anyhow, I think, I programmed a very aggressive driver, have to somehow tranquilize him or her.

However, there are still MASSIVE
sad.png
sad.png
issues regarding stability (sometimes the car just stalls after a few laps). Don't know what happens. May be the missing caps? I WANT MY CAPS!!

Also: Positioning is a nightmare. Can anybody help? Is a LM393 good for detecting 6.000 rpm, I.e. 12.000 pulses per minute? I attached this device to interrupt 0 of my Arduino.

In case the LM393 is fine, the front wheels may be the problem. They are treated with super glue and polished - just as it has to be - in order to remove friction. Anyhow, for this application this might be somewhat contra productive.

I hope the algorithm is fine. It's just:

newPosition = oldPosition + ((speedOld + currentSpeed) / 2.0 * timeInMillis / 1000.0);

Any ideas welcome!

In case you like to watch: Here is a video with the pace car running at 8V - still a long way to go to the intended 12V...

Hope you enjoy.


Cheers,

Diegu
 

·
Registered
Joined
·
1,204 Posts
Hi Diegu,

I've not used the LM393, but one thing to consider is ambient infra red light can leak in and skew the results. One easy way to check is run the car in nearly total darkness.

Yes those front wheels will need grip.

I assume the LM393 helps calculate where on the circuit the car is relative to the start finish line as well as speed?

With your Algo, are you updating the oldPosition with the new position at the end of the function, I.e oldposition = newPosition ; for next time the function is called?

or is everthing relative to the Start line?

Video looks good
thumbsup.gif
 

·
Registered
Joined
·
636 Posts
Hi Drifter2,

good point with the light. Will check. Also will install soft sponge tyres at front.

I use the LM393 for the following purposes:

  • Get the position on the track, relative to S/F line
  • Compute speed.
    Speed is currently only used to assure that the car is not too slow.
    Currently there is a fixed minimum speed to be reached at the end of braking and to negotiate through narrow curves.

In fact formula for position is:

currentPosition = currentPosition + ((speedOld + currentSpeed) / 2.0 * timeInMillis / 1000.0);

and currentPosition is set to zero at S/F line.

Cheers,
Diegu

PS: Another slotter pointed me to this web-site: GhostCarProjekt - Mikrocontroller.net so this already has been done very nicely.
 

·
Registered
Joined
·
636 Posts
Discussion Starter · #13 ·
Yesterday, the caps arrived. I think that cured my radio problems. So time to move on...

One of my more risky assumptions was, that a PID-Controller based on guide-angles would do all necessary, the make the car fast an keep it on track - at least when haven a sensible curve-entry speed.

Such a PID-Controller is programmed easily. It's just one line of code. But how do you determine the constants for P, I and D?

So now, all the ones with knowledge about cybernetics should be tolerant with me, or may also help me further in this topic.

For all the others: There are really cool vids on the tube, explaining the basics of PIC-Controllers. Searching for "PID Controller introduction" should yield som interesting 15-minutes-vids.

So having no real idea of what I am doing - how should I be able to configure the constants for such a controller?

One of the most panicking questions was: Can I achieve the required control frequency of about 100Hz? I just have the budget version of the Arduino Nano.
In my testbed with debug printing, I can just reach about 10 Hz.

However, went through the code again, eliminated debug display and reached slightly more than 100Hz. So, it makes sense to go further...

But regarding parameters: I thought of having an infinite curve, to determine the parameters. This would eliminate all the problems regarding left and right curves and breaking points.

So I got my old Ninco track from the attic and set up to concentric circles of Ninco R2 and R3 and applied 12V to all of these.

So after a day of fiddling and testing I came to some acceptable result.

Very interestingly, one of my basic assumptions was definitely wrong: A drift angle of 8 grade is far too high. Optimal drift angles seem to be around 2 grade - the rear already hangs out at 0 grade!

This was easy enough to configure. But it shows, that the car has to be aware whether it's in a left or in a right curve. The guide can also be turned to the inner of more than 2 grade.

Here is a vid with bad and better PID-Parameters. The car knows nothing about radii but it goes through Ninco R2 and R3 and 12V using an SRP 25. It is just controlled via drift angle. Hope you enjoy and you don't get dizzy.

[youtube-hd]oA41sUEFuPw[/youtube-hd]

Cheers,
Diegu
 

·
Registered
Joined
·
1,204 Posts
Hi Diegu,

video not showing up here..

Re drift angles, I moved the back of the car left and right whilst it was sitting on the track and observe the angle readings. This helped me to determine the dead zone. As I mentioned earlier I found that making the guide angle reading as reliable and accurate as possible is important. I guess you have already discovered most of this in your trials.

I also installed a spring on the guide to return it to centre as the car exits a curve, this gave a more reliable and repeatable result.

Re " Is the car turning left or right" I wondered if this could be "learned " or pre-programmed into the car because if you know how far from the start / finish you are then you know which corner (and max speed for that radius ) you are negotiating. I used mercury switches as a quick and easy way to detect if it was a left or right corner but if it can be done with software instead that would be better Imho. I guess you may already be doing it in software already :) .

Keep up the good work..
 

·
Registered
Joined
·
636 Posts
Discussion Starter · #15 ·
Hi Drifter2,

thanks for your support and tips!

I used the wrong embedding code. This should work:


Re drift angles: I fully agree, especially regarding determination of drift angle on track and accuracy of data.

Preprogramming of left and right should be rather easy, but I do not like the idea of hard-coding too much.

I would like to use a gyro to measure sideways acceleration and react accordingly. This could allow better control and more aggressive acceleration onto the straights.

Drawback is, this would require wireless online analysis of the data in order to understand it and this will require some time and more hardware.

Cheers,

Diegu
 

·
Registered
Joined
·
636 Posts
Long time no see. Anyhow, I had some days off again and it's time for a somehow frustrating update.

In the meantime, I was able to upgrade to an Arduino Nano 33 IoT.

Using that I can track acceleration data live on my smartphone. I could even use my smartphone as a remote for my slotcar.

That sounds good at first glance. Anyhow, this works only in my "dry dock", but on the track the arduinos are fried just in seconds.

I knew my approach was quite optimistic - to say the least, but I did not expect the parts to die so fast
ohmy.png
.

I have the impression, that motor control, speedometer, angle sensor and hall sensor for lap detection draw too much of power from my arduino. And I do not know, where to find reasonable parts with comprehensive documentation on the web - A***** seems not to be the correct place.

However, might be someone has good advice, otherwise, this might be the end of the journey here.
unsure.png


Cheers,
Diegu

edit: typos
 

·
novice jazz player &
Joined
·
6,257 Posts
Hi Diegu, is the track dc powered? and what circuit takes power from the track to control the motor?

c
 

·
Registered
Joined
·
636 Posts
Discussion Starter · #18 ·
Good questions.

The track is dc powered and the arduino is powered separately via usb using a small power pack.

For power control I use this module: CQUANZX

Diegu
 

·
Prof I T
Joined
·
11,098 Posts
Instead of Arduino try Ruggeduino, much more grunt
thumbsup.gif
 

·
Registered
Joined
·
636 Posts
Discussion Starter · #20 ·
Hi Ade,

nice hearing from you again! Anyhow, this one struck me by surprise ROFL
lmfao.gif
.

Very cool tipp, but this Ruggeduino is really huge and there is no Wi-Fi on it. I have very poor capabilities when it comes to hardware, so these things have to work "sort of" out of the box for me
unsure.png


May be this would be fine when going to 1:18.

Anyhow, seems to be bullet proof. I dunno. At least, not the intended solution.

I still hope there is another way...
biggrin.png
biggrin.png
dribble.gif
dribble.gif
innocent.gif
yikes.gif


Thx

Diegu
 
1 - 20 of 30 Posts
Top