Wednesday, November 19, 2014

Determining requirements (solar cell, battery, LiPower device)

Calculations:

We wanted to give a 5V device 1550mAh
We looked for a battery that would give us at least that amount of power. So our battery is 7.4Wh. Watts, or power, is equal to voltage times current (amperage). Or battery is 3.7V*2Ah = 7.4Wh...
P=IV, Power = Current*Voltage
But we're also adding a variable to time to it in Wh. The equation therefore becomes Pt=ItV.

So, we knew which battery to get because 5V*1.5Ah=7.5Wh, which is close to the battery we got. We can swap out our battery for a larger one later if it all works well. This is all for a prototype.

Now we have the battery.

The other calculation we did was for the size of the solar panel. We knew that we wanted to charge this battery to full in a reasonable amount of time, so we looked for a panel that was not too large but could collect a decent amount of energy. The panel we chose is 5.2W. To charge a 7.4Wh battery, it would take 1.42 hours to charge the battery fully (7.4Wh/5.2W).

There is only one kind of Sunny Buddy that is easy to work with, so there are no calculations needed.

Because the battery only puts out 3.7V, we needed a device that would step that up to 5V. That is what the LiPower does.



Tuesday, August 19, 2014

Programming Servos and LCD Shield

Reminder: Servos each have three wires.
In ours, black is ground, red is power, and white is signal.

Because we have two servos and not enough Arduino pins, we needed a breadboard for two of the three sets of 2 wires (for ground and power). We attached them to the breadboard for now and then ran two wires from each segment on the breadboard to the corresponding receptor on the ArduinoUno. The wires for signal will each be getting their own signal and there are plenty of signal receptors on the ArduinoUno so those could connect directly to the Arduino. In this case I am putting them into pins 8 and 9.
Again, this is all a prototype. A more permanent soldering job will be needed to attach everything later. For now, extra wires are used to connect the servos, Arduino, and breadboard.






Using breadboard for prototyping, we wired servos to the Arduino and programmed the Arduino to talk to servos. We're telling each servo to move together 180 degrees.

[video]

Code:
Sweep”, under Examples → Servo
...The writing in bold was added to the example since this prototype is using two servos and they will be moving together. Remember “//”signals a comment and is not read by the Arduino.

// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.


