News:

To visit MidNite Solar click this link www.midnitesolar.com

Main Menu

Arduino

Started by rosebudd, February 09, 2012, 09:30:42 AM

Previous topic - Next topic

rosebudd

starting a new thread on Arduinos...

I bought a Hall Effect sensor off Ebay: (my soldering skills need work)

http://www.ebay.ca/itm/50A-AC-DC-Current-Sensor-ARDUINO-AVR-PIC-PICAXE-MSP430-ARM-PSOC-/230685567407?pt=LH_DefaultDomain_0&hash=item35b5ee69af

and connected it to a Uno Arduino....it is a low cost solution to measuring amps in or out of the batteries. I also used a voltage divider and was able to measure the battery voltage with an Arduino. The trick is to get both working on the same Arduino, electronics is still black magic for me..<g>

lots of fun learning,

rosebudd

Arduino in action: http://sunenr.homedns.org/cgi-bin/ampsensor.pl

MS Classic 150, ~1.6kw pv, 500 ah , OB3524, ListerSL1/3kwgenAC .....so far
"retirement projects"

littlebird

Greetings
@rosebudd - Excellent stuff!! I saw that same HE sensor and dug around till i found a couple of each 50A/150A/200A. Im using an ArduinoMEGA-2560 (actually seems like it might be too much I/O for what is really needed). Ill need to study the smaller "ards" and see what they have for I/O. How are you doing with your code? What Ard are you using? Did you get a datalogger shield?

Ill show you my setup, and glad to share code, altho, im not even close to even sampling data yet.
So far..
Realtime Clock
4x20 IIC LCD with timed backlight
6 menu pages/1 level (this will change to multi level)
Reading 1 analog port (for testing & calcs) (ard wont do floating point, so, analog resolution is limited :-\)
2 button interface

Pretty Soon..
SD Card storage
Limited ModBus
5 button navigation UP/DN/L/R/ENTER
Voltage Divider implementations

Eventually..
Auto Device Detection for Multiple Mod-Bus Devices
  with key data retrieval..
   and some other stuff too.. :D

Best for Now
Littlebird

rosebudd

Littlebird

I can't pretend to be a programmer, but it is fun to learn. I tend to search the web and modify scripts to suit the need. Open source people are very helpful. This is a retirement "mental health" hobby for me, no commercial interests.

Below is the script I am using, came with the HE vendor data.
The HE sensor is ~30' feet from the Uno Arduino, so there is a little line loss. You need to check the voltages at the Arduino to calibrate the equation values.
I use crontab in Linux to poll the Arduino every minute to make the graphs in RRD.

I want to learn Modbus for Linux, but this will take some time..open to suggestions..hints.



/*
  Hall Effect, This is to measure current in amps of a Hall Effect
  sensor
*/

int inPin = 0;    // select the input pin for the Hall Effect Sensor
int val = 0.0;       // variable to store the value coming from the sensor
int Current = 0.0;

void setup() {
Serial.begin(9600); // connect to the serial port
}

void loop() {
val = analogRead(inPin);  // read the Hall Effect Sensor

Current = ((analogRead(0)*(4.9/1024))- 2.45)/ .0200;

/*tweaking calibration 2.44 to 2.29 ?*/

/*Serial.println(val);*/
Serial.println (Current);
delay(3000);
}


I am willing to share anything I have learned...If I step outside of any "MS" guidelines, please let me know...it is not intentional.

regards
rosebudd
MS Classic 150, ~1.6kw pv, 500 ah , OB3524, ListerSL1/3kwgenAC .....so far
"retirement projects"

rosebudd

Littlebird,

I missed one of your questions....

I am not using a shield, I just use telephone wire for the 30 foot run and connect with short wires to analogue side of the Uno.

I have another Uno, sometimes they are available for <$20. Thinking of the wireless approach eventually...too many projects, not enough time. The Arduinos can be used for so many useful applications.

on another thread...the new Raspberry Pi microcontoller sounds interesting.

rb
MS Classic 150, ~1.6kw pv, 500 ah , OB3524, ListerSL1/3kwgenAC .....so far
"retirement projects"

littlebird

No big news yet, little parts are coming in for the rs232, modular jacks, header pins and such.
The code can now...
  ...write to SDcard (time stamp and the 8 analog inputs on the 2560)
  ...the daily file size is acceptable
  ...can be interpreted by MSExcel Chart
  ...Automatic increment of filenames based on date
