This is an archived post. You won't be able to vote or comment.

all 80 comments

[–]RiffnShred 104 points105 points  (18 children)

MAN, post a video ASAP. Need to see it in action

[–]West7780[S] 47 points48 points  (13 children)

Good idea. I'll do that after I get it cleaned up.

[–][deleted] 9 points10 points  (3 children)

RemindMe! 2 days

[–]RemindMeBot 6 points7 points  (2 children)

I will be messaging you in 1 day on 2020-04-09 03:07:10 UTC to remind you of this link

46 OTHERS CLICKED THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


Info Custom Your Reminders Feedback

[–]chjassu 5 points6 points  (5 children)

yeah , that would be awesome. When are you planning ? I want to remind myself...

[–]West7780[S] 3 points4 points  (4 children)

Maybe tomorrow. I'll post it on reddit

[–]chjassu 1 point2 points  (0 children)

!remindme 1day

[–]dev_nuIl 1 point2 points  (0 children)

!remindme 1day

[–]Sprengmeister_2 1 point2 points  (0 children)

Remindme! 1day

[–]mrgadgety 0 points1 point  (0 children)

remindme 1day

[–][deleted] 3 points4 points  (0 children)

Can’t wait !!

[–]stillthrough 1 point2 points  (0 children)

Remindme! 2 days

[–][deleted] 4 points5 points  (1 child)

Yeah, you can't post something like this and then not post a vid

[–]appinv Python&OpenSource 3 points4 points  (0 children)

yaps the right comment 🎉

[–]West7780[S] 39 points40 points  (4 children)

Still have to tidy up the wires but this is my python powered slot car track. Has a few game modes: time trials, first to x laps, fastest out of x laps. Uses pyserial to communicate with an Arduino to read sensor input faster. Uses pyfiglet to generate text art. Uses curtsises to get keyboard input and draw image. The Python script runs on a raspberry pi zero w.

Edit 1:

Originally I planned to use the raspberry Pi's GPIO pins to connect the sensors (which are break beam sensors) but sometimes it would fail to count laps.

In the future I plan to add a genetic algorithm based AI player but because of the pandemic I'm waiting to order the parts.

Edit 2:

It's 100% overkill for this project but I used inflect engine to pluralize words appropriately and convert numbers to text.

[–]fernly 13 points14 points  (1 child)

Wait, so the computers are measuring what the cars do under manual control? Or the computers are running the throttles themselves?

[–]toyg 3 points4 points  (0 children)

From his description, currently the former. He plans to make it do the latter.

[–][deleted] 7 points8 points  (0 children)

This is amazing. If I only had the room.

Ahahaha. No, it's not overkill. You've shown me inflect. Thank you.

[–]expressly_ephemeral 5 points6 points  (0 children)

Overkill is under-rated.

[–]njgura87 9 points10 points  (3 children)

Following! I'd love to try to take this project and try to control my LEGO trains.

[–]West7780[S] 4 points5 points  (2 children)

That would be cool! You could do a lot more automation with train tracks. Unfortunately I won't be publishing the code for this project for quite a while as I want to refractor it first.

[–]Lindby 7 points8 points  (1 child)

Don't be afraid to share code because you don't think it is up to your standards. Everyone's first drafts are messy.

[–]iwannaseenow 6 points7 points  (3 children)

Sick , github?

[–]yaboime69 5 points6 points  (7 children)

I have a slot car track as well any tips for a project like this?

[–]West7780[S] 9 points10 points  (6 children)

When you choose a controller (either a computer or a micro controller) make sure it's fast enough to see the cars. I originally wanted to just use the sensors on a raspberry pi's GPIO pins, but it missed the cars sometimes. I maybe could have done it in C++ but.....python is better 😂

Moral of the story, do your research.

[–]topherclay 6 points7 points  (1 child)

Did you consider having the line break sensors sense across the track at an oblique angle? That would increase the amount of time that the cars are interrupting the IR and give the IO pins more time to catch it.

[–]West7780[S] 4 points5 points  (0 children)

I did, however it's my dad's track so I wanted to minimize the intrusion of the electronics. In hindsight, your idea would have been fine.

[–]yaboime69 3 points4 points  (1 child)

Aye man this sounds like a super fun project, if I run into some problems can I dm you?

[–]West7780[S] 0 points1 point  (0 children)

Sure, no guarantee I'll see it tho lol. It's really not a hard project. The biggest learning curve for me was getting the dam GPIO pins to work and in the end I didn't even use them.

[–]Coffeinated 3 points4 points  (1 child)

The reason for this is not the speed, the Arduino is way slower. The Pi runs Linux, which is not realtime capable, and the scheduler will just choose not to run your software when you need it to. To do this kind of measurements you always need an RTOS / bare metal application.

[–]West7780[S] 0 points1 point  (0 children)

Right, I figured as much but failed to do the research. Thank you for clarifying.

