Smart Solar Switch help.

Projects that are not for RC, but are cool and worthy of development.
User avatar
ShowMaster
Posts: 4327
Joined: Thu Dec 29, 2011 3:44 am
Country: -
Location: Los Angeles, CA USA

Re: Smart Solar Switch help.

Post by ShowMaster » Wed Jan 30, 2013 7:47 am

More info. I get the idea that the reset function on 3 may not want to go direct ally to ground?
I see push button circuits used on the UNO that have a 10k to let's say 3 and ground. The switch pulls 3 up to +5v.
Something to do with never actually shorting a pin to ground or + 5v without a resistance in line. If an input suddenly became an output the IC would be damaged. Interesting, theoretical I read the more confused. I'll check it out,
SM


Sent from my iPod touch using Tapatalk.


User avatar
gohsthb
Posts: 1412
Joined: Wed Dec 28, 2011 2:32 pm
Country: -
Location: Naperville, IL

Re: Smart Solar Switch help.

Post by gohsthb » Wed Jan 30, 2013 2:14 pm

add this line in setup()

Code: Select all

digitalWrite(BUTTON_RESET, HIGH);  // this is how you enable an internal pull-up
Having a resistor on every IO line is a good idea. You will find them on the sky9x board, and also on the stock board. That is one purpose of all those 200 ohm resistors.
-Gohst

User avatar
ShowMaster
Posts: 4327
Joined: Thu Dec 29, 2011 3:44 am
Country: -
Location: Los Angeles, CA USA

Re: Smart Solar Switch help.

Post by ShowMaster » Wed Jan 30, 2013 3:31 pm

Does it make sense to never connect ontput or output pins to 5 v or ground directly but always thru a current limiting resistor to stay under 40Ma?
In my case the external reset button and analog inputs.

Thinking of isolating all digital in and outs with optical isolators. This way I can have long lines and not worry about shorted cables. There has been in the past, field mouse families that move in our solar battery container and chew on cables. Made a mess, and a nest!
I'm going to dedicate a UNO to this project rather than mount the 323p on its own board. It'll live in a metal box mouse free, I hope.

I do find the UNOs wiring connectors to not get a tight grip on the wires I push into the.
I'm assuming I can use a strip of pins with the same slagging to make matching connector for my wiring?
Just throwing this out there as educate myself. So far I think it's going to work as planned.
SM



Sent from my iPod touch using Tapatalk.

User avatar
gohsthb
Posts: 1412
Joined: Wed Dec 28, 2011 2:32 pm
Country: -
Location: Naperville, IL

Re: Smart Solar Switch help.

Post by gohsthb » Wed Jan 30, 2013 6:30 pm

I remember Brent(skynorth) explaining that the inline resistor limits current in or out of the IO pins, and the capacitor was shorting any high frequencies that might cause problems. So it is not absolutely necessary to have these resistors and capacitors, it is a good idea to include them. I don't think you need to go as far as using opto-couplers, that might be a bit overkill.
-Gohst

User avatar
ShowMaster
Posts: 4327
Joined: Thu Dec 29, 2011 3:44 am
Country: -
Location: Los Angeles, CA USA

Re: Smart Solar Switch help.

Post by ShowMaster » Wed Jan 30, 2013 6:43 pm

Ok, thanks.
SM


User avatar
ShowMaster
Posts: 4327
Joined: Thu Dec 29, 2011 3:44 am
Country: -
Location: Los Angeles, CA USA

Re: Smart Solar Switch help.

Post by ShowMaster » Wed Jan 30, 2013 6:50 pm

I found this link that has a lot of good interfacing info
https://labitat.dk/wiki/Arduino_beginne ... 8Relays.29

User avatar
ShowMaster
Posts: 4327
Joined: Thu Dec 29, 2011 3:44 am
Country: -
Location: Los Angeles, CA USA

Re: Smart Solar Switch help.

Post by ShowMaster » Thu Jan 31, 2013 3:41 am

gohsthb wrote:add this line in setup()

Code: Select all

digitalWrite(BUTTON_RESET, HIGH);  // this is how you enable an internal pull-up
Having a resistor on every IO line is a good idea. You will find them on the sky9x board, and also on the stock board. That is one purpose of all those 200 ohm resistors.
-Gohst
I found this reference on turning on the pull up's?
pinMode(pin, INPUT); // set pin to input
digitalWrite(pin, HIGH); // turn on pullup resistors

Now I'm confused again?


Sent from my iPod touch using Tapatalk.

User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: Smart Solar Switch help.

