[Ovmsdev] V3 distance/speed units
mark at webb-johnson.net
Thu Oct 26 09:51:53 HKT 2017
I did a quick review of the way things were done in OVMS v2. Some notes:
The OVMS v2 protocol specified:
Car Environment message 0x44 “D"
• Temperature of the PEM (celcius)
• Temperature of the Motor (celcius)
• Temperature of the Battery (celcius)
• Car trip meter (in 1/10th of a distance unit)
• Car odometer (in 1/10th of a distance unit)
• Car speed (in distance units per hour)
• Ambient Temperature (in Celcius)
Car state message 0x53 “S”
• Units ("M" for miles, "K" for kilometers)
• Ideal range
• Estimated range
Registered parameter #2
• Miles / Kilometer flag
The OVMS v2 net_msg code did some conversions:
car_tpem is always stored in Celcius, and always sent as such
car_tmotor is always stored in Celcius, and always sent as such
car_tbattery is always stored in Celcius, and always sent as such
car_trip is stored in Miles, so a KmFromMi() conversion is done if units were “K”
car_odometer is stored in Miles, so a KmFromMi() conversion is done if units were “K”
car_speed is stored in user unit, and sent as such
car_ambient_temp is always stored in Celcius, and always sent as such
Units is stored as a parameter, and sent as such
car_idealrange is stored in Miles, so a KmFromMi() conversion is done if units were “K”
car_estrange is stored in Miles, so a KmFromMi() conversion is done if units were “K”
tpms is stored in raw (Tesla) format, and sent as PSI and Celcius
I did some quick checks against the OVMS v2 vehicle_*.c code. Here are some notes:
Kia Soul: Seems to have distances in metric, and uses MiFromKm() when storing to car_*. Temperatures in celcius, so no conversion necessary.
Mitsubishi iMiev: MiFromKm() for distances. Temperatures in celcius, so no conversion necessary.
Tesla Roadster: Miles for distances, Celcius for temperatures, so no conversions necessary (surprise, surprise, as OVMS v2 car model based on this car).
Nissan Leaf: MiFromKm() for distances. Temperatures in celcius, so no conversion necessary.
Twizy: MiFromKm() for distances. Temperatures in celcius, so no conversion necessary.
Renault Zoe: MiFromKm() for distances. Seemingly no temperature support.
I then looked at the OBDII standard. Here are the notes from that:
Temperatures are stored and transmitted in Celcius
Pressures are stored and transmitted in Pa / kPa
Distances are stored and transmitted in Km
Time is stored and transmitted in Seconds
I looked at the Apps.
Configurable for temperatures: car chooses / celcius / fahrenheit
Configurable for distances: car chooses / miles / kilometers
No configuration for pressures
Overall, I would conclude:
The OVMS v2 protocol is kind of messy, not symmetric. It does conversions in some place, but in others leaves it up to the App.
It seems that almost all the vehicles use metric units
OBDII uses metric units
We need to maintain compatibility with OVMS v2 protocol, but can do things differently for v3 protocol
I suggest the following:
The Metrics use metric units for their internal storage (sic).
We add units labels to the metrics. This can be used (a) as a nice display (SOC: 10% vs 10), and (b) as the basis for conversion support at the metric level.
We add units parameters to the configuration storage (for pressure, temperature, distance).
We make the ovms_server_v2 convert to the v2 protocol standard
Doing it that way means that most vehicles will store in their native format (metric) - only Tesla Roadster will incur a Miles->KM->Miles penalty. Using ‘float’ to some extent mitigates this.
The alternative (storing the unit with the metric, and having it passes whenever we set/read the metric) is much more complex and seemingly only required for one particular vehicle (ignoring the temporary issue of v2 protocol, until we roll out v3 protocol and apps).
I do think that whatever we decide, it needs to be decided now. We are converting the vehicle modules over, and doing this now is much simpler than trying to re-work it later.
> Really not a fan of this, as the app may not even know what kind of
> vehicle is being used (an attached HUD, for example). If there's a
> function in the metric object that does the conversion to make it
> transparent, I suppose that could work. But I'd really prefer to have
> at least the standard metrics table be vehicle-independent, and in
> standard units. The OBDII spec assumes this, and the devices all have
> Metric / Imperial mode switches included. For common items that may be
> missing from a particular vehicle (e.g. motor RPM on the Roadster), the
> vehicle code that populates the metrics table should derive them from
> what is available. For the Roadster example, motor RPM is basically
> vehicle speed times 70, so when receiving a speed CAN frame, both the
> v.p.speed and v.p.rpm (new metric, please?) would be updated.
> If there are metrics that don't apply to multiple vehicles, and don't
> fit into the standard ones, they can certainly be in vehicle-specific
> units. Best to have a separate table for them, I think, with the items
> prefaced by the 2-letter vehicle name. I can certainly deal with having
> a table name as part of the PID remapping scheme. But, please, not on a
> per metric basis.
> The vehicle-specific use can also be aided by scripting some of the
> conversion. Still working on how that can be done. But again, we
> shouldn't need to load in a whole library of vehicle-specific scripts
> just to handle the common parameters (speed, SoC, etc.).
> My $.02,
> On 25 Oct 2017, at 12:26 PM, HONDA S-2000 <s2000 at audiobanshee.com> wrote:
> I like the concept of storing vehicle units in the module and letting the app sort out the conversions. Theoretically, this allows for alternate app front ends that might do “something” with the additional information in the vehicle units that might be lost in translation (conversion). But, I am a nerd with a bias towards low-level details, and that might not be the best. :-)
> Obviously, the down side is that each additional vehicle unit adds to the code in the app. My usual assumption is that there’s more room in a front end application for these sorts of things, as opposed to the embedded side. To contradict myself, though, it seems that we’re allowing for the embedded firmware to be compiled for a single vehicle, meaning that none of the code needs to carry around unused conversions.
> Stepping away from my technical focus (where I might be interested in the exact vehicle units for, e.g., torque on my roadster), perhaps it would be better to design around the typical user, who will either be interested in miles or kilometers, foot-pounds or Newton-meters, and basically just English versus metric. In that case, maybe the embedded firmware could have a meta parameter to select English versus metric, and then all communications with the app would be in those units. The down side to this idea is that the embedded firmware would need to be capable of two different conversions for potentially every metric, assuming that every electric vehicle is available in multiple countries, both metric and English.
> Sorry to throw a jumbled set of ideas at the problem, but I wanted to share my thoughts.
> On Oct 24, 2017, at 1:08 PM, Michael Balzer <dexter at expeedo.de> wrote:
>> I've done the int to float changes and the temperature naming.
>> Not sure about the best way to solve the units problem yet, but I guess
>> we can start with storing in vehicle units and add the conversion later on.
>> Am 24.10.2017 um 04:46 schrieb Mark Webb-Johnson:
>>> Tough questions. Answers/comments inline.
>>>> On 23 Oct 2017, at 9:33 PM, Michael Balzer <dexter at expeedo.de> wrote:
>>>> Trying to catch up…
>>>> a) I'd love to get rid of those km→miles→km conversions in V3.
>>>> How about introducing a metric "v.units" instead to hold the units used
>>>> by the vehicle, and make conversions at the user level if necessary?
>>> I don’t have a good answer for this. I thought to just store all the metrics in ‘metric’ (celcius, kilometers, etc), and let the apps deal with it (as they do now). But, as you say, that does lead to the problem of km->miles->km, etc.
>>> An alternative is to store a ‘units’ with the metric, and have the metric deal with presentation conversion upon retrieval. That reduces the number of conversions.
>>> In general, having this done in the module seems to make more sense than doing it in the apps.
>>>> b) Regarding the standard metrics currently defined, I'd need to
>>>> introduce own copies again for higher precision. I.e. SOC, SOH, speed
>>>> and ranges all are integers now, and some more I'd like to be able to
>>>> set at higher precision.
>>>> How about making all these be floats now? I.e. everything that can
>>>> require more than integer precision.
>>>> The server_v2 can output the values as integers for v2 client compatibility.
>>>> c) I haven't seen a recommendation on naming vehicle specific metrics.
>>>> My proposal: use the vehicle code as the prefix, then try to reuse
>>>> similar paths from the standard metrics, adding detail as necessary.
>>>> For example, the vehicle module version on the Twizy ("RT") is
>>>> "rt.m.version", and for the min & max battery voltage I've got
>>>> "rt.v.b.voltage.min" & "rt.v.b.voltage.max".
>>>> OVMS > metrics list rt.
>>>> rt.m.version 1.0.0 Oct 23 2017 11:45:31
>>>> rt.v.b.voltage.max 0
>>>> rt.v.b.voltage.min 0
>>>> That way a path component can be used to list all related metrics:
>>>> OVMS > metrics list b.voltage
>>>> rt.v.b.voltage.max 0
>>>> rt.v.b.voltage.min 0
>>> Ok, but I would suggest an ‘x.’ prefix (seems to match many Internet standards, such as X- headers, etc).
>>> So: x.rt.v.b.voltage.max, etc.
>>>> d) I think most of the temperature metrics have wrong names:
>>>> …as "b." should be reserved for "battery".
>>>> How about…
>>>> …introducing "m." for motor and "i." for inverter?
> OvmsDev mailing list
> OvmsDev at lists.teslaclub.hk
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the OvmsDev