monitoring Dc help


koal01
 

Hi Howard,
I'm running the 2.0g and it works fine !
I wired the heater on a relay following you advice and switch it on only in extreme conditions. The rest of the time i switched it off since the box is small, readings can be skewed.

Now i'm concentrating on the status panel and DC voltage/current.
So i have a question.
If i want to monitor my external 12 v supply implementing STAT_DC_PS_ANALOG and STAT_DC_CURRENT_ANALOG
i suppose i have to wire the "S" pins on analog pins to the  supply cable 12 V + ?
In my case i chose A0 and A1.
Concerning the current i see that we have to complete a function in the misc.ino file ?
Is it a future evolution or do we have to complete the current function ?
Sorry if i'm not clear.
Thank you
Koal01


Howard Dutton
 

On Wed, Jan 22, 2020 at 01:47 PM, koal01 wrote:
If i want to monitor my external 12 v supply implementing STAT_DC_PS_ANALOG and STAT_DC_CURRENT_ANALOG
i suppose i have to wire the "S" pins on analog pins to the  supply cable 12 V + ?
In my case i chose A0 and A1.
Yes the OCS PCB Analog inputs A0 to A5 can handle measuring 12V DC directly.  The inputs are resistor divided and diode clamped for protection.

Concerning the current i see that we have to complete a function in the misc.ino file ?
Is it a future evolution or do we have to complete the current function ?
Since the individual user must decide on a sensor to measure current there is no one size fits all solution.  Each must be added.  I don't use this feature, nor do I intend to use every feature supported by the OCS, it was designed to be more comprehensive than for just my own use.

For DC the V=IR relationship can easily be used to calculate the voltage drop (V) across a known low resistance (R.)  If you know both V and R you can then calculate (I) the current.
For AC you need a sensor designed for that.

Google is your friend, lots of Arduino projects out there.


koal01
 

Thank you Howard,

I would say nearly all the features in OCS interest me. LOL
I was wondering if my solar panels 150 Watts X 2 and 2 batteries 100AH could supply OCS and all the equipments that's why i'm interested in monitoring the power.

Just for fun here is my equipments list and max current needs :

#define POWER_DEVICE1_NAME "OnStep_12V-2A"
#define POWER_DEVICE2_NAME "Camera_RAF_12V_4A"
#define POWER_DEVICE3_NAME "Hub_Usb_12V_5A"
#define POWER_DEVICE4_NAME "Heating_IR_5V_0.2A"
#define LIGHT_ORW_RELAY               12 // 12V_1A

Don't know how much amp OCS needs for its on purpose at least 1 A i suppose ?

Again thank you and thank you
Koal01
 


koal01
 

Hi Howard,
What I meant when talking about measuring intensity it is more a feature measuring all the current drawn from the relays (I’m using 12 v dc), introducing a kind of ammeter.
Affer some research it seems that what I need is using an ACS712 module that would measure the curent consumed by the accessories (camera, lights, onstep, etc...) and display it on the status panel of OCS. My question is if I plug the output of the ACS712 module to the « S » pin of an analogic pin on the OCS board will it work ?
Sorry for this small mini arduino project in OCS but current in my setup is critical.
Nice sky
Koal01


Howard Dutton
 

Just wire in the device per the examples on the internet.  The ACS712 seems to have isolation so just wire it right into an unused Mega2560 analog input.

The following code should do the trick (add to Misc.ino)

// converts a raw analog reading into current for STAT_DC_CURRENT_ANALOG and STAT_BATTERY_CURRENT_ANALOG
// return (invalid) if not implemented or if there's an error
#define ACS712_ANALOG_PORT  A0
#define ACS712_mV_PER_A     0.185
double toDCAmps(double d) {
 double V=0;

 for (int i=0; i<25; i++) { V+=(analogRead(ACS712_ANALOG_PORT)/1024.0)*5.0; delay(1); }
 V/=25.0;
 double A = (2.5 - V)/ACS712_mV_PER_A;

return A;
}


Howard Dutton
 
Edited

Looking at that again it won't work, those are just conversion functions so...

I've expanded the range of allowed Analog ports into the Config.h settings and added the following code to an Misc.ino example in the OCS (master branch)...

// converts a raw analog reading into current for STAT_DC_CURRENT_ANALOG
// return (invalid) if not implemented or if there's an error
#define ACS712_V_PER_A 0.185
double toDCAmps(double d) {
 double V = (d/1024.0)*5.0;
 double A = (2.5 - V)/ACS712_V_PER_A;
 return A;
}

