I am completely green. Though programming logic does not escape me, the syntax I have seen in the forums does, I think.
I am into slot cars, and racing them requires software and hardware. I am hoping the Arduino is a solution for me. I have a PC version using other equipment, but am tired of inherent Windows issues, and want to use my Mac. What I want is, in effect, an event counter. Here are the basic parameters:
The system will be triggered by the cars running over reed switches, or breaking a light beam.
I need to have counting up to 999, and lap counts accurate to 1/1000 of a second.
I feel sure you will be able to do this with the Arduino, how easily depends on how you detect the lap trigger for all the cars. The easiest way is to poll as many pins as there are cars and capture the duration using the millisecond timer. Send the time in milliseconds along with a tag indicating the car via the serial port to the mac for processing and display. You would need to ensure that your polling routine takes less than a millisecond including the time to send the data, if you need accuracy to 1/1000 of a second.
Assuming your want your design to cope with all cars crossing the line within a few milliseconds, you may need to use an interrupt to detect the trigger. There are only two external interrupts on the arduino, but you could add something simple like a six input OR gate so that an interrupt can be generated when any car triggers the sensor. I assume from yr GUI link that you have up to six cars You could still poll the individual input pins to find which one, but the fastest method is to use direct port access to read all six pins at the same time
It may be unnecessarily complicated, but the technique I would use if I was doing this would be to have the handler for the interrupt described above put the value from the input port and the least significant byte of the millisecond counter in a circular buffer. My sketch's loop would constantly check the buffer to see if any new data was added by the interrupt handler. If so, it would convert the millisecond byte into an actual elapsed duration and determine which car or cars caused the trigger (each car is represented by one bit of data ). I would then send a message to the mac containing the car ID and duration for each car that had the trigger bit set. As long as I could service all six triggers within the time for the fastest possible complete lap, a six element buffer would never overflow.
The GUI on the mac side is really dependant on what development environment you want to use that can handle serial messages from the arduino.
Anyway, I hope you can find some useful ideas here.
OK, you got it 100%. Two clarifications. I would need the software to handle anything from 2-10 lanes, and have the GUI allow for this selection, and to also allow for the insertion, and saving, of names, and teams. That brings us to the software to write the code. Any recommendations?
10 lanes is a little more demanding but should be possible using the technique above.
The lane selection logic should not be difficult assuming it is only changed between races (i.e. not once the timing mechanism is started). Actually, the proposal in the previous post just spits out lap times for all connected tracks so your selection logic will probably be on the mac, not the arduino.
Saving of names and teams? Does this need to be on the arduino, or could it be on the MAC? You have only 512 bytes of EEPROM on the Arduino, is this enough for you?
The arduino environment uses the C language and that is what I recommend you use for the non mac code. If you keep all the complex calculation and UI functionality on the mac, your arduino code will do little more than output a few bytes of data every time a track lap sensor is triggered. So everything but the critical lap timing function will be done on the mac. Is that how you see it?
Unlike the Arduino code, the mac code would not be time critical so you can choose whatever language you are most comfortable with. But it sounds to me like there is much more coding in the mac side than the arduino, are you up for that?