Replacing PAS with a push button

Joined
Jul 1, 2022
Messages
10
Hi all, as the title states, I am trying to replace the pas (hall sensor and magnets) with an arduino signal output at the push of a button. Is it possible to mimic the signal as shown in "full pedal graph.png" using pwm on the arduino or am I out of luck? also the ESC supplies the hall sensor with this am signal.

###this first post is full of errors scroll down for the results
 

Attachments

  • forwardvreverse5v.png
    forwardvreverse5v.png
    22 KB · Views: 690
  • full pedal graph.png
    full pedal graph.png
    118.2 KB · Views: 689
  • no pedal graph.png
    no pedal graph.png
    129 KB · Views: 688
  • PAS.png
    PAS.png
    844.5 KB · Views: 690
If you can emulate the signal it puts out, it would work just as if you were pedalling, even when you're not, if you disconnect the PAS and connect just the output of the emulator. It may also work with the two outputs paralleled, so you can have htem both and use whichever you need, if you prefer (but you might have to use a switch to toggle between them).

The controller uses filtering on the input(s), either in hardware or software, to "block" noise signals below whatever threshold was deemed necessary by the designers. Sometimes it isn't good enough and spurious signals come thru, which is probably one reason why devices like this may use signals that are specific lengths of off vs on, etc., because noise is unlikely to ever trigger such an input (though it could prevent correct input from reaching the controller, at least it wouldnt' ever accidentally turn on because of the noise).


This page:
https://ebikes.ca/getting-started/pas-options.html
may help with determining the signal you need to create, though you probably ahve to experiment with actual pulse lengths on vs off.
 
amberwolf said:
The controller uses filtering on the input(s), either in hardware or software, to "block" noise signals below whatever threshold was deemed necessary by the designers. Sometimes it isn't good enough and spurious signals come thru, which is probably one reason why devices like this may use signals that are specific lengths of off vs on, etc., because noise is unlikely to ever trigger such an input (though it could prevent correct input from reaching the controller, at least it wouldnt' ever accidentally turn on because of the noise).

Hey, Thanks for replying.

It turns out that I connected the Analog input to the arduino without grounding it. So it seems that whatever noise and signals were comming from the arduino itself. It also looks like I was probing the wrong pin from the 3 pin hall.

I recorded the signals again, this time connected to the correct Vout pin of the hall and got a few more graphs which indicate that this is a varied width PAS - https://ebikes.ca/learn/pedal-assist.html. And now replicating the signal doesn't seem so difficult

Overall, seems as if i'd made some rookie mistakes, not helped by the julet connectors from which i had to guess which pins were which. :wink:
 

Attachments

  • fewmoregraphs.png
    fewmoregraphs.png
    1.5 MB · Views: 617
  • wiring_hall2a1.png
    wiring_hall2a1.png
    26.9 KB · Views: 617
Everybody makes mistakes, even me. ;) As long as we don't keep making the same one every time, it's not so bad. :oops:

When you do get this working, would you be willing to post your code and schematics? There have been a number of people over the years that would like to do what you're doing, but that don't have the skills to come up with it (though maybe they could build it and flash a nano with it; that's about the level I'm at with these things).
 
I'm at a loss regarding the object of this exercise? I get you want to replace the PAS sensor with a push button, but with most PAS systems being so basic/simple, I'm left wondering why you might want to to that?

Is this some sort of system that doesn't have the ability to handle a throttle? That being the case, wouldn't it be simpler to figure out a way of installing one of those?
 
AHicks said:
I'm at a loss regarding the object of this exercise? I get you want to replace the PAS sensor with a push button, but with most PAS systems being so basic/simple, I'm left wondering why you might want to to that?

Is this some sort of system that doesn't have the ability to handle a throttle? That being the case, wouldn't it be simpler to figure out a way of installing one of those?
Not knowing the OP's intentions, some thoughts on the matter from my own experiences:


Some PAS-only controllers simply don't have a throttle input. Their MCUs are not designed to read one, so there is literally no way of adding one.

Some controllers require you to pedal for the throttle to be enabled. If you're not pedalling, the throttle doesn't cause the system to operate.

It may not be possible to change the controller out to alter either of those behaviors.

As an example, if it's an OEM bike with integrated controller/battery/etc where there is communication between the parts that it won't operate without, and is desirable to the rider because of say, battery built into frame or custom frame shape case, etc., it's not even possible to change out the controller without heavy modification of the whole system, or even replacing all of it, which basically means throwing away the entire bike and starting over with a completely new one....


There are several reasons I can imagine for doing this sort of modification the OP is asking about, and I'm sure there are others (all of the ones listed below are things I've personally encountered with typical PAS systems, except for 6 which is a problem someone had here on ES at some point, and 7 which is still a valid reason even if not one I'd use):

