SlotForum banner

1 - 8 of 8 Posts

·
Registered
Joined
·
45 Posts
Discussion Starter · #1 ·
I've written a little lap counter program over the past several months. I originally wrote it just to use the Scalextric RMS track piece but have since added support for parallel port status pins using the inpout32.dll. It's still a work in progress so isn't fully debugged.

It can be downloaded from the following link and needs the .Net framework 3.5 to use.

http://web.bethere.co.uk/kielder/lapx_lap_counter.html

I haven't tested the parallel port fully yet, so not sure how well it works. I have some infra-red LEDs and a pair of phototransistors but have yet to wire them up.
 

·
Registered
Joined
·
497 Posts
Hi Marvin thats a great little program are you intending to add lane rotation, and a 5 laps race too, keep up the work
 

·
Registered
Joined
·
45 Posts
Discussion Starter · #4 ·
QUOTE (RCH @ 26 Jun 2011, 20:57) <{POST_SNAPBACK}>Hi Marvin thats a great little program are you intending to add lane rotation, and a 5 laps race too, keep up the work

I added a 5 lap race and a few others too. Not sure how or if i'll do lane rotation as I don't have a championship mode or way to enter drivers names.

Still haven't got round to building the infrared sensors yet. I've had to make do with sticking wires into the back of the parallel port to test it


Anyway onto some techie stuff...

I've been testing it to see how often I can poll the sensors and most of the time it is about every 2ms which should be fast enough to detect a car using the parallel port. However it peaks from time to time at about 20ms which might not be fast enough. Not sure what's causing that, could be some Windows service or something running every so often in the background. I have a feeling it is my network card. Will need to test it on my other PC sometime.

I've also been trying to find out if I can read the parallel port status pins without using inpout32.dll and it seems it's possible to use the Win32 DeviceIOControl() and the IOCTL_PAR_QUERY_INFORMATION control code. However it appears that it can only read 3 lanes like this using pins 12, 13 and 15. Doing it this way might allow the use of a USB to Parallel adapter. Will have to add the code sometime and see if it really works.
 

·
Simon Platten
Joined
·
1,060 Posts
Hi Marvin,

I would be very skeptical of timing on Windows, the resolution of the clock is retarded by Windows and only accurate to approx. 50 ms, yes you can get snapshots at various intervals, but it isn't anywhere near as accurate as other operating systems such as Linux or better still QNX. In QNX you can have timers which are truely accurate to 2 nanoseconds, not that you would need it for this application.

You certainly can read the parallel port status pins with inpout32.dll, I did it a while back for SRS. You should also look at joystick game ports, I don't think you will get any joy with USB parallel port, I bought one of these for exactly the same purpose, but unlike a real parallel port, it didn't work as expected, could be the driver, but I couldn't get it to work with the same code that worked on a real parallel port.
 

·
Registered
Joined
·
45 Posts
Discussion Starter · #6 ·
Hi Sy,

I think you're right that Windows isn't that great regarding timers and timing, but then it is a general purpose OS. I've studied QNX a bit but never written programs for it.

I did some benchmarking and the time between reading the parallel port with inpout32.dll is about 2ms, only going over 20ms once or twice every few seconds, so not too bad. I basically have a thread that requests a 1ms sleep, reads the port, 1ms sleep, over and over.

The problem I have is using the .Net serial port interface as opposed to using inpout32.dll. When I use the serial port the time between reading the ports varies considerably especially when the screen updates, sometimes upto 100ms. If reading from a USB parallel port is this bad (even if it could read the pins) then it would still miss a lot of laps, so I'll leave that idea alone now and have a look at your suggestion of reading game controllers.
 

·
Simon Platten
Joined
·
1,060 Posts
One thing you could explore, would be to use a PIC for timing. PIC's are excellent for this sort of application and a lot of them now have USB support. You could read and time the laps with the PIC then send the results to the PC via USB or serial.
 

·
Premium Member
Joined
·
1,009 Posts
I have been working on something similar using an mbed board which has an ARM based chip on it. All race timing is handled by the chip so it should be considerable more accurate than relying on windows or similar.

I will be trailing the system at my local club this Wednesday and if it's successful I will be starting a thread on here with more details for those who are interested.
 
1 - 8 of 8 Posts
Top