Page 1 of 1
DAC Capable Pins
Posted: Wed Jan 03, 2024 12:51 am
by i_s_64
Hello,
I am trying to implement DAC using LUA on my Proteus. I'm just wondering which pins are capable of 0-3.3V output
Also, I can't seem to find any references to any functions in Lua to be able to utilize DAC on the LUA Scripting page
https://github.com/rusefi/rusefi/wiki/Lua-Scripting
Which functions can I access with LUA scripting? Any examples by chance?
Thanks,
Alex
Re: DAC Capable Pins
Posted: Wed Jan 03, 2024 1:21 am
by mi-hol
i_s_64 wrote: ↑Wed Jan 03, 2024 12:51 am
Any examples by chance?
Hi Alex,
example code is available on GitHub as mentioned at bottom of quoted wiki page, see:
https://github.com/rusefi/rusefi/tree/master/firmware/controllers/lua/examples
Regards
Michael
Re: DAC Capable Pins
Posted: Wed Jan 03, 2024 2:22 am
by AndreyB
i_s_64 wrote: ↑Wed Jan 03, 2024 12:51 am
I am trying to implement DAC using LUA on my Proteus.
What's your use-case to want a DAC?
Proteus was not developed with DAC in mind so firmware does not have it enabled, see
https://github.com/rusefi/rusefi_documentation/commit/ca5ffdb2ba5455b61b089ce8598faa3c16150e49 for more info.
Re: DAC Capable Pins
Posted: Wed Jan 03, 2024 1:49 pm
by i_s_64
Thanks Michael. That's great!
So I have two use cases on one of my cars.
The first, the car currently has a Link standalone that I'm keeping, but I would like to add DBW to the car. I need to output a 0-5V TPS signal to satisfy the need of the Link standalone. So I was going to have the Proteus do the DBW stuff, and output a 0-3.3V signal that I run through non-inverting Opamp to output to 0-5V
The other is to do the same thing to the stock oil pressure gauge in the factory cluster. The Opamp would end up doing 0-VBatt in that case
I'm sure down the road I'll run into more use cases. It's a powerful feature to work with.
Re: DAC Capable Pins
Posted: Wed Jan 03, 2024 4:28 pm
by AndreyB
Would an RC-filter work? At the moment Lua is limited at 1KHz PWM until
https://github.com/rusefi/rusefi/issues/5811
Re: DAC Capable Pins
Posted: Thu Jan 04, 2024 2:22 pm
by i_s_64
Yes you're absolutely right. An RC circuit would work since there isn't much load on the line considering I would still have to use an OpAmp to boost the output. This was originally how I was thinking of doing it, until I got caught up on reading the RusEFI changelog and noticing that DAC has been implemented. Without the DAC, it's only really two extra passive components, but a lot more flexibility on which lines I can use.
Thanks for the reality check. Makes way more sense to do it with PWM->RC in this case