1: PAS system is on/off, and doesn't have an appropriate assist level for the rider's specific use-case: one assist level is too low, not enough assist, but the next assist level is too high and zooms away. So the rider trying to pedal normally either doesn't get enough help for their personal needs, or they get so much help that the bike goes too fast for their riding situation, forcing them to constantly start/stop their pedalling, instead of having a smooth cadence and a nice ride.

2: Rider has problems pedalling, for whatever reason, and needs a "go button" that helps them continue when they can't pedal.

3: There are traffic or other situations where the usually-primitive-on/off-PAS-control most systems have is dangerous or unhelpful, where the rider needs instant manual control of the power assist, while still continously pedalling to control the bike's speed precisely, and engaging the motor as needed to help them do things they simply can't do without it.

4: Throttles aren't always the solution; sometimes holding a throttle at a specific position all the time is painful or otherwise just not possible for some people; you can't shift your grip around much or at all while maintaining the throttle position. A "go button" could be placed nearly anywhere, or even have several of them available, wired in parallel, so that any of them can activate the assist, whether by hand or foot or even your butt on the seat or your chin in a helmet, etc. Even voice-activated if necessary (chips for voice recognition and control cost about a dollar or two these days, and are easy to integrate into little bitty arduino and similar systems).

If the PAS is required to make the system operate, then emulating the PAS would be required to activate it even if the actual control of the system is still done via throttle, and the "go button" also sends a specific throttle voltage to the controller.

5: For systems that require pedalling to activate the throttle, if the rider can't pedal for whatever reason, *or* doesn't want the pedals to make the throttle active under some (or all) situations, for whatever reason, then a "go button" to activate it instead would be helpful.

6: Riding conditions might even make the PAS sensor itself unreliable (dirt, mud, vibrations, etc., frequently interfering with or causing misalignment of magnets to sensor, or other problems), and if the system has some form of integrated sensor that can't be replaced with a different one that's better, a "go button" might be the only solution if that PAS sensor input is required for the controller to operate (in whatever mode(s) it has).

7: Rider just doesn't want to have to pedal at all, but PAS is required to make the throttle work, and changing to a different controller isn't possible for whatever reason.
 
amberwolf said:
[

1: PAS system is on/off, and doesn't have an appropriate assist level for the rider's specific use-case: one assist level is too low, not enough assist, but the next assist level is too high and zooms away. So the rider trying to pedal normally either doesn't get enough help for their personal needs, or they get so much help that the bike goes too fast for their riding situation, forcing them to constantly start/stop their pedalling, instead of having a smooth cadence and a nice ride.

All perfectly logical, except this piece. It confuses/mixes the PAS sensor's function/purpose with controller functions. Anything having to do with speed is not within the realm of the PAS sensor.

The PAS sensor senses the crank motion, that's it. The CONTROLLER may count the first few pulses from the PAS sensor to allow power to the motor. This is true for some, but not all throttles as well.

STILL curious about the OP's reason for this exercise. Not trying to be critical, just curious....
 
It works bros :D

My reasons for wanting to bypass the PAS is because:
1) the PAS is on/off on my bike so the power is inconsistent and makes the pedaling too light or too hard (it cuts out while pedalling because it expects a signal at a constant rate despite road elevation changes)
2) The esc does not support a throttle. I did look into replacing it but I was put off at the idea of replacing all the connectors and having to buy additional bells and whistles when a push button would do the trick
3) also cruising just sounds cool
 

Attachments

  • bypass PAS.jpg
    bypass PAS.jpg
    1.3 MB · Views: 534
