Simple PAS to throttle converter using an Arduino Nano

fkopac

10 µW
Joined
Feb 25, 2017
Messages
6
The heading says it all. Solder according to the schematic and program the Arduino using attached program (adjust as needed, defaults work well for me). Should work instantly.
You can put the Arduino Nano inside the controller case (insulate using shrinking plastic), in that case connect the power to +5 pin, ground to GND pin, output to ZB pin.
If you put it outside the case, connect output to throttle input, power to throttle power and ground to throttle ground. Before reassembling, remove all power sources and short-circuit the big capacitors or you could blow the board as you insert it in the conductive housing.
PAS output can be connected directly to D2, Arduino has an in-built pull-up.
IMG_20170318_231638.jpg
 

Attachments

  • kolopretvornik.zip
    1 KB · Views: 931
Thanks for posting the design and source code.

I've been thinking I might do something like this if the PAS on the controller I get doesn't behave the way I like. The thing about doing your own is that you can tune it to behave the way you want. It's fairly straightforward to vary the throttle as a function of cadence, so at low cadence the motor switches off. You can also monitor battery current and wheel speed to to provide feedback algorithms based on power, torque, speed etc.
 
A bit of reverse engineering on the serial protocol of the bike controller (they are all the same, AFAIK) could open up MANY interesting possibilities :)
 
LIke these?
https://endless-sphere.com/forums/viewtopic.php?f=2&t=71008
https://endless-sphere.com/forums/viewtopic.php?f=2&t=73471
https://endless-sphere.com/forums/viewtopic.php?f=2&t=73475
 
Great!!!! I'll try to implement 25km/h PAS limit :) reading speed from motor hall.

And maybe PAS and throttle input to single output
 
Many thanks to you fkopac i really need this. ZB pin is applying for sabvoton controller or some other one?
 
I am trying this arduino board but it starts immediately after turn on bike without any pedal movement. I have tried higher min voltage also.

Honya96 If you want connect to single output just add diode on signal wire. Best to add 2 pieces. 1 for arduino and 1 for throttle
Edit: I have tested and board starts even withouth connected pas to D2. Tried different settings in code with no positive result
 
I am running Violamart hub motor with NO display or anyway to control PAS so I need this!

I am experimenting with this circuit using attiny841 (actually a bad DIYBMSv4 module).

Couple of questions, did you disconnect the PAS from controller board and go to D2 on nano (this is what I did).

What is the first element in your schematic going from Nano to throttle (SD on my controller board) before the 10uF cap?
Thanks for any help on this, really am interested in getting this tuned to control my PAS. I can use ISP plug in on my DIYBMSv4 module board to program, so simple to mod program settings.
 
Thanks a lot for sharing your tutorial fkopac.

I already soldered and connected many wires but have never worked with "Small stuff" like arduino or diodes or whatever your drawing shows :) That leads to my next problem.. i don't know how to read wiring diagrams and what parts are needed.
Would someone be so nice and write down a part list so also a newbie can find them on amazon or wherever ?
And could someone who already built the converter please share a picture of what the thing looks like when its ready ?
Thanks a lot for your help guys.

Best regards
Sparfuchs, vienna
 
Sparfuchs said:
Thanks a lot for sharing your tutorial fkopac.

I already soldered and connected many wires but have never worked with "Small stuff" like arduino or diodes or whatever your drawing shows :) That leads to my next problem.. i don't know how to read wiring diagrams and what parts are needed.
Would someone be so nice and write down a part list so also a newbie can find them on amazon or wherever ?
And could someone who already built the converter please share a picture of what the thing looks like when its ready ?
Thanks a lot for your help guys.

Best regards
Sparfuchs, vienna

Okay so i already found out that i need a arduino nano, a resistor (1K) and a electrolytic capacitor (10µF). Correct ?
But i would still appreciate a foto for better understanding :)
 
Ok guys,
i need your help.
I already tried to solder all the parts together and uploaded the code to the arduino, but it didn't work at all.
So before i try to figure out what went wrong i'd really really appreciate it if someone could take a look at my drawing and tell me if i connected all the parts correctly ??
Thanks a lot for your help !

IMG_20210128_153647.jpg
 
Sparfuchs said:
I already tried to solder all the parts together and uploaded the code to the arduino, but it didn't work at all.
What exactly does "didn't work at all" mean? Did it not even power on? Or did it power on but have no voltage on the output pin? Etc. Exact details of what *did* happen, and what voltages and signals you have on each used pin will help us help you figure it out. :)

Where does the 5V to power everything come from? You don't show that connection, so I want to be sure you *are* providing 5v and ground to all three devices. :)
 
