Home-built lap counter

before a track could be used for serius racing and not only for practice, there must be a lapcounting system.
kiklo
Administrator
Posts: 485
Joined: Mon 9. Nov 2015 11:49
Location: Norway
Contact:

Re: Home-built lap counter

Post by kiklo »

Got it !!

Thanks for your advice.

I did not have to use Putty, output came nicely on the Arduino Serial Monitor.
Racing Regards

Kim K.
steellynx
Posts: 30
Joined: Sat 26. Apr 2014 00:16

Re: Home-built lap counter

Post by steellynx »

That's great!
What software do you plan on using?
kiklo
Administrator
Posts: 485
Joined: Mon 9. Nov 2015 11:49
Location: Norway
Contact:

Re: Home-built lap counter

Post by kiklo »

I have had a 'talk' with guys at http://www.racecoordinator.net.

He was interested in incorporating MAGracing to their sw.
So now when I have my HW up and running I'll ask him how he's doing.
Racing Regards

Kim K.
steellynx
Posts: 30
Joined: Sat 26. Apr 2014 00:16

Re: Home-built lap counter

Post by steellynx »

kiklo wrote:I have had a 'talk' with guys at http://www.racecoordinator.net.

He was interested in incorporating MAGracing to their sw.
That's good news :)
If you need any help rewriting the Arduino code to e.g. output a different format for the car numbers please let me know. As far as I recall I had to make some optimizations due to timing issues, so the code is not easy to read.
kiklo
Administrator
Posts: 485
Joined: Mon 9. Nov 2015 11:49
Location: Norway
Contact:

Re: Home-built lap counter

Post by kiklo »

Today I got the new Arduino code to be used with RaceCoordinator. Going to be an interesting weekend.
I'd probably have some footage to show tonight.
Racing Regards

Kim K.
kiklo
Administrator
Posts: 485
Joined: Mon 9. Nov 2015 11:49
Location: Norway
Contact:

Re: Home-built lap counter

Post by kiklo »

As we are working with some IO issues on Arduino and RC I have put up a small table to compaire settings and output:

colum 1
magracing car no from web

colum 2
dip settings 0=low pos, 1=high pos.

colum 3
car no readings in hex from the Arduino (human readable - enabled)

No00 0000 0
No01 0001 8
No02 0010 4
No03 0011 C
No04 0100 2
No05 0101 A
No06 0110 6
No07 0111 E
No08 1000 1
No09 0110 6
No10 1010 5
No11 1011 D
No12 1100 3
No13 1101 B
No14 1110 7
No15 1111 F
Racing Regards

Kim K.
steellynx
Posts: 30
Joined: Sat 26. Apr 2014 00:16

Re: Home-built lap counter

Post by steellynx »

kiklo wrote:colum 1
magracing car no from web

colum 2
dip settings 0=low pos, 1=high pos.

colum 3
car no readings in hex from the Arduino (human readable - enabled)
Yes, the table is correct. What the Arduino sketch does is that it checks a number of pins (by default 0 to 7) and reports any car IDs spotted on those sensors.

When it sends data to the serial port it combines the sensor ID and car ID into one byte because there is a lower risk of communication problems if you only send one byte at a time - you don't have potential for out of sync and you don't need to implement a protocol and so on. Besides, 16 sensors and 16 cars are enough, at least for a proof of concept which is basically what this project was all about :-)

A few examples of what gets returned by the sketch (written in hexadecimal to make the two IDs more visible):
0x00 - sensor ID 0, car ID 0
0x0F - sensor ID 0, car ID 15 (F = 15)
0x47 - sensor ID 4, car ID 7
And so on and so on.

If the "human readable" option is enabled in the sketch two bytes are sent over the serial port which makes it easier to read in a serial monitor.

Race Coordinator (RC) expects some kind of ID to be transmitted and while I do have some code running that responds as it should to commands from RC there are some issues about how to actually use RC's data protocol correctly with MAGracing where the cars are not confined to being in a single lane.
steellynx
Posts: 30
Joined: Sat 26. Apr 2014 00:16

Re: Home-built lap counter

Post by steellynx »

For those interested in testing here's a simple C# application made with the free version of Visual Studio. It only supports car IDs 0-3, but should show how to work with the serial port and it should be easy to expand it to include more cars, a nicer look and so on.

If you get a lot of "sensor 1, car 0" events change Serial.println to Serial.print in the Arduino sketch or change the event handler in the C# program to read a line and filter out the newline character(s). This is just a quick proof of concept so I didn't want to spend a lot of time on those things.

Enjoy :-)
Attachments
LapCounterPOC.zip
(16.49 KiB) Downloaded 755 times
kiklo
Administrator
Posts: 485
Joined: Mon 9. Nov 2015 11:49
Location: Norway
Contact:

Re: Home-built lap counter

Post by kiklo »

Hi.

Got some good testing tonight on RC.

Setup : I use 3 sensors on 3 Arduino Digital pins (2,3,4).
Have coded my cars from 0 to 5 (hex wise, from the table above.).


Now running Skjalm cleaned RC.ino code with latest RC we are closer:

Procedure:

starting with car 0, passing all sensors 1,2,3 3,2,1 I get readings on lane 6,5,4 4,5,6 + som one 3

repeating with car 1 same sequens giving same readings.

And so with all cars.

Still som IO issues to clear out but now we have usable readings.
Racing Regards

Kim K.
kiklo
Administrator
Posts: 485
Joined: Mon 9. Nov 2015 11:49
Location: Norway
Contact:

Re: Home-built lap counter

Post by kiklo »

Now we are counting !!
RaceCoordinatorDigital is live.
Thanks a lot to Dave at RC, and Skjam who did the Ardiono code and boardlayout !!

Racing Regards

Kim K.
Post Reply