<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
<link rel="self" type="application/atom+xml" href="http://forum.robosavvy.com/feed.php?f=5&amp;t=1783" />

<title>RoboSavvy Forum</title>
<subtitle>Robosavvy Forum: The largest online community of Humanoid Robot Builders</subtitle>
<link href="http://forum.robosavvy.com/index.php" />
<updated>2008-04-23T22:41:28+01:00</updated>

<author><name><![CDATA[RoboSavvy Forum]]></name></author>
<id>http://forum.robosavvy.com/feed.php?f=5&amp;t=1783</id>
<entry>
<author><name><![CDATA[cosa]]></name></author>
<updated>2008-04-23T22:41:28+01:00</updated>
<published>2008-04-23T22:41:28+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=15464#p15464</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=15464#p15464"/>
<title type="html"><![CDATA[New good solution for C programmers?]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=15464#p15464"><![CDATA[
Hi,<br /><br />I'm currently testing your code. It works fine: the battery is recharging and I'm measuring the change rate of ADC1. How small does the ADC1 value normally get? Atm it's at 200 and it only changes every ~80 seconds.<br /><br />Edit: my test code (ADC1 is checked every 1000ms, 30 values are accumulated, the RECHARGEREMOVECYCLES  largest and smallest value are removed and the average of the rest of the values is calculated. If the average hasn't changed from the last 30 second time frame a counter is increased. If this counter is larger than maxCycles the recharging ist aborted)<br /><br /><dl class="codebox"><dt>Code: </dt><dd><code>// still testing<br />#define RECHARGECYCLES 30<br />#define RECHARGEREMOVECYCLES 4<br />#define RECHARGEPAUSE 100000<br />#define RECHARGEMAX 10 // 10 cycles a 30 seconds 5mins = 300 seconds without change in batterie voltage<br /><br />// recharge batteries functions<br />// thanks to kess and pieddemamouth &#40;robosavvy-forums&#41;<br />unsigned int readADC&#40;byte channel&#41;<br />&#123;<br />    ADMUX  = 0x40 | channel;<br />    ADCSRA = 0xC6;<br />    while&#40;bit_is_set&#40;ADCSRA, ADSC&#41;&#41;;<br />    return &#40;ADCL | &#40;ADCH&lt;&lt;8&#41;&#41;;<br />&#125; <br /><br />void rechargeBatteries&#40;unsigned int maxCycles&#41;<br />&#123;<br />   // configuration<br />   cli&#40;&#41;;<br />   <br />   PORTE |= _BV&#40;PE4&#41;;    //enable pull-up resistor 4<br />    EIMSK |= _BV&#40;INT4&#41;;   //enable interrupt 4<br />    DDRC = 0xFF;<br />    PORTC = 0xFF;<br />    DDRB |= _BV&#40;DDB5&#41;;  //output for bit PB5<br /><br />    //ADC configuration<br />    ADMUX = 0x10;<br />    ADCSRA = 0x80; <br />   <br />    sei&#40;&#41;;<br />   <br />   unsigned int voltage&#91;RECHARGECYCLES&#93;, voltageCounter, counter, average, oldAverage;<br />   byte buffer&#91;8&#93;;<br />   int i,j;<br />   <br />   // enable charging<br />   PORTB &amp;= ~PB5; <br />   <br />   counter = 0;<br />   voltageCounter = 0;<br />   average = 0;<br />   oldAverage = 10000;<br />   <br />   while &#40;true&#41;<br />   &#123;<br />       voltage&#91;voltageCounter&#93; = readADC&#40;1&#41;;<br />      voltage&#91;voltageCounter&#93; *= 2;<br />      voltageCounter++;<br />      <br />      if &#40;voltageCounter &gt;= RECHARGECYCLES&#41;<br />      &#123;<br />         voltageCounter = 0;<br />         <br />         // min sort<br />         unsigned int min;<br />         int minId;<br />         for &#40;i=0; i&lt;RECHARGECYCLES; i++&#41;<br />         &#123;<br />            min = voltage&#91;i&#93;;<br />            minId = i;<br />            for &#40;j=i+1; j&lt;RECHARGECYCLES; j++&#41;<br />               if &#40;voltage&#91;j&#93; &lt; min&#41;<br />               &#123;<br />                  minId = j;<br />                  min = voltage&#91;j&#93;;<br />               &#125;<br />               <br />            min = voltage&#91;i&#93;;<br />            voltage&#91;i&#93; = voltage&#91;minId&#93;;<br />            voltage&#91;minId&#93; = min;<br />         &#125;<br />         <br />         // calc average &#40;without REMOVECYCLES largest and smallest values&#41;<br />         unsigned long int tmp = voltage&#91;RECHARGECYCLES&#93;;<br />         for &#40;i=RECHARGEREMOVECYCLES+1; i&lt;RECHARGECYCLES-RECHARGEREMOVECYCLES; i++&#41;<br />         &#123;<br />               tmp += voltage&#91;i&#93;;<br />         &#125;<br />         <br />         double tmpf = &#40;double&#41; tmp / &#40;&#40;double&#41;&#40;RECHARGECYCLES-2*RECHARGEREMOVECYCLES&#41;&#41;;<br />         <br />         average = &#40;unsigned int&#41; &#40;tmpf + 0.5&#41;;<br />         <br />         if &#40;average &gt;= oldAverage&#41; // unchanged<br />            counter++;<br />         else<br />         &#123;<br />            counter = 0; // reset counter if changed<br />            oldAverage = average;<br />         &#125;<br />      &#125;<br />      <br />      if &#40;counter &gt;= maxCycles&#41;<br />      &#123;<br />         buffer&#91;0&#93; = 0xFF;<br />         buffer&#91;1&#93; = 0xFF;<br />         buffer&#91;2&#93; = 0xFF;<br />         buffer&#91;3&#93; = 0xFF;<br />         buffer&#91;4&#93; = 0xFF;<br />         buffer&#91;5&#93; = 0xFF;<br />         buffer&#91;6&#93; = 0xFF;<br />         buffer&#91;7&#93; = 0xFF;<br />         writeData&#40;buffer, 8&#41;;<br />         break;<br />      &#125;   <br />         <br />      buffer&#91;0&#93; = voltage&#91;&#40;voltageCounter - 1&#41; % RECHARGECYCLES&#93;  &amp; 0xFF;<br />      buffer&#91;1&#93; = &#40;voltage&#91;&#40;voltageCounter - 1&#41; % RECHARGECYCLES&#93; &#41; &gt;&gt; 8;<br />      buffer&#91;2&#93; = average &amp; 0xFF;<br />      buffer&#91;3&#93; = &#40;average&#41; &gt;&gt; 8;<br />      buffer&#91;4&#93; = counter &amp; 0xFF;<br />      buffer&#91;5&#93; = &#40;counter &amp; 0xFF00&#41; &gt;&gt; 8;<br />      buffer&#91;6&#93; = maxCycles &amp; 0xFF;<br />      buffer&#91;7&#93; = &#40;maxCycles &amp; 0xFF00&#41; &gt;&gt; 8;<br />      writeData&#40;buffer, 8&#41;;<br />      <br />      sleep&#40;RECHARGEPAUSE&#41;; //1000ms<br />   &#125;<br />   <br />   // disable charging<br />   PORTB |= PB5; <br />&#125;</code></dd></dl><p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=412">cosa</a> — Wed Apr 23, 2008 10:41 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Kess]]></name></author>
<updated>2008-04-05T22:46:44+01:00</updated>
<published>2008-04-05T22:46:44+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=15212#p15212</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=15212#p15212"/>
<title type="html"><![CDATA[New good solution for C programmers?]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=15212#p15212"><![CDATA[
Sorry, I'm not sure what you mean by &quot;the buttons are pushed permanent&quot;.  If one or more of the buttons on your CM-5 have stuck down then I don't see how this could be caused by overcharging - none of the buttons are directly connected to the charging circuit.<br /><br />The pushbuttons are small switches mounted on the printed circuit board beneath the plastic buttons - see   <!-- m --><a class="postlink" href="http://robosavvy.com/Builders/Kess/CM5_PCB_Rear_1.jpg">http://robosavvy.com/Builders/Kess/CM5_PCB_Rear_1.jpg</a><!-- m --> .  I don't know if you have any experience of electronics but you could open up your CM-5 and use a multimeter to check the resistance of each the switches and see if any is permanently closed.<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=809">Kess</a> — Sat Apr 05, 2008 10:46 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[bergere]]></name></author>
<updated>2008-04-04T10:38:43+01:00</updated>
<published>2008-04-04T10:38:43+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=15173#p15173</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=15173#p15173"/>
<title type="html"><![CDATA[New good solution for C programmers?]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=15173#p15173"><![CDATA[
Thx, but I think it´s to late.<br />After charging CM-5 the Buttons on the top are pushed permanent. I loaded my software on another CM-5 and it works fine.  Is it possible that this is a effect of overcharging?<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=818">bergere</a> — Fri Apr 04, 2008 10:38 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Kess]]></name></author>
<updated>2008-03-17T20:45:58+01:00</updated>
<published>2008-03-17T20:45:58+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14851#p14851</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14851#p14851"/>
<title type="html"><![CDATA[New good solution for C programmers?]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14851#p14851"><![CDATA[
Hi Bergere,<br /><br />Your numbers of 32/610 look about right; assuming those are the raw ADC data values from ADC1 and ADC0 then they equate to about 0.64V for the battery -ve and 12.2V for the battery +ve.  <br /><br />During charging the lower number should get smaller and eventually stop changing.  At that point the battery is full and you should disable the charging - please be careful not to overcharge the battery!<br /><br />Kess<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=809">Kess</a> — Mon Mar 17, 2008 8:45 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[pieddemamouth]]></name></author>
<updated>2008-03-17T18:33:08+01:00</updated>
<published>2008-03-17T18:33:08+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14849#p14849</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14849#p14849"/>
<title type="html"><![CDATA[New good solution for C programmers?]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14849#p14849"><![CDATA[
Personaly, my code for charging is :<br /><dl class="codebox"><dt>Code: </dt><dd><code>PORTB &amp;= ~PB5;<br /></code></dd></dl><br /><br />I haven't use my bioloid for a while, so I don't remember exactly my last test. But I have done as Kess as said : doubled the value and display it (value in mV). Here is my code for displaying :<br /><dl class="codebox"><dt>Code: </dt><dd><code>int main&#40;void&#41; &#123;<br />    CM5_init&#40;&#41;;<br />    unsigned int i=1, retour,condition=0;<br /><br />    PORTE |= _BV&#40;PE4&#41;;    //enable pull-up resistor 4<br />    EIMSK |= _BV&#40;INT4&#41;;   //enable interrupt 4<br />    DDRC = 0xFF;<br />    PORTC = 0xFF;<br />    DDRB |= _BV&#40;DDB5&#41;;  //output for bit PB5<br /><br />    //ADC configuration<br />    ADMUX = 0x10;<br />    ADCSRA = 0x80;<br /><br />    while&#40;1&#41;<br />    &#123;<br />            CM5_RS232_writeString&#40;&quot;\rTension batterie : &quot;&#41;;<br />            retour = ReadADC&#40;16&#41;;<br />            retour = retour*2;<br />            CM5_RS232_writeHexInt&#40;retour&#41;;<br />            CM5_RS232_writeString&#40;&quot;\n\r&quot;&#41;;<br />    &#125;<br />&#125;<br /></code></dd></dl><p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=908">pieddemamouth</a> — Mon Mar 17, 2008 6:33 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[bergere]]></name></author>
<updated>2008-03-17T09:53:26+01:00</updated>
<published>2008-03-17T09:53:26+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14830#p14830</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14830#p14830"/>
<title type="html"><![CDATA[New good solution for C programmers?]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14830#p14830"><![CDATA[
I tried it again and know the batteries loading. <br />My mistake was that i forget the following function.<br /><dl class="codebox"><dt>Code: </dt><dd><code>if&#40;!&#40;DDRB &amp;&#40;1&lt;&lt;5&#41;&#41;&#41; DDRB |=&#40;1&lt;&lt;5&#41;;<br /></code></dd></dl><br /><br />I don´t know if I understand this function completly.<br /><br />if(DDRB!=1)then{DDRB=1}???<br /><br />And the output of Kess function give me the following Output.<br /><br />33/609...33/609...32/610... are this correct Output values? (I think you know it if you test the programm, too)<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=818">bergere</a> — Mon Mar 17, 2008 9:53 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[pieddemamouth]]></name></author>
<updated>2008-03-12T19:54:01+01:00</updated>
<published>2008-03-12T19:54:01+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14745#p14745</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14745#p14745"/>
<title type="html"><![CDATA[New good solution for C programmers?]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14745#p14745"><![CDATA[
Hi,<br /><br />Kess has give a programm at the top of this page. isn't it what you need ?<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=908">pieddemamouth</a> — Wed Mar 12, 2008 7:54 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[bergere]]></name></author>
<updated>2008-03-12T16:11:39+01:00</updated>
<published>2008-03-12T16:11:39+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14741#p14741</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14741#p14741"/>
<title type="html"><![CDATA[New good solution for C programmers?]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14741#p14741"><![CDATA[
Are there any news about Loading the Batteries?<br />Need a programm!  <img src="http://forum.robosavvy.com/images/smilies/icon_razz.gif" alt=":P" title="Razz" /><p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=818">bergere</a> — Wed Mar 12, 2008 4:11 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[pieddemamouth]]></name></author>
<updated>2008-02-18T22:44:50+01:00</updated>
<published>2008-02-18T22:44:50+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14224#p14224</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14224#p14224"/>
<title type="html"><![CDATA[New good solution for C programmers?]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14224#p14224"><![CDATA[
Thanks for your reply.<br />Now, i know why my code didn't work.<br /><br />See you<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=908">pieddemamouth</a> — Mon Feb 18, 2008 10:44 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Kess]]></name></author>
<updated>2008-02-18T21:40:05+01:00</updated>
<published>2008-02-18T21:40:05+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14220#p14220</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14220#p14220"/>
<title type="html"><![CDATA[New good solution for C programmers?]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14220#p14220"><![CDATA[
<blockquote><div><cite>pieddemamouth wrote:</cite><br />Why did you have choose &quot;AVCC with external capacitor at AREF pin&quot; for the voltage reference ... I have use &quot;AREF, Internal Vref turned off&quot; for the voltage reference.<br /></div></blockquote><br />Since the AREF pin is connected to AVCC you can use either setting, it should give the same result.<br /><blockquote class="uncited"><div><br />- Why did you have selected the &quot;ADC Prescaler&quot;. To my mind it's useless, we want the ADC result asap.<br /></div></blockquote><br />The ADC <span style="text-decoration: underline">can't</span> be run at the full 16MHz processor clock speed - some prescaling is essential.  According to the Atmel data sheet:<br /><blockquote class="uncited"><div><br />By default, the successive approximation circuitry requires an input clock frequency between 50kHz and 200kHz to get maximum resolution. If a lower resolution than 10 bits is needed, the input clock frequency to the ADC can be higher than 200kHz to get a higher sample rate.<br /></div></blockquote><br />My prescaler setting of 6 gives a divide-by-64 so the ADC clock rate will be 125kHz.  <br /><br />Out of interest I just tried adding a second ADC routine to my test code with a different prescaler setting, displaying the results of the two routines.  A prescaler setting of 5 (divide-by-32) seems to work fine, even though the 250kHz ADC clock speed is slightly higher than recommended, but a prescaler setting of 4 (divide-by-16) or less gives jittery results.<br /><br />I wouldn't worry about speeding up the ADC conversion, however, as voltage doesn't change very quickly.  It would be better to modify the ADC routine to prevent the processor having to wait for the result, e.g. use an interrupt to grab the result from the ADC when it's ready, or simply allow the processor to go away and do some other stuff and come back for the result later.  My little ADC routine can definitely be improved...<br /><br />Kess<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=809">Kess</a> — Mon Feb 18, 2008 9:40 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[pieddemamouth]]></name></author>
<updated>2008-02-17T15:49:14+01:00</updated>
<published>2008-02-17T15:49:14+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14196#p14196</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14196#p14196"/>
<title type="html"><![CDATA[New good solution for C programmers?]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14196#p14196"><![CDATA[
Hi,<br /><br />I've try your code Kess, and it works on my bioloid to. But I don't understand some of your configuration's choice :<br />- Why did you have choose &quot;AVCC with external capacitor at AREF pin&quot; for the voltage reference ? In one of your post you have said :<br /><blockquote class="uncited"><div><br />One other thing you guys may need to know is that the processor's AREF pin (pin 62), which provides the reference voltage for the ADC, is connected directly to the +5V rail.<br /></div></blockquote><br />So I have use &quot;AREF, Internal Vref turned off&quot; for the voltage reference.<br />- Why did you have selected the &quot;ADC Prescaler&quot;. To my mind it's useless, we want the ADC result asap.<br /><br />Thanks for your responses.<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=908">pieddemamouth</a> — Sun Feb 17, 2008 3:49 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[siempre.aprendiendo]]></name></author>
<updated>2008-02-14T14:12:08+01:00</updated>
<published>2008-02-14T14:12:08+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14134#p14134</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14134#p14134"/>
<title type="html"><![CDATA[New good solution for C programmers?]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14134#p14134"><![CDATA[
Wow, thank you very much, Kess<br /><br />I will try it asap <img src="http://forum.robosavvy.com/images/smilies/icon_smile.gif" alt=":)" title="Smile" /><br /><br />P.S.<br />As Lego with Mindstorms changed their &quot;policy&quot; form RCX to NXT, from non public information about hardware and software to <a href="http://mindstorms.lego.com/press/2057/Open%20Source%20Announcement.aspx" class="postlink">open source</a> &quot;policy&quot;, <a href="http://mindstorms.lego.com/Overview/NXTreme.aspx" class="postlink">publishing all the information</a>, included source code, of their Mindstorms NXT product, I hope that Robotis would take a similar path.<br /><br />I think that an open source policy will allow create software more easily than now, adding more value to Bioloid. At least with Mindstorms, the grow have been impressive from RCX, for example, <a href="http://mindstorms.lego.com/Books/" class="postlink">more than 10 books</a> about NXT in less than a year and half<br /><br />(Please, excuse my English  <img src="http://forum.robosavvy.com/images/smilies/icon_rolleyes.gif" alt=":roll:" title="Rolling Eyes" /> )<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=698">siempre.aprendiendo</a> — Thu Feb 14, 2008 2:12 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[pieddemamouth]]></name></author>
<updated>2008-02-14T07:44:04+01:00</updated>
<published>2008-02-14T07:44:04+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14132#p14132</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14132#p14132"/>
<title type="html"><![CDATA[New good solution for C programmers?]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14132#p14132"><![CDATA[
Thanks for your code.<br />I will test it this week-end and aware you of the results<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=908">pieddemamouth</a> — Thu Feb 14, 2008 7:44 am</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Kess]]></name></author>
<updated>2008-02-13T23:18:37+01:00</updated>
<published>2008-02-13T23:18:37+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14128#p14128</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14128#p14128"/>
<title type="html"><![CDATA[New good solution for C programmers?]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14128#p14128"><![CDATA[
Hi again,<br /><br />My ADC reading code (which uses the 5V supply as the ADC reference) is as follows:<br /><br /><dl class="codebox"><dt>Code: </dt><dd><code>unsigned ReadADC&#40;byte channel&#41;<br />&#123;<br />    ADMUX  = 0x40 | channel;<br />    ADCSRA = 0xC6; <br />    while&#40;bit_is_set&#40;ADCSRA, ADSC&#41;&#41;;<br />    return &#40;ADCL | &#40;ADCH&lt;&lt;8&#41;&#41;;<br />&#125;<br /></code></dd></dl><br /><br />This works for me.  I call the function with the parameter set to 0 to read ADC0 (the battery +ve voltage) or 1 to read ADC1 (the battery -ve voltage).  My test program has a simple loop that continuously reads and displays the two ADCs and allows me to enable or disable charging by pressing the buttons on the CM-5.<br /><br />A couple of other things:<br /><br />- The actual battery voltage is equal to the data from ADC0 or ADC1 multiplied by 0.01968 (this factor allows for the resistive potential dividers in the circuit as well as the 5V reference voltage etc.).  However, if you simply double the ADC data you'll get a result that gives voltage in 10mV steps (e.g. a result of 1250 means 12.50 volts) and is less than 2% in error.<br /><br />- Battery charging is controlled by PORTB pin PB5.  Charging is activated by setting PB5 to 0 and disabled by setting PB5 to 1.  Charging progress can be monitored by watching the voltage on ADC1, which creeps downwards as the battery gets charged; I guess the &quot;official&quot; charging code disables charging once the rate of change on ADC1 drops below a certain rate.<br /> <br />Hope that helps,<br />Kess<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=809">Kess</a> — Wed Feb 13, 2008 11:18 pm</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[Kess]]></name></author>
<updated>2008-02-13T22:21:50+01:00</updated>
<published>2008-02-13T22:21:50+01:00</published>
<id>http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14126#p14126</id>
<link href="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14126#p14126"/>
<title type="html"><![CDATA[New good solution for C programmers?]]></title>

<content type="html" xml:base="http://forum.robosavvy.com/viewtopic.php?t=1783&amp;p=14126#p14126"><![CDATA[
Hi pieddemamouth,<br /><br />I wrote some ADC software a couple of months ago to verify that the ADCs worked as predicted by my CM-5 circuit diagram and observe how they changed during charging.  I'll dig out the code and post it here shortly...  <br /><br />Kess<p>Statistics: Posted by <a href="http://forum.robosavvy.com/memberlist.php?mode=viewprofile&amp;u=809">Kess</a> — Wed Feb 13, 2008 10:21 pm</p><hr />
]]></content>
</entry>
</feed>