AHicks said:
amberwolf said:
[

1: PAS system is on/off, and doesn't have an appropriate assist level for the rider's specific use-case: one assist level is too low, not enough assist, but the next assist level is too high and zooms away. So the rider trying to pedal normally either doesn't get enough help for their personal needs, or they get so much help that the bike goes too fast for their riding situation, forcing them to constantly start/stop their pedalling, instead of having a smooth cadence and a nice ride.

All perfectly logical, except this piece. It confuses/mixes the PAS sensor's function/purpose with controller functions. Anything having to do with speed is not within the realm of the PAS sensor.

The PAS sensor senses the crank motion, that's it. The CONTROLLER may count the first few pulses from the PAS sensor to allow power to the motor. This is true for some, but not all throttles as well.

STILL curious about the OP's reason for this exercise. Not trying to be critical, just curious....

Here's a pushbutton solution, but electro-mechanical rather than electronic:

https://youtu.be/FAwKiXiQiLM?t=15
 
amberwolf said:
When you do get this working, would you be willing to post your code and schematics? There have been a number of people over the years that would like to do what you're doing, but that don't have the skills to come up with it (though maybe they could build it and flash a nano with it; that's about the level I'm at with these things).

yeah this can be setup with an arduino nano sending a signal from Digital pin 12 to the esc and Digital pin 4 going to the button. With regards to schematics and how to wire it up with julet connectors, bear with me, i'll post some diagrams over a few days.

For those wondering: the pas on-time for me was 100 milliseconds and off-time was 37 milliseconds corresponding to a duty cycle of 73% and frequency of 7.3Hz this may vary for you depending on your magnet configuration. I'll try to detail how to figure these values for your case (if you plan to follow along).
 
That looks like a fun little experiment with an Arduino. However, I suspect that by the time you get done soldering all that into a small waterproof enclosure and running a button to the handlebars it wouldn't be much more effort to replace the controller with one that supports a throttle. You could even install a CAv3 and a torque sensor bottom bracket to address your problem with PAS.
 
RunForTheHills said:
That looks like a fun little experiment with an Arduino. However, I suspect that by the time you get done soldering all that into a small waterproof enclosure and running a button to the handlebars it wouldn't be much more effort to replace the controller with one that supports a throttle. You could even install a CAv3 and a torque sensor bottom bracket to address your problem with PAS.

Maybe use the existing sensor and a square wave signal generator to create electromagnetic pulses. Less logic involved.
 
RunForTheHills said:
That looks like a fun little experiment with an Arduino. However, I suspect that by the time you get done soldering all that into a small waterproof enclosure and running a button to the handlebars it wouldn't be much more effort to replace the controller with one that supports a throttle. You could even install a CAv3 and a torque sensor bottom bracket to address your problem with PAS.


There isn't that much soldering, at most 4-5 wires. and connecting a button just requires long wires. The bike came from an OEM and includes a 9 pin shengyi dgw07 250w hub motor which may be compatible with the CAv3 but keeping the costs low was one of my objectives

I recon a cleaned up version would look like this:
 

Attachments

  • arduinoremovable.png
    arduinoremovable.png
    209.7 KB · Views: 479
E-HP said:
Maybe use the existing sensor and a square wave signal generator to create electromagnetic pulses. Less logic involved.



The arduino generates a square wave. having an electromagnet would be unecessary if it can send the signal directly to the esc.

In the first slide I said that the signal wire from the esc also outputs 5v but when i connect the ground of the arduino to the ground pin (from the esc) and take a voltage measurement, it only comes out to 2v. This means that a square wave with an amplitude of 3v goes to the esc from the arduino. I don't exaclty know why the potential differences goes from 5v to 2v. Can someone explain this?
But this 2v is enough to light an led (quite dimly) even when the arduino isn't sending an output signal of 5v.
 
Here is the completed tutorial
 

Attachments

  • Picture1.png
    Picture1.png
    314.1 KB · Views: 443
  • Picture2.png
    Picture2.png
    908.7 KB · Views: 442
  • Picture3.png
    Picture3.png
    404.1 KB · Views: 442
  • Picture4.png
    Picture4.png
    423 KB · Views: 442
  • Picture5.png
    Picture5.png
    153 KB · Views: 442
  • Picture6.png
    Picture6.png
    174.2 KB · Views: 442
  • Picture7.png
    Picture7.png
    219.3 KB · Views: 442
  • picture8v2.png
    picture8v2.png
    406.9 KB · Views: 420
  • Picture9.png
    Picture9.png
    51 KB · Views: 420
  • complete schematic v2.png
    complete schematic v2.png
    630.3 KB · Views: 420
  • arduinoA0.png
    arduinoA0.png
    624.2 KB · Views: 420
all the code here:

Slide 4:

void setup() {
//the setup routine runs once when you press reset

Serial.begin(9600); //initialize serial communication at 9600 bits per second
}

void loop() {
//the loop routine runs over and over again forever

int sensorValue = analogRead(A0); //read the input on analog pin 0

Serial.println(sensorValue); //print out the value you read

delay(10); //delay in between reads for stability
}

Slide 5:

const int BUTTON_PIN = 4; // the number of the pushbutton pin
const int LED_PIN = 12; // the number of the LED pin ###LED_PIN is the name of the signal pin going to the esc

int buttonState = 0; // variable for reading the pushbutton status

void setup() {
// initialize the LED pin as an output:
//###LED_PIN is the name of the signal pin going to the esc
pinMode(LED_PIN, OUTPUT);
// initialize the pushbutton pin as an pull-up input:
// the pull-up input pin will be HIGH when the switch is open and LOW when the switch is closed.
pinMode(BUTTON_PIN, INPUT_PULLUP);
}

void loop() {
// read the state of the pushbutton value:
buttonState = digitalRead(BUTTON_PIN);

// control LED according to the state of button
if(buttonState == LOW) {
// If button is pressing
digitalWrite(LED_PIN, HIGH);
delay(100);
digitalWrite(LED_PIN, LOW);
delay(37);
}
else{
digitalWrite(LED_PIN, LOW);
}
}
 
Back
Top