PWM to Analog circuits?

Introduction and miscellaneous that we haven't created categories for, yet
Post Reply
User avatar
mdrobnak
Posts: 692
Joined: Thu Mar 05, 2020 5:08 pm
Location: Colorado, United States
Has thanked: 1 time
Been thanked: 5 times

PWM to Analog circuits?

Post by mdrobnak »

One of the things I will need to do with my hybrid is generate pedal position sensor values to feed to the stock ECU controlling the engine. I mean, in theory I could do a lot of work to take a torque input from CAN and write code for the Motorola CPU32, but then I'm not sure if my modified code will pass Oregon emissions (ie do they check the calibration verification number, which will change...)..so in theory a significantly easier job will sending out a modified pedal position signal to deal with the desired torque split between engine and electric.

I the GS450h board is Arduino Due based, which I think can do D/A conversion on two of the pins, however, I'll probably be driving this from something else. I've realized the inverter is probably going to live in the trunk as there's not exactly a lot of room in the engine bay with the engine still there... So I definitely would not want to drive such critical signals from the engine bay to the rear and then back again. This also means I may have to make custom HV phase cables.

In any case, what's the simplest way to accurately generate a 0-5V signal based upon a PWM to ground (ie low-side drive) output?

-Matt
User avatar
joromy
Posts: 371
Joined: Fri Jun 28, 2019 12:56 pm
Has thanked: 1 time
Been thanked: 4 times

Re: PWM to Analog circuits?

Post by joromy »

What about a LTC 2644, have used that many times where PWM filtering is not adequate.

https://www.analog.com/media/en/technic ... TC2644.pdf

PWM_to_ANA.JPG

I used this module resently for a 0-5 volt controlled power supply:

https://www.ebay.com/itm/163596299408
PWM_module.JPG
PWM_module.JPG (41.36 KiB) Viewed 1497 times
Thomas A. Edison “I have not failed. I've just found 10,000 ways that won't work"
User avatar
mdrobnak
Posts: 692
Joined: Thu Mar 05, 2020 5:08 pm
Location: Colorado, United States
Has thanked: 1 time
Been thanked: 5 times

Re: PWM to Analog circuits?

Post by mdrobnak »

I saw similar items on Amazon, my concern was quality due to the nature of emulating a throttle pedal I wanted as accurate as possible. I was actually looking at the LTC2644 - they have a LTC2645 demo board which is $75 unfortunately, and requires me to figure out how to get a 5V reference signal to it. Apparently the demo setup only does 0-2.5V output. :( Also, wow that's crazy markup - the price of the device is $7 on digi-key. I guess I may end up designing a PCB for this (and probably something to handle cruise control as well). The non-CAN cruise control BMWs use a simple protocol that goes back to the 80s...but it's a pain to work with lol.

-Matt
User avatar
johu
Site Admin
Posts: 6618
Joined: Thu Nov 08, 2018 10:52 pm
Location: Kassel/Germany
Has thanked: 342 times
Been thanked: 1485 times
Contact:

Re: PWM to Analog circuits?

Post by johu »

Why not just low pass filter your PWM? It's no exactly fast but a throttle signal isn't "fast" in computers terms anyway. So PWM 10kHz -> filter with 20-50Hz cutoff frequency (say, 10k, 1µ) will get you near perfect analog voltage
Support R/D and forum on Patreon: https://patreon.com/openinverter - Subscribe on odysee: https://odysee.com/@openinverter:9
User avatar
mdrobnak
Posts: 692
Joined: Thu Mar 05, 2020 5:08 pm
Location: Colorado, United States
Has thanked: 1 time
Been thanked: 5 times

Re: PWM to Analog circuits?

Post by mdrobnak »

Hmm. Actually, yeah, I can do up to a 20kHz signal...which if the ripple is small enough that should be fine? Simpler is better, that's for certain, but I also want accurate is the issue.

Reading https://www.allaboutcircuits.com/techni ... g-voltage/ now :)

Oh boy.
let's increase the carrier frequency to 10 MHz
Yeah.....don't think so.

Need to get some random caps like I have of resistors to give that a quick try. The other piece is my PWM is to ground, so I need a pull-up to 5V on it. How do you size that resistor? It's also going to be about response time again, right?

-Matt
xp677
Posts: 439
Joined: Sat Jul 27, 2019 10:53 am
Location: UK
Has thanked: 1 time
Been thanked: 15 times

Re: PWM to Analog circuits?

Post by xp677 »

Am I missing something? The obvious solution is to leave the pedal connected to the stock ECU as normal, and take your readings from it, either directly (spliced in) or over CAN.

It sounds like your plan is to disconnect the pedal from the ECU, run it to your controller, then create a pseudo-output for the ECU. Is this because you want to be able to use the pedal, but have your controller decide if/when to throttle the engine? If so then I'd just use a filter as discussed above. I'd agree with the choice of a discreet controller.

There are also dedicated DAC interfaces available. I remember using this one in the past, it has 4x inputs and 1x output, over I2C: https://www.nxp.com/docs/en/data-sheet/PCF8591.pdf

There's probably a SPI variant available, if there is then I'd place this in the drivers footwell and keep to your controller in the trunk.

Edit: Loads of SPI D/A converters available.
User avatar
mdrobnak
Posts: 692
Joined: Thu Mar 05, 2020 5:08 pm
Location: Colorado, United States
Has thanked: 1 time
Been thanked: 5 times

Re: PWM to Analog circuits?

Post by mdrobnak »

xp677 wrote: Sun Apr 05, 2020 11:02 pm Am I missing something? The obvious solution is to leave the pedal connected to the stock ECU as normal, and take your readings from it, either directly (spliced in) or over CAN.

It sounds like your plan is to disconnect the pedal from the ECU, run it to your controller, then create a pseudo-output for the ECU. Is this because you want to be able to use the pedal, but have your controller decide if/when to throttle the engine? If so then I'd just use a filter as discussed above. I'd agree with the choice of a discreet controller.

There are also dedicated DAC interfaces available. I remember using this one in the past, it has 4x inputs and 1x output, over I2C: https://www.nxp.com/docs/en/data-sheet/PCF8591.pdf

There's probably a SPI variant available, if there is then I'd place this in the drivers footwell and keep to your controller in the trunk.

Edit: Loads of SPI D/A converters available.
I2C isn't an option here with what I'm working with.

I'm trying to manage the torque split between electric and gas, so yes, I'm trying to feed it alternate values.

Re: discrete controller do you mean the LTC2644?

-Matt
xp677
Posts: 439
Joined: Sat Jul 27, 2019 10:53 am
Location: UK
Has thanked: 1 time
Been thanked: 15 times

Re: PWM to Analog circuits?

Post by xp677 »

Sorry, I meant a separate unit just to handle this, rather than sending analog signals through the car and back.

Either a microcontroller, or just some ADCs and DACS mounted in an enclosure, communicating with your microcontroller in the trunk over whatever protocol you choose. I2C wouldn't be suitable for this, but SPI should.
Post Reply