No subject


Fri Sep 27 23:39:33 HKT 2013


unsigned int car_tmotor =3D 0; // Tmotor


Regards, Thomas



2014/1/14 Mark Webb-Johnson <mark at webb-johnson.net>

> Reviewing this, I find:
>
> extern signed char car_ambient_temp; // Ambient Temperature (celcius)
> extern signed char car_tpem;         // Tpem
> extern unsigned char car_tmotor;     // Tmotor
> extern signed char car_tpms_t[4];    // TPMS temperature
>
>
> The car_tbattery and car_cooldown_tbattery are already signed int.
>
> I propose to change car_ambient_temp, car_tpem, car_tmotor and car_tpms_t
> to signed int. For the sake of 7 bytes I don't think it is worth the risk=
.
>
> Code in vehicle_twizy.c is a good example of guarding for this:
>
>       // MOTOR TEMPERATURE:
>       if (CAN_BYTE(5) > 40 && CAN_BYTE(5) < 0xf0)
>         car_tmotor =3D CAN_BYTE(5) - 40;
>       else
>         car_tmotor =3D 0; // unsigned, no negative temps allowed...
>
>
> Simplifying code like that will probably save as much flash as we lose in
> going from 8 to 16 bits.
>
> Once we've got over the current compilation flags / space issue with the
> 1.6 firmware, I'll make this change.
>
> Regards, Mark.
>
> On 13 Jan, 2014, at 10:46 pm, Mark Webb-Johnson <mark at webb-johnson.net>
> wrote:
>
> Sound advise.
>
> Given just a handful of temperatures, it is probably least impacting to
> just change to 16 bit signed and put this one to rest. It keeps coming
> back, and it would be good to solve it once and for all. Impact is 1 byte
> extra ram per temperature, plus some flash for the 16 vs 8 bit.
>
> Moving to a 40C offset is tricky to maintain backwards compatibility.
>
> Regards, Mark
>
> On 13 Jan, 2014, at 9:51 pm, Collin Kidder <collink at kkmfg.com> wrote:
>
> I don't think you'd want to do that. 127 deg C really isn't that terribly
> hot and -128C is extremely cold. If it is necessary to retain use of an 8
> bit variable then the standard solution is to just offset the temperature
> stored by -40. That way you can read -40 to 215C which is a pretty
> reasonable range. Unfortunately, I fear such a change would necessitate
> many other changes in code. It might be better to expand to a signed 16 b=
it
> integer.
>
>
> On Mon, Jan 13, 2014 at 7:50 AM, H=E5kon Markussen <
> hakon.markussen at gmail.com> wrote:
>
>> Hi (Mark).
>>
>> In ovms.h the motor temperature is defined as unsigned char
>> (non-negative):
>> extern unsigned char car_tmotor; // Tmotor
>>
>> Currently the weather is cold in Norway (-15 C) and I noticed that motor
>> temp was 244C.
>>
>>
>> Is it possible to update the car_tmotor to
>> extern signed char car_tmotor; // Tmotor
>>  in ovms.h?
>>
>> Best regards
>> H=E5kon
>>
>> _______________________________________________
>> OvmsDev mailing list
>> OvmsDev at lists.teslaclub.hk
>> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>>
>>
> _______________________________________________
> OvmsDev mailing list
> OvmsDev at lists.teslaclub.hk
> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>
> _______________________________________________
> OvmsDev mailing list
> OvmsDev at lists.teslaclub.hk
> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>
>
>
> _______________________________________________
> OvmsDev mailing list
> OvmsDev at lists.teslaclub.hk
> http://lists.teslaclub.hk/mailman/listinfo/ovmsdev
>
>

