How to read and modify a PWM signal

I have what I believe to be a PWM signal coming from a e-go-kart throttle pedal
(well, it has white, red, black, green & yellow wires).

Q1) How can I tell whether the output from the pedal is indeed PWM? Can I read it in Arduino?

I want to modify the duty cycle of the signal using Arduino. So, presumably reading the PWM signal, adjusting the duty cycle, and output the PWM from Arduino to the existing connection that the pedal went into before.

Q2) How do I do this on Arduino?

It would be easiest to use an oscilloscope to visualise the pwm signal. Search for arduino oscilloscope. There are a number of PWM capable pins on arduino boards

If the signal is actually PWM then I'd convert the PWM to PPM, where the signal can be read and reapplied with modification, such as limiting the speed of the e-go-thingy.

What evidence leads you to believe that?

E-bike and scooter throttles are often either potentiometers, or Hall effect devices that output a control voltage.

But my existing 24v motor controller expects the same kind of signal as from the pedal. Is it not better to stick with that?

Just guessed from the fact that there are 5 wires. Again, is there a way I can tell for sure what these wires are without purchasing an oscilloscope?

Lousy basis for a guess. Find someone with an oscilloscope to help.

If you have a multimeter you check the voltage. If you get a reliable variable DC readings at different throttle settings it's probably DC from a pot, but meters can be unreliable with PWM.

If all of the voltmeter readings are less than 5V you can connect to an Arduino analog input to see what you get. (You can run code from the Analog Read Serial Example). If the readings are "randomly" reading between nearly zero and nearly 1023 (or whatever the maximum is) that's PWM.

If the voltages are above 5V you can use a voltage divider (two resistors) to knock-down the voltage, making it safe for the Arduino. Then you can run the above analog read experiment.

You can convert PWM to analog with a low pass filter A filter of about 10Hz should be slow enough to filter the PWM but fast enough for throttle changes.

Then you can read the DC and convert that to PWM.

My guess is 3 wires for a pot, plus two wires for a switch to turn it completely off when your foot is off the pedal.

1 Like

I have checked the pedal out – it's a Hall effect sensor with an on/off switch for low throttle position as you suspected. :slight_smile:

I connected WHITE to A2 pin, RED to 5V pin and BLACK to GND of Arduino. Serial monitor of pin A2 has continuous values from 191 for no throttle to 830 for full throttle.

But when I connect the RED to 3.3V, the full throttle position reads 460.

What is the meaning of this value?
How can I output a value of A2 * 0.6 (i.e. reduce throttle position to 60%) to feed to the WHITE pin on the motor controller board? I don't see any analog out pins. :confused:

HI,
Do you have a DMM?

If so measure the output of the throttle with 5V and with 3V3, you will see the difference due to you supplying the Hall Effect with 3V3 instead of 5V.

Tom... :smiley: :+1: :coffee: :australia:

I understand that the values read by analogIn are digital representation of the voltage.

I basically just want to modify (using the Arduino) the voltage which has been output by the pedal.

I initially thought the best way to do this would be to read the voltage into Arduino, modify it, and output the voltage using Arduino – however, when this is supplied to the motor controller, the motor sounds whiney and does not operate correctly. I presume this is because the controller board now receives PWM and not true analog.

So maybe it's better to just use a voltage regulator which I can control digitally using Arduino. Does such a thing exist?

If you do the scaling in Arduino and output the result as a PWM signal, you will need to smooth this to get an analogue signal as expected by the motor controller. The Arduino documentation I'm sure suggests what values of R and C are needed to do this. Are you sure that the supply voltage to the throttle sensor is supposed to be 5V? Do you have a digital multimeter with which to measure both the supply voltage and the voltage output? If not you are working in the dark - they only cost a few £/$ for a simple one which will do the job.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.