#include <Servo.h>
Servo myservo; // create servo object to control a servo
Servo myservo2; // a maximum of eight servo objects can be created
int pos = 0; // variable to store the servo position
void setup()
{
myservo.attach(9);
myservo2.attach(8); // attaches the servo on pin 9 to the servo object
}
void loop()
{
for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
{ // in steps of 1 degree
myservo.write(pos);
myservo2.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees
{
myservo.write(pos);
myservo2.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}

We set up servos in bracket. Later, we will need to attach to foundation and epoxy solar cell to top bracket.


LCD screen-
The LCD screen lets us read what the Arduino is thinking for now. We are using the Adafruit LCD Shield. It is only for the prototype. We pop it on over the Arduino and use it to give us information about how much solar energy the solar cell is collecting. After we tell the Arduino to figure our the sun's position on its own, we'll pop off the LCD Shield to save energy.



Saturday, July 19, 2014

Tinkering is tricky

Trying to wrap my head around electronics is surprisingly similar to trying to sew a complicated pattern with a sewing machine. In sewing you need to think about the order of everything, measurements, ratios, materials like the fabric and lining and reinforcement and buttons... I could go on. I never really got into sewing the way my mom did. Electronics also seems to require holding a lot in your head at once.

I am really starting from scratch here.

I found out that in first designing a circuit, you use what is called a “solderless breadboard,” pictured below:



As its name would suggest, it lets you put in wires and parts without soldering. Instead of sticking in two wires to one pin, you can use this breadboard to make more connections possible. (More information can be found at: https://learn.adafruit.com/adafruit-arduino-lesson-14-servo-motors/overview )

Underneath a breadboard, there are rows of metal strips. On top, there are holes which you can plug a wire into. If you plug two wires into the same row of holes, they become connected, because they both touch the same metal piece. If you want to connect 5 wires together, you just plug all 5 wires into the same breadboard row.

The Arduino come in where if you have two servos, you need to connect 6 wires (2 signal wires, 2 power wires, 2 ground wires). The Arduino has only 1 power pin, and you might not want to shove two wires into the same pin if the wire is too thick. Instead, you would connect one end of one wire to the Arduino power pin, and the other end of the same wire into a breadboard row. That gives you 4 holes left in the same row, into which you can plug a servo power wire. You can do the same for ground.

Then, when I want to program the servos, in order to tell them to calculate the angle, the Arduino software program has a built-in library for servos. The library is basically a way to use simple words like write(56) to mean much more complicated things, like "calculate the angle to make the servo go to 56, then send that signal to the servo”.

So instead of calculating the necessary angles yourself, the library does the heavy code stuff for you. All I have to do is give the angle.

At the end of the code in the tutorial below there's a code example:

arduino.cc

Then, to just get my servo running, all I need to do is copy and paste that into the Arduino program and hit upload. This code makes my servo sweep back and forth between 0 and 180 degrees. (In this coding program, everything after // is a comment. The Arduino doesnt know these comments exist, so I can write anything I want. They're helpful for showing other programmers, and future me, my thought process while coding).
The brackets move based on instructions from the code myservo.write(pos), which is the actual piece of code that makes the servo turn. So if I just write myservo.write(56);, the servo will spin to 56 degrees and stay there until I send another instruction.

By the way, a servo is used when you need to spin something precisely. A regular motor spins as fast as it can whenever you give it power, but the problem is you never know exactly how far the motor has spun. Therefore, a servo has a special chip inside that can sense how far the servo motor has spun, and based on that can calculate the angle of whatever is attached to the servo motor.
The servo has 3 wires: power, signal, and ground. This chip listens for instructions sent to it over the signal line. Once it receives an instruction to spin to a certain angle, it takes care of the math needed to spin the motor a precise amount, then stops the motor itself once the angle has been reached, and waits for further instructions.

So where is the instruction coming from? What does that consist of? Well, it cannot spin on its own, its just a smart motor really, so it needs a brain, like an Arduino, to tell it where to turn to!
When I write myservo.write(56); , the Arduino looks up what that means in the servo library (which it knows is being used because of the #include Servo.h instruction at the top of the code). The servo.h library then translates the angle provided into the instruction that's to be sent to the servo, and then passes that information along (in this example pin 9, which is where the servo's signal line is connected). The signal itself is in the form of a pulse wave, meaning it's a very quick pulse of energy. The longer the pulse, the greater the angle requested from the servo.
I'm not certain of the specific pulse widths, but it's something like: a 10ms pulse would turn the servo to 10 degrees, and 100ms would turn the servo to 100 degree.

It's based on both the amount of energy collected from the solar panel and the angle of the sun.

The amount of energy coming in is equal to the optimal sun angle. Therefore, when we're at the optimal angle, we're collecting the largest amount of energy.

The basic flow of the program will be:
  1. The Arduino tells the servo to spin to degree 1
  2. The Arduino writes down the amount of energy collected at degree 1
  3. The Arduino tells the servo to stop at each angle from 2-180, taking a measurement at each degree of solar energy
  4. Once all the data has been collected, the Arduino chooses the angle at which is detected the most amount of energy, and tells the servo to go to that angle and stay there
  5. Then it stays at that angle until it senses that the amount of energy coming in has dropped
  6. Then repeats the cycle to find the new optimum angle
It's not actually going to move that much because if it goes to far it will sense a drop in energy coming in. The servos will be attached to the solar cell, and they will use it to move it about. As long as the bottom of the pan/tilt bracket is anchored in something heavier than the panel, it should work (Spolier alert: the panel IS to heavy and we still need to fix the problem).

The Sunny Buddy is smart enough to be able to charge the battery while something is plugged in.
learn.sparkfun.com

The pads that are labeled Load are where we'll be soldering the usb jack. All we have to so is solder the + to the + side of the usb jack, - to -, and away we go.

The LiPower Boost converter is needed because the battery only outputs 3.7V. Therefore, if you measured the voltage at the Load pads, you'd only see the voltage coming out of the battery, which is ~3.7V. We need to step this up to 5V so we can charge over USB, which expects 5V. The LiPower is what holds the charge and releases it to increase the voltage.

Therefore, the connection will be: Sunny Buddy → battery → LiPower → USB

By using an inductor, the LiPower Boost converter can build a magnetic charge within itself and by carefully timing the pulses going into the inductor, it can step up the voltage leaving the inductor.

The solar panel plugs into the sunny buddy, which handles the conversion from solar energy into battery charging energy.

The ideal place for adding cable length is tricky to figure out--we'll have to do some calculations.


The Arduino and servos will hook up to for power the LiPower output as well, same 5V place as the USB jack. We're supposed to use power-saving techniques to reduce the amount of power they actually use.

*Next* we'll talk more about programming the servos and using LCD Shield to help us make sure that the Arduino is performing correctly.

Monday, June 16, 2014

Time to tinker series: Materials for the solar charging station

I recently read the first book in a series titled, "Mad Tinker Chronicles." A quote from the novel got my attention. It read... of course I can't find the page right now. My interpretation was that it said something about how scientists are lazy because they don't apply their knowledge. So, as someone who aspires to think of herself as a scientist, but does not wish to be lazy, I am trying my hand at applying the science behind solar panels and solar charging stations. As a bonus, my wonderfully engineer-minded boyfriend set up a project for me. He ordered the parts to build a solar-powered charging station. It is my job to read the tutorials on the open-source websites SparkFun Electronics and Arduino and figure out how to put everything together and code it.

Act 1, Scene 1.
Unfortunately, as soon as I began, I opened the box to discover that the glue holding the wires in place at the back of the solar cell had not been allowed to set properly. Here was the result:


Now, I think I could fix this myself by getting some kind of putty and just overlaying it on that little misaligned square box... but for that I would have to know where to buy putty. So, I asked my boyfriend to save me and now SparkFun Electronics will send me a new solar cell. (They will likely be more vigilant in the future as well.) Because the solar cell seems fine on its own and SparkFun Electronics has a pretty cool set-up with its whole open-source business model, I will mail the misaligned panel back to them once I receive the new one.

Act 2, Scene 1.
While I wait for the replacement solar cell to arrive, I can take advantage of the lull in my schedule (recent graduate here) to learn a bit and try to figure out the other parts of my project.

First, let's go over the parts list. I'll list them and then in this or the next entry discuss the important new things that I am learning...
I have:

My boyfriend helped me sketch out a design but that was about a month ago. My goal is to have it stationed in a sunny spot outside my house with a wire relaying it inside, maybe to my room, to be used for charging my dumb phone and my iPod Touch.  In my head, it will go something like this: 

A. The Solar Cell takes in solar energy.  It uses a Pan/Tilt Bracket and Servos that are programmed to scan the sky for the position of the sun and instruct the Solar Cell to move to the angle that will collect the most sunlight. This will use require some energy to run the Servos but it should be outweighed by the benefit of continually collecting an optimal amount of sunlight.
B. Energy collected from the Solar Cell goes to the Servos for running the pan and tilt bracket and the rest is relayed to the Polymer Lithium Ion Battery. Something needs to happen with the other gadgets that I have. The Arduino will be used to program the Pan/Tilt Bracket Servos thing and the Sunny Buddy Solar Charger is important for regulating voltage (or is it amps? I should have taken a class for this. Fortunately, SparkFun has tutorials to teach me about these things).
C. Somehow I will connect the USB Type A Female Bracket to the charging station, probably using the Hook-up Wire (which can be any color, but you probably don't actually want to use black, red, or white, because those have other common significance in the world of electronic tinkering).
D. Once the battery is charged, I will be able to charge my phone using solar power! Neat! It may take me some time to get to that point. I am going to post this, let my boyfriend read it, and have him tell my where my brain is confused.


To be continued...