While alot of the basis for the code is out there, it all must taylored and hacked up a but to achieve the objective.
as an example, the libraries available for the time-clock chip would return the date value as a "string", but the SDcard library will only accept a char*(character array).. So, i had to go into the library for the clock, and customize it to return the proper.. Then i was looking around in there, and i said.. wow, half of this stuff will never be used.. So its on my mind to strip some of this down as well in a future. The code as it is is not really worth posting, as it is in dis-array and i couldnt want to spend much time trying to fix things that are incomplete.

I will soon begin the writing of a library for comms to the classic cc's. I need to get with these fine folks here, and see where exactly this unit can exist in a multi-classic setup scenario. 

If you want to know what parts to collect meanwhile..
Arduino MEGA 2560 / UNO (UNO only has 1 serial port, and will become feature limited in time)
DS1302 real time clock (rtc) with trickle charger (tc not implemented)
4x20 IIC LCD
SDcard board
...im also toying with the idea of eeprom -vs- .ini file on sd... for storing prefs
..nlRF24LO1+ wireless for remote sensors/controls

The best news.. Im supposed to be receiving my 32pcs ~200watt panels and my classic from my dist today..
..the smile is from ear to ear baby!!

LittleBird

code snippet....

void WriteSD()     //********************************
      {
        // make a string for assembling the data to log:
       
           lcd.setCursor(19,3);
           lcd.print("+");
       
        dataString = "";
        dataString += rtc.getTimeStr();
        dataString += ",";
        // read three sensors and append to the string:
        for (int analogPin = 0; analogPin < 8; analogPin++) {
          int sensor = analogRead(analogPin);
          dataString += String(sensor);
          if (analogPin < 7) {
            dataString += ",";
          }
        }
        // open the file. note that only one file can be open at a time,
        // so you have to close this one before opening another.
         
          WorkFile = rtc.getTodayFileStr();
          File dataFile = SD.open(WorkFile, FILE_WRITE);
            // lcd.setCursor(0,1);
            // lcd.print (WorkFile);
                   
          // if the file is available, write to it:
        if (dataFile) {
          dataFile.println(dataString);
          dataFile.close();
           lcd.setCursor(19,3);
           lcd.print("#");
          // print to the lcd port too:
          //lcd.print(dataString);
         
        } 
        // if the file isn't open, pop up an error:
        else {
         
          lcd.print("Error Opening Work File!");
          //lcd.print(WorkFile);
        }
      }
           
     
      void GetWirless()
      {     
      //Code here to Refresh Data from Wireless Modules
       
      }


[attachment deleted by admin]

littlebird

@rosebudd.. yeah, some of the other development boards with sexy full color touchpanels look delicious ;-) im thinking the ard is pretty low power and has enough I/O to satisfy.

Westbranch

love the fact that that is only a 9V battery in the pic running things...
KID FW1811 560W >C&D 24V 900Ah AGM
CL150 29032 FW V.2126-NW2097-GP2133 175A E-Panel WBjr, 3Px4s 140W > 24V 900Ah AGM,
2 Cisco WRT54GL i/c DD-WRT Rtr, NetGr DS104Hub
Cotek ST1500 Inv  want a 24V  ROSIE Inverter
OmniCharge3024  Eu1/2/3000iGens
West Chilcotin 1680+W to come

littlebird

@westbranch .. yeah, im not sure of the actual power consumption, but its way better than a pc running.. the lcd is backlit via leds..and shuts off after some inactivity..should be a power sipper  :) 

@group ... so, hows this sound?

the periodic daily measurements will log a file... with one file for each day.. named  mmddyy.txt
the daily totals and averages will log to a separate file... with a file for each month ... named mmyy.txt
and to keep the hardware/complexity to a min.. perhaps the .ini file is the way to go - vs- the eeprom chip..

altho..(speaking of eeprom) the little board that i got had a rtc&battery-eeprom-buzzer-temp sensor-IRrcv.. all in one, thought it was pretty complete, and 90% usable for a robusto logger.

Question? is this something you folks will want me to "put the kit together for you" and send it to you.. source code will be made public once it is matured a bit, regardless..