--001a1132fc4009f13c04f06b1390
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi Mark.<div><br></div><div>it looks like you have forgot =
to change the car_tmotor to signed int?<br><div><br></div><div>From changes=
.txt:</div><div><pre class=3D"" style=3D"font-family:Consolas,&#39;Liberati=
on Mono&#39;,Courier,monospace;font-size:12px;margin-top:0px;margin-bottom:=
0px;color:rgb(51,51,51)">
# Change car_ambient_temp, car_tpem, car_tmotor and car_tpms_t to signed in=
t</pre><pre class=3D"" style=3D"font-family:Consolas,&#39;Liberation Mono&#=
39;,Courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;color=
:rgb(51,51,51)">
<br></pre><pre class=3D"" style=3D"font-family:Consolas,&#39;Liberation Mon=
o&#39;,Courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;co=
lor:rgb(51,51,51)"><span style=3D"font-family:arial;font-size:small;color:r=
gb(34,34,34)">From ovms.c</span>:</pre>
<pre class=3D"" style=3D"font-family:Consolas,&#39;Liberation Mono&#39;,Cou=
rier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;color:rgb(51=
,51,51)"><span class=3D"" style=3D"color:rgb(68,85,136);font-weight:bold;li=
ne-height:18px">unsigned</span><span style=3D"line-height:18px"> </span><sp=
an class=3D"" style=3D"color:rgb(68,85,136);font-weight:bold;line-height:18=
px">int</span><span style=3D"line-height:18px"> </span><span class=3D"" sty=
le=3D"line-height:18px;background-color:rgb(255,255,255)">car_tmotor</span>=
<span style=3D"line-height:18px"> </span><span class=3D"" style=3D"font-wei=
ght:bold;line-height:18px">=3D</span><span style=3D"line-height:18px"> </sp=
an><span class=3D"" style=3D"color:rgb(0,153,153);line-height:18px">0</span=
><span class=3D"" style=3D"line-height:18px">;</span><span style=3D"line-he=
ight:18px"> </span><span class=3D"" style=3D"color:rgb(153,153,136);font-st=
yle:italic;line-height:18px">// Tmotor</span><br>
</pre><pre class=3D"" style=3D"font-family:Consolas,&#39;Liberation Mono&#3=
9;,Courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px;color:=
rgb(51,51,51)"><span class=3D"" style=3D"color:rgb(153,153,136);font-style:=
italic;line-height:18px"><br>
</span></pre><pre class=3D"" style=3D"font-family:Consolas,&#39;Liberation =
Mono&#39;,Courier,monospace;font-size:12px;margin-top:0px;margin-bottom:0px=
;color:rgb(51,51,51)"><span style=3D"color:rgb(34,34,34);font-family:arial;=
font-size:small;white-space:normal">Regards, Thomas</span><br>
</pre></div></div></div><div class=3D"gmail_extra"><br><br><div class=3D"gm=
ail_quote">2014/1/14 Mark Webb-Johnson <span dir=3D"ltr">&lt;<a href=3D"mai=
lto:mark at webb-johnson.net" target=3D"_blank">mark at webb-johnson.net</a>&gt;<=
/span><br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div style=3D"word-wrap:break-word">Reviewin=
g this, I find:<div><br></div><div><blockquote style=3D"margin:0 0 0 40px;b=
order:none;padding:0px">
<div><font face=3D"Andale Mono">extern signed char car_ambient_temp; // Amb=
ient Temperature (celcius)</font></div><div><font face=3D"Andale Mono">exte=
rn signed char car_tpem; =A0 =A0 =A0 =A0 // Tpem</font></div><div class=3D"=
im"><div><font face=3D"Andale Mono">extern unsigned char car_tmotor; =A0 =
=A0 // Tmotor</font></div>
</div><div><font face=3D"Andale Mono">extern signed char car_tpms_t[4]; =A0=
 =A0// TPMS temperature</font></div></blockquote></div><div><br></div><div>=
The=A0car_tbattery and=A0car_cooldown_tbattery are already signed int.</div=
><div>
<br></div><div>I propose to change car_ambient_temp, car_tpem, car_tmotor a=
nd car_tpms_t to signed int. For the sake of 7 bytes I don&#39;t think it i=
s worth the risk.</div><div><br></div><div>Code in vehicle_twizy.c is a goo=
d example of guarding for this:</div>
<div><br></div><div><blockquote style=3D"margin:0 0 0 40px;border:none;padd=
ing:0px"><div><div><font face=3D"Andale Mono">=A0 =A0 =A0 // MOTOR TEMPERAT=
URE:</font></div><div><font face=3D"Andale Mono">=A0 =A0 =A0 if (CAN_BYTE(5=
) &gt; 40 &amp;&amp; CAN_BYTE(5) &lt; 0xf0)</font></div>
<div><font face=3D"Andale Mono">=A0 =A0 =A0 =A0 car_tmotor =3D CAN_BYTE(5) =
- 40;</font></div><div><font face=3D"Andale Mono">=A0 =A0 =A0 else</font></=
div><div><font face=3D"Andale Mono">=A0 =A0 =A0 =A0 car_tmotor =3D 0; // un=
signed, no negative temps allowed...</font></div>
</div></blockquote></div><div><br></div><div>Simplifying code like that wil=
l probably save as much flash as we lose in going from 8 to 16 bits.</div><=
div><br></div><div>Once we&#39;ve got over the current compilation flags / =
space issue with the 1.6 firmware, I&#39;ll make this change.</div>
<div><br></div><div>Regards, Mark.</div><div><div class=3D"h5"><div><br><di=
v><div>On 13 Jan, 2014, at 10:46 pm, Mark Webb-Johnson &lt;<a href=3D"mailt=
o:mark at webb-johnson.net" target=3D"_blank">mark at webb-johnson.net</a>&gt; wr=
ote:</div>
<br><blockquote type=3D"cite"><div dir=3D"auto"><div>Sound advise.</div><di=
v><br></div><div>Given just a handful of temperatures, it is probably least=
 impacting to just change to 16 bit signed and put this one to rest. It kee=
