PDA

View Full Version : Sioc Leading Zero Blanking Probs



iwik
04-28-2013, 01:46 AM
Hi Guys,<br>
Having a problem with blanking a leading zero on a O/C Display II card. I've tried to follow Nico Howto which was very helpful.<br>
I have a four digit display for RPM and when below 1000rpm I want the leading zero supressed. I have run my code thru the IOconsole<br>
in SIOC and it seems to give me the correct values UNTILL I hit &gt; 1000 or 2000 rpm. It then goes weird giving incorrect values.<br>
When operated with the hardware, Master card outputs and other Displays operate even though they are not configured in Sioc.<br>
Could someone please review my code and see where im wrong and correct if possible. My maths and programming skills are <br>
very basic and all help would be appreciated.<br>
Here is the code and thanks<br>
Les<br>
<br>

Var 6020, name rpm, Link FSUIPC_IN, Offset $0898, Length 2, Type 1<br>
{<br>
&nbsp;&nbsp;L0 = &amp;rpm * 10800<br>
&nbsp;&nbsp;L1 = L0 / 65536<br>
&nbsp;&nbsp;L2 = MOD L1 10<br>
&nbsp;&nbsp;&amp;Digitr = L2<br>
&nbsp;&nbsp;L2 = MOD L1 100<br>
&nbsp;&nbsp;&amp;Digitl1 = L2<br>
<br>
&nbsp;&nbsp;L2 = MOD L1 1000<br>
&nbsp;&nbsp;&amp;Digitl2 = L2<br>
<br>
&nbsp;&nbsp;L2 = Div L1 1000<br>
&nbsp;&nbsp;IF L2 &lt; 1<br>
&nbsp;{<br>
&nbsp;&nbsp;&amp;Digitl3 = -999999<br>
&nbsp;}<br>
&nbsp;ELSE<br>
&nbsp;{<br>
&nbsp;&nbsp;&amp;Digitl3 = L2 &nbsp;<br>
&nbsp;}<br>
}<br>
<br>
<br>
Var 1, name Digitr Link IOCARD_DISPLAY, Digit 0, Numbers 1<br>
<br>
Var 2, name Digitl1 Link IOCARD_DISPLAY, Digit 1, Numbers 1<br>
&nbsp;Var 3, name digitl2 Link IOCARD_DISPLAY, Digit 2, Numbers 1<br>
&nbsp;Var 4, name Digitl3 Link IOCARD_DISPLAY, Digit 3, Numbers 1

kiek
04-28-2013, 04:00 AM
Hi Les,

It looks to me that the second and third digits are also wrong.
You forgot to divide by 10 before doing the Modulo operations. You have to divide by 10 in order to get the next digit.

Try this:


Var 6020, name rpm, Link FSUIPC_IN, Offset $0898, Length 2, Type 1
{
L0 = &rpm * 10800
L1 = L0 / 65536


L2 = MOD L1 10
&Digitr = L2
L1 = DIV L1 10
L2 = MOD L1 10
&Digitl1 = L2
L1 = DIV L1 10
L2 = MOD L1 10
&Digitl2 = L2
L1 = DIV L1 10
L2 = MOD L1 10
IF L2 = 0
{
&Digitl3 = -999999
}
ELSE
{
&Digitl3 = L2
}
}


Regards,
Nico

iwik
04-28-2013, 06:38 AM
Hi Nico,
Thanks, it works fine now in sioc sim, i thought i could do div with the Mod, but obviously i was wrong. Didnt think
to do div first.
Regards
Les