Post by rperkins » Thu Jan 31, 2013 4:38 am

this one needs to have pin replaced with a number or the variable pin defined as a number
and the pinMode line is sorta redundant. pins are inputs by default. but using that line assures that the pin is set as an input
pinMode(pin, INPUT); // set pin to input
digitalWrite(pin, HIGH); // turn on pullup resistors


this one is using a variable for the pin number
digitalWrite(BUTTON_RESET, HIGH); // this is how you enable an internal pull-up

for example look at the blink tutorial where the variable led is given the value of 13. then later the variable is used in digitalWrite()
http://arduino.cc/en/Tutorial/Blink
int led = 13
digitalWrite(led, HIGH);
the previous line is the same as digitalWrite(13, HIGH);

hth

User avatar
ShowMaster
Posts: 4327
Joined: Thu Dec 29, 2011 3:44 am
Country: -
Location: Los Angeles, CA USA

Re: Smart Solar Switch help.

Post by ShowMaster » Thu Jan 31, 2013 3:32 pm

I did add the button_reset string to the setup and it sid fix the random reset I was getting and I removed my external pull up resistor.
Do you think it's better to not turn on the pull-up mode and use external pull-up's or to use the internal ones?
I'm not sure of any pro's or con's?

I believe it's all working now. Next I have to add the divider resistors for the 12 v monitoring and solar input.

I now have some 40 pin headers that fit the UNO connectors so I can make up cables that plug on.
The reset button will have a longer cable on it from where the UNO will be mounted. I'm still thinking of opto isolating this cable so I don't have a long "antenna" hanging on the reset input that can pickup stray rf and noise from all the radio and generator noise around. Any thoughts on that or how I should bypass the cable? I guess a lower value external pull-up resistor would also work.
Maybe add another external 10k to make it less than the internal 20k
?
Just little details I'm working out now so it just works when it's installed.
SM



Sent from my iPod touch using Tapatalk.

User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: Smart Solar Switch help.

Post by rperkins » Thu Jan 31, 2013 3:53 pm

Yahoo. congratulations

I've never had to play with the pullups. With that said I'd use the internal ones. They're so much neater looking :)

I dont know about the opto isolator. I guess they arent expensive if they give you piece of mind. I could see being worried about lightening strikes if it is real long or the highest point. Have you thought about just using a shielded cable ? I guess a decent length of shielded cable could cost as much as one of those opto isolators.

User avatar
ShowMaster
Posts: 4327
Joined: Thu Dec 29, 2011 3:44 am
Country: -
Location: Los Angeles, CA USA

Re: Smart Solar Switch help.

Post by ShowMaster » Thu Jan 31, 2013 4:32 pm

I bought a lot of 4n34's in the past for ham radio interfacing projects and have extras. I found them useful when running long cables that are exposed to 10-1000W of RX energy. Saved a lot time, a s shielded cable as you mentioned. It also make it hard for the external world to damage the device it's array ached to.
Here's a picture grab I made with my iPod, no editing. FYI
ImageUploadedByTapatalk1359649401.975632.jpg
I was thinking of using a multi turn pot for the voltage dividers?
That way Ivan fine tune the final values to match the cutoff I need to the calculated values on the program, or am I over thinking this?

I've printed out the program and will focus on fullyf understanding what each line of code is doing.
I'm still cheating by using the posted code, thank you everyone, so I won't stop there.
SM



Sent from my iPod touch using Tapatalk.

User avatar
gohsthb
Posts: 1412
Joined: Wed Dec 28, 2011 2:32 pm
Country: -
Location: Naperville, IL

Re: Smart Solar Switch help.

Post by gohsthb » Thu Jan 31, 2013 4:44 pm

Internal pull-ups are between 30 and 50 k ohms. You only need to use an external one if you need a lower value. Using an isolator, you still need to power the isolated side of the circuit. Me, I would just use a couple of resistors and a capacitor. These would be a lower value pull-up resistor, probably 0.1uF from the pin to ground. And an inline resistor, maybe 330 ohms. This way you only need 2 wires to the switch, instead of a separate power supply.
My original program has the serial port enabled to you can set up your resistor dividers. Then using a power supply, apply the threshold voltage to your divider. Finally use the serial monitor in Arduino to read what the ADC is reading. You can then use these values as the ones in your program.
-Gohst

User avatar
ShowMaster
Posts: 4327
Joined: Thu Dec 29, 2011 3:44 am
Country: -
Location: Los Angeles, CA USA

Re: Smart Solar Switch help.

Post by ShowMaster » Sat Feb 09, 2013 3:43 pm

