# Can the PPM mapping be changed so that higher duty cycle means slower speed?

4 posts / 0 new
UncleJoe
Offline
Last seen: 2 years 1 week ago
Joined: 2018-06-02 05:42
Posts: 6
Can the PPM mapping be changed so that higher duty cycle means slower speed?

Trying to use VESC to drive the blower motor in a car. Yes I know it's not wise to use hobbyist quality parts for automotive applications...

The PWM speed signal from the 2009 Camry is open collector, so that means lower duty cycle maps to higher speed.

Is there any way to change the mapping to do this? I was thinking of making the throttle curve have a negative slope, but can't do it. In the PPM app, I also tried changing

"Pulselength start"  = 2

"Pulselength end" = 0

but that didn't work either.

appreciate your help

TheFallen
Offline
Last seen: 3 months 3 weeks ago
Joined: 2017-09-11 11:46
Posts: 222

What's the actual Camry output? Is it a PPM signal thats just inverted or is it a PWM signal?

PPM being the 1-2ms pulse every 20ms thats pretty much only found in remote control systems.

If it's PWM where 100% high is fully off and 0% high is fully on then adding a small filter and using the ADC control mode should let you flip the directions.

UncleJoe
Offline
Last seen: 2 years 1 week ago
Joined: 2018-06-02 05:42
Posts: 6

"using the ADC control"

That's a great suggestion. Thanks. I was about to use an inverter.

All I know is that the control signal is not push/pull, only pull down, so it's probably open collector. It's PWM with a 2ms period. When measured from the 100k pull up resistor, the duty cycle ranges from 100% (off) to 17% (highest)

UncleJoe
Offline
Last seen: 2 years 1 week ago
Joined: 2018-06-02 05:42
Posts: 6

I changed my mind about using current mode. Actually, I never tried it, after realizing it might be susceptible to battery load (big trouble if the control signal is proportional to the battery voltage directly; not so much if you use a stepped down, regulated voltage). I ended up using PWM, but inverted the pulse length in software

diff --git a/servo_dec.c b/servo_dec.c
index 3b85852..3a54218 100644
--- a/servo_dec.c
+++ b/servo_dec.c
@@ -43,7 +43,7 @@ static volatile bool is_running = false;
static void(*done_func)(void) = 0;

static void icuwidthcb(ICUDriver *icup) {
-       last_len_received[0] = ((float)icuGetWidthX(icup) / ((float)TIMER_FREQ / 1000.0));
+       last_len_received[0] = 2 - ((float)icuGetWidthX(icup) / ((float)TIMER_FREQ / 1000.0));
float len = last_len_received[0] - pulse_start;
const float len_set = (pulse_end - pulse_start);