Pedal assist speed sensor - detect back pedalling

Get all your technical information about electric bikes here.
Post Reply
Roncos   1 mW

1 mW
Posts: 19
Joined: Oct 08 2016 5:03am

Pedal assist speed sensor - detect back pedalling

Post by Roncos » Oct 08 2016 5:17am

I'm researching a diy ebike project. Today I'm looking at speed sensors. Planning to use teensy 3.2 as microcontroller.

I think the cheap sensors (like the one at the link below) cannot tell direction of rotation. Is this true? I would like to be able to detect back peddling. How do other projects deal with this? Is there an alternative sensor? Easy mod to this sensor? Extra magnet? Or can direction be inferred somehow?

Thanks

Ron

http://www.ebay.co.uk/itm/33-5-Electric ... SwAuZX3Oad)

d8veh   100 GW

100 GW
Posts: 5501
Joined: Dec 10 2010 10:45am
Location: Telford

Re: Pedal assist speed sensor - detect back pedalling

Post by d8veh » Oct 08 2016 6:09am

They only work in one direction, but you can reverse the direction by flipping the magnet disc so that it rotates in the other direction. if you want to detect both forward and reverse pedalling separately, you can use two of those sensors, one on each side.

Roncos   1 mW

1 mW
Posts: 19
Joined: Oct 08 2016 5:03am

Re: Pedal assist speed sensor - detect back pedalling

Post by Roncos » Oct 08 2016 6:30am

d8veh wrote:They only work in one direction, but you can reverse the direction by flipping the magnet disc so that it rotates in the other direction. if you want to detect both forward and reverse pedalling separately, you can use two of those sensors, one on each side.
Thanks for your answer. Are you sure about this? If the sensor is a simple Hall effect sensor then it should work equally well in each direction but not know the direction. How can it ignore the magnets in one direction? What does the physics/ electronics inside the pick up look like?

User avatar
teklektik   10 GW

10 GW
Posts: 4020
Joined: Mar 26 2011 1:15pm
Location: CT, USA

Re: Pedal assist speed sensor - detect back pedalling

Post by teklektik » Oct 08 2016 10:21am

First, the unit that you linked has only 5 magnets - not a good choice. Go for a 12 magnet unit that will allow you detect start/stop pedaling with less crank rotation.

Next, there are two types of PAS units - with either one or two halls. The incredibly cheap models have a single hall and pulse when pedaling in either directon. The better models use the second hall to condition the output so you only get pulses in the forward direction. Unfortunately, in your case you wish to actually get a signal in the reverse direction AND be able to determine direction.

However, if you start with one of the better 2-hall units this capability is easy to obtain by bypassing the internal logic (which is pretty simple-minded) and routing the output of both raw hall signals to your uproc directly. You can arrange/leave pull-up resistors in the sensor head or add them to the chip input ports.
Here's a post about doing that mod on my Mundo build.

80-12_reworkedPasPickup.jpg
Two halls (black blobs) re-wired to two output leads.
80-12_reworkedPasPickup.jpg (15.39 KiB) Viewed 1690 times

The two halls are offset less that the inter-magnet offset and so generate a quadrature signal like this:
QuadratureEncoding.png
Sample quadrature encoding from CA V3 Unofficial Guide
QuadratureEncoding.png (2.44 KiB) Viewed 1690 times
As you can see, it's pretty simple to determine the direction by using the RPM signal to enable logic that looks at the direction of transition of the DIR signal (i.e. scan the image right-to-left (REV rotation) vs left-to-right (FWD rotation) and eyeball the red line transition only while the green is high).

Easy-peasy. :D
Visit Grin Technologies at www.ebikes.ca
Build Thread: 2WD Yuba Mundo V4

docw009   100 kW

100 kW
Posts: 1081
Joined: Aug 02 2015 7:43am
Location: Chicago area suburbs.

Re: Pedal assist speed sensor - detect back pedalling

Post by docw009 » Oct 08 2016 11:13am

Nice post, Telektik. Very well done solution.

I've only owned the three wire Hall sensors that only has one signal output, so presumably only have one sensor. They have puzzled me ever since I installed my first PAS sensor.

I put that one on the non drive side, and it just happened to work right. Much later, when I went to grease the BB later and inadvertantly flipped the disk, the controller only detected the cranking if I spun it backwards. It figured that the disk had an arrow, and I had to have it spin the right direction. Must have to do with the polarity of the magnetic field.

The next one, I figured I had better put on the drive side. I did, and the disk had no arrow, but I faced the shiny side toward the sensor and it worked.