gohsthb wrote:Internal pull-ups are between 30 and 50 k ohms. You only need to use an external one if you need a lower value. Using an isolator, you still need to power the isolated side of the circuit. Me, I would just use a couple of resistors and a capacitor. These would be a lower value pull-up resistor, probably 0.1uF from the pin to ground. And an inline resistor, maybe 330 ohms. This way you only need 2 wires to the switch, instead of a separate power supply.


-Gohst
-------
I finally found time to get this project working on the bench. So far just led's but they all behave as they and a relay should. I now have to make the dividers and decide on the actual battery detect voltages I'm going to use.

Please explain more about using the enabled serial port function and the serial monitor function.
Thank you

"My original program has the serial port enabled to you can set up your resistor dividers. Then using a power supply, apply the threshold voltage to your divider. Finally use the serial monitor in Arduino to read what the ADC is reading. You can then use these values as the ones in your program."

Sent from my iPod touch using Tapatalk.

User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: Smart Solar Switch help.

Post by rperkins » Sat Feb 09, 2013 5:34 pm

Maybe this will keep you going till gohsthb gets a chance to comment.

It looks like his code is set up to report the Light and battery level to you over the serial line.
typing a lower case ' v ' in the serial monitor will get it give back good information.
type anything else in the serial monitor and it just parrots what you typed back at ya ( good test to see if it is actually listening correctly)

The arduino IDE (program ) has a built in serial monitor. So connect your arduino to your computer and fire up the program. There is a magnifying glass in the top right hand side. clicking on it will open a box where you can type in the top of it and see the output in the bottom. There is a place to set the baud rate. The baud rate for this program is set at 9600 .
Screenshot_arduino.png
You can also monitor the serial connection outside of arduiono using a serial comm program. minicom(linux) , hyperterminal? (windows ) . I've done this a few times in linux but dont remember exactly how.

User avatar
ShowMaster
Posts: 4327
Joined: Thu Dec 29, 2011 3:44 am
Country: -
Location: Los Angeles, CA USA

Re: Smart Solar Switch help.

Post by ShowMaster » Sat Feb 09, 2013 8:05 pm

Ok, got the idea now. It's enough info to try it.
SM


Sent from my iPod touch using Tapatalk.

User avatar
ShowMaster
Posts: 4327
Joined: Thu Dec 29, 2011 3:44 am
Country: -
Location: Los Angeles, CA USA

Re: Smart Solar Switch help.

Post by ShowMaster » Wed Feb 20, 2013 3:58 pm

I'm real close now. I've got a 40A relay board with pre regulator for the UNO to feed it 8 volts from 12-14 v. I've hot a led board with a reset switch option. These plug into the UNO with color coded headers. Pictures later. Being a prototype it's a little spread out.

It seems to work using a pot for the battery detect and connecting the light detect to +5v for now.

Now I need to work on the divider input values.
I may need some more code help.
Good battery health says that a lead acid battery should be considered discharged at 12.1 volts, and fully charged at 12.8 or above.
I would like to have the system shut off the charging station if the battery rail drops below 12v and not come back on for 2 days of sun and then only if the batteries are 12.7 or above. These are starting values and will be adjusted later if required for battery health.

The cutoff and rearm after 2 days is in the code provided already but I'm not sure there is a provision for turning on the output only after 2 sun cycle days and over a certain voltage.
I would like to add that option in the code if I was better at it unless its there now and I'm missing seeing it?

I did get the button pull-up resistor option turned on and no more flaky things going on when I touched the UNO.
This has been a real education and I'm slowly working my way thru the code. The hardware is going OK n my head at least.
I'll post schematics and the final code everyone's helped with when it actually is installed and working, soon I hope.

Then I'll tackle the smart AC bench power timer that was started on last year.
Thanks everyone for getting me this far along.
SM


Sent from my iPod touch using Tapatalk.

User avatar
ShowMaster
Posts: 4327
Joined: Thu Dec 29, 2011 3:44 am
Country: -
Location: Los Angeles, CA USA

Re: Smart Solar Switch help.

Post by ShowMaster » Wed Feb 20, 2013 10:47 pm

My progress today.

50k fixed and a 20k, 10 turn pot divider.
50k to the battery source in series with the 20k pot to ground. The pot wiper is set to 12.42k to ground and to the UNO A1 input.

A battery hysteresis value of 21 was used.

The results are,
The relay out turns off at 11.91 volts and after the time out period (15 seconds for test purposes), the system arms and the relay out triggers the relay again at 12.65 volts.
The actual voltage the UNO A1 sees 2.518 for the 11.9volts and 2.673 for the 12.65volts limits.