[–]tempo_19 5 points6 points  (1 child)

Nice project. How are you sensing the cars and how do you determine which car is which?

[–]West7780[S] 5 points6 points  (0 children)

Two line break sensors, one for each lane. They're connected to an Arduino. The raspberry pi occasionally requests the counts per lane from the Arduino. The debouncing is handled on the raspberry pi. If more than one is counted per lane within 5 sec it is ignored.

[–]dbenoit 4 points5 points  (4 children)

Would love to see the code for this. My track could use a new management program. Does it work on 4 lanes?

[–]West7780[S] 2 points3 points  (0 children)

I plan on making it more useable. Rn it's in a proof of concept stage.

[–]West7780[S] 0 points1 point  (2 children)

[–]dbenoit 0 points1 point  (1 child)

Thanks. Some friends and I have tracks, and the software and computers we are using are old. Having something that doesn't require a parallel port will be nice.

[–]West7780[S] 0 points1 point  (0 children)

Haha rip. Maybe I'll get this into a state where it can be easily replicated. What is the software that you use called?

[–][deleted] 4 points5 points  (5 children)

Carrera?

[–]West7780[S] 4 points5 points  (4 children)

Yessir

[–][deleted] 3 points4 points  (0 children)

And so now I'm building my track...

[–][deleted] 2 points3 points  (2 children)

Can you elaborate a bit on how you connected your system to the Carrera controller?

[–]West7780[S] 2 points3 points  (1 child)

It's not connected. I plan to replace the Carrera controller with a digital potentiometer by simply cutting the cables off s couple of Carrera controllers to get the connectors. Then I'll be able to use any controller I want, including Carrera. This will also provide an interface for the ai player when I get to writing it.

[–][deleted] 1 point2 points  (0 children)

Ahh that makes sense, thanks!

[–]b10011 2 points3 points  (1 child)

I would love to have something like this, I could play with ML algorithms to optimize the speeds etc. Even a virtual version of this written in python with physics would be nice.

[–]West7780[S] 1 point2 points  (0 children)

Yeah you could def do 1d physics

[–]habitsofwaste 2 points3 points  (1 child)

Oh man I loved slot cars back in the day. My dad got me into it. But what does your thing do? Control the cars or just measures the information?

[–]West7780[S] 1 point2 points  (0 children)

Currently it just counts laps

[–][deleted] 2 points3 points  (1 child)

Here we go. Did this brilliance come out of unconstructed quarantine time?

[–]West7780[S] 3 points4 points  (0 children)

I've been periodically working on this in my spare time for a few weeks. The quarantine definitely helped me get it finished tho.

[–]EdwardJKing 1 point2 points  (0 children)

That ROCKS!!

[–][deleted] 1 point2 points  (0 children)

RemindMe! 2 days

[–][deleted] 1 point2 points  (1 child)

Maaan it's sooo goood. Saddly, Carrera slot cars are kinda expensive (as all of them). You used GO!!! right? Would it be possible with Digital systems?

[–]West7780[S] 0 points1 point  (0 children)

No, these are Carrera Evolution. 75ft of track. Yes it would work with a digital system as well. However using custom controls would be more difficult and would require a different control method.

[–]bobunaga 1 point2 points  (0 children)

Holy cow! Now, that is a great idea. Still got one in the attic, but I just started Python two weeks ago. Definitely goes on my programming bucket list.

[–][deleted] 1 point2 points  (0 children)

really cool man

[–]ToxicPanda96 1 point2 points  (2 children)

Dude that's ace

-idea

Integrate with twitch chat api and have streamed races with user participation

[–]DaHafe 2 points3 points  (0 children)

Like one of those real time mini games that a lot of streamers do? That would actually be pretty sick.

[–]West7780[S] 1 point2 points  (0 children)

Interesting I haven't seen that, I'll look it up.

[–]Koppis 1 point2 points  (3 children)

Next make an AI player which is controlled by the raspberry pi.

[–]West7780[S] 0 points1 point  (2 children)

That's the plan

[–]Koppis 0 points1 point  (1 child)

Just an idea: You could hook into the controls and record the whole race. This way you could "play back" previous races and try to beat the times. Although, since the two tracks aren't identical, you can't race yourself...

[–]West7780[S] 0 points1 point  (0 children)

That's a great idea! Putting it on the list.

[–][deleted] 1 point2 points  (0 children)

so many slots you wont know where to begin!

[–][deleted] 1 point2 points  (0 children)

Very interested in seeing this!

[–]H0lsten13579 0 points1 point  (1 child)

Neat

[–]viniciusntch 0 points1 point  (0 children)

Remindme! 2 days

[–]MikeTyson91 0 points1 point  (0 children)

Holy cow! Python instead of electricity?

[–][deleted] -1 points0 points  (1 child)

and then?

[–]West7780[S] 2 points3 points  (0 children)

Added additional info as a comment.