Page 1 of 1
Implementing an Odometer in ECU Firmware
Posted:
Tue Jan 10, 2023 4:47 am
by raheelfarouk
Hello,
I am trying to implement an odometer to measure the total distance travelled that can be reset with a switch. Has anyone done something similar or would have some ideas of how to do this?
Thank you in advance
Re: Implementing an Odometer in ECU Firmware
Posted:
Tue Jan 10, 2023 7:53 am
by David Ferguson
I would look at the code for total engine run time for how to do a preserved channel. But calculate distance from integrating vehicle speed over time.
You do realize that MoTeC dash products already have this feature.
Re: Implementing an Odometer in ECU Firmware
Posted:
Wed Jan 11, 2023 2:01 am
by raheelfarouk
Wonderful I’ll have a look at that, thank you!
Unfortunately we only use/have a D153 dash which I believe doesn’t have the ability to do this(correct me if I am wrong).
We are also looking at using this for an EV platform which is controlled mainly by the ECU, hence the reason to use the ECU for accomplishing this.
Re: Implementing an Odometer in ECU Firmware
Posted:
Wed Mar 29, 2023 1:12 pm
by MalcolmG
Just remember that you need a scheduled function that calls System.Preserve() periodically to write the value to Flash, and set the channel type to "Flash Backed" rather than volatile. If you're not using a GP package as a baseline then you'll need to add System.Preserve() into your package somewhere - most likely in your odometer function. Ideally you don't want to be writing it multiple times a second for the sake of the flash memory, so best to use a condition in the function so it will only be written to flash once every 10-30s.