Go Down

### Topic: shortest code for techometer using reed switch (Read 1 time)previous topic - next topic

##### Aug 03, 2013, 08:01 pm
i want the shortest possible  code for tachometer using reed switch. plz help

#### AWOL

#1
##### Aug 03, 2013, 08:39 pm
Don't use a reed, they bounce.
Use a digital Hall effect.

Where is your code so far?
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

#### Grumpy_Mike

#2
##### Aug 03, 2013, 08:55 pm

i want the shortest possible  code for tachometer using reed switch. plz help

Why is it for a compertition?
Short code is very often the most difficult to read and understand.

#3
##### Aug 03, 2013, 09:04 pm
actually i want to measure the speed of my bicycle using arduino, and i have ready made reed switch assembly available to be placed on bicycle

#### robtillaart

#4
##### Aug 03, 2013, 09:08 pm
Code: [Select]
`uint32_t x;float d=1;void setup(){}void loop(){if(digitalRead(4))x++;Serial.println(x*P*d);}`
Can't make it shorter than 1 line
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### johnwasser

#5
##### Aug 03, 2013, 09:13 pm
Connect the reed switch through a circuit that will produce a fixed-length LOW pulse.  In the example below the LOW time has been determined experimentally to be 3446 microseconds.  Add the LOW time to the HIGH time measured by 'pulseIn()' to get microseconds per revolution.  Divide that into microseconds per minute (60 * 1000 * 1000) to get REVOLUTIONS PER MINUTE.

Code: [Select]
`int RPM = 60000000UL / (pulseIn(5, HIGH)+3446);`

Because of the LOW pulse time the maximum measurable RPM is around 17,000.  How short a LOW pulse you can use depends on the bounce time of your reed switch.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

#### AWOL

#6
##### Aug 03, 2013, 09:16 pm
Quote
the maximum measurable RPM is around 17,000

It's a bicycle - that's unlikely to be a problem.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

#7
##### Aug 03, 2013, 09:19 pm
thanx... and from this speed i want to drive a high torque servo motor which is connected to the gear shifter. so at regular speed interval gear shift can be achieved.  so please provide me with an ultra responsive code which would perform this job perfectly.  Assume every gear shift at 10 degree of servo rotation for every increment in speed of 5 km/hr

#### robtillaart

#8
##### Aug 03, 2013, 09:25 pm
Quote
thanx... and from this speed i want to drive a high torque servo motor which is connected to the gear shifter.

OK,

Quote
so please provide me with an ultra responsive code which would perform this job perfectly. Assume every gear shift at 10 degree of servo rotation for every increment in speed of 5 km/hr.

Sorry, helped you to get started, now it is your turn to do some coding (we help people here to help themselves)

After a serious try you can post your code and we will help you to make another step.

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#9
##### Aug 03, 2013, 09:43 pm
thanx  i undestand

Go Up

Please enter a valid email to subscribe