So now just add this code to Misc.ino and specify the analog port in Config.h
to enable it.

Note: this is for the ACS712ELCTR-05B-T, the +/- 5A device.


koal01
 

Thank you Howard for having implemented this feature.
So i updated OCS to 2.0 h yesterday and wired the ACS712 output to the A10 pin of the Mega.
Following examples in the web the ACS module is supplied on the negative source of the 12 V DC power on one pin and to let the current cross the module the other pin goes to the ground of the installation.
I can see the red led on the module meaning it is on, ok.
However the values i see in the panel are wrong. When i switch on OCS at the very beginning i can see 4 amps  without activating anything,  after a few minutes it decreases to around 2 amps.
When i swich lights, onstep, heating amps are not increasing or decreasing as if the system does not take anything into account.
My module is 20 A so i changed this line #define ACS712_V_PER_A 0.185 setting it to #define ACS712_V_PER_A 0.100 as described on the datasheet.
I left the systeme running all night long leaving only OCS running without any feature activated and here's the panel, the panel displays 6 A.
I certainly did something wrong but for the moment i have no idea of why it doe not work.

 
Thank you again
Koal01



Howard Dutton
 

Confirm the correct Mega2560 Analog input is connected.  Again, don't use one of the protected inputs on the OCS PCB use an spare Analog input right on the Mega2560.  Not much in that code to go wrong such that it doesn't return a proportional number of some sort.

If the correct voltage (proportional to the current) is produced on the device output (test with multi-meter) then we'll go from there.


koal01
 

Ok i'll do that, testing the output with a multimeter will be very instructive.
Thanks
Koal01


koal01
 

Howard,
I checked the analogic pin and the output it correctly wired on the A10 pin directly on the mega.
I tested with a multimeter the ACS712 output, i can read 2.588 to 2.618 volts  whereas the status panel displays 5 amps...
OCS, Onstep and 2 litghts were on at that moment, i swtiched off OnStep and the lights but OCS still displaid 5 amps

Thank you
Koal01


Howard Dutton
 

Ok, and if that's using...

#define STAT_DC_CURRENT_ANALOG A10

I'm out of ideas.


koal01
 

yes i've already set this statement like that.
Never mind !
i'll try to test the component on a bench with a simple sketch and if something appears interesting i'll try to report it to you

Thank you
Koal01


Howard Dutton
 
Edited

...2.588 to 2.618 let call it 2.6V

Code goes like this...

#define STAT_DC_CURRENT_ANALOG A10

The analogRead(A10) returns a value 0 to 1023 which equals 0 to 5V so d is about 532.

#define ACS712_V_PER_A 0.1
double toDCAmps(double d) {
 double V = (d/1024.0)*5.0;
 double A = (2.5 - V)/ACS712_V_PER_A;
 return A;
}

// gets the floating point current in Amps
... f=toDCAmps(analogRead(STAT_DC_CURRENT_ANALOG));
strcpy_P(tem ...

V=(532.0/1024.0)*5.0 which returns 2.6
A=(2.5-2.6)/0.1 which is -1.0 Amp.

Change the last line in the function to return abs(A); to make all values positive.


koal01
 

Howard,
 
There's something new with this change in the function using "return abs(A);"
Also i moved from pin A10 to A7, i had doubt on this A10 pin which seems out or badly soldered.
Now when i switch on and off the relays amps are increasing and decreasing so it is responding correctly now.
But OCS is displaying very small values going from 0.1 A to 0.5 A max, it should be higher.
I changed the code moving back the function with "return A;" but the values were the same but negatives
I'm going to check again if the ACS is a 20 Amp model and also have a look on the wiring
See you
Koal01


Howard Dutton
 

abs() is needed only since current is actually negative, reverse the leads and the value would be positive.  Still we aren't interested in that for this application so I'll add abs to the code.

As for the actual current have you measured it with the multi-meter to know roughly what it should be?


koal01
 

Hi Howard,
The ACS172 20 Amp is working nicely thanks to your misc.ino update
Sorry I was testing with my 2 spots in my shelter thinking they were 12V-1A but actually my spots are 12V-1W that it is to say 12V-0.08 Amp, using very low amps !
So the ACS was displaying around 0.2 Amps and i was expecting 2 Amps...shame !
I spent the afternoon launching gotos with OnStep, so interesting to see how much intensity drivers are drawing, never exceding 1.5 Amp.
I like this feature and you made it possible to do that. The status panel is done.

Thank you so much
Koal01