The reset ends the off cycle and if the voltage is over 11.9 the relay energizes and would allow the charging stations to function until the voltage again drops to 11.9v

The light detect circuit will work and has been pulled to 5 volts for testing.
The light detect, relay energized, relay not energized, 3 LEDs, all function as planed.
More testing and calibration still planned but I'm getting closer.
Thanks everyone for getting me this far do soon.
SM


Sent from my iPod touch using Tapatalk.

ReSt
Posts: 1548
Joined: Tue Dec 27, 2011 11:34 pm
Country: -

Re: Smart Solar Switch help.

Post by ReSt » Wed Feb 20, 2013 11:09 pm

ShowMaster wrote:
Good battery health says that a lead acid battery should be considered discharged at 12.1 volts, and fully charged at 12.8 or above.
You can use quite a wider range

A single lead acid cell should not discharged below 1.8 Volt
A fully charged cell will go up to about 2.7 volt, but at around 2.4 volt it will start to exhaust gas by splitting water into H2 and O2 (explosive).Staying below 2.4 volt will be save.

Charging 'should' be done similar to lipo accus, that is charge with constant current up to <2.4 volt and then with constant voltage.

That means, you can safely discharge a 12 volt accu down to 6 x 1.9v= 11.4 volt and charge it up to 6 x 2.3 volt = 13.8 volt.

Reinhard

User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: Smart Solar Switch help.

Post by rperkins » Wed Feb 20, 2013 11:10 pm

Looking good. I'm sure you have enough resolution in your voltage reading but if you wanted more resolution you would adjust your voltage dividers so that you were reading closer to 5v when the battery was charged. You would also have to adjust your threshholds from 512 to ~1000. The hysteresis would probably nearly double also. Overall probably doesnt matter in this application.

http://arduino.cc/en/Reference/analogRead

User avatar
jhsa
Posts: 19387
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Smart Solar Switch help.

Post by jhsa » Wed Feb 20, 2013 11:15 pm

You would need all the info on a LCD now :D ;)
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: Smart Solar Switch help.

Post by rperkins » Wed Feb 20, 2013 11:31 pm

beginning to think i was wrong about the resolution post. Not sure anymore

User avatar
gohsthb
Posts: 1412
Joined: Wed Dec 28, 2011 2:32 pm
Country: -
Location: Naperville, IL

Re: Smart Solar Switch help.

Post by gohsthb » Wed Feb 20, 2013 11:59 pm

rperkins, You are correct about the resolution. The ADC has a resolution of 5/2^10 = 0.00488V. With Showmaster's current voltage divider 4:1, means the total resoltion is 0.00488 * 4 = 0.02V. If Showmaster were to crank his pot all the way to 20k, his divider would change to a 2.5:1, and the total resolution would then be 0.012V. Of course the maximum voltage with the 2.5:1 divider is only 12.5V on the high end.
Showmaster, glad it is working for you!
-Gohst

User avatar
ShowMaster
Posts: 4327
Joined: Thu Dec 29, 2011 3:44 am
Country: -
Location: Los Angeles, CA USA

Re: Smart Solar Switch help.

Post by ShowMaster » Thu Feb 21, 2013 7:23 am

Well, blew up my first UNO board tonight. Not sure what went wrong. I had it plugged into my computer and it took out a USB port also. Luckily it was a add on USB card port not my motherboard ports. There are a few ports still working on the card.
I was working on the solar/sun detect and had ext 12v and the UNO 5 volts, and the USB all going. I fortunately have another UNO to use. Too bad but R&D isn't a free ride! I'm glad my computer mb was spared!
I'll try again after I wipe up the tears and clear out the smoke ha ha.

SM


Sent from my iPod touch using Tapatalk.

User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: Smart Solar Switch help.

Post by rperkins » Thu Feb 21, 2013 9:37 am

thats a bummer. I guess that's uno down :)

User avatar
gohsthb
Posts: 1412
Joined: Wed Dec 28, 2011 2:32 pm
Country: -
Location: Naperville, IL

Re: Smart Solar Switch help.

Post by gohsthb » Thu Feb 21, 2013 12:27 pm

Did it blow something in spectacular fashion? (bright flash, lots of smoke, shrapnel flying) Or did it go pretty quietly? Maybe you connected the 12V directly to the board somehow?
-Gohst

User avatar
ShowMaster
Posts: 4327
Joined: Thu Dec 29, 2011 3:44 am
Country: -
Location: Los Angeles, CA USA

