Go Down

Topic: shortest code for techometer using reed switch (Read 707 times) previous topic - next topic

gangradesudarshan

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

AWOL

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


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.

gangradesudarshan

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

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

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

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.

gangradesudarshan

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

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)


Go Up