Introduction: Lap Timer Mini 4WD ( IR Sensor )

About: First time is fun and motivated when saw people around the world creating some great instructables until unconsciously i get infected enjoy to build something that i never learn before.

Greetings

Continue developing based from my Lap Timer project on https://www.instructables.com/id/Lap-Timer/, the function is a tool for measure time lap for mini 4WD race on the circuit. This tool very helpful for analyze time travel on different kind of circuit pointed to modify character of car setting, also can be use for time attack race category

My previous version is lack of function founded after use by my brother, so i start to re create from beginning

I really enjoy every step for develop this project, start from research the problem until learn how to programming. Here we go

Step 1: Work Principle

Detecting when the car pass the sensor is the main of system, after that we need to give some information

1. Measure time attack from three lap (When the circuit have three track).

2. Measure average speed.

Every circuit have different kind of distance, so we bounded to put fix distance of two sensor to make easy implementation on the different kind track.

3. Save the data for analyze need.

We found some friend make the relatively same project, and its quite superb

http://rcarduino.blogspot.co.id/2012/07/lap-timer-...

Step 2: Build Sensor

List of needs

  • Sensor IR Vishay TCRT 5000 : 4 pcs : to read object
  • Usb Female : 4 pcs (use only case)
  • Cable : total 2,5 m
  • Connektor : 4 pcs
  • Electrical tape

IR-E-18-d50nk is IR sensor that i use for previous version, quiet precise for capture fast object, and flexible range of sensitivity, so if you have more budgetary fund it can be second option to choose this sensor

At this moment i try to use cheap TCRT 5000 as reading sensor, with 4 cable at the end use black housing to make ease plug into terminal pin. At the end sealed sensor with electrical tape and cover it with the plastic female usb cover.

Good theory of IR sensor http://maxembedded.com/2013/08/how-to-build-an-ir-sensor/

Step 3: Sensor Support Stand

List of Need is PVC Pipe

  • 10 cm : 3 pcs : height
  • 5 cm : 5 pcs : joint "T"
  • 2 cm : 4 pcs : inside for sensor support
  • 50 cm : 1 pcs : Distance for calculate speed
  • "T" : 5 pcs : Support stand and sensor
  • "L" : 5 pcs

Using PVC pipe to put cable inside easily, by using 1/2" of pipe and cut length as need, we not using glue just plug it like playing lego so we can turn /rotate the support sensor, adjust up and down, left and right, all adjustment for make sure sensor is precisely center in the circuit

Step 4: Indicator Box

List of Needs

  • Plastic case, i found on the electrical market
  • 10K variable resistor
  • Led Indicator Green and Red
  • Glue

To put together microcontrol and light indicator is use plastic case, make two holes on upper part of case for led indicator, green is mean sensor read object, red is mean when received stop command and see the result of counter on computer display. Make one more small hole 6mm for variable resistor to adjust sensitivity of sensor, try to glue carefully between variable resistor and plastic case or it became stack close you r resistor cannot be use.

For square hole on the side for usb cable and circle hole for the other side for input sensor, drill if we have 6mm and 18mm drag bit or we can use some sharp tool like knife or scissor to carve build hole carefully.

Step 5: Wiring and Control Programing

List of Needs

  • Arduino Nano : 1 pcs : processing and interface
  • IC LM 358 : to convert sensor read become digital signal
  • Terminal screw : 2 pcs (4hole)
  • Pcb : 3x8
  • Resistor 10K and 4,7 @ 1 pcs

Make it become one card so i put arduino nano, LM358 on one protoboard that fit with plastic case, use 2 terminal screw one terminal for input sensor and other terminal is for leds indicator and variable resistor.

Programming is use arduino IDE, and put key of parameter needs

  • Stop watch : Sensor reda object and send action to start measure the time (second), every time sensor read object then starting count from zero
  • Counter : Sensor read object and send action to count increasingly number of lap
  • Average Speed : Read from two sensor and calculate distance : time
  • Send raw reading result from arduino to PC and Received command from PC
  • Detail source code is on attached file

Below is some good reference regarding this step

Step 6: Interface With Visual C#

I'm absolutely graduated from search engine and start learn C# programming, so i make breakdown the needs, to make easy search reference in the internet.

So below is workflow and function of software interface

Serial Port :

1. Show Serial port active in the pc

2. Choose where is Arduino

Display :

Display time and average of speed, we try to use seven segment style font maybe looks more digital :D

Log Activity Counter :

Basically it just to show the counter is working

Result box :

This is the hardest part i have been faced up, how to separate data from arduino and showing to the different box

After couple of week finally found some good reference and combine become function to separate only data what i want, so

The format serial print from arduino is like this

0 : 1 : 109 Lap : 2 |km/h : 9

From hundred serial print of line was received and we try to keep on txt file, and after "StreamReader" have a job to read and filtering data, with this way

if (line.Contains("Lap : 2")) {
textBox2.Text = line; }

The function of print separator "|" is for separate line, "0: 1: 109 Lap: 2" is detected line "0" and "km/h: 9" is line "1", so with this way

if (line.Contains("km/h :")) { textBox5.Text = line; string[] newLine = line.Split('|'); textBox5.Text = newLine[1]; }

I put some reference how saving txt file and read by function of StreamReader is on the last step

and i put source file for take a look or maybe give me other suggestion is welcome


Start :

1. Start connecting the Serial port has been choose

2. Arduino start to run

3. Data of serial print received and show in Log Activity Counter and Display

Stop :

1. Give Command stop to arduino, (actually is not a stop operation just give some serial print with longer delay)

2. Save all data to txt file

3. Read txt file by StreamReader function

4. Filtering data time counter lap and speed

5. Show data Lap 1, Lap2, Lap 3 to the box

6. Show data average speed to Text on the display

Reset Counter :

1. Send command to reset arduino

2. Start count lap from 0

Save : Is to capture the page, like printscreen function

Detail dirty my source code is on attached

Some reference source C# code i put below

  • For Button : Arduino and Visual C# - Control Arduino with Windows Forms Application // keyword search engine
  • Data in and save : Arduino and Visual C# - Receive-Show-Save Data in Windows Forms Application Part 1-2// keyword search youtube
  • Save Dialog : C# Beginners Tutorial - 44 - SaveFileDialog // keyword search engine
  • Split Data in : split - C#, splitting serial data and displaying in separate textBox's - OK // keyword search engine
  • Read Data : http://www.dotnetperls.com/streamreader
  • Serial Button : Aplikasi Komunikasi Serial pada PC Menggunakan Visual C# 2010 _ Express _ WanGReadY

Step 7: Try It

Maybe is far from perfection, but complete interface is on attached file. after unzip in on C: , unfortunately this only run on windows. Feedback and any gift of idea is welcome,

thank you for reading :) and enjoy to count laps your car

Sensors Contest 2016

Participated in the
Sensors Contest 2016

Robotics Contest 2016

Participated in the
Robotics Contest 2016