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

Smart Solar Switch help.

Post by ShowMaster »

I can use the groups help on this.
I have a Arduino and micropic programmer but still lack the knowledge to write the code and decide what to program it into.

The project I'm taking on is this.
We have a 40A solar charging station feeding 10+ 12v high capacity car batteries (320A/720 cranking) in parallel.
The available voltage to users is controlled by a solar switch so only power available sunup to sundown to discourage all night usage by uninvited guests.
There is generator charging for weekend usage.

What's happening is the charge demand because of larger lipo packs and quad chargers is taking more current out of the system than is being inputed. Shorter days doesn't help either.
We now manually disable the system to users when the voltage drops to 11.9 or less until the system has a day or more to recharge to a safe level again.

What I would like to have help with is a smart cutoff switch.
My idea is to have it cutoff when the system voltage goes below 12v and stay off for 24 or 48 hours lets say.
The solar cell switch could be used as a counter. If the system shuts down it doesn't come back on line to users until two sunup sundown cycles have occurred. That or just an internal timer function set to a specific time frame. This switch selected for 1-5 days lets say.
There should also be a master reset in case the generator(s ) and battery chargers are turned on by a field tech committee member on site.

One generator will have the option of self starting or remote starting by a ham radio touch tone backbone system this year so we (I) don't have to drive to the field to start the generator if we use that option.
There is currently a 24/7 Wx station there that reports not only weather info but also monitors battery voltage and internal storage temp.
All this reports to the Internet through a APRS system since there is no Internet access at the field.
Most of these control functions can or could be under remote manual control but I would like to have it not require personal monitoring.

Summer months are not as big an issue, and as more solar donations are collected more panels will be added. Not a lot of donations coming in in this economy right now.

FYI
So many connecting to their car batteries under the hood prompted the solar charging station. I have a friend that sparked his car battery and it blew up. Fortunately he turned his head at the right moment and because of that and his glasses his eye were spared. Just the side if his face was injured and no scaring. The DR said he was a lucky man!

Any ideas and designs that come from this project I'm sure will be something other clubs may want to use.
Thank you
SM


Sent from my iPod touch using Tapatalk.
Please add a location to your profile. Thank You

User avatar
Kilrah
Posts: 11108
Joined: Sat Feb 18, 2012 6:56 pm
Country: Switzerland

Re: Smart Solar Switch help.

Post by Kilrah »

Why a delay and not just a low voltage cutoff? 11.9V=cut, 12.1V= turn on again. If someone goes and draws on it again before it has charged enough it will just shut down again. But I think it makes little sense to disable the whole thing for 2 days and thus prevent a guy from charging charging a tiny 2s 1000mAh lipo it would be sufficient for in the meantime...
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 »

There are at any given time 15-25 flyers many only charge at the field. This is not a private field so anyone can fly and they do. Weekends are super crowded. Los Angeles Wx let's us fly pretty much all year long and electric has taken over. Many bring quad chargers now and large packs.
There is no way to limit users charging so it will never be just one 2200Ma battery and that's why the batteries never charge now.
SM


Sent from my iPod touch using Tapatalk.
Please add a location to your profile. Thank You
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 »

Sounds like a pretty simple little project. The code part should be pretty easy. What kind of switch do you have to disconnect the batteries? I will think about this some more over the weekend.
-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 »

The switch is a 12 volt relay. I'm not sure of the coil current requirement but not a real issue. A power FET should work.
Final idea is a master reset to override the preprogrammed events?
SM


Sent from my iPod touch using Tapatalk.
Please add a location to your profile. Thank You

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 »

This should get you started. This program will only allow charging while the sun is up. Also if the battery voltage goes low it will disable people from charging, until the battery voltage recovers + 1 hour. The program expects a light sensor (analog) and a battery voltage divider. At the top of the program are some 'defines' so you can set the trip levels and a hysteresis. Once you have the sensors connected you can test them through the Arduino serial monitor, where it will show you their values on request. Use that when setting up the defines. Let me know if you have any questions.
I saw your other Arduino post, the answer to your first assignment is in this code.... :mrgreen:

-Gohst
Attachments
SolarControl.ino.txt
remove the .txt extension so Arduino can recognize the file. Arduino v1.0.3
(4.28 KiB) Downloaded 537 times
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 »

Thank you gohst.
I'll give it a try. I did hook up my uno last night and made the led blink every 5 seconds instead of every 1 second so I'm almost up to speed, not!
I'm seeking local help to speed this up.
I'm ok with the hardware interfacing as long as I know what pins need what input and what pins give what output when the programs running.
Power and regulator circuit is no problem either.
I'll have some questions we both know but I'll try and make them intelligent ones.
SM


Sent from my iPod touch using Tapatalk.
Please add a location to your profile. Thank You
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 »

I just loaded it in the Arduino 1.03 pgm and now I can see your comments and pin outs. It makes enough sense to me that I can breadboard and try it in the next few days. I'll look up the chips input voltage max but do I assume 3.3v or 5v as a working max input?
One other question, for now....
Is it better to keep this on the uno board instead of building up a separate board operation wise? This board does a lot for $30.
As time permits I hope to be able to attend the free robotics club programming classes offered in the coming months.
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 »

