Pc Lap Counter

Logiciel de comptage
 
HomeHome  FAQFAQ  SearchSearch  RegisterRegister  MemberlistMemberlist  UsergroupsUsergroups  Log in  

Share | 
 

 Error with Arduino sending SF message

View previous topic View next topic Go down 
AuthorMessage
KosieSnyman



Number of posts : 5
Registration date : 2013-05-03

PostSubject: Error with Arduino sending SF message   6/5/2013, 23:57

Good day all

I am a newbie to Arduino and PCLapCounter. I am using Arduino Uno and IR LED phototransistors to detect cars on my anologue track. LED phototransistors connected to Digital Pin 2 and 4. When I get to about 30 laps on PC lap counter using script below, PC lap counter start to respond very slowly. What must I do differently in the script to avoid the issue?

/*
DigitalReadSerial Test for IR Photo Transistors on Digital pins
Reads a digital input on pin 2 & 4, prints the result to the serial monitor

This example code is in the public domain.
*/

/* digital pin 2 (Yellow input wire) & 4 (White input wire) has an IR phototransistor with a 10k ohm resistor connected.
They are shielded, so that they will have HIGH value while IR LED is shined on them and
LOW when light is interrupted or not correctly aligned.Input are defined below:
*/

int inputYellowLane = 2;
int inputWhiteLane = 4;

// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
// here we make the Phototransistor value on the pin an input:
pinMode(inputYellowLane, INPUT);
pinMode(inputWhiteLane, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
int YellowState = digitalRead(inputYellowLane);
int WhiteState = digitalRead(inputWhiteLane);
// Determinie if need to print out the state of the White and Yellow light:
if (YellowState == LOW) { Serial.println("[SF01]"); };
if (WhiteState == LOW) { Serial.println("[SF02]"); };
delay(20);
}
Back to top Go down
View user profile
guy

avatar

Number of posts : 2067
Localisation : Belgique
Registration date : 2006-01-25

PostSubject: Re: Error with Arduino sending SF message   7/5/2013, 23:36

Strange it happen after 30 laps , Is there any message in pc lap counter like "reject lap" ?
One thing is not good in the code but i don't know if it can be solved in the sketch: you send the SF message when the state is LOW and therefore when a car stay on the sensor it will send many SF message , it's better to send the SF message only when the state change from HIGH to LOW.

Back to top Go down
View user profile http://www.pclapcounter.be
KosieSnyman



Number of posts : 5
Registration date : 2013-05-03

PostSubject: Re: Error with Arduino sending SF message   8/5/2013, 00:23

Managed to get it working by introducing a counter on the Arduino code and only print to PC Lap Counter when counter exceeds a preset value. Any new laps reported will be rejected since they are less than 1 second from the previous lap reported. On a 25m track and car length of 130mm, and a lap completed in 10seconds, The IR phototransistor will remain in a low state for 0.052 seconds or 52 milliseconds. So I just used a counter. Your idea to check status change is better and once figured out I will post the Arduino sketch here again for others to use.
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: Error with Arduino sending SF message   

Back to top Go down
 
Error with Arduino sending SF message
View previous topic View next topic Back to top 
Page 1 of 1
 Similar topics
-
» Posting or sending gold around Australia or overseas
» Write-Up: Fuel / Oil Pressure Sending & Gauges
» Gas tank sending unit
» Error Code P1870
» 1985 R100RT Fuel Level Sending Unit

Permissions in this forum:You cannot reply to topics in this forum
Pc Lap Counter :: Hardware :: Arduino-
Jump to: