Speed Sensor Input to PICAXE Microcontroller

Beagle123

10 kW
Joined
May 2, 2007
Messages
620
Location
Los Angeles
Hi:

I'm developing a dual-motor ebike with a low speed and high speed motor. I'm programming the throttle inputs using a PICAXE chip. However, I need to be able to have a speed (rpm) sensor, so I can maximize efficiency of the motors.

I have a hall sensor and a magnet already, and I can read RPMs by using the count command:

count pin5, 1000, w0

This would count the number of times the magnet passed the sensor in one second, and store the value in a variable, w0. The problem with this is that my program freezes while it waits for this count. I can't just shorten the time period because when the bicycle wheel is traveling at 10mph for example, I'd need at least few seconds to accurately measure a few turns of the wheel.

It occurred to me that there is already lots of electrical pulses in the motors that will very accurately report the speed. There are electrical pulses in the motor's sensors that fire many times for every turn of the wheel. For example, if a motor had 21 magnets in it and a gear ratio of 5:1. Then the sensors would fire 105 times (21 X 5) for each revolution of the wheel. Right?

Can I just "tap-into" those pulses, and input into a pin on my microcontroller? Since there are 3 sensor wires each one should fire 35 times per revolution of the wheel (105 / 3)

Another option could be to use one of the power wires leading to the motor. If I tapped into a power wire it should be carrying a high voltage pwm signal 35 times per revolution. If I made a voltage divider with a 10K resistor and a 5v zener diode, it would reduce the voltage down to 5v. Then I could even the signal using capacitors. (Or maybe a diode then capacitor first.)

Does anyone know exactly what's happening with these motor wires and how I can use them to get a RPM reading?

Thanks,
Eric
 
You can use any one of the hall sensors in the motor. If you're lucky you can use the controller's 5v supply to the hall sensors to power your PICaxe. Any of the other three wires on the 5 pin connector will give you a pulsing output to count. I'd use a normal cycle computer to measure the speed of the wheel while you count the pulses, then you can convert directly into your program, so you don't need to know the number of poles and magnets.
 
Hi d8ev:

Thanks for your help. I can tap the pulses in the hall sensors?!?! Cool!!! That makes my life much easier. I was planning on using the +5v wire from the throttle to power the PICAXE. Do you think that will work better? While developing, I may also need to run an LCD that takes about 20mA too. I don't know if that would tax the +5v line too much. What do you think?

I bought a clunky yescom motor today as my guinea pig, so now I can actually try these ideas.

I looked at your bikes. Excellent job. I'm particularly interested in your dual Q100 build. I'm trying to build a dual motor bike that's very similar to yours. Any advise you can give me would be much appreciated. I think you made an excellent choice choosing higher C rate battereis (Headway) to keep your pack size down. It makes the bike look very polished without huge battery packs. I'm sure I'll try to follow in your footsteps on that issue.

Please tell me the types of Q100 motors you're using. Do you have a build thread? Are they fast wind? or slow? What type of rpms do they output? Are they the same?

On my build, I'm hoping to use two different motors: a high rpm motor in a 26 inch wheel in the front and a low rpm 24 inch wheel in the back. This should give me essentially two gears--low and high. Both motors will be cute gearmotors, so they will freewheel when not being used. Its easy to find a good high speed motor, but I'm having trouble finding a really low speed one. The low speed on is really critical too. I need something that goes perhaps 15mph on 48v. Any ideas? The basic idea is that the low speed motor will handle the majority of the work up to 15 mph, then turn off and freewheel after that. The PICAXE will manage the throttles.

Please let me hear all ideas.

EDIT: Just found your response. I'm reading it now:

High speed and low speed Cute Q100 builds:
http://endless-sphere.com/forums/viewtopic.php?f=3&t=49691

Eric
 
Interesting ideas.

The 201 rpm Q100 runs to about 15mph on the road at 36v. It's best climbing power is when it's doing about 7mph. It's happy at that speed, but it's efficiency will be down, so it'll heat up if you keep it like that for a prolonged period. The slowest small motors I've seen are some Bafang SWX types that are designated 185 rpm, but they don't seem to be any slower on the road. The Bafang's best climbing power seems to me to be at a slightly higher speed than the Q100.

The 328rpm Q100 runs well above 15mph, but for me doesn't really have enough power to accelerate the bike on its own. I'm 100kg. It should be better for a lighter rider. I've built three 2WD bikes. The first had two 201 rpm Q100s. It climbs pretty well, but quite slowly. Top speed is just over 15mph. The second one had two 328 rpm ones. It was very fast and difficult to ride slowly. On a very long 10 - 12% hill, both controllers over-heated because they didn't get enough airflow, and they were basically maxed-out the whole time. Top speed was about 27 mph and it would cruise at about 25mph until hills slowed it down. It was doing about 15mph up the long 10%. The third bike has a 201 rpm Bafang on the front and a 328 rpm Q100 on the back. I've not done enough miles on it to give a full evaluation, but it definitely climbs better than with the single Bafang, and just when the Bafang's starting to gasp, you can use the Q100 to get reasonable acceleration until conditions prevent it's lowish power from reaching it's top speed (down-hill) of somewhere close to 30 mph.

These sort of experiments are interesting, but being honest, for the same weight you can get a nice 270 rpm Bafang CST rear geared motor that will climb a lot better, and still give a reasonable speed of about 22mph. You also get a lot more mid-range power.

I'm not sure how much power you can take from the 5v regulator. I've heard that for some controllers, it's a bit marginal. Some people have successfully run PICaxe chips for their throttles, but I don't know anybody running a LCD display as well. Best to try it and see how you get on. It makes no difference where you pick up the 5v. All the 5v is supplied from the same regulator, which gets it's supply from a 12v regulator. There's a schematic here:
http://www.avdweb.nl/Article_files/Solarbike/Motor-controller/China-BLDC-motor-controller-36V-250W.pdf

It might be possible to splice another 5v regulator in parallel to the one in your controller as a supply for your Picaxe.

Here's my build thread for the first 2WD I built:
http://www.pedelecs.co.uk/forum/electric-bicycles/12481-rocky-mountain-element-conversion.html
 
Back
Top