Ok, just a little more help please.
Assuming 12 v as the LV cutoff that starts this all, I;m using 12.1v as discharged and anything above OK.
I'm not sure on how to assign a number in the program to start this all.
Is it possible for you to make up some values and add them to your program so I can fast track actually modifying your original one by substituting my actual values and bench test it with my variable PS and a simulated solar cell input? I can use a single cell or any value if I use the actual panels output or the current cell that I'll have to measure. No info on that circuit from the original designer some years ago. Many option there so not a real issue.
It may be a self contained commercial solar switch being it came from a volunteer designer. I'll find out when I do more documentation on the systems wiring.
Thank you again
SM
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 »

The Uno is 5V. So everything on there will run at 5V.
The battery input voltage will be through a divider. Let's assume you use Vbat -> 100k -> Arduino Input -> 30k -> Gnd
So if you put 12V as Vbat the arduino input will be 2.77V. The adc is 10bits so it's resolution is 5V/2^10(bits) or 0.00488.
Now take the 2.77V and divide it by the resolution 0.00488. This will be about 567 counts. Counts is the number I'm using in the program so the Arduino doesn't have to do the math. This was another reason I included the serial code. Make your divider, and apply a voltage to it. The through the serial monitor you can see (in counts) what the Arduino thinks the voltage is. And it is easy to convert the counts to volts also. Just take counts * 0.00488 and that will give you volts at the input.
-Gohst
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 »

You can change from the Arduino Uno to a mega328p (the same chip used on the Uno). The Arduino folks have writeup for doing that here: http://arduino.cc/en/Main/Standalone

-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 »

Your info and link is super!
Just what I need to get the brain in gear.
Thanks again for your patience and posts.
SM


Sent from my iPod touch using Tapatalk.
Please add a location to your profile. Thank You
User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: Smart Solar Switch help.

Post by rperkins »

gohsthb wrote:You can change from the Arduino Uno to a mega328p (the same chip used on the Uno). The Arduino folks have writeup for doing that here: http://arduino.cc/en/Main/Standalone

-Gohst
I recently went through this . didnt realize that the 328P is not the same as a 328-pu . the 'p' before the hyphen is 'pico power'. the 'pu' after the hyphen is the package type. Either chip would work for me but they have different signatures. The Arduino IDE is not configured to utilize the non pico power version and some setting had to be modified to get it to work. So the moral is get the 328p version to keep it simple
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 »

328p version
Got it.
I see $13-$15 Ebay colones of the uno r3 boards. maybe that the way to go after i get this working?
I can't build it for much less if I have to order parts.
Any comments on the clones on ebay?
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 »

Another of many maybe.
If I want to replace or use another
ATmega328p how do I load the boot loader?
SM


Sent from my iPod touch using Tapatalk.
Please add a location to your profile. Thank You
User avatar
rperkins
Posts: 1422
Joined: Sun Jan 08, 2012 12:51 pm
Country: -

Re: Smart Solar Switch help.

Post by rperkins »

I'm fairly new at this so hopefully if I'm mistaken someone will come along

buy a chip with it already preloaded
but out of stock
https://www.sparkfun.com/products/10524

load it yourself
http://arduino.cc/en/Hacking/Bootloader ... Bootloader

I think you hook a uspasp programmer up to the ICSP pins. Looks like you may need a 10to6 pin adapter
I did mine on a breadboard but you can remove the existing AVR from the uno socket. If you got one that is in a DIP package.
Image
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 »

Great info!
Thank you for taking the time to post it.
I have several extra HK USBasp programmers I used to fill up a HK order.
Once in more familiar with this project I'll try programming the boot loader into a blank.
SM


Sent from my iPod touch using Tapatalk.
Please add a location to your profile. Thank You
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Smart Solar Switch help.

Post by jhsa »

SM, you could get the datasheet for the 328p, a 16Mhz Xtal and two 22pF caps, connect them to the right pins, and burn the bootloader with your USBasp just the same way as to flash the 9x. Not sure about what fuses you should use though.
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 »

I'll save all this info, thanks.
If the USBasp connected to the UNO board works I like that idea. The eBay knockoff UNO r3 boards for $15 I'd buy to install and keep the real uno for programming.
SM



Sent from my iPod touch using Tapatalk.
Please add a location to your profile. Thank You
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 »

The fuse settings are easy to find. If I was at a computer I could tell you what they are. There is a file called 'boards.txt' in the arduino directory, somewhere under hardware I think. It lists information for all of the different arduino boards. If you burn the bootloader using the arduino ide, it uses this file for the fuse settings. I recently got some Leonardo clones.
-Gohst

Sent from my LG-P999 using Tapatalk 2
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 »