man, i love hacking code, brings back mems of the 2+ years i spent writing an employee scheduling program for the wifes coffee shop.. lost it all to a computer crash.. oh, reminds me. time to back it all up, dont want that again :o   I wish i had a couple extra days a week to dedicate, but the wife would kill.. so evenings where-ever it is then..

Westbranch

to me, it makes sense for there to be only one scribe for the code ( keeps the 'waters' from being muddled) and the rest can assist as readers/testers/reviewers.
ps been there, done it on a 5 year project, not programming though.
hth

Eric
KID FW1811 560W >C&D 24V 900Ah AGM
CL150 29032 FW V.2126-NW2097-GP2133 175A E-Panel WBjr, 3Px4s 140W > 24V 900Ah AGM,
2 Cisco WRT54GL i/c DD-WRT Rtr, NetGr DS104Hub
Cotek ST1500 Inv  want a 24V  ROSIE Inverter
OmniCharge3024  Eu1/2/3000iGens
West Chilcotin 1680+W to come

littlebird

totally agree, i just dont want anybody to feel im holding all the cards.. if anybody ever wants the code tho, im totally agreeable to release it. I dont want to field questions about it tho, aside from some general assistance to help out. Im novice myself, but i feel i have a pretty good head about the structuring. ect..  stay tuned ;-)


littlebird

Update..
Greetings once again group, first, allow me to profess my love of my Classic 150, it really hits the spot.

Some months back i had limited success with communication from Classic150 to Arduino via Modbus. I was able to retrieve Charge Amps and Battery Volts. The limitation was that after about 300 'pings' with very good communication success(97% success), it (and i suspect the "it" is Arduino side) the communication becomes almost 90% failure with my arduino reporting "Bad Command/ID Failure/Timeout". Very exciting and frusterating, and i get the feeling the fix is going to be very simple.. But ive already tried some of the obvious, flushing the Rx buffer, clearing all strings.. ect..

All the while, i was working with this breadboad that had all kinds of fragile components hanging off. but i wanted to work from on the couch (damn lazy hacker). So i started building the home.. (pics).. This is much better for debugging on the couch..

A few weeks ago, took all the Arduino stuff to Beach Vacation with intent to hack away, and while i worked a few things out to satisfaction, i made the screen very flickery in the refresh script.. And so it goes.. Im having alot of fun and loving the challenge, but man.. this is going to be some more months.. winter.. spring? The fall/winter will actually be better, as my work slows down, the daylight is shorter, the temp is colder outside, and the grass dont need mowed..



boB


Isn't this stuff fun !!  Especially when you get something to work.

Sounds like you are well on your way, even if you have some kinks to get around.

You ARE running at 19.2 K baud, right ?  I peeked down the forum here and saw reference
to 9600 baud somewhere.

boB
K7IQ 🌛  He/She/Me

littlebird

Hey boB,
Yeah 19.2.. Problem is in the arduino.. if i unplug  the tele wire, it still thinks it recieves about 5 more pakets before it absolutely 'times out'. Its as if its getting backed up, and the clear rx buff commands arnt actually clearing. Ive got to dig thru the 3rd party modbus library, and further into the serial library thats the core of the ard..  I rcd a ping for a snip of code from a new user here today, and i thought i sent it, but i cant seem to see anything in my sent PM's. Ill give it a few mins to propogate, then send again. Hope this finds you well. Your CC ROCKS!

Best
littlebird

rosebudd

interesting update....very good,

I have put the Arduino aside for the moment. Upgraded the system with an OB3524 and the wiring got a lot bigger, worried about cooking the little Haff Effect sensor.

I have had some success using bash/Modpoll on the Classic 150...it works well. Next step is parsing the values into a useful format.

Maybe an Arduino/Modbus combo is the way to go? Too many choices, not enough knowledge...still fun.

thanks for the info,
steve
MS Classic 150, ~1.6kw pv, 500 ah , OB3524, ListerSL1/3kwgenAC .....so far
"retirement projects"

Westbranch

KID FW1811 560W >C&D 24V 900Ah AGM
CL150 29032 FW V.2126-NW2097-GP2133 175A E-Panel WBjr, 3Px4s 140W > 24V 900Ah AGM,
2 Cisco WRT54GL i/c DD-WRT Rtr, NetGr DS104Hub
Cotek ST1500 Inv  want a 24V  ROSIE Inverter
OmniCharge3024  Eu1/2/3000iGens
West Chilcotin 1680+W to come