Tachometer for my bike #1695
Replies: 22 comments
-
Posted at 2016-08-17 by Zicog The Puck has a magnetometer (compass), it can detect a magnet nearby. So a magnet on a wheel could be used to count the rotations. No reed switch or other hardware required. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-17 by @gfwilliams Sounds like a great idea! The magnetometer on the Puck is handy, but it only outputs readings 80 times a second. I did a quick check and at 20 km/hr a typical wheel should be rotating 2.5 times a second, so it should work well enough. However, when running at that speed it draws a bit of power (1mA, so only 200 hrs battery life), so you'd have to be careful to only turn it on for high speed readings when it thought the bike was moving. In many ways just using a reed switch (especially if you used one off a cheap bike computer that's all set up for it) would be easier. You then don't have to worry about power consumption at all, as Puck.js will only wake up when it detects the input change state. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-17 by avanc Both sound very promising. Do the IO ports have internal pull-up or pull-down resistors? How should the reed contact be connected to the Puck for lowest power consumption? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-17 by @gfwilliams
Yes, they have both - and they're switchable with software - simply use
Yes, absolutely. Stuff like setWatch and pinMode are identical.
Not in terms of how you write the software. Just define the pins you're using as variables right at the top of your code ( |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-17 by @allObjects I see the convenience of using the magneto meter... but what about having a deep sleep with a setWatch() on a pin with a coil connected (...of course with reverse voltage and spike suppression)? Would that not yield a better battery life? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-17 by avanc First prototype is working :-)
My new bike computer cable will arrive on Saturday. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-17 by @allObjects ...you may actually vary your interval depending on your cal culated speed... within the counter loop... Since the event knows about the time since lat event, you can speed up or down... and extend battery life... and even more sophisticated: intervalling based on the increase/decrease of the acceleration and deceleration... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-18 by @gfwilliams Great! Actually, if you looked at the time between pulses, rather than the number of pulses in a period, I guess you might get a more accurate speed value?
Hmm, maybe - but then why not just use a reed switch instead of the coil and you could do everythig, with great battery life :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-18 by @allObjects
dooohhhh... the 'mechanic' version of hall switch / magneto'meter' / magneto-schmitt-trigger! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-18 by avanc Sorry, I don't understand the discussion regard reed switch or not. I modified the code so that the interval timer is deactivate if the speed is 0. It's activated again by the first rotation: https://github.com/avanc/espruino-tachometer/blob/master/tachometer.js @gfwilliams: Is it not cheaper to calculate the speed just every few seconds than adding more logic into each wheel turn? In addition, caluclating the time in the watch function, I get some problems:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-18 by @gfwilliams
Well it would be if your wheel was turning quickly, but I think the maximum speed it'll do is around 5 revs per second, so it's not a big deal. IMO the problem is because it's not turning that fast, it's hard to accurately tell what speed it's going just by counting rotations. Suppose it is going round 5 times a second, and you test every 2 seconds - that means you'll only have counted to 10 - so the speed you're getting is only 10% accurate. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-18 by @gfwilliams
Yes, but it's easy enough to work around?
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-18 by @allObjects
Absolutely, but you can go for a middle ground: you just store the times away and keep doing what you do every 30..60..90 seconds. This way you do insignificantly prolongate the power-on state per wheel rotation, but have good data to calculate / prep/ update (prep an update) for a graph in desired intervals and may be show it graph on a nokia 5110 (or better) on demand... managing the back lighting accordingly... Don't know the e-paper power consummation on update... (see e-paper GDE021A1 display). |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-18 by avanc Thank you both for the quick responses. Adding an e-paper is also an interesting idea. I have to see were to get one :-) A general question on using Espruino:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-19 by @gfwilliams Nice idea removing
The only bad point is that if you had an LCD or some external hardware that needed initialisation, you'd still need onInit to handle that. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-21 by avanc Hello, this weekend I got my reed switch from Sigma and connected it to my pico (GND and B3). As proposed, I set the pin to input_pullup and wrote a basic watch function:
Now I get some strange behaviours with different options: edge: 'rising', debounce: 10 edge: 'falling', no debounce edge: 'falling', debounce: 10 Not exactly what I expected. Am I right that it seems that the reed switch only closes very short but not keep closed while the magnet is next to the sensor? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-21 by avanc Just for completeness: I did a clearWatch() before each evaluation to be sure there is no other event listener. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-21 by @allObjects ...I'm baffled... I could understand some bouncing... but that is weird...
In our case you get a rapid sequence of ons and then nothing for a while... if you just take the first one and ignore all others within a particular time frame. Not an elegant solution, but it may work, since you know that it is a wheel that can run only within a particular speed range. Debouncing is not an easy thing, as other users noticed in their conversations: here (1) and here (2). |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-22 by @gfwilliams A reed switch will tend to 'bounce' because it's a mechanical contact. What can happen is that it bounces so fast that the underlying hardware detects a change, but by the time the software gets to check the pin state it has changed again. If you're using You're storing lastTime anyway, so it should be pretty easy:
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-22 by avanc Thanks for the hints. I got it working with the 50ms downtime. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-22 by avanc Interestingly, BT LE already provides a service for Cycling Speed and Cadence Service (CSCS). I collected some information: Looking forward for information on the Espruino JS interfaces for Bluetooth LE :-) I'm still confused, how pairing is done in general and how to define GATT services. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-23 by @gfwilliams Nice - it should be pretty easy to get Espruino to output to CSCS, and then (hopefully) it'll be compatible with other cycling apps. It depends what you want though - if you're just trying to communicate with your own app (web or not), you might find that you're making more work for yourself by trying to adhere to the Bluetooth standard :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-08-16 by avanc
Just want to share my idea, what I gonna do with the Puck when it arrives:
Last week, I bought my new bike. Normally, I don't need a tachometer. But I'm still interested, how much kilometres I have ridden the past year.
So my idea is to connect the Puck to a reed contact and count the wheel ticks. If needed, I can use my smartphone to read out the kilometres.
Beta Was this translation helpful? Give feedback.
All reactions