How to detect rotation and turn on a circuit - Page 1
Forum section: electronics / beginners

author: Spemo
author_rank: Regular Contributor
timestamp: April 18, 2021, 10:11:47 am
content: Hello once again,I have another question... I hope you don't mind.Here is what I'm trying to do:I need to sense the rotation of the pedals on my bicycle, and the output signal of that sensor is supposed to activate a relay once there is rotation.So if there is rotation -> relay on, no rotation -> relay off.I have found what is in the attached picture, which looks like it's a hall effect sensor and a disk with magnets which is supposed to spin in front of the sensor.So I have the first part of the solution, but whatelse do I need to make it work?what do I need to do here?Is there an easy solution to this problem?Thank you for your timeDaniel

author: shaheansar
author_rank: Contributor
timestamp: April 18, 2021, 11:00:30 am
content: If you just want something that detects rotation, you can use a tilt switch and an RS latch (A CD4044BE might be good), and reset the latch with an RC discharge circuit followed by a schmitt trigger (Or using a 555 timer in monostable mode).The latch output will be on if rotation is detected and off if it isn't.

author: Spemo
author_rank: Regular Contributor
timestamp: April 18, 2021, 11:46:18 am
content: Thanks for your input, sadly my knowledge isn't good enough to have any clue about what you're talking aboutI have done some more research, and basicly I need something that takes a sqare wave signal, let's say 0-12V, which gets pulsed b a reed switch and magnets, and convert it into a solid DC signal.But it also has to keep the output signal off when there is no rotation, and the input signal is still highDoes that make any sense?

author: MarkF
author_rank: Super Contributor
timestamp: April 18, 2021, 12:10:40 pm
content: A 555 Timer configured in the monostable mode is the simplest.You set the RC time constant for the amount of time you want your relay to stay ON after rotation stops.The time constant must also be longer than the time between the pulses from the sensor.Take a look at this article:https://www.electronics-tutorials.ws/waveforms/555_timer.htmlMonostable configuration:You may need a transistor on the output to drive your relay (i.e. coil instead of lamp, motor, speaker in example).See the end of the article for NPN and PNP transistor options.You could also use a MOSFET.

author: Spemo
author_rank: Regular Contributor
timestamp: April 18, 2021, 12:33:21 pm
content: Perfect!This is exaclty what I was looking for, thank you very much!

author: shaheansar
author_rank: Contributor
timestamp: April 18, 2021, 01:26:33 pm
content: Do keep in mind that you'll need a flyback diode if you're driving a relay or motor

author: Renate
author_rank: Super Contributor
timestamp: April 19, 2021, 02:20:35 am
content: That 555 circuit is not going to work.Even with continuous rotation there are going to be glitches every timeout.Then there is the problem that it will do that if you left the sensor in the wrong position.You could disconnect pin 7 (discharge), connect pin 2 to pin 6 and have your input signal discharge the cap.That would make it a missing pulse detector and not a monomulti.But then you have to process the input so it's never in a constant trigger position.You can just AC couple it or XOR it with an RC delayed input.The XOR could feed a transistor to discharge the cap.

author: james_s
author_rank: Super Contributor
timestamp: April 19, 2021, 02:58:08 am
content: Well there's another even simpler solution, use a cheap 8 pin microcontroller such as the attiny12. Lower component count than the 555 circuit and you can write the code to behave any way you want.