I'm going to make lab time (garage) today to hook this up and see what happens on the bench.
Thanks to all the help here I understand the read and write to toggle the output pins. I also think I've got the syntax for assigning functions to pins. That what the examples are for and I'm going through them.
One thing that's got me confused is the schematics i've downloaded for the UNO R3 board. If I run blink the Yellow LED blinks. I see the program define pin 13 as the output pin and the board must have the led connected to pin 13 or it wouldn't blink. The UNO R3 schematics I download don't show the led(L) connected to pin 13? I do see a LED (L) connected by a another ic pin to pin 19 SCK?
Am I missing the latest UNO R3 schematic? I'm just making sure all my info is correct for the board I have so I don't get sidetracked in my thinking.
The UNO board I have says UNO R3 on it and it looks like all the real Arduino board pictures front and back.

A good ham friend of mine that lives 10 miles away says he's using raspberry I think he said, but has used Arduino also so i hope to bug him for some local help. I hoping the local robotics club will work out education wise.
Thanks again for helping me learn something new for the new year.
I'm working on my new years resolutions and this is more fun than losing holiday weight so I moved it up the list.
SM
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Smart Solar Switch help.

Post by jhsa »

There are the normal pins of the atmega, and there are the so called digital pins.. so pin19 of the atmega might be digital pin 13. Didn't check though. I was scratching my head over this before as well.. ;)
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 »

It makes sense the way you put it.
Ok, off to google 328pu digital pin assignments.
I'm going to monitor the pins when blink is running and see what's toggling. It's the brute force direct approach method when all "logic" fails my thinking.
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 »

It makes sense the way you put it.
Ok, off to google 328pu digital pin assignments.
I'm going to monitor the pins when blink is running and see what's toggling. It's the brute force direct approach method when all "logic" fails my thinking.
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 »

You nailed it! :D
It's all making sense now! woo Hoo
Same pin out as the 328pu the link said.
Attachments
Atmega168PinMap2.png
User avatar
jhsa
Posts: 19480
Joined: Tue Dec 27, 2011 5:13 pm
Country: Germany

Re: Smart Solar Switch help.

Post by jhsa »

yes, atmega 8, 88, 168, 328, share the same pinout. in some situations you can replace one with the other, as long as you compile the aplication for the correct one, and choose also the correct one when you flash the application to it..
I'm also a beginner on this thing myself, so please feel free to correct me guys.. :)
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
ReSt
Posts: 1581
Joined: Tue Dec 27, 2011 11:34 pm
Country: -

Re: Smart Solar Switch help.

Post by ReSt »

As I'm also struggling with that Arduino stuff.

Has somebody found how to:
a) save the result of compiling a sketch that you upload to the board (the hex file) so you can use it later again ?
b) load an existing hex file to the board without having the Arduino sketch (the source file) ?


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

Re: Smart Solar Switch help.

Post by rperkins »

The hex is saved, the location is dependent on your Operating system.
http://arduino.cc/en/Hacking/BuildProcess

I also learned a lot by turning on the verbose option in the preferences as mentioned at the above link.

Once you locate the hex file I'm sure you can burn it with avrdude, as that is what the arduiono ide uses . I've never dont it but I imagine if you turn on the verbose, it will show you the exact command line options used.

As far as moving a sketch from one avr to another. When I tried to move one from an atmega 328 to an atmega 8, some of the register and/or bit names changed. This had to do with the timers, I still havent got it figured out, been working on something else.
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 »

I loaded the solar file into me Arduino today and tried to simulate the needed inputs to get outputs.
Didn't quite make it but the yellow led was blinking and I could change the timing in the pgm and load it and it changed. I at least know I've got that working.
I don't want yo drag this out too much but if its ok in this topic I'll continue with a few more questions.
What I think would help is to break the pgm into smaller operations.
Maybe not include the photocell detect.
First would be to have it detect a voltage less than 12v and change state on the relay output and led and stay that way for 1 min after the voltage is above 12v and then change again.
This will allow me to change detect voltages and hysterics values to better understand its operation. The flashing led can stay in as it is.
Then I can work on the photocell detect part.
Is it as easy as adding a jump or goto line in the code so the unwanted operations will not happen? The idea is to not have to rewrite a new version, just not implement operations until needed.
If this is a real bother I'll put this on hold and work on trying all the examples Arduino provided and build my knowledge better.
I understand the concept.
I built up the divider and it indeed gives me a range of around 2.77V at 12 volts in, less than 5 at 14.5V
From what I could make work I think I've found that my load, relay and led, can be from +5 or ground giving me an inverse action?
I'm frantically reading all I can find but a schematic of the parts connections will reinforce my thinking. Then I'll tweak it from there.
I'm not foreign to logic circuits but I am to this type.
Thanks for your patience, I hope.
Also, in case I co kill this 328 I'm thinking of buying a spare. Hopefully I can find a local source with boot loader installed. I don't want to take that on until I get this working.
SM



Sent from my iPod touch using Tapatalk.
Please add a location to your profile. Thank You
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 »

Looks like a good place for me to start
http://playground.arduino.cc/projects/ideas
SM


Sent from my iPod touch using Tapatalk.
Please add a location to your profile. Thank You

Post Reply

Return to “Other Electronic Projects”