Implementing an Odometer in ECU Firmware

Support forum for users of the M1 Build

Implementing an Odometer in ECU Firmware

Postby raheelfarouk on Tue Jan 10, 2023 4:47 am

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
raheelfarouk
 
Posts: 5
Joined: Sun Jan 22, 2017 4:16 am

Re: Implementing an Odometer in ECU Firmware

Postby David Ferguson on Tue Jan 10, 2023 7:53 am

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.
David Ferguson
Veracity Racing Data
David Ferguson
Pro User
 
Posts: 1374
Joined: Fri Nov 07, 2008 2:45 am
Location: Paso Robles, California

Re: Implementing an Odometer in ECU Firmware

Postby raheelfarouk on Wed Jan 11, 2023 2:01 am

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.
raheelfarouk
 
Posts: 5
Joined: Sun Jan 22, 2017 4:16 am

Re: Implementing an Odometer in ECU Firmware

Postby MalcolmG on Wed Mar 29, 2023 1:12 pm

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.
MalcolmG
Pro User
 
Posts: 76
Joined: Fri Dec 18, 2015 1:34 pm
Location: Auckland, NZ


Return to M1 Build

Who is online

Users browsing this forum: No registered users and 4 guests