crossbreak said:
maybe the blue PAS wire is GND and not signal?
Thanks a lot for your reply crossbreak,
Thats what i thought at first, but in the discription it says yellow is ground. Maybe i should just try to change them ?
 
crossbreak said:
does the LED stay off? when any throttle value is set, the Onboard LED D13 should switch on

//Use LED for status info
digitalWrite(ledPin, state);

When i turn my switch on key, the pwr led turns on and stays like that.
 
amberwolf said:
Sparfuchs said:
I already tried to solder all the parts together and uploaded the code to the arduino, but it didn't work at all.
What exactly does "didn't work at all" mean? Did it not even power on? Or did it power on but have no voltage on the output pin? Etc. Exact details of what *did* happen, and what voltages and signals you have on each used pin will help us help you figure it out. :)

Where does the 5V to power everything come from? You don't show that connection, so I want to be sure you *are* providing 5v and ground to all three devices. :)

Thanks a lot for your reply amberwolf,
sorry that i have not expressed myself clearly. So if i turn my switch key the green pwr led turns on and stays like that but when i spin the pas the motor doesn't move at all. If i measured right there are about 4 Volts at the pas connection.. so that should be ok i guess ? Is there anything else i should measure or check ? The +5V and GND comes from the throttle connection to my controller (so the connection where i usually connect my throttle to). Do you think i soldered all the parts correctly if you look at my picture ?
 
Maybe i should tell more about the steps i did to program the arduino before i soldered the parts to the pins ?
At first i downloaded the driver of the company that produced the arduino, then i downloaded the arduino sketch 1.8.13 and connected my arduino. Then i downloaded the code from endless sphere and opened it by double click. The sketch with the code opened up. Then i clicked at tools and chose "arduino nano" as board and "ATmega328P (Old Bootloader)" as Processor. The arduino was found at port "COM3". As programmer i chose "AVRISP mkll".The i just clicked at "upload" and after a few seconds it said "upload successful". I disconnected the arduino and that's it. Did i maybe forget to do any steps ?
Thanks a lot for your help guys :)
 
Ok, short update. I took a new arduino, capacitor and resistor and soldered all together again as shown in my pic.
Now it works..a bit. So when i spin the pas the motor starts spinning full throttle i guess, independently of how fast i move the pas. When i stop moving the motor stops moving a few second after, but sometimes it doesn't stop.

So should the speed when everything works correctly be depending on how fast i move the pas, or is it more like a on/off switch ?
And is it normal that it takes a few second to stop after i stopped pedaling ?
Do you think it cold solve my "non stop" problem if i change my 5 pole pas to a 8 or 12 pole pas ?
 
I don't know how the code for the converter works, but almost certainly what it is doing is converting the pulses from the PAS into a voltage on the throttle output.

SInce it has an RC filter on that output, then it implies that the voltage it outputs is done via PWM, meaning it is also pulses, but of different widths (longer or shorter) depending on how fast the pulses from the PAS input pin come in.

So the voltage you measure on the PAS input pin *should* be a series of on and off pulses as you rotate the cranks. Most likely they will be at only two voltages, somewhere around 0.8v, and somewhere around 4v. Different PAS sensors (and throttles) may have different wiring colors and connections, so you'll need to check which way yours operate before you can be sure the converter will work.

Some PAS sensors have a light on them that blinks as the cranks rotate, when it's wired up right *and* the magnet disc is installed the correct direction. (if the disc is backwards, it may only work when pedalling backwards!). If yours has a light, you can check it with that. If not, then you'll need to use your voltmeter on the signal wire and ground to check it, with a 5v source powering the PAS sensor from it's 5v input and ground.

Crossbreak also said that "Onboard LED D13" should light up, presumably whenever the PAS input is working to cause the Arduino to send a throttle voltage. What does your LED D13 do? (note that I don't know what it *should* do, but others might).


Next...does your controller respond to an actual throttle on it's input correctly? If not, it wont' be any different on this converter. ;)

Some controllers only have on/off capability--they detect an input and then give full power of whatever assist level they are set at. If yours is this type, then this converter won't work--you have to have a controller that can use a throttle to vary it's speed.

Additionally, it *also* must be a controller that does *not* require PAS input to enable use of the throttle. There are some that do, and for those, you would have to also feed your PAS sensor output to the controller's PAS input at the same time it's being fed to the arduino. That should probably be fine, but it depends on whether the controller has any pullups or pulldowns inside it on the PAS signal line, and how those affect the PAS signal, as to how the Arduino will then respond.
 
