<?xml version="1.0" encoding="UTF-8"?>        <rss version="2.0"
             xmlns:atom="http://www.w3.org/2005/Atom"
             xmlns:dc="http://purl.org/dc/elements/1.1/"
             xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
             xmlns:admin="http://webns.net/mvcb/"
             xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
             xmlns:content="http://purl.org/rss/1.0/modules/content/">
        <channel>
            <title>
									Battery Charger array of objects - Help Wanted				            </title>
            <link>https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/</link>
            <description>Discussion board for Robotics, Arduino, Raspberry Pi and other DIY electronics and modules. Join us today!</description>
            <language>en-US</language>
            <lastBuildDate>Mon, 08 Jun 2026 20:15:55 +0000</lastBuildDate>
            <generator>wpForo</generator>
            <ttl>60</ttl>
							                    <item>
                        <title>RE: Battery Charger array of objects</title>
                        <link>https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12673</link>
                        <pubDate>Fri, 28 Aug 2020 17:55:04 +0000</pubDate>
                        <description><![CDATA[OK, I&#039;ve largely got this working now, both the INA219 &amp; BatteryHolder classes are finally playing nice. Now i just have to work out how to have four of these instances running &#039;virtuall...]]></description>
                        <content:encoded><![CDATA[<p>OK, I've largely got this working now, both the INA219 &amp; BatteryHolder classes are finally playing nice. Now i just have to work out how to have four of these instances running 'virtually' in my battery slots of the charger.</p>
<p> </p>
<p>Thnx for the help!</p>
<p> </p>
<p>Christine</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/help-wanted/">Help Wanted</category>                        <dc:creator>Christine86</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12673</guid>
                    </item>
				                    <item>
                        <title>RE: Battery Charger array of objects</title>
                        <link>https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12643</link>
                        <pubDate>Tue, 25 Aug 2020 19:19:08 +0000</pubDate>
                        <description><![CDATA[Okay, I&#039;m so sorry, I&#039;m not doing this intentionally, I&#039;m trying to learn C++. I even bought a second hand copy of &#039;C++ Primer&#039; by Lippmam, Lajoie &amp; Moo(imagine going through life with t...]]></description>
                        <content:encoded><![CDATA[<p>Okay, I'm so sorry, I'm not doing this intentionally, I'm trying to learn C++. I even bought a second hand copy of 'C++ Primer' by Lippmam, Lajoie &amp; Moo(imagine going through life with that name).</p>
<p>It's supposed to be the C++ bible, but not exactly the Rosetta stone, easily translated to my experience level.</p>
<p>I'm attaching my .INO.h files, &amp; will have to copy my .cpp file(is there a way to upload that, other than by 'pasting' it?)</p>
<p>About two months go, I started designing the display portion of my charger design, &amp; had succeeded in making the display. </p>
1936
<p> </p>
<p>The battery charging portion, that you had helped me with, finally had no errors while compiling. So, earlier today, I put both together, &amp; it has refused to work for me. I'm getting ridiculous current readings of "inf mA", regardless of the PWM input I'm feeding it. I'm guessing I'm not actually linking the INA219, &amp; am receiving some built in value.</p>
<p>Again, I'm sorry. I'm trying to understand your help, but am not up to the task.</p>
<p>Christine</p>
1937
1938
<p>/* Battery Holder library<br /><br />Copyright 2020 Christine Whybrow</p>
<p><br />Unless required by applicable law or agreed to in writing,<br />software distributed under the License is distributed on an "AS IS" BASIS, <br />WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br />See the License for the specific language governing permissions and<br />limitations under the License.<br /><br />This library takes care of all the code to charge an individual battery, either AAA, AA.<br />Example of constructors for NiMH AA Battery in each slot. <br />You can of course change this, &amp; in that eventuality, you should vary the following <br /><br />BatterySlot: 1 BatterySlot: 2 BatterySlot: 3 BatterySlot: 4<br />PWN pin: 4 PWN pin: 6 PWN pin: 8 PWN pin: 10<br />Relay pin: 5 Relay pin: 7 Relay pin: 9 Relay pin: 11<br />Highside pin: A0 Highside pin: A3 Highside pin: A6 Highside pin: A9<br />Lowside pin: A1 Lowside pin: A4 Lowside pin: A7 Lowside pin: A10<br />Temperature pin; A2 Temperature pin; A5 Temperature pin; A8 Temperature pin; A11<br />BatteryType: 2 BatteryType: 2 BatteryType: 2 BatteryType: 2<br />Capacity: 2500 Capacity: 2500 Capacity: 2500 Capacity: 2500<br />ChargeRate: 6 ChargeRate: 6 ChargeRate: 6 ChargeRate: 6<br />INA219Adress: 0x40 INA219Adress: 0x41 INA219Adress: 0x42 INA219Adress: 0x43<br /><br />Please take care to assign the correct pins when constructing the individual battery circuit.</p>
<p>I have used 3.3v from the Arduino Mega, to supply the TMP36 temperature sensor, as this gives better<br />readings &amp; stability!<br />*/</p>
<p> </p>
<p>#include &lt;Wire.h&gt;<br />#include "Adafruit_INA219.h"<br />#include "BatteryHolder.h"<br />#include "Adafruit_INA219.h"</p>
<p>//#define I2C_ADDRESS1 0x40 //address of INA219 current sensor<br />//#define I2C_ADDRESS2 0x41<br />//#define I2C_ADDRESS3 0x42<br />//#define I2C_ADDRESS4 0x43</p>
<p>//Adafruit_INA219 slotCurrent(I2C_ADDRESS1); //One ina219 per battery</p>
<p>//Adafruit_INA219 slotCurrent = {<br />//Adafruit_INA219(I2C_ADDRESS1),<br />//Adafruit_INA219(I2C_ADDRESS2),<br />//Adafruit_INA219(I2C_ADDRESS3),<br />//Adafruit_INA219(I2C_ADDRESS4)<br />//};</p>
<p><br />//const float VGSmin = 2.0; //in volts for irf510<br />//const float VGSmax = 4.2; //in VGS conductive range<br />//int VGSminSet = VGSmin * 255/ 5.0;//Converts figures to PWM Output values<br />//int VGSmaxSet = VGSmax * 255 / 5.0;<br />//int startOutput = (VGSmaxSet + VGSminSet) / 2; //Pick an arbitrary mid point<br />//float nowOutput = startOutput;<br />//float CapacityNiMH = 2300; //in mAh<br />//float Capacity18650 = 3600; //maximum charge rate 1250mA<br />//float targetVoltage = 4200.0; //cut off in millivolts<br />//float XL005Set = 5.00; //manually adjust XL005 to this voltage for niMH<br />//float XL00518650set = 6.2; //manually adjust XL005 to this voltage for 18650<br />//int slot_Number = 1; //holds which slot is active</p>
<p>//float voltageHighAverage = 0; //this will hold ten high readings of battery voltage<br />//float voltageLowAverage = 0; //this will hold ten low readings of battery voltage<br />////float targetCurrent = Capacity18650 / 4;//416.0 mA<br />////float trickleCurrent = Capacity18650 / 20.0;//CapacityNiMH / 20, which is around 125.0 mA<br />//float currentAverage = 0; //allow averaging of current readings<br />//float nowCurrent = 0; //will hold the averaage current readings<br />//float highVolts = 0; //low side analog pin for slot 1 <br />//float lowVolts = 0; //high side analog pin for slot 1 <br />//float voltageOverCount = 0;<br />//double tempHolder = 0; //holds calculation of temperature<br />//double celsius = 0; //holds final celsius temperature<br />//int temperatureAverage = 0; //holds average of multiple temperature readings<br />//int temperatureCount = 0; //ensures through multtiple readings that temp must 'STOP'<br />//int temperatureOverCount = 0; //if temp over limit 3 times,we'STOP', &amp; go to trickle<br />//float TemperatureCutOff = 37.0; //Battery should go to trickle at this temp<br />//bool overTemp = false; //these will be set to 'true' if these conditions are met<br />//bool _overVolt = false;<br />//bool overTime = false;</p>
<p> </p>
<p>char *errorMsg[] = { "\t\t\tCurrent hasn't been changed", "\t\t\tCurrent has been increased",<br />"\t\t\tCurrent has been decreased", "\t\t\tBattery charged, going to trickle",<br />"\t\t\tTemperature exceeded, going to trickle","\t\t\tCharging STOPPED, time exceeded"};</p>
<p>BatteryHolder::BatteryHolder (int slot, int PWM, int relay, uint8_t highside, uint8_t lowside, <br />uint8_t temperature, int batteryType, float capacity, float chargeDivider,<br />uint8_t address)<br />{<br />_slot = slot;<br />_PWM = PWM;<br />_relay = relay;<br />_highside = highside;<br />_lowside = lowside;<br />_temperature = temperature;<br />_batteryType = batteryType;<br />_capacity = capacity;<br />_chargeDivider = chargeDivider;<br />_address = address;<br /><br />pinMode(PWM, OUTPUT); //Sets the gate voltage for MOSFET<br />pinMode(relay, OUTPUT);<br />pinMode(highside, INPUT); //Low side voltage of battery<br />pinMode(lowside, INPUT); //High side voltage of battery<br />pinMode(temperature, INPUT); //temperature of battery<br /><br />}<br /><br />bool BatteryHolder::setLimits(float targetCurrent, float targetVoltage, float trickleCurrent)<br />{<br />_targetCurrent = targetCurrent; //setlimits<br />_targetVoltage = targetVoltage;<br />_trickleCurrent = trickleCurrent;<br />}</p>
<p>void BatteryHolder::setBatteryParameters(int temperatureCutOff, int nowOutput, int VGSminSet, int VGSmaxSet, <br />int voltageOverCount, bool overVolt)<br />{<br />_temperatureCutOff = temperatureCutOff;<br />_nowOutput = nowOutput;<br />_VGSminSet = VGSminSet;<br />_VGSmaxSet = VGSmaxSet;<br />_voltageOverCount = 0;<br />_overVolt = false;<br /><br />}</p>
<p>void BatteryHolder::setNowOutput(int output)<br />{<br />_nowOutput = output;<br />}</p>
<p>bool BatteryHolder::batteryIsIn()<br />{<br />if (!_batteryInstalled)<br />{<br />_batteryInstalled = true;<br />return false;<br />}<br />return true;<br />}</p>
<p>bool BatteryHolder::returnBatteryInsertion()<br />{<br />return _batteryInstalled;<br />}</p>
<p>float BatteryHolder::batteryInstalled()<br />{<br />//float temp = analogRead(_highside);<br />//_batteryInstalled = true;<br /><br />return analogRead(_highside);<br />}</p>
<p>BatteryHolder::~BatteryHolder()<br />{<br />// set a destructor here if needed<br />}</p>
<p>bool BatteryHolder::doesExist()<br />{<br />return true;<br />}</p>
<p>bool BatteryHolder::setCapacity(float capacity)<br />{<br />_capacity = capacity;<br />return true;<br />}</p>
<p>bool BatteryHolder::setBatteryType(int batteryType)<br />{<br />_batteryType = batteryType;<br />return true;<br />}</p>
<p>bool BatteryHolder::setChargeDivider(float chargeFraction)<br />{<br />_chargeDivider = chargeFraction;<br />return true;<br />}</p>
<p>void BatteryHolder::setTimeToStop(unsigned long stopTime) //When battery inserted, note time to STOP<br />{<br />_timeToStop = stopTime + millis(); //note the start of charging<br />return true; <br />}<br />/* <br />* This is the main program, doing the bulk of the work to charge the battery<br />* **************************************************************************<br />*/<br />bool BatteryHolder::batteryUpdate()<br />{ <br /><br /><br />if (millis() &gt; _timeToStop)<br />{<br />Serial.print("at start of time loop ");Serial.print(_timeToStop);Serial.print("\t\t"); Serial.println(millis());<br />return false; //charging has been stopped, go no further<br />}<br />digitalWrite(_relay, HIGH); <br />analogWrite(_PWM, _nowOutput);<br />Serial.print(_PWM); Serial.print("\t");Serial.println( _nowOutput);<br />delay(50); //allow time for mosfet to settle<br /><br />float currentAverage = 0; //reset average tally<br />for (int i =0; i&lt;10; i++)<br />{<br />currentAverage += slotCurrent.getCurrent_mA();//get another reading<br />delay(60); //allow MOSFET to settle between readings<br />}<br />float _nowCurrent = currentAverage / 10; //we now have ten readings to average</p>
<p>analogWrite(_PWM, 0); //temporarially stop charging<br />digitalWrite(_relay, LOW); //switch relay 'OFF' to allow precision measure of voltage<br />delay(50); //allow time to settle</p>
<p>float temperatureAverage = 0;<br />float voltageHighAverage = 0; //reset average tally<br />float voltageLowAverage = 0;<br />for (int i =0; i&lt;10; i++)<br />{<br />voltageHighAverage += analogRead(_highside);//get another high reading<br />voltageLowAverage += analogRead(_lowside);//get another low reading<br />temperatureAverage += analogRead(_temperature);<br />delay(50); //allow probes to settle between readings<br />}<br /><br />temperatureAverage = temperatureAverage / 10;<br />int readPin = temperatureAverage;<br />double tempHolder = (double)readPin / 1024;<br />tempHolder = tempHolder * 5;<br />tempHolder = tempHolder - 0.5;<br />float celsius = tempHolder * 100;<br /><br />float highVolt = voltageHighAverage / 10; //we now have ten readings to average<br />float lowVolt = voltageLowAverage / 10;<br />float highVolts = highVolt * (5000.0 / 1023.0);<br />float lowVolts = lowVolt * (5000.0 / 1023.0);<br />float voltage = highVolts - lowVolts;<br />delay(50);<br /><br />Serial.println("\t**************Reading battery charge*********************");<br />Serial.print("\t* PWM Output: "); Serial.print(_nowOutput); Serial.println("\t\t\t*");<br />Serial.print("\t* battery current: "); Serial.print(_nowCurrent); Serial.println(" mA \t\t*");<br />Serial.print("\t* high reading: "); Serial.print(highVolt); Serial.println("\t\t\t*");<br />Serial.print("\t* low reading: "); Serial.print(lowVolt); Serial.println("\t\t\t*");<br />Serial.print("\t* high voltage: "); Serial.print(highVolts); Serial.println(" mV \t\t*");<br />Serial.print("\t* low voltage: "); Serial.print(lowVolts); Serial.println(" mV \t\t*");<br />Serial.print("\t* battery voltage: "); Serial.print(voltage); Serial.println(" mV \t\t*");<br />Serial.print("\t* temperature: "); Serial.print(celsius); Serial.println(" C \t\t\t*");<br />Serial.println("\t*********************************************************\n\n");<br /><br />analogWrite(_PWM, _nowOutput);<br />digitalWrite(_relay, HIGH);</p>
<p><br />if (voltage &gt; _targetVoltage)<br />{<br />if (_voltageOverCount &gt; 3)<br />{<br />Serial.println(errorMsg);<br />_targetCurrent = _trickleCurrent; //need to stop heavy charging<br />_nowOutput = _VGSminSet;<br />_overVolt = true;<br />_voltageOverCount = 0; <br />}<br />_voltageOverCount++;<br />return true; <br />}<br />if (celsius &gt; _temperatureCutOff)<br />{<br /><br />if (_temperatureOverCount &gt; 3)<br />{<br />_nowOutput = _VGSminSet; //drop PWM output back to lowest output<br />_temperatureOverCount = 0; //reset the count<br />_overTemp = true;<br />Serial.println(errorMsg);<br />return false;<br />}<br />_overTemp = false; //charging CAN go back to full rate, after cooling<br />_temperatureOverCount++;<br />return true; //keep charging for now<br /><br />}<br />if (millis() &gt; _timeToStop) //Out of time<br />{<br />Serial.println(errorMsg);<br />digitalWrite(_relay, HIGH); //switch off charging circuit<br />_nowOutput = 0; //turn off PWM output<br />//overTime = true; //no more charging allowed<br />return false;<br />}<br /><br />if (abs(_nowCurrent - _targetCurrent) &gt; 25) //Don't change output unless greater than 25mA difference<br />{<br />if ((_nowCurrent &gt; _targetCurrent) &amp;&amp; (_nowOutput &gt; _VGSminSet))<br />{<br />_nowOutput--;<br />Serial.println(errorMsg);<br />return true;<br />}<br /><br />else if ((_nowCurrent &lt; _targetCurrent) &amp;&amp; (_nowOutput &lt; _VGSmaxSet))<br />{<br />_nowOutput++;<br />Serial.println(errorMsg);<br />return true;<br />}<br /><br />}<br />Serial.println(errorMsg); <br /><br />return true;</p>
<p>}</p>
<p> </p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/help-wanted/">Help Wanted</category>                        <dc:creator>Christine86</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12643</guid>
                    </item>
				                    <item>
                        <title>RE: Battery Charger array of objects</title>
                        <link>https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12596</link>
                        <pubDate>Sun, 23 Aug 2020 07:45:54 +0000</pubDate>
                        <description><![CDATA[@christine86

 Posted by: @christine86 
Hi,
I think I&#039;d already tried this.

I&#039;m not sure what you mean by that, because as an experienced C++ programmer, the error message that I conf...]]></description>
                        <content:encoded><![CDATA[<p>@christine86</p>
<blockquote data-userid="2663" data-postid="12588" data-mention="christine86">
<div class="wpforo-post-quote-author"><strong> Posted by: @christine86 </strong></div>
<p>Hi,</p>
<p>I think I'd already tried this.</p>
</blockquote>
<p>I'm not sure what you mean by that, because as an experienced C++ programmer, the error message that I confirmed to you previously, was pretty accurate and very clear!</p>
<blockquote data-userid="2663" data-postid="12588" data-mention="christine86">
<div class="wpforo-post-quote-author"><strong> Posted by: @christine86 </strong></div>
<p>Can you tell me what I'm doing wrong? I think I've tried just about everything....except the RIGHT thing apparently!</p>
<p>Thanks again, sorry my C++ experience is limited, I'd mostly just thought this project would allow me to learn Fusion360, though now, that's been the EASIER part.</p>
<p> </p>
</blockquote>
<p>I'm trying to help you, but you're changing your code without really understanding what's going on, and at the same time, you're not providing us with the details of the changes you have made in your code!</p>
<p>Please elaborate, provide your latest code changes and error messages, and lets take it from there, OK?</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/help-wanted/">Help Wanted</category>                        <dc:creator>frogandtoad</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12596</guid>
                    </item>
				                    <item>
                        <title>RE: Battery Charger array of objects</title>
                        <link>https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12590</link>
                        <pubDate>Sat, 22 Aug 2020 17:49:17 +0000</pubDate>
                        <description><![CDATA[I&#039;ve found the problem, I have declared the Adafruit_INA219 as a private member of the BatteryHolder.h file. I&#039;ve altered lots of things, I have to now check what i THINK it does, is what it...]]></description>
                        <content:encoded><![CDATA[<p>I've found the problem, I have declared the Adafruit_INA219 as a private member of the BatteryHolder.h file. I've altered lots of things, I have to now check what i THINK it does, is what it ACTUALLY does;</p>
<p> </p>
<p>but at least it's stopped drowning me in 'error messages'!</p>
<p> </p>
<p>Thnx I'm hoping this might be IT!</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/help-wanted/">Help Wanted</category>                        <dc:creator>Christine86</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12590</guid>
                    </item>
				                    <item>
                        <title>RE: Battery Charger array of objects</title>
                        <link>https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12588</link>
                        <pubDate>Sat, 22 Aug 2020 16:30:47 +0000</pubDate>
                        <description><![CDATA[Hi,
I think I&#039;d already tried this.
If I put this in my main Battery_Charger_v2.INO file;
#define I2C_ADDRESS1 0x40 //address of INA219 current sensor#define I2C_ADDRESS2 0x41#define I2C_...]]></description>
                        <content:encoded><![CDATA[<p>Hi,</p>
<p>I think I'd already tried this.</p>
<p>If I put this in my main Battery_Charger_v2.INO file;</p>
<p>#define I2C_ADDRESS1 0x40 //address of INA219 current sensor<br />#define I2C_ADDRESS2 0x41<br />#define I2C_ADDRESS3 0x42<br />#define I2C_ADDRESS4 0x43</p>
<p>Adafruit_INA219 slotCurrent = {<br />Adafruit_INA219(I2C_ADDRESS1),<br />Adafruit_INA219(I2C_ADDRESS2),<br />Adafruit_INA219(I2C_ADDRESS3),<br />Adafruit_INA219(I2C_ADDRESS4)<br />};</p>
<p>then within my BatterHolder.cpp tells me that a call to slotCurrent[].whatever is 'out of scope'.</p>
<p> </p>
<p>If i put those same lines in BatteryHolder.CPP at the top, then a call to slotcurrent[].whatever is met with the same error, in Battery_Charger_v2.INO.</p>
<p> </p>
<p>Can you tell me what I'm doing wrong? I think I've tried just about everything....except the RIGHT thing apparently!</p>
<p> </p>
<p>Thanks again, sorry my C++ experience is limited, I'd mostly just thought this project would allow me to learn Fusion360, though now, that's been the EASIER part.</p>
<p> </p>
<p>Christine</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/help-wanted/">Help Wanted</category>                        <dc:creator>Christine86</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12588</guid>
                    </item>
				                    <item>
                        <title>RE: Battery Charger array of objects</title>
                        <link>https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12581</link>
                        <pubDate>Sat, 22 Aug 2020 04:57:18 +0000</pubDate>
                        <description><![CDATA[@christine86

 Posted by: @christine86 
URGH, I perhaps spoke too soon?
 
I&#039;m using a INA219 current sensor, to track the current applied to the rechargeable battery, &amp; have four of...]]></description>
                        <content:encoded><![CDATA[<p>@christine86</p>
<blockquote data-userid="2663" data-postid="12578" data-mention="christine86">
<div class="wpforo-post-quote-author"><strong> Posted by: @christine86 </strong></div>
<p>URGH, I perhaps spoke too soon?</p>
<p> </p>
<p>I'm using a INA219 current sensor, to track the current applied to the rechargeable battery, &amp; have four of them, each of which I've soldered tracks to give all four possible units.</p>
<p>As such, as I called every BatteryHolder  constructor 'object' I also called the Adafruit class like this;</p>
<p><strong><em>Adafruit_INA219 slotCurrent(_address);</em></strong><br /><strong><em>if (! slotCurrent.begin()) </em></strong><br /><strong><em>{</em></strong><br /><strong><em>Serial.println("Failed to find first INA219 chip");</em></strong><br /><strong><em>while (1) { delay(10); }</em></strong><br /><strong><em>}</em> </strong></p>
<p>I had hoped that would mean for every call to BatteryHolder::BatteryUpdate, would mean I was referring to those distinct objects, so I would be able to use something like this;</p>
<p><strong>float currentAverage = 0; //reset average tally</strong><br /><strong>for (int i =0; i&lt;10; i++)</strong><br /><strong>{</strong><br /><strong>currentAverage +=slotCurrent.getCurrent_mA();//get another reading</strong><br /><strong>delay(50); //allow MOSFET to settle between readings</strong><br /><strong>}</strong></p>
<p>I thought that having initialized the objects within my constructor, I could thereafter just refer to slotCurrent.whatever(), the class would ensure the right getCurrent() but alas, I get this error;</p>
<p> </p>
<p><span style="color: #0000ff;font-size: 10pt"><em>BatteryHolder.cpp:169:25: error: 'slotCurrent' was not declared in this scope</em></span><br /><span style="color: #0000ff;font-size: 10pt"><em>currentAverage +=slotCurrent.getCurrent_mA();//get another reading<br /></em><em>^~~~~~~~~~~</em></span></p>
<p> </p>
<p>Could I perhaps initialize the Adafruit sensor by returning a Adafruit_INA218 'object' or a -&gt;'pointer' so that the other calls to BatteryHolder subroutines, would know exactly WHICH sensor is being used at that time?</p>
<p>Or am I just getting myself confused? WHY can't I upload a '.cpp' file to here, now I'm confused bout THAT too.? I'll just attach it to the end here. This must be the MOST drawn out 'weekend build' in all history!</p>
</blockquote>
<p><span style="font-size: 10pt;color: #000000">The error message is correct... having a quick look, you have declared and defined the "<em><span style="color: #0000ff">slotCurrent</span>" variable of type "</em><span style="color: #0000ff">Adafruit_INA219</span><em>", local to your constructor "</em><span style="color: #0000ff">BatteryHolder::BatteryHolder(...)</span>".  Once your constructor runs, and your BatteryHolder objects are instantiated, this variable goes out of scope, therefore it is not visible in other parts of the code.</span></p>
<p><span style="font-size: 10pt;color: #000000">If you want it to be part of the class, add it is as a member variable of the class, and then dereference it with an object (or without and object if made static), or place it in the global namespace area which will make it easier to use overall.</span></p>
<div><span style="font-size: 10pt;color: #000000">I would try making it global first.</span></div>
<div> </div>
<div><span style="font-size: 10pt;color: #000000">Cheers!</span></div>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/help-wanted/">Help Wanted</category>                        <dc:creator>frogandtoad</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12581</guid>
                    </item>
				                    <item>
                        <title>RE: Battery Charger array of objects</title>
                        <link>https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12578</link>
                        <pubDate>Fri, 21 Aug 2020 20:22:20 +0000</pubDate>
                        <description><![CDATA[URGH, I perhaps spoke too soon?
 
I&#039;m using a INA219 current sensor, to track the current applied to the rechargeable battery, &amp; have four of them, each of which I&#039;ve soldered tracks t...]]></description>
                        <content:encoded><![CDATA[<p>URGH, I perhaps spoke too soon?</p>
<p> </p>
<p>I'm using a INA219 current sensor, to track the current applied to the rechargeable battery, &amp; have four of them, each of which I've soldered tracks to give all four possible units.</p>
<p>As such, as I called every BatteryHolder  constructor 'object' I also called the Adafruit class like this;</p>
<p><strong><em>Adafruit_INA219 slotCurrent(_address);</em></strong><br /><strong><em>if (! slotCurrent.begin()) </em></strong><br /><strong><em>{</em></strong><br /><strong><em>Serial.println("Failed to find first INA219 chip");</em></strong><br /><strong><em>while (1) { delay(10); }</em></strong><br /><strong><em>}</em> </strong></p>
<p>I had hoped that would mean for every call to BatteryHolder::BatteryUpdate, would mean I was referring to those distinct objects, so I would be able to use something like this;</p>
<p><strong>float currentAverage = 0; //reset average tally</strong><br /><strong>for (int i =0; i&lt;10; i++)</strong><br /><strong>{</strong><br /><strong>currentAverage +=slotCurrent.getCurrent_mA();//get another reading</strong><br /><strong>delay(50); //allow MOSFET to settle between readings</strong><br /><strong>}</strong></p>
<p>I thought that having initialized the objects within my constructor, I could thereafter just refer to slotCurrent.whatever(), the class would ensure the right getCurrent() but alas, I get this error;</p>
<p> </p>
<p><em>BatteryHolder.cpp:169:25: error: 'slotCurrent' was not declared in this scope</em><br /><em>currentAverage +=slotCurrent.getCurrent_mA();//get another reading<br /></em><em>^~~~~~~~~~~</em></p>
<p> </p>
<p>Could I perhaps initialize the Adafruit sensor by returning a Adafruit_INA218 'object' or a -&gt;'pointer' so that the other calls to BatteryHolder subroutines, would know exactly WHICH sensor is being used at that time?</p>
<p>Or am I just getting myself confused? WHY can't I upload a '.cpp' file to here, now I'm confused bout THAT too.? I'll just attach it to the end here. This must be the MOST drawn out 'weekend build' in all history! 😜 </p>
1931
1932
<p>/* Battery Holder library<br /><br />Copyright 2020 Christine Whybrow</p>
<p><br />Unless required by applicable law or agreed to in writing,<br />software distributed under the License is distributed on an "AS IS" BASIS, <br />WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br />See the License for the specific language governing permissions and<br />limitations under the License.<br /><br />This library takes care of all the code to charge an individual battery, either AAA, AA.<br />Example of constructors for NiMH AA Battery in each slot. <br />You can of course change this, &amp; in that eventuality, you should vary the following <br /><br />BatterySlot: 1 BatterySlot: 2 BatterySlot: 3 BatterySlot: 4<br />PWN pin: 4 PWN pin: 6 PWN pin: 8 PWN pin: 10<br />Relay pin: 5 Relay pin: 7 Relay pin: 9 Relay pin: 11<br />Highside pin: A0 Highside pin: A3 Highside pin: A6 Highside pin: A9<br />Lowside pin: A1 Lowside pin: A4 Lowside pin: A7 Lowside pin: A10<br />Temperature pin; A2 Temperature pin; A5 Temperature pin; A8 Temperature pin; A11<br />BatteryType: 2 BatteryType: 2 BatteryType: 2 BatteryType: 2<br />Capacity: 2500 Capacity: 2500 Capacity: 2500 Capacity: 2500<br />ChargeRate: 6 ChargeRate: 6 ChargeRate: 6 ChargeRate: 6<br />INA219Adress: 0x40 INA219Adress: 0x41 INA219Adress: 0x42 INA219Adress: 0x43<br /><br />Please take care to assign the correct pins when constructing the individual battery circuit.</p>
<p>I have used 3.3v from the Arduino Mega, to supply the TMP36 temperature sensor, as this gives better<br />readings &amp; stability!<br />*/</p>
<p> </p>
<p>#include &lt;Wire.h&gt;<br />#include "Adafruit_INA219.h"<br />#include "BatteryHolder.h"<br />#include "Adafruit_INA219.h"</p>
<p>//#define I2C_ADDRESS1 0x40 //address of INA219 current sensor<br />//#define I2C_ADDRESS2 0x41<br />//#define I2C_ADDRESS3 0x42<br />//#define I2C_ADDRESS4 0x43</p>
<p>//Adafruit_INA219 slotCurrent(I2C_ADDRESS1); //One ina219 per battery</p>
<p><br />const float VGSmin = 2.0; //in volts for irf510<br />const float VGSmax = 4.2; //in VGS conductive range<br />int VGSminSet = VGSmin * 255/ 5.0;//Converts figures to PWM Output values<br />int VGSmaxSet = VGSmax * 255 / 5.0;<br />int startOutput = (VGSmaxSet + VGSminSet) / 2; //Pick an arbitrary mid point<br />float nowOutput = startOutput;<br />//float CapacityNiMH = 2300; //in mAh<br />//float Capacity18650 = 3600; //maximum charge rate 1250mA<br />//float targetVoltage = 4200.0; //cut off in millivolts<br />float XL005Set = 5.00; //manually adjust XL005 to this voltage for niMH<br />float XL00518650set = 6.2; //manually adjust XL005 to this voltage for 18650<br />int slot_Number = 1; //holds which slot is active</p>
<p>float voltageHighAverage = 0; //this will hold ten high readings of battery voltage<br />float voltageLowAverage = 0; //this will hold ten low readings of battery voltage<br />//float targetCurrent = Capacity18650 / 4;//416.0 mA<br />//float trickleCurrent = Capacity18650 / 20.0;//CapacityNiMH / 20, which is around 125.0 mA<br />float currentAverage = 0; //allow averaging of current readings<br />float nowCurrent = 0; //will hold the averaage current readings<br />float highVolts = 0; //low side analog pin for slot 1 <br />float lowVolts = 0; //high side analog pin for slot 1 <br />float voltageOverCount = 0;<br />double tempHolder = 0; //holds calculation of temperature<br />double celsius = 0; //holds final celsius temperature<br />int temperatureAverage = 0; //holds average of multiple temperature readings<br />int temperatureCount = 0; //ensures through multtiple readings that temp must 'STOP'<br />int temperatureOverCount = 0; //if temp over limit 3 times,we'STOP', &amp; go to trickle<br />float TemperatureCutOff = 37.0; //Battery should go to trickle at this temp<br />bool overTemp = false; //these will be set to 'true' if these conditions are met<br />bool overVolt = false;<br />bool overTime = false;</p>
<p> </p>
<p>char *errorMsg[] = { "\t\t\tCurrent hasn't been changed", "\t\t\tCurrent has been increased",<br />"\t\t\tCurrent has been decreased", "\t\t\tBattery charged, going to trickle",<br />"\t\t\tTemperature exceeded, going to trickle","\t\t\tCharging STOPPED, time exceeded"};</p>
<p>BatteryHolder::BatteryHolder (int slot, int PWM, int relay, uint8_t highside, uint8_t lowside, <br />uint8_t temperature, int batteryType, float capacity, float chargeDivider,<br />uint8_t address)<br />{<br />_slot = slot;<br />_PWM = PWM;<br />_relay = relay;<br />_highside = highside;<br />_lowside = lowside;<br />_temperature = temperature;<br />_batteryType = batteryType;<br />_capacity = capacity;<br />_chargeDivider = chargeDivider;<br />_address = address;<br /><br />pinMode(PWM, OUTPUT); //Sets the gate voltage for MOSFET<br />pinMode(relay, OUTPUT);<br />pinMode(highside, INPUT); //Low side voltage of battery<br />pinMode(lowside, INPUT); //High side voltage of battery<br />pinMode(temperature, INPUT); //temperature of battery</p>
<p>Adafruit_INA219 slotCurrent(_address);<br />if (! slotCurrent.begin()) <br />{<br />Serial.println("Failed to find first INA219 chip");<br />while (1) { delay(10); }<br />} <br /><br />}<br /><br />bool BatteryHolder::setLimits(float targetCurrent, float targetVoltage, float trickleCurrent)<br />{<br />_targetCurrent = targetCurrent; //setlimits<br />_targetVoltage = targetVoltage;<br />_trickleCurrent = trickleCurrent;<br />}<br />BatteryHolder::~BatteryHolder()<br />{<br />// set a destructor here if needed<br />}</p>
<p>bool BatteryHolder::doesExist()<br />{<br />return true;<br />}</p>
<p>bool BatteryHolder::setCapacity(float capacity)<br />{<br />_capacity = capacity;<br />return true;<br />}</p>
<p>bool BatteryHolder::setBatteryType(int batteryType)<br />{<br />_batteryType = batteryType;<br />return true;<br />}</p>
<p>bool BatteryHolder::setChargeDivider(float chargeFraction)<br />{<br />_chargeDivider = chargeFraction;<br />return true;<br />}</p>
<p>bool BatteryHolder::setTimeToStop(double stopTime) //When battery inserted, note time to STOP<br />{<br />_timeToStop = stopTime + millis(); //note the start of chargingstartTime<br />return true; <br />}<br /><br />bool BatteryHolder::batteryUpdate()<br />{<br />if (overTime)<br />{<br />return false; //charging has been stopped, go no further<br />}<br />analogWrite(_PWM, nowOutput);<br />digitalWrite(_relay, HIGH);<br />delay(50); //allow time for mosfet to settle<br /><br />float currentAverage = 0; //reset average tally<br />for (int i =0; i&lt;10; i++)<br />{<br />currentAverage +=slotCurrent.getCurrent_mA();//get another reading<br />delay(50); //allow MOSFET to settle between readings<br />}<br />nowCurrent = currentAverage / 10; //we now have ten readings to average</p>
<p>analogWrite(_PWM, 0); //temporarially stop charging<br />digitalWrite(_relay, LOW); //switch relay 'OFF' to allow precision measure of voltage<br />delay(50); //allow time to settle</p>
<p>temperatureAverage = 0;<br />voltageHighAverage = 0; //reset average tally<br />voltageLowAverage = 0;<br />for (int i =0; i&lt;10; i++)<br />{<br />voltageHighAverage += analogRead(_highside);//get another high reading<br />voltageLowAverage += analogRead(_lowside);//get another low reading<br />temperatureAverage += analogRead(_temperature);<br />delay(50); //allow probes to settle between readings<br />}<br /><br />temperatureAverage = temperatureAverage / 10;<br />int readPin = temperatureAverage;<br />tempHolder = (double)readPin / 1024;<br />tempHolder = tempHolder * 5;<br />tempHolder = tempHolder - 0.5;<br />celsius = tempHolder * 100;<br /><br />float highVolt = voltageHighAverage / 10; //we now have ten readings to average<br />float lowVolt = voltageLowAverage / 10;<br />highVolts = highVolt * (5000.0 / 1023.0);<br />lowVolts = lowVolt * (5000.0 / 1023.0);<br />float voltage = highVolts - lowVolts;<br />delay(5000);<br /><br />Serial.println("\t**************Reading battery charge*********************");<br />Serial.print("\t* PWM Output: "); Serial.print(nowOutput); Serial.println("\t\t\t*");<br />// Serial.print("\t* target current: "); Serial.print(targetCurrent); Serial.println("\t\t\t*");<br />Serial.print("\t* battery current: "); Serial.print(nowCurrent); Serial.println(" mA \t\t*");<br />Serial.print("\t* high reading: "); Serial.print(highVolt); Serial.println("\t\t\t*");<br />Serial.print("\t* low reading: "); Serial.print(lowVolt); Serial.println("\t\t\t*");<br />Serial.print("\t* high voltage: "); Serial.print(highVolts); Serial.println(" mV \t\t*");<br />Serial.print("\t* low voltage: "); Serial.print(lowVolts); Serial.println(" mV \t\t*");<br />Serial.print("\t* battery voltage: "); Serial.print(voltage); Serial.println(" mV \t\t*");<br />Serial.print("\t* temperature: "); Serial.print(celsius); Serial.println(" C \t\t\t*");<br />Serial.println("\t*********************************************************\n\n");<br /><br />analogWrite(_PWM, nowOutput);<br />digitalWrite(_relay, HIGH);</p>
<p><br />if (voltage &gt; _targetVoltage)<br />{<br />if (voltageOverCount &gt; 3)<br />{<br />Serial.println(errorMsg);<br />_targetCurrent = _trickleCurrent; //need to stop heavy charging<br />nowOutput = VGSminSet;<br />overVolt = true;<br />voltageOverCount = 0; <br />}<br />voltageOverCount++;<br />return true; <br />}<br />if (celsius &gt; TemperatureCutOff)<br />{<br /><br />if (temperatureOverCount &gt; 3)<br />{<br />nowOutput = VGSminSet; //drop PWM output back to lowest output<br />temperatureOverCount = 0; //reset the count<br />overTemp = true;<br />Serial.println(errorMsg);<br />return false;<br />}<br />overTemp = false; //charging CAN go back to full rate, after cooling<br />temperatureOverCount++;<br />return true; //keep charging for now<br /><br />}<br />if (millis() &gt; _timeToStop) //Out of time<br />{<br />Serial.println(errorMsg);<br />digitalWrite(_relay, LOW); //switch off charging circuit<br />nowOutput = 0; //turn off PWM output<br />overTime = true; //no more charging allowed<br />return false;<br />}<br /><br />if (abs(nowCurrent - _targetCurrent) &gt; 25) //Don't change output unless greater than 25mA difference<br />{<br />if ((nowCurrent &gt; _targetCurrent) &amp;&amp; (nowOutput &gt; VGSminSet))<br />{<br />nowOutput--;<br />Serial.println(errorMsg);<br />return true;<br />}<br /><br />else if ((nowCurrent &lt; _targetCurrent) &amp;&amp; (nowOutput &lt; VGSmaxSet))<br />{<br />nowOutput++;<br />Serial.println(errorMsg);<br />return true;<br />}<br /><br />}<br />Serial.println(errorMsg); <br /><br />return true;</p>
<p>}</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/help-wanted/">Help Wanted</category>                        <dc:creator>Christine86</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12578</guid>
                    </item>
				                    <item>
                        <title>RE: Battery Charger array of objects</title>
                        <link>https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12539</link>
                        <pubDate>Wed, 19 Aug 2020 04:16:15 +0000</pubDate>
                        <description><![CDATA[@christine86

 Posted by: @christine86 
The first iteration you provided led to these errors;
IRF540_Test_take_2:48:21: error: no matching function for call to &#039;BatteryHolder::BatteryHol...]]></description>
                        <content:encoded><![CDATA[<p>@christine86</p>
<blockquote data-userid="2663" data-postid="12534" data-mention="christine86">
<div class="wpforo-post-quote-author"><strong> Posted by: @christine86 </strong></div>
<p><strong>The first iteration you provided led to these errors;</strong></p>
<p>IRF540_Test_take_2:48:21: error: no matching function for call to 'BatteryHolder::BatteryHolder()'<br />BatteryHolder Slot;<br />^<br />In file included from /Users/christine/Documents/Arduino/IRF540_Test_take_2/IRF540_Test_take_2.ino:41:0:</p>
</blockquote>
<p><span style="color: #0000ff"><em><strong></strong></em></span></p>
<blockquote data-userid="2663" data-postid="12534" data-mention="christine86">
<div class="wpforo-post-quote-author"><strong> Posted by: @christine86<br /><br /></strong>IT WORKS!!</div>
<p>Any idea why the first didn't work, was it reliant on my having a second 'default constructor'?</p>
</blockquote>
<p>Of course I do ;-)</p>
<p>In my previous post, I mentioned the following:</p>
<blockquote data-userid="171" data-postid="12533" data-mention="frogandtoad">
<div class="wpforo-post-quote-author"><strong> Posted by: @frogandtoad </strong></div>
<p>and you may need a <span style="color: #0000ff">default constructor</span>, if so, you should get a warning message stating something to that nature</p>
</blockquote>
<p>...and the message was:</p>
<blockquote data-userid="2663" data-postid="12534" data-mention="christine86">
<div class="wpforo-post-quote-author"><strong> Posted by: @christine86 </strong></div>
<p>IRF540_Test_take_2:48:21: error: no matching function for call to '<span style="color: #0000ff">BatteryHolder::BatteryHolder()</span>'</p>
</blockquote>
<p>...you see, the moment you declare your own constructor, the implementation no longer provides a default one for you, so an object(s) such as:</p>
<p><span>BatteryHolder Slot; // Requires default constructor<br />BatteryHolder Slot; // 4 objects that require the default constructor<br /></span></p>
<p>...will not compile.</p>
<p>So, for your class, just declare a default constructor as well: "BatteryHolder();", with the body in the .cpp implementation file like your custom constructor, and it should also work.</p>
<blockquote data-userid="2663" data-postid="12534" data-mention="christine86">
<div class="wpforo-post-quote-author"><strong> Posted by: @christine86 </strong></div>
<p>In any event, thank you, I hope I can now get this thing to work, &amp; finally be able to get this 'weekend task' working. My code does charge NiMH  Lithium batteries, I just have to get that done with my newly created class!</p>
<p>You &amp; <a title="Ruplicator" href="https://forum.dronebotworkshop.com/profile/ruplicator/">@Ruplicator</a> have both been fabulous  !</p>
</blockquote>
<p>Glad to help, and happy you got it working :-)</p>
<p>Cheers!</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/help-wanted/">Help Wanted</category>                        <dc:creator>frogandtoad</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12539</guid>
                    </item>
				                    <item>
                        <title>RE: Battery Charger array of objects</title>
                        <link>https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12534</link>
                        <pubDate>Tue, 18 Aug 2020 19:26:53 +0000</pubDate>
                        <description><![CDATA[The first iteration you provided led to these errors;
IRF540_Test_take_2:48:21: error: no matching function for call to &#039;BatteryHolder::BatteryHolder()&#039;BatteryHolder Slot;^In file includ...]]></description>
                        <content:encoded><![CDATA[<p><strong>The first iteration you provided led to these errors;</strong></p>
<p>IRF540_Test_take_2:48:21: error: no matching function for call to 'BatteryHolder::BatteryHolder()'<br />BatteryHolder Slot;<br />^<br />In file included from /Users/christine/Documents/Arduino/IRF540_Test_take_2/IRF540_Test_take_2.ino:41:0:<br />sketch/BatteryHolder.h:42:5: note: candidate: BatteryHolder::BatteryHolder(int, int, int, uint8_t, uint8_t, uint8_t, int, float, float, uint8_t)<br />BatteryHolder (int slot, int PWM, int relay, uint8_t highside, uint8_t lowside,<br />^~~~~~~~~~~~~<br />sketch/BatteryHolder.h:42:5: note: candidate expects 10 arguments, 0 provided<br />sketch/BatteryHolder.h:39:7: note: candidate: constexpr BatteryHolder::BatteryHolder(const BatteryHolder&amp;)<br />class BatteryHolder<br />^~~~~~~~~~~~~<br />sketch/BatteryHolder.h:39:7: note: candidate expects 1 argument, 0 provided<br />IRF540_Test_take_2:49:1: error: 'Slot' does not name a type<br />Slot = BatteryHolder(1, 4, 5, A0, A1, A2, 3, 2300.0, 5.0, 0X40);<br />^~~~<br />IRF540_Test_take_2:50:1: error: 'Slot' does not name a type<br />Slot = BatteryHolder(2, 6, 7, A3, A4, A5, 3, 2300.0, 5.0, 0X41);<br />^~~~<br />IRF540_Test_take_2:51:1: error: 'Slot' does not name a type<br />Slot = BatteryHolder(3, 8, 9, A6, A7, A8, 3, 2300.0, 5.0, 0X42);<br />^~~~<br />IRF540_Test_take_2:52:1: error: 'Slot' does not name a type<br />Slot = BatteryHolder(4, 10, 11, A9, A10, A11, 3, 2300.0, 5.0, 0X43);<br />^~~~<br />exit status 1<br />no matching function for call to 'BatteryHolder::BatteryHolder()'</p>
<p><strong>The second, resulted in the following;</strong></p>
<p>IT WORKS!!</p>
<p>I couldn't believe it, as my slot.doesExist() returned that the class had been created!</p>
<p>Any idea why the first didn't work, was it reliant on my having a second 'default constructor'?</p>
<p>In any event, thank you, I hope I can now get this thing to work, &amp; finally be able to get this 'weekend task' working. My code does charge NiMH  Lithium batteries, I just have to get that done with my newly created class!</p>
<p>You &amp; @Ruplicator have both been fabulous 😍 !</p>
<p>Thnx,</p>
<p>Christine</p>
<p> </p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/help-wanted/">Help Wanted</category>                        <dc:creator>Christine86</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12534</guid>
                    </item>
				                    <item>
                        <title>RE: Battery Charger array of objects</title>
                        <link>https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12533</link>
                        <pubDate>Tue, 18 Aug 2020 15:56:57 +0000</pubDate>
                        <description><![CDATA[@christine86

 Posted by: @christine86 
Thank you for your response.
Unfortunately, I tried that method two days ago, &amp; had tried EVERYTHING I could think of!
Doing it as you sugges...]]></description>
                        <content:encoded><![CDATA[<p>@christine86</p>
<blockquote data-userid="2663" data-postid="12531" data-mention="christine86">
<div class="wpforo-post-quote-author"><strong> Posted by: @christine86 </strong></div>
<p>Thank you for your response.</p>
<p>Unfortunately, I tried that method two days ago, &amp; had tried EVERYTHING I could think of!</p>
<p>Doing it as you suggest, gives the following errors;</p>
<p>Arduino: 1.8.13 (Mac OS X), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"</p>
<p>IRF540_Test_take_2:48:23: error: conflicting declaration 'BatteryHolder Slot '<br />BatteryHolder Slot = BatteryHolder (2, 6, 7, A3, A4, A5, 3, 2300.0, 5.0, 0X41);<br />^</p>
</blockquote>
<p>Sorry, in my example I just copied your's and added the temporaries, but forgot to remove the multiples - Of course there will be conflicts having 4 slots :-)  Try either of the following, should work:</p>
<pre><span style="color: #000000">BatteryHolder</span> <span style="color: #000000">Slot</span><span style="color: #000000"></span><span style="color: #000000">;</span> 
<span style="color: #000000">Slot</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">BatteryHolder</span><span style="color: #000000">(</span><span style="color: #000000">1</span><span style="color: #434f54">,</span> <span style="color: #000000">4</span><span style="color: #434f54">,</span> <span style="color: #000000">5</span><span style="color: #434f54">,</span> <span style="color: #000000">A0</span><span style="color: #434f54">,</span> <span style="color: #000000">A1</span><span style="color: #434f54">,</span> <span style="color: #000000">A2</span><span style="color: #434f54">,</span> <span style="color: #000000">3</span><span style="color: #434f54">,</span> <span style="color: #000000">2300.0</span><span style="color: #434f54">,</span> <span style="color: #000000">5.0</span><span style="color: #434f54">,</span> <span style="color: #000000">0X40</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
<span style="color: #000000">Slot</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">BatteryHolder</span><span style="color: #000000">(</span><span style="color: #000000">2</span><span style="color: #434f54">,</span> <span style="color: #000000">6</span><span style="color: #434f54">,</span> <span style="color: #000000">7</span><span style="color: #434f54">,</span> <span style="color: #000000">A3</span><span style="color: #434f54">,</span> <span style="color: #000000">A4</span><span style="color: #434f54">,</span> <span style="color: #000000">A5</span><span style="color: #434f54">,</span> <span style="color: #000000">3</span><span style="color: #434f54">,</span> <span style="color: #000000">2300.0</span><span style="color: #434f54">,</span> <span style="color: #000000">5.0</span><span style="color: #434f54">,</span> <span style="color: #000000">0X41</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
<span style="color: #000000">Slot</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">BatteryHolder</span><span style="color: #000000">(</span><span style="color: #000000">3</span><span style="color: #434f54">,</span> <span style="color: #000000">8</span><span style="color: #434f54">,</span> <span style="color: #000000">9</span><span style="color: #434f54">,</span> <span style="color: #000000">A6</span><span style="color: #434f54">,</span> <span style="color: #000000">A7</span><span style="color: #434f54">,</span> <span style="color: #000000">A8</span><span style="color: #434f54">,</span> <span style="color: #000000">3</span><span style="color: #434f54">,</span> <span style="color: #000000">2300.0</span><span style="color: #434f54">,</span> <span style="color: #000000">5.0</span><span style="color: #434f54">,</span> <span style="color: #000000">0X42</span><span style="color: #000000">)</span><span style="color: #000000">;</span>
<span style="color: #000000">Slot</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">BatteryHolder</span><span style="color: #000000">(</span><span style="color: #000000">4</span><span style="color: #434f54">,</span> <span style="color: #000000">10</span><span style="color: #434f54">,</span> <span style="color: #000000">11</span><span style="color: #434f54">,</span> <span style="color: #000000">A9</span><span style="color: #434f54">,</span> <span style="color: #000000">A10</span><span style="color: #434f54">,</span> <span style="color: #000000">A11</span><span style="color: #434f54">,</span> <span style="color: #000000">3</span><span style="color: #434f54">,</span> <span style="color: #000000">2300.0</span><span style="color: #434f54">,</span> <span style="color: #000000">5.0</span><span style="color: #434f54">,</span> <span style="color: #000000">0X43</span><span style="color: #000000">)</span><span style="color: #000000">;</span>

<span style="color: #000000">Or</span><span style="color: #434f54">.</span><span style="color: #434f54">.</span><span style="color: #434f54">.</span>

<span style="color: #000000">BatteryHolder</span> <span style="color: #000000">Slot</span><span style="color: #000000"></span> <span style="color: #434f54">=</span> <span style="color: #000000">{</span>
  <span style="color: #000000">BatteryHolder</span><span style="color: #000000">(</span><span style="color: #000000">1</span><span style="color: #434f54">,</span> <span style="color: #000000">4</span><span style="color: #434f54">,</span> <span style="color: #000000">5</span><span style="color: #434f54">,</span> <span style="color: #000000">A0</span><span style="color: #434f54">,</span> <span style="color: #000000">A1</span><span style="color: #434f54">,</span> <span style="color: #000000">A2</span><span style="color: #434f54">,</span> <span style="color: #000000">3</span><span style="color: #434f54">,</span> <span style="color: #000000">2300.0</span><span style="color: #434f54">,</span> <span style="color: #000000">5.0</span><span style="color: #434f54">,</span> <span style="color: #000000">0X40</span><span style="color: #000000">)</span><span style="color: #434f54">,</span>
  <span style="color: #000000">BatteryHolder</span><span style="color: #000000">(</span><span style="color: #000000">2</span><span style="color: #434f54">,</span> <span style="color: #000000">6</span><span style="color: #434f54">,</span> <span style="color: #000000">7</span><span style="color: #434f54">,</span> <span style="color: #000000">A3</span><span style="color: #434f54">,</span> <span style="color: #000000">A4</span><span style="color: #434f54">,</span> <span style="color: #000000">A5</span><span style="color: #434f54">,</span> <span style="color: #000000">3</span><span style="color: #434f54">,</span> <span style="color: #000000">2300.0</span><span style="color: #434f54">,</span> <span style="color: #000000">5.0</span><span style="color: #434f54">,</span> <span style="color: #000000">0X41</span><span style="color: #000000">)</span><span style="color: #434f54">,</span>
  <span style="color: #000000">BatteryHolder</span><span style="color: #000000">(</span><span style="color: #000000">3</span><span style="color: #434f54">,</span> <span style="color: #000000">8</span><span style="color: #434f54">,</span> <span style="color: #000000">9</span><span style="color: #434f54">,</span> <span style="color: #000000">A6</span><span style="color: #434f54">,</span> <span style="color: #000000">A7</span><span style="color: #434f54">,</span> <span style="color: #000000">A8</span><span style="color: #434f54">,</span> <span style="color: #000000">3</span><span style="color: #434f54">,</span> <span style="color: #000000">2300.0</span><span style="color: #434f54">,</span> <span style="color: #000000">5.0</span><span style="color: #434f54">,</span> <span style="color: #000000">0X42</span><span style="color: #000000">)</span><span style="color: #434f54">,</span>
  <span style="color: #000000">BatteryHolder</span><span style="color: #000000">(</span><span style="color: #000000">4</span><span style="color: #434f54">,</span> <span style="color: #000000">10</span><span style="color: #434f54">,</span> <span style="color: #000000">11</span><span style="color: #434f54">,</span> <span style="color: #000000">A9</span><span style="color: #434f54">,</span> <span style="color: #000000">A10</span><span style="color: #434f54">,</span> <span style="color: #000000">A11</span><span style="color: #434f54">,</span> <span style="color: #000000">3</span><span style="color: #434f54">,</span> <span style="color: #000000">2300.0</span><span style="color: #434f54">,</span> <span style="color: #000000">5.0</span><span style="color: #434f54">,</span> <span style="color: #000000">0X43</span><span style="color: #000000">)</span>
 <span style="color: #000000">}</span><span style="color: #000000">;</span>
</pre>
<p>I had a quick look at your header file, and you may need a default constructor, if so, you should get a warning message stating something to that nature. Hopefully it's all good this time :-) Cheers</p>]]></content:encoded>
						                            <category domain="https://forum.dronebotworkshop.com/help-wanted/">Help Wanted</category>                        <dc:creator>frogandtoad</dc:creator>
                        <guid isPermaLink="true">https://forum.dronebotworkshop.com/help-wanted/battery-charger-array-of-objects/#post-12533</guid>
                    </item>
							        </channel>
        </rss>
		