ps coming back, and it would be good to solve it once and for all. Impact i=
s 1 byte extra ram per temperature, plus some flash for the 16 vs 8 bit.</d=
iv>
<div><br></div><div>Moving to a 40C offset is tricky to maintain backwards =
compatibility.</div><div><br></div><div>Regards, Mark</div><div><br>On 13 J=
an, 2014, at 9:51 pm, Collin Kidder &lt;<a href=3D"mailto:collink at kkmfg.com=
" target=3D"_blank">collink at kkmfg.com</a>&gt; wrote:<br>
<br></div><blockquote type=3D"cite"><div dir=3D"ltr">I don&#39;t think you&=
#39;d want to do that. 127 deg C really isn&#39;t that terribly hot and -12=
8C is extremely cold. If it is necessary to retain use of an 8 bit variable=
 then the standard solution is to just offset the temperature stored by -40=
. That way you can read -40 to 215C which is a pretty reasonable range. Unf=
ortunately, I fear such a change would necessitate many other changes in co=
de. It might be better to expand to a signed 16 bit integer.<br>

<div class=3D"gmail_extra"><br><br><div class=3D"gmail_quote">On Mon, Jan 1=
3, 2014 at 7:50 AM, H=E5kon Markussen <span dir=3D"ltr">&lt;<a href=3D"mail=
to:hakon.markussen at gmail.com" target=3D"_blank">hakon.markussen at gmail.com</=
a>&gt;</span> wrote:<br>

<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><div><div>Hi (Mark).<b=
r><br></div>In ovms.h the motor temperature is defined as unsigned char (no=
n-negative):<br>

extern unsigned char car_tmotor; // Tmotor<br><br></div>Currently the weath=
er is cold in Norway (-15 C) and I noticed that motor temp was 244C.<br>
<br></div><br><div><div><div>Is it possible to update the car_tmotor to<br>=
extern signed char car_tmotor; // Tmotor<br></div><div>=A0in ovms.h?<br></d=
iv><div><br></div><div>Best regards<span><font color=3D"#888888"><br>
</font></span></div><span><font color=3D"#888888">H=E5kon<br></font></span>=
</div>
</div></div>
<br>_______________________________________________<br>
OvmsDev mailing list<br>
<a href=3D"mailto:OvmsDev at lists.teslaclub.hk" target=3D"_blank">OvmsDev at lis=
ts.teslaclub.hk</a><br>
<a href=3D"http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target=3D"_b=
lank">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a><br>
<br></blockquote></div><br></div></div>
</blockquote><blockquote type=3D"cite"><span>______________________________=
_________________</span><br><span>OvmsDev mailing list</span><br><span><a h=
ref=3D"mailto:OvmsDev at lists.teslaclub.hk" target=3D"_blank">OvmsDev at lists.t=
eslaclub.hk</a></span><br>
<span><a href=3D"http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target=
=3D"_blank">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a></span><b=
r></blockquote></div>_______________________________________________<br>Ovm=
sDev mailing list<br>
<a href=3D"mailto:OvmsDev at lists.teslaclub.hk" target=3D"_blank">OvmsDev at lis=
ts.teslaclub.hk</a><br><a href=3D"http://lists.teslaclub.hk/mailman/listinf=
o/ovmsdev" target=3D"_blank">http://lists.teslaclub.hk/mailman/listinfo/ovm=
sdev</a><br>
</blockquote></div><br></div></div></div></div><br>________________________=
_______________________<br>
OvmsDev mailing list<br>
<a href=3D"mailto:OvmsDev at lists.teslaclub.hk">OvmsDev at lists.teslaclub.hk</a=
><br>
<a href=3D"http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target=3D"_b=
lank">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a><br>
<br></blockquote></div><br></div>

--001a1132fc4009f13c04f06b1390--


More information about the OvmsDev mailing list