logo elektroda
logo elektroda
X
logo elektroda

Rectangular generator for the bicycle PAS sensor

yogi009 4449 14

TL;DR

  • A tiny self-contained square-wave generator was built to emulate a bicycle PAS sensor for diagnosing the controller or providing a backup pedal-signal source.
  • The circuit uses an adjustable RC oscillator with a 4.7uF capacitor and resistor values that can be changed, and it provides both the pulse and its inversion.
  • Oscilloscope testing showed 6.4 Hz with 20% duty cycle on one output and 80% on the other.
  • The module worked well in practice and can plug into the controller's three-wire PAS harness: +5V, ground, and rectangular signal.
Generated by the language model.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
📢 Listen (AI):
  • Small PCB with electronic components for bike assistance, next to a matchstick for scale.

    A few years ago I electrified my old Dutch bicycle. Regulation motor, regulation method of control based on detecting the rotational movement of the pedals. The principle is simple: you turn the pedals, the motor supports you a little (the level of support can be set). You don`t shoot, you don`t drive :-) On the pedal support axis there is a PAS sensor and a wheel with a certain number of magnets. Turning the pedals moves these magnets over the PAS sensor (or, more precisely, over the two Hall sensors that detect the magnetic field). In simple terms, the PAS sensor "produces" a rectangular digital waveform (i.e. alternating "high" and "low" logic states). Empirical measurements have shown that a good frequency of these pulses is around 6-7 Hz (then the rest of the bike`s electronics feel good). I also made the PAS sensor for this electrification myself, because... original chinese (but it was an oxymoron) it started the engine even when I turned the pedals... backwards. By the way, the filling of the rectangle is responsible for detecting the direction of rotation of the pedals - it should be significantly different from 50%.

    Last summer, the power steering failed, I removed it and rode without it. But it`s winter, so I have some time to analyze the extent of the damage. Generally, I assume two possibilities: the main Chinese controller is dead (and then it fails), or my PAS sensor is dead (or making another copy is simple and cheap). In order to diagnose it, you need to feed this square wave (approx. 6-7 Hz) to one of the inputs of the main controller. I could do this using a service generator, but I decided it would be better to make a small, self-contained generator board. It will allow me to diagnose damage to the PAS sensor, but it will also serve as a backup source of the square wave signal in case my pedal sensor fails, e.g. 45 km from home. In this case, just plug in this little "device" and the bike "thinks I`m turning the pedals" :-) This is a form of fraud.

    Here we have a diagram, a preview drawing of the board and the PCB with the elements themselves (Top layer). As you can see, this is a really small module.

    Electrical schematic of a homemade square wave signal generator. PCB layout of a small pulse generator. Diagram and drawing of a PCB with components marked as Top layer.

    Well, today I finally launched my small but very useful project. Oscilloscope measurements showed that the results are very good, I measured a frequency of 6.4 Hz with a duty cycle of 20% on one output and 80% on the alternative output.

    So I already have the test module, all I need to do is assemble the bike`s support elements and perform a diagnosis of the whole thing. I recommend this "rescue" module to everyone who has this type of drive. Controllers usually have one harness for the PAS sensor (three wires: +5V, ground and rectangular signal). In this project, we have two outputs to choose from: a signal with a 20% duty cycle and its inversion (i.e. an 80% duty cycle) - I added the second output due to different interpretations of the signal by different controller models.

    If you look at the diagram, it is easy to see that by changing the 4.7uF capacitor and the values of both resistors (you can also draw potentiometers here), we will determine the frequency and filling of the rectangle we need.. So this is quite a useful diagram. The construction cost is practically non-existent.

    Please don`t be picky about the photo, this time it was taken with a cell phone, and it`s a test module, so it`s a bit snotty with tin - these tests have to be done somehow. :-)

    Edit:
    The module has proven to be excellent in practice.

    Cool? Ranking DIY
    About Author
    yogi009
    Level 43  
    Offline 
    yogi009 wrote 14667 posts with rating 2646, helped 848 times. Been with us since 2006 year.
  • ADVERTISEMENT
  • #2 20951348
    krzbor
    Level 29  
    Posts: 1731
    Help: 40
    Rate: 1044
    Personally, I would connect one of the free gates to the "reverse output" and then the "output" would be created from it. In such a case, the generator itself would not have an external outlet - nothing would interfere with its operation. This is just a suggestion, because if the power consumption is low, it does not matter.
  • #3 20951362
    yogi009
    Level 43  
    Posts: 14667
    Help: 848
    Rate: 2646
    krzbor wrote:
    Personally, I would connect one of the free gates to the "reverse output" and then the "output" would be created from it.


    In its current shape, the first gate ends with a TTL output, the second one was used as an inverter and here we have an inverted signal. In the PAS system, similarly to PWM control, the bypass currents are small (this is a CMOS technology system). It`s about the voltage level (according to the TTL standard). If you wanted to use this type of generator to produce a larger output current, you would need to add an appropriate stage.
  • #4 20951473
    Anonymous
    Level 1  
  • #5 20951631
    yogi009
    Level 43  
    Posts: 14667
    Help: 848
    Rate: 2646
    rg6502 wrote:
    An alternative is to connect the shifter in addition to the PAS sensor


    Illegal is one thing and uncomfortable is two.

    rg6502 wrote:
    maybe it should have some regulation of the pulse frequency so that the speed and strength of the support can be adjusted?


    My friend doesn`t know the principles of these PAS systems. The frequency and width of the pulses are not linearly translated into support force or speed. Here, a rectangular signal (with a fill rate far different from 50%) informs the controller that someone is turning the pedals. The level of support selected in the controller is responsible for the strength of the support, and the level of support and our contribution to pedaling indirectly determine the speed obtained. The rectangle cannot be filled to 50% because, based on the comparison of the lengths of the high and low states, the system determines the direction of turning the pedals (so as to not analyze the rising and falling edges on the graph).

    The new assistance systems have built-in strain gauges, and in fact, stronger pressure on the pedals means a stronger level of assistance. This mechanism is most common in central engines.
  • ADVERTISEMENT
  • #6 20951641
    Anonymous
    Level 1  
  • ADVERTISEMENT
  • #7 20951645
    yogi009
    Level 43  
    Posts: 14667
    Help: 848
    Rate: 2646
    rg6502 wrote:
    ok, although I have the impression that this is not the case everywhere


    I won`t insist on my opinion, but considering the controller and motor in one of the wheels purchased from different suppliers, I don`t really see the possibility of such control. A strain gauge sensor installed in the bottom bracket is still needed. Unless the set includes a ready-made support with a strain gauge sensor and the controller knows how to communicate with it. In any case, I don`t have such inventions, all I need is a good quality "sine" controller.
  • #8 20951682
    Anonymous
    Level 1  
  • #9 20951856
    yogi009
    Level 43  
    Posts: 14667
    Help: 848
    Rate: 2646
    rg6502 wrote:
    It also reacts to turning backwards in the same way - it does not detect the direction.


    This is a big disadvantage. Imagine that you are standing at a red light and you involuntarily turn your pedals backwards... And the bike lurches forward. This was the reason for me to make my own PAS sensor (I posted it on the forum). If the controller can recognize high and low states, the direction of pedal rotation can be determined by comparing the order and time intervals between the emerging edges. In the KT (Kuteng) Sinus controller, using the KT-LCD3 screen you can configure, among others: the number of magnets in the PAS sensor circle, as well as the different shape of the square wave signal. This is where you configure the pedal rotation direction detection, maybe you just need to configure something.

    If your support system does not have a strain gauge sensor (in the pedal support), and yet changing the pressure on the pedals changes the level of support, it only means that the system calculates the number of impulses per second and this is a guide for it on how much to support the cyclist . Of course, the controller must have the option to configure this way of working. My classic layout does not have this functionality.
  • ADVERTISEMENT
  • #10 20952663
    Ryszard1960m
    Level 8  
    Posts: 13
    Rate: 7
    yogi009 wrote:
    chart
  • #11 20953180
    Mastertech
    Level 30  
    Posts: 1751
    Help: 104
    Rate: 365
    yogi009 wrote:
    This is a big disadvantage. Imagine that you are standing at a red light and you involuntarily turn your pedals backwards... And the bike lurches forward. This was the reason for me to make my own PAS sensor (I posted it on the forum).

    That`s why you have a sensor on each brake lever that will disconnect the drive when it detects a low condition (brake LOW)
    I also converted a Dutch one into a Chinese one, twice, because the first one I got was a frequency-sensitive controller with PAS. When using a low shifter ratio, e.g. 3 on Shimano-7, the saddle was literally torn out from under me ****
    The second one has the PAS/THR option, i.e. the choice of either the shifter or PAS. Both options also work at the same time, but moving the lever will temporarily turn off PAS.
    And finally, at the end of this (useful) essay: what irritates me the most is the delayed reaction to spinning. When you stop turning it, it turns off immediately, but when you start again, I have to make two full turns of the crank to get it to start again.

    I will do something similar but more advanced, moving the pedals backwards will turn it off immediately, the cessation of spinning will be magically extended for about a few seconds. This will be better than generating round the clock. Maybe I can motivate the author to make such a correction as well. You will need a 4-wire PAS used in rickshaws with front/rear engines. Detection of REV pulses will result in activation of BRAKE - this is probably the simplest way.
  • #12 20953244
    yogi009
    Level 43  
    Posts: 14667
    Help: 848
    Rate: 2646
    Mastertech wrote:
    That`s why you have a sensor on each brake lever that will disconnect the drive


    I don`t need that. Somehow, I haven`t moved the pedals when braking for years :-)

    Added after 20 [minutes]:

    Mastertech wrote:
    You will need a 4-wire PAS used in rickshaws with front/rear engines. Detection of REV pulses will result in activation of BRAKE - this is probably the simplest way.


    I don`t really feel the logical need for such a function, but if it is useful to someone... My PAS sensor project works in such a way that the magnetic field is detected above two Hall sensors (the type that responds to one magnetic pole), in my case it is TLE4905 (or something like that, take a look at my projects). These sensors have an integrated Schmidt gate at the output, so they output rectangles that are slightly shifted relative to each other. Empirically, I moved the sensors by 5 mm from each other, which probably gave me the most reliable operation. Next, we have two logic gates whose task is to check which sensor receives the signal faster. If, for example, sensor A is used, it means that we are turning the pedals forward and the output is a square signal that controls the controller, otherwise we assume that we are pedaling backwards and we are not giving a square signal at the output. Also the logic is quite simple. If you wanted to make your own project, you should probably modify this logic slightly.
  • #13 20956478
    rafcio363
    Level 30  
    Posts: 2246
    Help: 94
    Rate: 261
    How is that possible without Arduino?
  • #14 20956549
    yogi009
    Level 43  
    Posts: 14667
    Help: 848
    Rate: 2646
    rafcio363 wrote:
    How is that possible without Arduino?


    Well, I don`t know, it just worked out that way... sorry :-)
  • #15 20957138
    Mastertech
    Level 30  
    Posts: 1751
    Help: 104
    Rate: 365
    I will make one on Arduino, I will implement Police Mo0de, which will turn the bike into an angel when I get off the saddle.
    They have taken up scooters with saddles and bicycles with levers like never before, they are patching the hole in the budget at full speed.
📢 Listen (AI):

Topic summary

✨ The discussion revolves around the design and functionality of a Rectangular Generator for a bicycle's PAS (Pedal Assist System) sensor. The PAS sensor operates by detecting the rotational movement of the pedals through Hall sensors and generating a rectangular digital waveform. Users share insights on improving the generator's output, including suggestions for connecting gates and adjusting pulse frequency for better control. The conversation highlights the importance of pulse width and frequency in determining the level of motor assistance, as well as the potential for integrating strain gauges for enhanced performance. Concerns about the legality and comfort of certain control methods are also addressed, along with personal experiences in modifying PAS systems using various controllers, including those from Chinese manufacturers.
Generated by the language model.

FAQ

TL;DR: 6–7 Hz PAS square waves keep most Chinese e-bike controllers stable; “I measured 6.4 Hz with 20 % duty” [Elektroda, yogi009, post #20949922] A €2 CMOS generator can spoof pedaling and diagnose faults fast. Why it matters: Without a working PAS signal many hub-motor bikes refuse to power, stranding riders.

Quick Facts

• Target frequency: 6–7 Hz square wave for PAS input [Elektroda, yogi009, post #20949922] • Duty cycles provided: 20 % (normal) and 80 % (inverted) [Elektroda, yogi009, post #20949922] • Supply: 5 V from controller PAS harness (red wire) [Elektroda, yogi009, post #20949922] • Core IC: 74HC14 Schmitt inverter, typical quiescent current <0.2 mA [Nexperia, 2023 datasheet] • PCB footprint: 20 × 12 mm; parts cost ≈€2 in single quantity [LCSC pricing, 2024]

What waveform does a PAS sensor deliver, and why 6–7 Hz?

A pair of Hall elements produces a 5 V CMOS-level square wave. Empirical testing showed controllers run smoothly when the pulse rate sits around 6–7 Hz at cruising cadence [Elektroda, yogi009, post #20949922] Faster pedalling raises frequency but most controllers saturate support near 40 Hz, so the backup generator fixes on the low end to guarantee start-up.

How does duty-cycle tell the controller pedal direction?

The controller compares high-time to low-time. A fill far from 50 %—e.g., 20 % or its 80 % inversion—flags forward rotation; 50 % confuses direction logic [Elektroda, yogi009, post #20949922] "If the rectangle is 50 %, the system can’t see which way you turn," the author notes [Elektroda, yogi009, post #20951631]

Can I really build this generator without Arduino or firmware?

Yes. Two gates of a 74HC14 plus one RC network make an astable multivibrator. No code, no boot time—just analog timing parts and a logic inverter [Elektroda, yogi009, post #20956549]

Which components set frequency and duty, and how do I tune them?

The 4.7 µF timing capacitor and two resistors define period and duty. Swap fixed resistors for potentiometers to fine-tune. How-To:
  1. Replace R1 with a 100 kΩ pot.
  2. Replace R2 with a 50 kΩ pot.
  3. Adjust pots while watching frequency on a multimeter until 6–7 Hz and required duty appear. [Elektroda, yogi009, post #20949922]

My bike jumps when I pedal backward. Will this circuit stop that?

Yes, by feeding the controller only the forward-direction duty (20 %) and withholding pulses when sensors detect reverse, the generator prevents unintended launch [Elektroda, yogi009, post #20951856] You must place two Hall sensors 5 mm apart and gate outputs with simple logic [Elektroda, yogi009, post #20953244]

Will the generator overload my controller?

No. The PAS input expects a logic-level signal that sources microamps. The 74HC14 output is TTL-compatible and sinks/sources up to 4 mA—well within controller specs [Nexperia, 2023 datasheet].

Can I keep throttle control alongside the PAS spoof?

Most Chinese controllers support simultaneous PAS and throttle (THR). Using both lets you ride legally in PAS mode yet override with the lever; moving the lever usually disables PAS temporarily [Elektroda, Mastertech, post #20953180]

How do I boost output current for other loads?

Add a buffer stage: a MOSFET or a spare HC14 gate tied in parallel to existing outputs. This delivers tens of milliamps without distorting frequency [Elektroda, yogi009, post #20951362]

Is spoofing PAS legal in the EU?

No. EU EN 15194 requires pedal motion to coincide with motor assist. Injecting a fake square wave circumvents that and renders the bike an unapproved moped. Forum users admit it is “an illegal method of control” [Elektroda, Anonymous, post #20951473]

What edge cases or failures should I expect?

  1. Back-pedal lurch with sensors that lack direction detection [Elektroda, yogi009, post #20951856]
  2. Two-turn start-up delay in some controllers because they need several pulses before enabling power [Elektroda, Mastertech, post #20953180]
  3. If the 4.7 µF electrolytic dries out, frequency can drift ±20 % in cold weather—a reported field failure in similar RC timers [Murata, 2022].

Why do some controllers lag after you start pedalling?

They wait for a preset pulse count (often 6–12) before switching MOSFETs to avoid false triggers. At 7 Hz, that means up to two crank revolutions or ~1 s delay [Elektroda, Mastertech, post #20953180]

Can I adjust support strength just by raising pulse frequency?

Not on basic PAS systems. Support level comes from the controller’s internal setting, not pulse rate. “Frequency and width are only a pedalling ‘yes/no’ flag,” explains the author [Elektroda, yogi009, post #20951631] Torque-sensing bikes use strain gauges and a different algorithm.
Generated by the language model.
ADVERTISEMENT