<div dir="ltr">Here is the code I'm trying for reading the SOC,<div><br></div><div><u>Filter:</u></div><div><br></div><div><div>// Filters: low byte bits 7..5 are the low 3 bits of the filter, and bits 4..0 are all zeros</div>
<div> // high byte bits 7..0 are the high 8 bits of the filter</div><div> // So total is 11 bits</div><div><br></div><div> // Buffer 0 (filters 0, 1) for extended PID responses</div><div> RXB0CON = 0b00000000;</div>
<div> // Mask0 = 0b11111111000 (0x7F8), filterbit 0,1,2 deactivated</div><div> RXM0SIDL = 0b00000000;</div><div> RXM0SIDH = 0b11111111;</div><div> </div><div> // Filter0 0b01100000000 (0x300..0x3F8)</div><div> RXF0SIDL = 0b00000000;</div>
<div> RXF0SIDH = 0b01100000;</div></div><div><br></div><div><br></div><div><u>Can_poll</u>:</div><div><br></div><div><div>////////////////////////////////////////////////////////////////////////</div><div>// can_poll()</div>
<div>// This function is an entry point from the main() program loop, and</div><div>// gives the CAN framework an opportunity to poll for data.</div><div>//</div><div>BOOL vehicle_mitsubishi_poll0(void)</div><div> {</div>
<div> unsigned int id = ((unsigned int)RXB0SIDL >>5)</div><div> + ((unsigned int)RXB0SIDH <<3);</div><div><br></div><div> can_datalength = RXB0DLC & 0x0F; // number of received bytes</div>
<div> can_databuffer[0] = RXB0D0;</div><div> can_databuffer[1] = RXB0D1;</div><div> can_databuffer[2] = RXB0D2;</div><div> can_databuffer[3] = RXB0D3;</div><div> can_databuffer[4] = RXB0D4;</div><div> can_databuffer[5] = RXB0D5;</div>
<div> can_databuffer[6] = RXB0D6;</div><div> can_databuffer[7] = RXB0D7;</div><div><br></div><div> RXB0CONbits.RXFUL = 0; // All bytes read, Clear flag</div><div> </div><div> car_estrange = id; //debug</div><div><br>
</div><div> switch (id)</div><div> {</div><div><div> /*</div><div> case 0x346:</div><div> car_estrange = MiFromKm((unsigned int)can_databuffer[7]); // Range</div><div> car_idealrange = car_estrange;</div>
<div> break;</div><div> </div><div> case 0x373:</div><div> // BatCurr & BatVolt</div><div> break;</div><div> */</div></div><div><br></div><div> case 0x374:</div><div> car_idealrange = id; //debug</div>
<div> car_SOC = (char)(((int)can_databuffer[1] - 10) / 2); //SOC</div><div> break;</div><div><br></div><div> case 0x389:</div><div> car_linevoltage = (unsigned int)can_databuffer[1];</div><div> car_chargecurrent = ((unsigned int)can_databuffer[6] / 10);</div>
<div> break;</div><div> }</div><div><br></div><div> return TRUE;</div><div> }</div></div><div><br></div><div><br></div><div>I using car_estrange and car_idealrange for debug. car_estrange gets updates, but car_idealrange is never updated and are always 0.</div>
<div>Have also tried car_estrange++; in the code, and I can see that the number increases for each DIAG message.</div><div><br></div><div><br></div><div>Regards, Thomas </div><div><br></div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">2013/9/19 Thomas Bergo <span dir="ltr"><<a href="mailto:thomas.bergo@gmail.com" target="_blank">thomas.bergo@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr">I'm pretty sure. I got this <span style="font-family:arial,sans-serif;font-size:13px">calculation</span> from Xavier, he made the first version of the Canion app. A Android app to <span style="color:rgb(51,51,51);font-family:Roboto,Arial,sans-serif;font-size:14px;line-height:20px;background-color:rgb(245,245,245)">visualize data from the can-bus on i-Miev, iOn and C-Zero. </span><a href="https://play.google.com/store/apps/details?id=emobility.canion&hl=no" target="_blank">https://play.google.com/store/apps/details?id=emobility.canion&hl=no</a><div>
<br></div><div>The <span style="font-family:arial,sans-serif;font-size:13px">calculation</span> also seams to be correct when i logged the can bus during charging yesterday, I had 14 bars and SOC was 85% with this <span style="font-family:arial,sans-serif;font-size:13px">calculation</span>.</div>
<div><br></div><div>Regards, Thomas</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><br><div class="gmail_quote">2013/9/19 Håkon Markussen <span dir="ltr"><<a href="mailto:hakon.markussen@gmail.com" target="_blank">hakon.markussen@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>@Thomas:<br></div>Are you sure this calculation is correct for iMiEV?<br><i>car_SOC = (char)(((int)can_databuffer[1] - 10) / 2);<br>
</i></div><br>This means byte 1 can be:<br>Ah (d10) = 0% SOC (minimum)<br>
</div>6Eh (d110) = 50% SOC<br></div>D2h (d210) = 100% SOC (maximum)<br><br></div>Br.<br>Håkon<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/9/19 Thomas Bergo <span dir="ltr"><<a href="mailto:thomas.bergo@gmail.com" target="_blank">thomas.bergo@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div>Thank you for your attention.<div><br></div><div>This is the same information that i have:</div><div>
<br></div><div>SOC shuld be 0x374, byte 1. This I have confirmed using my laptop and the CAN-Do SW.</div>
<div><br></div><div>
I used the Think code as a template for setting up the filter and poll interupts. So I belived that it shuld be a straight forward task to read the messages.</div><div><br></div><div>I will post my filter setup and poll1 code later, I belive that you will see what's wrong<span></span>. </div>
<div><br></div><div>Regards, Thomas<br><br>torsdag 19. september 2013 skrev Nikolay Shishkov følgende:<div><div><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div style="font-size:12pt;font-family:times new roman,new york,times,serif">
<div><span>Hi Thomas,</span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif"><span><br></span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">
<span>Here is some info on the messages that you can see on the Miev CAN bus.</span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">
0x210 - accelerator pedal</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif"><span style="background-color:transparent">0x298 - trip meter</span><br>
</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">0x346 - range</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">
0x373 - amps, volts</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">0x374 - SOC</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">
0x389 - Amp, Volts</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">0x412 -
speed, odometer</div><div style="background-color:transparent">0x418 - shifter position</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">
0x424 - switches and stuff - like lights, etc.</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">0x6E1, 0x6E2, <span style="font-size:12pt">0x6E3, 0x6E4 - cell voltages, and temps</span></div>
<div style="font-style:normal;font-size:12pt;background-color:transparent;font-family:'times new roman','new york',times,serif"><span style="font-size:12pt"><br></span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">
<span style="font-size:12pt">Once you get familiar with the ovms, maybe you can find it easier to use the Twizy or the Think code, instead of starting from scratch.</span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif">
<span style="font-size:12pt"><br></span></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:'times new roman','new york',times,serif"><span style="font-size:12pt">Hope this helps,</span></div>
<div style="font-style:normal;font-size:12pt;background-color:transparent;font-family:'times new roman','new york',times,serif"><span style="font-size:12pt">Nikolay</span></div><div><br></div> <div style="font-family:'times new roman','new york',times,serif;font-size:12pt">
<div style="font-family:'times new roman','new york',times,serif;font-size:12pt"> <div dir="ltr"> <hr size="1"> <font face="Arial"> <b><span style="font-weight:bold">From:</span></b> Thomas Bergo <<a>thomas.bergo@gmail.com</a>><br>
<b><span style="font-weight:bold">To:</span></b> OVMS Developers <<a>ovmsdev@lists.teslaclub.hk</a>> <br> <b><span style="font-weight:bold">Sent:</span></b> Thursday, September 19, 2013 9:01 AM<br>
<b><span style="font-weight:bold">Subject:</span></b> Re: [Ovmsdev] i-Miev/C-Zero/iOn<br> </font> </div> <div><br>
<div>Yesterday I managed to verify that both poll0 and poll1 interrupt is called.<div><br></div><div>Printed "car_idealrange =id;" from poll0 to see the PID's that triggered the interrupt. Only get id 768 (0x300) printed out.</div>
<div><br></div><div>Also tried to do a the printout fom inside case 0x374: but no updates. The strange ting is that I can see a lot of "374" messages, and none "300" when using my laptop.</div><div><br>
</div><div>Start wonder if the PID "374" that I find on my laptop is not a hex value? Any one here that has any experiance with CAN-Do SW for analysing <span></span>CAN mesages? </div><div><br></div><div>Will do some more testing later.</div>
<div><br></div><div>Regards, Thomas<br><br>onsdag 18. september 2013 skrev Mark Webb-Johnson følgende:<br><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">
<div><br></div><blockquote type="cite"><div dir="ltr">Is there a simple way to print out a value to the DIAG port for debugging?</div></blockquote><div><div dir="ltr"><br></div></div><div dir="ltr">You can just net_puts it, normally prefixed with a "#" sign as a comment. Have a look in diag.c for lots of examples. You will need to type 'ATE1' when going into diag mode, to get the echo output. The way it works is that you send the command to the modem (net_puts()), which discards it as unrecognised, but echos it back to the terminal.</div>
<div dir="ltr"><br></div><div dir="ltr">But, you can't do that in interrupt handlers - only in normal ticker(), or message handler, style code</div><div dir="ltr"><br></div><div dir="ltr">Regards, Mark.</div><div dir="ltr">
<br></div><div><div>On 18 Sep, 2013, at 8:22 PM, Thomas Bergo <<a rel="nofollow">thomas.bergo@gmail.com</a>> wrote:</div><br><blockquote type="cite">
<div dir="ltr">Thank you for your help.<div><br></div><div>Fixed some typos and now ODO updates in "STAT?" ODO is still wrong, but at least i get updates. No luck with SOC so far.</div><div><br></div><div>Have verified that the PID and the data is correct by using a CAN interface on my laptop. </div>
<div><br></div><div>Will do some more debugging to verify that both poll0 and poll1 is called.</div><div><br></div><div>Is there a simple way to print out a value to the DIAG port for debugging?</div><div><br></div><div>
Regards, Thomas</div>
</div><div><br><br><div>2013/9/17 Mark Webb-Johnson <span dir="ltr"><<a rel="nofollow">mark@webb-johnson.net</a>></span><br>
<blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word"><div><br></div>Thanks, Håkon - nice clear answer.<div><br></div><div>One other suggestion is that you can put "car_idealrange++; return TRUE;" and "car_estrange++; return TRUE;" in the poll0 and poll1 functions, near the top. A few STAT commands and you can see if the poll functions are actually being called. You can also put "car_idealrange=id; return TRUE;", etc, to get an idea of what IDs are being delivered. It is very nasty trying to debug interrupt handlers, but this approach can help.</div>
<div><br></div><div>The diag port mentioned is shown here:</div><div><br></div><div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><a rel="nofollow" href="http://www.youtube.com/watch?v=-24PoWtHVzk" target="_blank">OVMS Setup Diagnostics Mode</a></div>
</blockquote></div><div><br></div><div>Regards, Mark.</div><div><div><br><div><div>On 16 Sep, 2013, at 4:55 PM, Håkon Markussen <<a rel="nofollow">hakon.markussen@gmail.com</a>> wrote:</div>
<br><blockquote type="cite"><div dir="ltr"><div><div><div><div><div><div><div>Hi Thomas,<br><br><i>"Still has some debugging to do on the i-Miev code, as i'm only get "SOC: 0%" from STAT?"<br></i></div>
<br>Are you able to read any CAN-bus values from your iMiEV?<br>
<br></div>I experienced once at my Think City, that the Ovms-module did not read the CAN-bus at all; I got 0% SOC.<br>The problem was I had two external CAN-devices connected at the same time (Duinomite Mega + OVMS). It worked fine when both modules were powered on at the same time, but Ovms failed to read the bus when the Duinomite Mega was powered off.<br>
<br></div>Du you have access to any kind of can-reader tool? This can be used to verify that you are looking at the correct bytes.<br></div>I've used P-CAN USB adapter<br><a href="http://www.peak-system.com/PCAN-USB.199.0.html?&L=1" target="_blank">http://www.peak-system.com/PCAN-USB.199.0.html?&L=1</a><br>
and PCANView <br><a href="http://www.computer-solutions.co.uk/gendev/can-basic-dll.htm" target="_blank">http://www.computer-solutions.co.uk/gendev/can-basic-dll.htm</a><br><br></div>You can use it to verify you have SOC in msg 0x374 byte 1.<br>
<br></div><div>To understand the mask and filter, you have to consider the mask as a bit "enable" / "disable". Any zero in the mask bit disables that</div></div></div></blockquote></div></div></div></div>
</blockquote></div></div></blockquote></div></div></blockquote></div></div></div></div> </div> </div></div></blockquote></div></div></div>
<br></div></div><div>_______________________________________________<br>
OvmsDev mailing list<br>
<a href="mailto:OvmsDev@lists.teslaclub.hk" target="_blank">OvmsDev@lists.teslaclub.hk</a><br>
<a href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target="_blank">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a><br>
<br></div></blockquote></div><br></div>
<br>_______________________________________________<br>
OvmsDev mailing list<br>
<a href="mailto:OvmsDev@lists.teslaclub.hk" target="_blank">OvmsDev@lists.teslaclub.hk</a><br>
<a href="http://lists.teslaclub.hk/mailman/listinfo/ovmsdev" target="_blank">http://lists.teslaclub.hk/mailman/listinfo/ovmsdev</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>