Randomly, I found this link
https://www.amazon.com/HiLetgo-ATmega328P-Controller-Development-Unsoldered/dp/B01DLIJQA2
for three of the nano boards for $13 shipped. Never used this company, so just posting in case someone needs a source.
 
amberwolf said:
I don't know how the code for the converter works, but almost certainly what it is doing is converting the pulses from the PAS into a voltage on the throttle output.

SInce it has an RC filter on that output, then it implies that the voltage it outputs is done via PWM, meaning it is also pulses, but of different widths (longer or shorter) depending on how fast the pulses from the PAS input pin come in.

So the voltage you measure on the PAS input pin *should* be a series of on and off pulses as you rotate the cranks. Most likely they will be at only two voltages, somewhere around 0.8v, and somewhere around 4v. Different PAS sensors (and throttles) may have different wiring colors and connections, so you'll need to check which way yours operate before you can be sure the converter will work.

Some PAS sensors have a light on them that blinks as the cranks rotate, when it's wired up right *and* the magnet disc is installed the correct direction. (if the disc is backwards, it may only work when pedalling backwards!). If yours has a light, you can check it with that. If not, then you'll need to use your voltmeter on the signal wire and ground to check it, with a 5v source powering the PAS sensor from it's 5v input and ground.

Crossbreak also said that "Onboard LED D13" should light up, presumably whenever the PAS input is working to cause the Arduino to send a throttle voltage. What does your LED D13 do? (note that I don't know what it *should* do, but others might).


Next...does your controller respond to an actual throttle on it's input correctly? If not, it wont' be any different on this converter. ;)

Some controllers only have on/off capability--they detect an input and then give full power of whatever assist level they are set at. If yours is this type, then this converter won't work--you have to have a controller that can use a throttle to vary it's speed.

Additionally, it *also* must be a controller that does *not* require PAS input to enable use of the throttle. There are some that do, and for those, you would have to also feed your PAS sensor output to the controller's PAS input at the same time it's being fed to the arduino. That should probably be fine, but it depends on whether the controller has any pullups or pulldowns inside it on the PAS signal line, and how those affect the PAS signal, as to how the Arduino will then respond.

Thank you soo much for your detailed reply amberwolf.
since the weak controller i wanted to use it for broke, i decided to buy a stronger one with pas included.
But i still wanna give it a try and will keep you up to date about my progress when i resume the project.
 
I found some of these Arduino Nanos for cheap, and bought a handful for a few dollars along with some other stuff I was getting anyway, so at some point I will try this project out and see if I can improve it any (because everything can always be made better by making it more complicated, right? :lol: ).

No idea when I'll get around to this, but...eventually. :)


In my case, I'm using a Cycle Analyst v3 to take a PAS cadence sensor and turn it into a throttle voltage to run a pair of controllers. But the CA doesn't quite behave the way I want, and the parts I don't like can't be changed. So I'm going to try to use this project to use the cadence sensor output to make a throttle voltage to run the motors once I'm moving.

Then also use a second one (with some other program I'll probably have to hack together out of various people's stuff if I can find the bits I want) to take the torque sensor output (from the same device) and make a throttle signal out of *that* that will startup the motors from a complete stop (which the cadence sensor cant' do), while monitoring the speed sensor, and once it begins to get a reading from the speed sensor it shuts off it's output and lets the cadence sensor unit take over.

Thats' the idea...though I have no idea how the code has to work to do this yet. :oops: :roll:

Any programmers out there that would like to help? ;)

Thread is over here:
https://endless-sphere.com/forums/viewtopic.php?f=2&t=110497
 
Tiger_one said:
I am running Violamart hub motor with NO display or anyway to control PAS so I need this!

The Violamart controller can be connected to a SW900 display, allowing you to access the PAS settings. You need to connect 2 wires for the serial comms (Rx Tx) on the board and move the DMS connection as below.

I Used the existing 6 wire throttle cable, so I could use the throttle, as below.

In the controller:
Removed the green and yellow cables from DMS to - Green to Tx, Yellow to RX. Located at the far end of the board
Put a blue connected to DMS (where the Gr and Y cables were ) and brought out through grommet.

Using the cable to the throttle:
cut the Brown, Green and Yellow cables
cut the plug off the SW900 (mine was not the waterproof one)
connect (T)brown to (SW)Red
connect (T)green to (SW)Green
connect (T)Yellow to (SW)Yellow
connect extra blue cable to (SW)blue
joint (T)black to (SW)black - keeping the black connected out to the throttle.

worked straightaway fro me.

Newer SW900 has 9 PAS levels
 
Back
Top