UPS system code problems

The EtherTen combines an Uno-equivalent Arduino-compatible board and Wiznet-based Ethernet support, along with a microSD card slot and Power-over-Ethernet support. [Product page]
Stylmast
Posts: 36
Joined: Sat Sep 06, 2014 8:19 am

UPS system code problems

Post by Stylmast » Mon Dec 08, 2014 7:14 am

I'm having a problem trying to combine 4 sketches into 1.

I'm building a UPS system with an arduino being used to monitor the system.

Current setup is - 12Vdc battery bank 600Ah, 30 Amp charger, 1Kw inverter.

This is a test rig to get all of the monitoring etc sorted out, I will be adding solar & maybe wind for charger at a later date.

All current monitoring is being done by Allegro ACS758 Series Hall Current Sensor, both Bi & uni directional. 50A & 200A units.

These are displaying output over ethernet to my computer and displaying via ajax gauges.

https://github.com/stylmast/UPS-system

The problem that I'm having is that has to do with the gauge code on the SD card, lines 17 - 20. I'm not sure what is wrong but this is where it appears to be.

Regards

Scott

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: UPS system code problems

Post by angusgr » Tue Dec 09, 2014 3:32 am

Hi Scott,

Sounds like an interesting project. Can you elaborate any more about the problems you are seeing?

You may find it useful to rename the two files in github to .htm and .ino respectively, so github knows that they are HTML & Arduino source code respectively - you'll get automatic syntax highlighting in the web interface then.


Angus

Stylmast
Posts: 36
Joined: Sat Sep 06, 2014 8:19 am

Re: UPS system code problems

Post by Stylmast » Tue Dec 09, 2014 4:12 am

Will change the github. Please make any comments on how to improve my code.

This is my first project, I'm having fun with it & no fun some days..

The problem I am having is trying to get the outputs code from the Arduino to talk correctly with the input for the gauges. I have the first one working ( volt meter ) but I don't get any data displayed on the rest of the gauges. The math is correct as each gauge work fine as a stand alone.

I think the problem is with the ('analog')[1] [2], [3] part. As [0] works. Maybe I have to change the code on the arduino. Code lines 182 - 200, not sure how this is working.

data_val1 = this.responseXML.getElementsByTagName('analog')[0].childNodes[0].nodeValue;
data_val2 = this.responseXML.getElementsByTagName('analog')[1].childNodes[0].nodeValue;
data_val3 = this.responseXML.getElementsByTagName('analog')[2].childNodes[0].nodeValue;
data_val4 = this.responseXML.getElementsByTagName('analog')[3].childNodes[0].nodeValue;
data_val1 = (data_val1 * 4.77 / 1024.0) / 0.2941;
data_val2 = ((data_val2 * 4.77 / 1024.0) - 2.385) / 0.04;
data_val3 = (data_val3 * 4.77 / 1024.0) / 0.2941;
data_val4 = ((data_val4 * 4.77 / 1024.0) - 0.5724) / 0.02;

When I have all of the above on the SD card and volt connected to the input A0 ( voltmeter ) the math does not get use. It only displays the the input value 0 - 1024 and the gauge needle is constantly moving because it out side of it paramaters. With only the one set of data_val 1 there it works.

I'm currently using a power supply 0 - 5 V instead of the sensors, as this is on my desk next to my computer and not standing out in my garage..

Also I'm thinking of making the code a little cleaner by put all of the related sensor code for each sensor into its own group.

Scott

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: UPS system code problems

Post by angusgr » Tue Dec 09, 2014 8:33 pm

Hi Scott,

This looks OK to me at a glance. You could try adding some debug code to the JavaScript, like:

Code: Select all

console.log("initial value " + data_val1);
... and sprinkle this at a few points, so you can log the initial raw value and then the value after you scale it, and check the values look right.

(The output from console.log appears in the "Browser Console" which is usually a tab on the developer tools section of your browser, exactly where depends on the browser.)


Angus

Stylmast
Posts: 36
Joined: Sat Sep 06, 2014 8:19 am

Re: UPS system code problems

Post by Stylmast » Wed Dec 10, 2014 12:37 am

Angus,

I will give it a go.

Scott

Stylmast
Posts: 36
Joined: Sat Sep 06, 2014 8:19 am

Re: UPS system code problems

Post by Stylmast » Fri Feb 06, 2015 2:05 am

I have gotten the code working for the first 3 gauges, still having a problem with the 4 one.
I will try the console log & see if that helps. I will update the code on grit hub also.

Stylmast
Posts: 36
Joined: Sat Sep 06, 2014 8:19 am

Re: UPS system code problems

Post by Stylmast » Fri Feb 06, 2015 2:12 am

I entered console.log etc into the code but I got an compile message - 'console' was not declared in this scope, how do I declare this?

angusgr
Freetronics Staff
Freetronics Staff
Posts: 853
Joined: Tue Apr 09, 2013 11:19 pm
Location: Melbourne, Australia
Contact:

Re: UPS system code problems

Post by angusgr » Sun Feb 08, 2015 10:57 pm

What web browser are you loading the JavaScript in? I thought 'console' was standard but it might only be named that on some browsers?

Stylmast
Posts: 36
Joined: Sat Sep 06, 2014 8:19 am

Re: UPS system code problems

Post by Stylmast » Mon Feb 09, 2015 11:38 pm

I'm using chrome. I have found the console in chrome, but when I try to add the console into the code on the arduino I get a compile error or am I doing something wrong. Or do I just run the current code & view it through the console?

Is there a way to run the code before I put it on the sd card as I am making small change, put it in and out of the sd slot is a pain in the butt whilst trying to find code errors.

Scott

Stylmast
Posts: 36
Joined: Sat Sep 06, 2014 8:19 am

Re: UPS system code problems

Post by Stylmast » Tue Feb 10, 2015 1:46 am

I have updated the code with some minor changes, but I'm having a problem with the 4 gauge.
When its added to the SD card it stops the whole lot from working. The first 3 gauges work well.
I can't even get just the raw ADC to work lines 17 - 24.
I'm missing something.

https://github.com/stylmast/UPS-system

Scott

Post Reply