Now I am at my third sensor. I put it on the non drive side because I didn't want to pull off the crank arm. I played with it off the bike. It seemed like it only worked if the magnet came in toward the pointed end. So I mounted it that way. Then I saw that to work right, the arrow was pointing the wrong way. It's OK. I'll take it. The controller does not detect backward pedaling either.
pas_4.jpg
pas_4.jpg (165.62 KiB) Viewed 1697 times
Finally, my last usage of the orange PAS sensors was as a speed sensor on a rear wheel. I fiddle with it til I get a speed reading. When I'm done, I realize that the magnet comes in from flat end. OK. I'll take it. it works. Today, I learn something new. My controller reads the speed if I spin the wheel backwards too. Remember, this is a different input, not the PAS input.
P1510292.jpg
P1510292.jpg (188.56 KiB) Viewed 1697 times
I could go and think about this info. I worked in semiconductor physics years ago. It's all hazy. If I ever build another ebike, I will just continue to fiddle with the PAS mounting til I get it working right.

User avatar
teklektik   10 GW

10 GW
Posts: 4020
Joined: Mar 26 2011 1:15pm
Location: CT, USA

Re: Pedal assist speed sensor - detect back pedalling

Post by teklektik » Oct 08 2016 5:42pm

Yep - the two hall units only have one output that is conditioned internally by the second hall to work cranking only one way. Because there's only a single output, folks think there's just a single hall in there, but there's a little more going on than meets the eye... :)
Visit Grin Technologies at www.ebikes.ca
Build Thread: 2WD Yuba Mundo V4

Roncos   1 mW

1 mW
Posts: 19
Joined: Oct 08 2016 5:03am

Re: Pedal assist speed sensor - detect back pedalling

Post by Roncos » Oct 09 2016 5:48am

Thanks all. Great info... much appreciated.

R

d8veh   100 GW

100 GW
Posts: 5501
Joined: Dec 10 2010 10:45am
Location: Telford

Re: Pedal assist speed sensor - detect back pedalling

Post by d8veh » Oct 12 2016 7:07am

It's the double hall ones that are handed, so be careful. It's the 12 magnet PASs that often have the double hall sensor. On a single hall one, the orientation and direction of the magnet affects the signal patern, which is how the controller can see the direction. Single hall ones are not handed, which gives you more fitting options.

User avatar
ABritInNY   100 W

100 W
Posts: 116
Joined: Jul 12 2015 1:55pm

Re: Pedal assist speed sensor - detect back pedalling

Post by ABritInNY » May 26 2018 4:39pm

In NYC all throttle Ebikes are illegal, only class 1 ebikes, pedelecs are immune, but throttle is very necessary from a stop on heavier/(+fast) ebikes. When the light goes green, car traffic gets impatient with slow to get going bikes and struggling to get away to a decent cadence can be difficult when drivers start getting silly and honking/swerving around :( and much more so if you forgot to gear down before stopping and don't have a CVT or IGH that can shift from standstill!
To that end I noticed that the cheapo single hall PAS, (biggest I've seen was 12 magnet,) will allow the forward signal on a freewheeling backpedal ;) so with an auxiliary PAS grin up/down switch (and updated aux input firmware) I can moderate my takeoff power how I like and reduce power for comfortable cadence (or phantom/ghost pedal to accelerate, which although a little different to most people's standard PAS programming, is nevertheless a workable PAS as throttle workaround, if not quite a 'mod.'
EEB frame set, 1500w Leafmotor 4t winding, Powervelocity 18fet/Lyen 18 fet 4110 ESC, 24s 30ah prismatic cell Lifepo4 batt w/60a-120a BMS, CA V3, Dropper Seat post.
Fusion 48v AGM (4x 12v 15ah) 1000w nom DD rear hub, 50a max ESC, 21sp FS Genesis overkill 650b conversion
Kayman Flash+ 350w Mxus geared hub, dual 36v 5.2ah batts 10.4ah 13a-15a ESC
Freway Vr01, 27sp Pedelec 250w Bafang geared hub, (2x) 36v 5.2ah batt, FVS ESC limited to 10a!! (yup sloow on roads but great on trails ;)

User avatar
teklektik   10 GW

10 GW
Posts: 4020
Joined: Mar 26 2011 1:15pm
Location: CT, USA

Re: Pedal assist speed sensor - detect back pedalling

Post by teklektik » May 26 2018 6:03pm

Clever workaround!

If you want to go for a bit faster response (more magnets), you could use one of the new Grin 24 magnet sensors, disconnect the direction pin (DIR), and configure the CA for 1-wire operation. The disconnected pin will go high and will always report the same direction so the CA will use the RPM pin regardless of which way you actually pedal.
Visit Grin Technologies at www.ebikes.ca
Build Thread: 2WD Yuba Mundo V4

Post Reply