author: CatalinaWOW
author_rank: Super Contributor
timestamp: April 19, 2021, 04:00:37 am
content: Depending on how much motion you will allow (or how little you need to detect) a really old school approach may work. Just put an old school generator on the bike. These had a friction wheel that contacted a bike tire and would run headlights or other accessory when the bike was moving. While this was (and is) bulky and introduced significant friction to the ride, it also provided real power to run the low efficiency lamps of the day. A much simpler and smaller version of the same thing could direction operate a low power relay.You might want to think about this problem in two broad ways. In one general class you have a battery or other power source operating a sensing circuit, which might be as simple as a friction paddle or reed switch, up through optical interrupters which would detect the periodic blockages caused by spokes and on to complex systems like the optical sensor like that in a computer mouse which would detect motion of the tire. The other general class would use power collected from motion of the bike to generate the detection signal. Generators, induction sensors, and piezo devices might fit in this category. Each class has advantages and disadvantages, and each approach within the class also has similar tradeoffs. The best choice will depend on your application and goals.

author: Renate
author_rank: Super Contributor
timestamp: April 19, 2021, 11:50:42 am
content: Quote from: james_s on April 19, 2021, 02:58:08 amWell, I was thinking of ATTiny85 (8 pin DIP) since I have a tube of them.But the point was the general discrete logic of how to implement this.Optical, hall effect, reluctance pickups, whatever. It's all about the same.Do you need/want to process both signal edges?The circuit I described above (using the 555 as a Schmitt trigger inverter) and discharging the cap on activity would work fine.Still, I kind of dislike the idea of a cap charging slowly and discharging instantly. Nothing discharges "instantly".Ok, in this case you could add a resistor to mellow the discharge.That would also be helpful in making it so that a single event wouldn't trigger the output.Whether this is useful/desirable is another question.If it's one pulse per revolution, you probably don't want that.Technically a capacitor is not a good state storage element unless the changes are gradual.A digital counter is much better.A rotation event would reset the counter.The counter stops when it reaches a value (probably a single high bit).Your output signal is that high bit complimented.

author: rstofer
author_rank: Super Contributor
timestamp: April 19, 2021, 04:07:48 pm
content: Quote from: Spemo on April 18, 2021, 11:46:18 amA lot depends on how you define 'turning'. Let's say you had 1 magnet on the sprocket and you had a reed relay or other sensor on the frame. It could take as long as a full revolution to get a pulse. That could take a long time (days) between pulses if the pedal motion was slow. The thing about waiting for the next pulse is that it may never come so you have to decide how long to wait before deciding that the pedals aren't turning.OK, 'days' isn't the proper time base but the idea is that seconds might not be either. You have to decide how this will work out. One solution is to add more magnets. That will pick up the slower rotations but there is an upper limit to the operating speed of the reed relay.I like the generator approach given above. Rather than a massive generator, use a small DC motor like those in robotic toys. Some will generate 12V at 10,000 RPM and we need 0.7V so somewhere around 500 RPM as a minimum. That's going to be pretty easy with the front wheel as large as it is and some small rubber tire on the motor shaft. Some calculation on the maximum wheel RPM and maximum generator RPM will give an optimum size for the generator wheel.The generator will start generating 'some' voltage with very little rotation. Detecting that voltage should be fairly easy. You might just run the generator output, filtered by some capacitor, limited by a zener and resistor (?), into the base of a transistor that is controlling the relay. No uC required. I don't know how the lower end of rotation will work out. You only need to get to 0.7V to turn a transistor completely on. Or you could run it into an op amp or comparator and measure much smaller voltages.

author: rstofer
author_rank: Super Contributor
timestamp: April 19, 2021, 04:10:18 pm
content: A conventional generator:https://www.amazon.com/Motorized-Generator-Alternating-Headlight-Taillight/dp/B07D34NBCN

author: CatalinaWOW
author_rank: Super Contributor
timestamp: April 19, 2021, 05:04:51 pm
content: Quote from: rstofer on April 19, 2021, 04:07:48 pmYour comments and questions lead directly to the real question. What is the OP trying to do? Is he trying to monitor how fast the pedals are spinning (cadence)? Is he looking to implement a speedometer function that is less of a problem when changing wheels? Is this a theft detection approach? Is he just looking for a fun way to learn some electronics? Motivation by a "real" world application. The best answer and best advice will result from knowing answers to those questions.