Re: Smart Solar Switch help.

Post by ShowMaster » Thu Feb 21, 2013 4:02 pm

A small pop and a puff of smoke. Yes to something 12 volt relayed!
It was late and I had wires everywhere, perfect for disaster. (OK I had a glass of wine but don't tell anyone!)
But it gets better. My bench PS is a Alinco 30 amp switching type. Very compact with voltage and current metering and front push connectors for smaller wires and screw Banana Jacks on the back. Its voltage range is 5-14.5 volts out fixed with a pot for that value or a switch that transfers control to a front mounted pot. If you plug in a simple 10 turn pot in a jack in the back you can vary the voltage with it. I use this pot for projects. I also use it at 13 volts for my ham gear @20+ Amps. Great for testing speed control cutoffs ect.

Not cheap but I use it a lot for all my hobbies, had it for 5 years now.
http://www.universal-radio.com/catalog/hamps/4082.html


So... Down side, stupid me didn't use any current limiting in my 12v circuits so what ever went wrong was able to draw 30 amps. That's why I lost a USB hub and the port on the computer USB card in an instant! I was messing with FW values.
I'm sure if I had used a low power 12 regulator to power the circuits I wouldn't have burned it a up pulling 30 A!
I needed 140 Ma for the repay I'm using plus what the UNO and LEDs need. I have some 5 volt 10A relay boards ordered and the final design will use 5 volts from the UNO, to power the LEDs and relay needed. I may need to add a heatsink to the UNO regulator for insurance, TBD.
Then I only have to supply 12 volts from the solar battery system for monitoring and I'm going to be very careful with that input now!

I ordered another UNO board for $20 and a 7 port USB powered hub for $6 that will get here from china next month, a $4.89 5 port pci card locally so maybe a week for that.
I'm good with what I have now but I've got more projects and I'm so lucky I didn't blow up my project computer MB USB ports or the MB itself.

I'm taking a day off and doing some RC flying, too much bench time!
SM







Sent from my iPod touch using Tapatalk.

User avatar
jhsa
Posts: 19387
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Smart Solar Switch help.

Post by jhsa » Mon Feb 25, 2013 3:13 am

SM, You like little challenges, why not building your own UNO? I think it is cheaper.. I just built one with parts I had laying around my workshop

viewtopic.php?f=85&t=2893

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
ShowMaster
Posts: 4327
Joined: Thu Dec 29, 2011 3:44 am
Country: -
Location: Los Angeles, CA USA

Re: Smart Solar Switch help.

Post by ShowMaster » Mon Feb 25, 2013 4:40 pm

Great job. Is that the Sparkfun USB interface board you're using?
I may build them in the future if I use more of them and get better at programming.
The ones I'm using @$19 delivered to my door is a pretty good trade off of time vs money. Ever so often I sell off a toy I'm not using and add it to the hobby/toy fund so I can buy other ones.
So far I'm ahead.
Where I get killed building from scratch anymore is the minimum order charge for parts orders and any added shipping and handling. It's a trade off, pay $19 for parts, pay $19 for a working board in many cases.
I do have a working UNO r3 board that now has a blown USB interface IC. I'm thinking of replacing it if I can find a cheap part source.
I have spare 328P ic's with boot loader.
If I order the sparkfun USB interface board I could save this board as another option.
In any case, great idea and good building you've done.
SM


Sent from my iPod touch using Tapatalk.

User avatar
jhsa
Posts: 19387
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Smart Solar Switch help.

Post by jhsa » Mon Feb 25, 2013 4:48 pm

I'm trying to build a LCD shield for it now.. I do it because it's fun.. I prefer building the stuff to buying it..
Will update the thread as long as I have it working :)

João
My er9x/Ersky9x/eepskye Video Tutorials
https://www.youtube.com/playlist?list=PL5uJhoD7sAKidZmkhMpYpp_qcuIqJXhb9

Donate to Er9x/Ersky9x:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YHX43JR3J7XGW

User avatar
gohsthb
Posts: 1412
Joined: Wed Dec 28, 2011 2:32 pm
Country: -
Location: Naperville, IL

Re: Smart Solar Switch help.

Post by gohsthb » Mon Feb 25, 2013 6:43 pm

I have an Uno (that had) a blown USB chip. I removed the chip, and now I can actually use the serial interface for other things. And if I need to program it through the bootloader, I just remove the mega328 from a working Uno and connect the serial pins together.
-Gohst


Post Reply

Return to “Other Electronic Projects”