Sunday, October 14, 2012

Listen to the Radio from ANYWHERE

Since I moved to South Florida I've noticed that there aren't any appropriate radio stations anywhere down here. They're all mindless Clear Channel-type Top 40 or country stations. Unacceptable. There weren't this many country stations when I lived in South Carolina or Tennessee. Anyway! I thought maybe I could build a radio that would get radio stations from far away, and it would let me listen to independently-owned and happily non-country stations 105.5 The Bridge from Charleston and Lightning 100 from Nashville.

My idea was to interface a parallel port port in a computer to a set of buttons. Each button would launch Firefox which would then load the online stream of one of these stations. The computer controlling it would be headless and hidden, so the visible hardware would look and perform just like a regular radio. The only downside to this is that I can't get 95.7 The Ride out of Charlotte with this build because they don't have an online stream anymore.

At boot, the computer executes a script that starts a C program called "launcher". The C program is necessary to take control of the printer port, and therefore it must be run as root. To allow the computer to execute the script as root, I added the following line to the sudoer's file with the command "sudo visudo":

ALL    ALL = (root) NOPASSWD: /home/bryan/programs/radio/launcher

The script is very simple:

#!/bin/bash
sudo /home/bryan/programs/radio/launcher

I also ran "chmod 755 startup.sh" on the script to make it executable. Next is the C program that will actually handle the parallel port and launch the browser when a button press is detected:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/io.h>
#include <time.h>

#define base 0x378 // printer port base address
#define status 0x379 //printer port status register

//Define button push events. Status register default 0x78 = 0b01111000. 
#define PUSH1 0x70 //0x70 = 0b01110000
#define PUSH2 0x68 //0x68 = 0b01101000

int A=1;
int lastA=0;
int B=1;
int lastB=0;
int regval=0;
int lastregval=1;

int main(int argc, char **argv) {
  //make sure the program has access to the parallel port
  if (ioperm(base,1,1))
   fprintf(stderr, "Couldn't get the port at %x\n", base), exit(1);
  if (ioperm(status,1,1))
   fprintf(stderr, "Couldn't get the port at %x\n", status), exit(1);

  //write 0b00000001 to the output lines to get +5V for the switches
  outb(1, base);

  while(1) { //run forever
  //print status register if and only if it changes
/*    regval=inb(status);
    if(regval != lastregval) {
      printf("%x\n",regval);
      lastregval=regval;
    } */

    if (inb(status)==PUSH1 && A!=lastA) {
      //enable other button pushes
      B++;
//      printf("button 1 pushed!\n");
      //call script
      system("/bin/bash /home/bryan/programs/radio/script1.sh");
      //disable a second button 1 push event to debounce and to
      //prevent closing of browser and opening the same page it was on
      A=lastA; 
    }

    if (inb(status)==PUSH2 && B!=lastB) {
      //enable other button pushes
      A++;
//      printf("button 2 pushed!\n");
      system("/bin/bash /home/bryan/programs/radio/script2.sh");
      //disable a second button 2 push event to debounce and to
      //prevent closing of browser and opening the same page it was on
      B=lastB;
    }
  }
}


No problem. I complied it using "gcc -O launcher.c -o launcher". Compiling with these options is necessary for proper functionality of the parallel port.

This program only handles two stations now but it could be expanded for more if 95.7 WXRC ever decided to have an online stream again. I believe the next step is to program this on my Raspberry Pi when it gets here, and install it in the radio that I have that has been the subject of previous posts on this blog. I think I could rewire the memory buttons on the radio to be inputs to the Pi and have the radio display "105.5" or "100.1" on its LCD. This has some potential! If anyone has some tips on how I can be a better programmer, I am open to those suggestions. I'm an engineer, not a computer scientist.


Sunday, August 12, 2012

Halon Alarm

I found this halon alarm in the garbage a long, long time ago and I finally have some time to goof off. Believe it or not, this relates to my ongoing solar panel build. To build a maximum power point tracking circuit will require the construction of a special switch mode power supply topology, and since I have never built even a simple switch mode power supply, I figure I could get some experience with one before moving on to the complicated stuff.


The halon alarm consists of two modules, a bell and a strobe light. They are wired in parallel and accept a 24V DC power source. Since 24V systems are less common than 12V systems (and I may install this in a vehicle in the future) I attempted to build a 12V DC to 24V DC boost converter, with varying degrees of success.

A brief explanation of boost converters: a transistor is used to rapidly switch power flowing through an inductor. The rapid switching action exploits an inductor's resistance to changes in current. When the current flow to an inductor is switched off, a voltage spike occurs as the inductor attempts to keep current flowing through it at the same rate. By charging a capacitor with this voltage spike, a DC voltage greater than the input voltage can be obtained. Before transistors (and before they became cost-effective to mass produce) DC-DC conversion was either expensive, impractical, unreliable, or some combination of those three. This is why the power grid is alternating current, as it is much easier to change the voltage levels using AC than with DC.

The first step is actually the most difficult: creating a circuit that will switch the power transistor. For a power supply like this, the switching action must happen many thousands of times per second. PWM is often the best option for rapid transistor switching, so for this I used a 555 timer chip wired to produce a 28 kHz square wave. The output of the timer was attached to the gate of an IRF510 MOSFET. The rest of the power supply is comparatively easy to build.


This is the point that I had some difficulties. Switch mode power supplies can be very particular. The duty cycle of the signal that switches the transistor must be precise, as this directly controls the output voltage. The other quirk with these circuits is that the output voltage tends to be dependent on the load that is connected to them. Without a load, the voltage (on this circuit anyway) tended to "run away", growing higher and higher until I realized something catastrophic was about to happen, at which point I turned it off. This contrasts to a linear voltage regulator, which (while it wastes about 70% of the input power) will have a relatively stable output voltage regardless of load.

Another point I would like to make here is that this design does not include any feedback on the output voltage. I designed it for 12V input and 24V output but "really" what it does is double the input voltage. If I put 5V input it will output 10V, and (theoretically, although it would burn up first) a 100V input would produce a 200V output. The alarm is rated for 20-24VDC (and I'm assuming a little above that as well) so as long as the 12V source is fairly constant (a car battery, etc) then this shouldn't be a problem, and keeps the design simple.

The other major difficulty is managing the power spikes inherent in the design. On computer power supplies, the electrical noise and harmonics that are produced are dramatic. Most are required to have special filters on them to prevent them from harming a power utility's power factor and voltage waveforms (compact fluorescent bulbs produce a similar amount of noise but are not required to have as strict of filtering, which causes problems). So anyway, it turns out that I melted through two ground wires because of this.


Notice the bubbles on the white wire. Whoops. The circuit draws 100 mA on average, but this doesn't necessarily account for the spikes that the inductor causes.

Once I got everything straightened out I tested the alarm (very, very briefly) in my apartment with numerous cloths wrapped around the bell. I didn't want to remove the bell for fear that I would damage the striking mechanism. Once I was sure everything was in working order, I drove far away to test it more thoroughly.


If you look closely during and after the test, you will see that I melted through the orange ground wire. When I build this circuit in a permanent manner (not on the breadboard) I will be using much heavier gauge wire. I also plan on enclosing the circuit within the junction box that houses the strobe light.

You will also notice that the strobe light is noticeably not strobing. I am currently working on repairing this. I'm not sure how successful I will be, but it would be nice if it worked too. Updates on that will follow.



MEANWHILE! I got around to repairing an old set of Pioneer headphones I commandeered from my dad when I was younger, in an effort to reduce the number of times either one of my parents accused me of listening to my CD player too loud while we were on car trips. The effort was largely in vain. But the headphones needed some TLC (and one of the ears wasn't working any way) so I finally took them all apart, soaked them in acetone to clean them up, rewired the malfunctioning speaker, and hot-glued the ear pads on (the plastic that was supposed to hold them on had broken off). Then I used some WD-40 to clean up the leftover residue from the duct tape that was holding them together. Viola! A brand new set of headphones that I can use with my piano to keep the neighbors happy.



Thanks for all the free stuff, Dad!

UPDATES

I built a permanent version of the boost converter and put it inside the strobe light housing. Pictures! The inductor is a 1mH 0.8A high-current choke that I had laying around. I believe an inductor of this size is overkill. So it goes. Also, I used a IRF530 MOSFET driven by a 555 timer. The capacitor values are not as important.


All the capacitors are there because I didn't have one that was the right value, so I paralleled them up to get the capacitance I needed.


Installed, complete with fuse. Now I just need to fix the strobe light and I'll be in business!


This was the extent of this project's damage. The white wire I bubbled up while I was still figuring out the ins and outs of SMPS design, the orange one is the wire I melted through during the test that I recorded in the video above. You can watch it melt if you look real closely.

Saturday, July 21, 2012

Holy oscilloscope, Batman!

I bought an analog Hewlett-Packard oscilloscope today. It was designed in the 70s, built in 1985, and decommissioned by the US Navy in 1993. Still going strong apparently. It's about two feet long (which is not evident in the picture, but it does not fit on my recliner). I don't have any test leads yet, but this is one of the two tools I needed to start working on switch-mode power supplies. It also makes me feel like I'm back in my Circuits I class with lab equipment that rarely worked. Hopefully this will go better!

Sunday, July 1, 2012

Outlet Control Pictures


I took some pictures while I was making a permanent enclosure for my web-controlled power outlets. These are going in the kitchen and are attached to the old Gateway that plays my fridge music and serves up my tunes. I made it work in a way that each plug on the outlet can be independently controlled.

 

 Oh, and I used a ton of hot glue to seal everything up...

 



I took 12V DC control wiring from the IDE drives' power wires and ran it out of the front of the computer.



Very professional!




New update relating to my lamp: I was successfully able to install a webcam and set it up to monitor the lamp. This is more of a temporary solution until I can learn Python.

Any way! I installed a program called "streamer" which can do many things, including take a JPEG picture from a webcam. Then I wrote a script to run this program every second.

#!/bin/sh
while [ true ] do 
 streamer -s 640x480 -f jpeg -o /var/www/images/snapshot.jpeg 
 sleep 1
done

The picture gets rewritten every time it runs. That way the web server doesn't need to think about which picture to show. Now I need to execute this program as root at boot time. I added a line to the /etc/init.d/rc.local file:

/home/bryan/streamer &

Hooray! This method obviously takes quite a bit more system resources. If this was something that people would look at all the time, maybe it would be a good method, but I'll maybe use this once a week, so hopefully when I learn Python I'll figure out a way to execute the "streamer" program once when the page is requested.

Saturday, June 23, 2012

Desk Lamp Web Control

Once I got the web server working from the last post, it was time to get the parallel port to do something useful. As its first task, I decided to hook it up to my desk lamp so that anyone in the world could turn the light in my apartment on and off. If you would like to try it yourself (and my computer is on), go to http://108.233.132.201/.

THIS IS IMPORTANT: I can't tell who is turning my lamp on and off yet. So! If you're going to play around with it, please let me know who you are. Phone/text/email/facebook are all acceptable, or just leave a comment below.

I used an AC adaptor I had laying around (from my kitchen light switch mod from two and a half years ago) to get 12V DC for the relay. When I actually hook this up in the kitchen, I plan on splicing in to the old Gateway's power supply to get the 12V. I tied the output ground from the power supply to the 0V pins of the parallel port and put an LED in to let me know when I had the device powered up. Next I wired up a TIP31 NPN bipolar junction transistor. The base was attached to one of the parallel pins, the collector was attached to the relay coil (I also put an LED here just for peace of mind), and the emitter was attached to ground. And that's it! Once I get this in the kitchen (and wired up properly, i.e. not with live 120AC wires taped to terminals) I'll post a video of it in action. 

An overview of the setup. Parallel port on the left, electronics in the middle, AC adaptor, relay, and the lamp's plug on the upper right.


A close-up of the electronics. The IC on the right is a 555 timer that's not being used. 

Everything together including the lamp. 

My not-quite-up-to-code wiring, which shows how I fed the 120V AC from the wall, through the adaptor, through the relay, and to the lamp. Not super safe but I won't leave it plugged in until I build a more permanent enclosure for it.


Also I promise I had this idea before this episode of the Big Bang Theory aired. WHAT A COINCIDENCE! This is what I felt like though. Then it was creepy when people started turning my lamp on and off.

Tuesday, June 19, 2012

Progress on the "Turing" Slow Cooker

I have successfully managed to control the pins on a parallel (printer) port over the internets. I now document my efforts.

I already have this working on my personal desktop (which is apparently old enough to still have a parallel port in it?). For the purposes of writing this without flaws, I will be re-creating my work on the old Gateway in the kitchen, mostly using SSH. As of this writing, the computer is running Ubuntu 12.04 with LXDE.

First, I installed the apache2 webserver.

sudo apt-get install apache2

Next, I need to modify apache to run CGI scripts. This is much easier than everyone else on the internet seems to think. First, open /etc/apache2/apache2.conf with your favorite text editor and add the following line above  
ErrorLog ${APACHE_LOG_DIR}/error.log:

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ 

Now it is time to get dirty. I used www.epanorama.net/circuits/parallel_output.html as a primer. It is full of spelling and grammar mistakes (and a few coding mistakes) but it's legible and helpful. Any way, the default web page that apache serves is /var/www/index.html. Mine looks like this:

<html>
<head>
<title>Parallel port controlling test page</title>
</head>
<body>
<h1>Parallel port controlling test page</h1>
<p>
<form action="/cgi-bin/lpton.cgi" method="get" name="on">
<input type=submit value="Set all data pins high">
</form>
<p>
<form action="/cgi-bin/lptoff.cgi" method="get" name="off">
<input type=submit value="Set all data pins low">
</form>
<p><img src="pic.png">
<p>
</body>
</html>


The picture was to double-check to make sure apache was serving more than just index.html because at first I had problems serving the CGI scripts. Any way! Now we need to get those CGI scripts written. I use two, in this example, one to set all the data pins on the parallel port high (turn things on) and one to set them all low (turn them off). I started off in ~/programs with two C programs.


lptoff.c:
include
#include
#include
#include
#include


lpton.c:
#include
#include
#include
#include
#include


I compiled the programs:

gcc -O lptoff.c -o lptoff
gcc -O lpton.c -o lpton 


Then I moved the programs to the /usr/sbin/ directory and gave them root access. This means that every time these programs are called they run as root automatically, even if the user who executes the programs does not have root privileges. This may seem like bad practice, but the reason for this is that writing to the parallel port requires root. This seems unavoidable. Just make sure the program won't get stuck in an infinite loop or it will be difficult to stop it. Any way...

sudo cp lptoff /usr/sbin/
sudo cp lpton /usr/sbin/
cd /usr/sbin
sudo chmod +s lptoff
sudo chmod +s lpton


The next step is to write CGI scrips that tell apache to run these two programs. They will be placed in the /usr/lib/cgi-bin/ directory. There are two buttons in this example, so there are two CGI scripts:

lptoff.cgi:
#!/bin/sh
# Parallel port CGI script
#
# Send HTTP headers
echo Content-type: text/html;charset=ISO-8859
echo
# Do the controlling
/usr/sbin/lptoff
# Output web page data
echo ""
echo "Parallel port controlled
"
echo "Go back to controlling page"
echo ""
#


lpton.cgi:
#!/bin/sh
# Parallel port CGI script
#
# Send HTTP headers
echo Content-type: text/html;charset=ISO-8859
echo
# Do the controlling
/usr/sbin/lpton
# Output web page data
echo ""
echo "Parallel port controlled
"
echo "Go back to controlling page"
echo ""
#


That's all! Again, credit where credit is due, most of the pages came from http://www.epanorama.net/circuits/parallel_output.html#webcontrol, and I modified the rest to suit my needs. This blog is primarily a way that I can keep track of what I do, and that is what I have done. Hooray science!

A video of it in action:




UPDATE: Actually a lot of this code is messed up because it's almost impossible to post code with this blog publisher's web software. So if anyone REALLY WANTS the files, maybe I'll make them available for download from my server. Also. You'll need to make the .cgi files executable! This is important otherwise you'll get a "INTERNAL SERVER ERROR!!!!!11" error when you try to run this. Do sudo chmod +x on the files and you'll be fine.

Sunday, June 10, 2012

Slow Cooker + Fridge Speakers

The iPod finally gave up all the way. The screen still works but it doesn't play audio even if it's cold. As a stop-gap in the awesomeness that is fridge speakers, I had been using the "brypod" to play the fridge music, but I wanted that back for listening to music in other places. So I took the old Gateway computer I have, put a fun version of Linux on it, and made it play the music in the fridge. As a bonus: This computer also has a parallel port (a consequence of it being about 12 years old) which I will eventually use to control other things in the kitchen over the internet, such as the slow cooker. This is how I did it!

First! I downloaded the Ubuntu 12.04 x86 (32-bit) alternate desktop installer and burned it to a CD-RW and used that to install Ubuntu to the Gateway. This led to a problem that is becoming worse and worse with Ubuntu: despite having an "alternate installer" for old computers that don't have enough system resources to run the GUI, it's either impossible or very difficult to boot it to a command-line interface once it is installed. To me, this seems to defeat the purpose of having an alternate installer, but I also don't claim to be any sort of Linux expert. But any way! I spent about two hours coaxing the resource hog of a GUI into a terminal window so I could do something useful.

sudo apt-get install lxde

This installed a new GUI called LXDE which is extremely efficient and light-weight (unlike GNOME/Unity), without being downright unusable and terrible (unlike Fluxbox). After logging out and logging in to my LXDE session, I was able to actually use the computer.

sudo apt-get install ssh vlc x11vnc build-essential ubuntu-restricted-extras
sudo apt-get update
sudo apt-get upgrade


This installed all the system updates as well as the tools I will be using on this computer:
  1. VLC, a versatile media player (easier to manipulate than my personal preference, Rhythmbox)
  2. SSH, which allows me to login to the computer remotely via command-line
  3. X11VNC, which gives me remote desktop control (so I don't have to have a monitor/keyboard hooked up to the computer).
I needed to configure the remote desktop software to start automatically at boot.

x11vnc -storepasswd

It is necessary to have a password. Next: I went to ~/.config/autostart and created a shortcut named X11VNC.desktop. (It is necessary to create the autostart directory if it does not exist already.) The file should look like this:

[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=X1VNC
Comment=
Exec=x11vnc -forever -usepw -httpport 5900
StartupNotify=false
Terminal=false
Hidden=false


The next step is to configure the login options:
sudo nano /etc/lightdm/lightdm.conf

Now I need to configure the computer to automatically log in to an LXDE session when it starts up, so I don't have to type in a user name and password. I changed the lightdm.conf file from this:

[SeatDefaults]
user-session=ubuntu
greeter-session=unity-greeter


to this:

[SeatDefaults]
user-session=lxde
greeter-session=unity-greeter
autologin-user=bryan
autologin-user-timeout=0


The next step is to install folder sharing software (samba) so I can easily drag and drop music to the computer for my refrigerator listening pleasure. I decided to share the Music folder (~/Music) over the network. (I could have used SSH to do this, but it's a lot easier to drag-and-drop).

Once all the music I wanted was on the computer, I moved all the .mp3 files to one folder and created an .m3u playlist:

ls -d * | grep .mp3 > "${PWD##*/}.m3u"

This creates a file called ~/Music/Music.m3u. The final step is to tell the computer to start VLC when it boots, AND play this playlist file when it starts the program, AND turn on repeat and shuffle. This was accomplished by making a file called vlc.desktop and placing it in the autostart folder.


[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=vlc
Comment=
Exec=vlc /home/bryan/Music/Music.m3u --random --loop
StartupNotify=false
Terminal=false
Hidden=false


That's it! Now the computer plays fridge music, is accessible remotely by VNC, SSH, and Samba, and is ready to start controlling things in the kitchen over the internets!

Saturday, May 12, 2012

Solar Power for the Truck

I've always wanted to play around with a solar panel large enough to do something useful. Since I occasionally drive my truck well into the middle of nowhere, running some of the electronics in it (the stereo, the radio equipment, or the inverter) off of a solar panel seemed possible, but as a secondary goal I also decided I would like for the solar panel to run the cabin fans during particularly hot days to keep the heat manageable (I live in South Florida). Most of what I have done up to this point is proof-of-concept, and I am not planning on having this particular panel permanently attached to my truck.

As an electrical engineer in the power industry, I must start this with a disclaimer: my goal is NOT to offset any of the fossil fuels used in my truck with solar. From my experience, there is a pervasive belief that solar photovoltaics are much more practical than they really are. However, to put it in perspective, to even offset 20% of the power my truck's engine normally produces, the solar panel would have to be around 3,000 square feet. My engineering opinion in a nutshell is that energy from solar photovoltaic is useful in remote, sunny areas, but solar thermal should be used for any sort of large-scale power production.

Nevertheless! I found a 50-watt panel for dirt cheap that should work pretty well for what I want to do: essentially turn my truck into a portable battery that will be able to run the electronics worry-free if it runs out of gas.



When I first started this, I thought, "Surely I can tie a solar panel to my truck's electrical system. Shouldn't take more than a week to build a charge controller!" So here I am, two months later, with the finished product. The theme of the day is "how much I hate programming" which, as anyone who knows me will attest to, is "a lot". Sure, I could have just bought a charge controller, but what fun would that be? But I also wanted the ability to add additional functionality, and I would like for the Arduino will eventually expand its programming to include solar tracking, so it keeps my options open.

Another thing that I would like to point out is that I will be wiring the panel (via the controller) essentially straight to the battery, rather than directly to individual loads in the truck. There are two main reasons for this. First, it greatly simplifies the design and the work involved. Second, many things need a very smooth, constant power flow, which a solar panel like this simply cannot provide. When all of the energy is sent to the battery first, the battery acts as a sort of capacitor, storing and smoothing out the erratic energy from the panel so it can be used safely and efficiently by any device in the truck.


The first step, however, was to make sure that the power from the panel didn't overwhelm the controller. The panel produces 20V open-circuit, which may not harm the microcontroller immediately, but may degrade it over time. I stuck a 12V regulator (with heat sink) in the circuit to help the Arduino out a little bit. The other chip is the transistor that will drive the relay that will control when the solar panel delivers power to the battery in the truck.

The battery can be damaged if it is over- or under-charged, so the general idea is to measure the voltage at the panel and at the battery, compare the two values, and then have the microcontroller decide if the battery needs help from the panel. The voltage at each point was sent through a voltage divider to get them both down from the 0-20V range they are at normally to the 0-5V range that the Arduino likes. I chose 12.4 volts as the "low" point for the battery, where the panel will send energy to the battery (provided there is enough sunlight) and 14.4 volts as the "high" point where the microcontroller will disconnect the panel to keep from damaging the battery.



That is a rental Sentra. Not because I was afraid to hook this up to my own vehicle, but because my truck decided to randomly blow its rear main seal and spew crank and gear oil all over creation. But we persevere! The tests on the Sentra were promising, but the programming needed some tweaking. I also found out that the controller behaves erratically when it is not hooked up to the battery first.

This video shows some of the action from testing it on my homemade bench power supply (not pretty, but gets the job done):



Any way. On to putting it all together! Since I don't intend for this to be bulletproof or permanent, I put it together from stuff I had lying around. If you have read my blog extensively, you will notice that the enclosure is from the remote kitchen light switch I built a long time ago.


Building the circuitry. The large heat sink is for a Schottky diode. This prevents the battery from discharging back into the solar panel when there isn't any sunlight. Without the diode, the panel would behave as a resistive load in low-light conditions and drain the battery (and possibly damage the cells). This was more or less just a precaution though. Since the panel provides power to the microcontroller and associated circuitry directly, in low-light conditions one would assume that there wouldn't be enough energy to drive the relay. What I actually found out was that a surprisingly low amount of light is enough to turn everything on. Plus, since I'm an electrical engineer, plopping a precautionary diode in the circuit is much easier than doing any sort of programming, or trying to predict what the Arduino will do if it gets random spurts of power with a voltage less than 5V.


Addition of the relay and microcontroller, as well as a 10-amp main fuse (because I didn't have any smaller than 10 but greater than 5) and a 1-amp fuse to protect the Arduino and power transistor.


Preliminary layout in the enclosure.


Attached to the truck for testing. The red LED indicates that the panel has enough power to run the microcontroller but nothing else (very overcast days, dusk and dawn, etc.). The yellow LED indicates that the panel has sufficient power to charge the battery but the battery already has a full charge, and the green battery indicates that the panel is supplying power to the battery and/or the rest of the truck's electrical system.


Testing on the truck this time. 


The second relay was added to control power delivery to the fans in the truck. It is a SPDT relay with the coil connected to the truck's ignition. When the truck turns on, the fans behave normally, and when the truck is turned off, the fans are connected directly to the panel. I was able to splice it in to the control circuitry in the truck with little issue. To further reiterate how little power solar panels produce for their size, this panel barely has enough energy to spin the cabin fans at their lowest setting in direct sunlight.

A second video illustrates the panel and controller being tested on the truck.



A rousing success! Next was to attach the LEDs somewhere where I could see them easily. I used CAT5 ethernet cable for this, and used the final twisted pair out of the set of four twisted pairs to hook up a reset button for the Arduino, just in case things got wily.



I drilled these into the trim around the stereo's head unit and the CB radio and soldered the CAT5 cable. I used a regular ethernet jack here as well to enable the trim to be removed easily. 


The red button is the reset for the Arduino.


I also used this project as an excuse to add a voltmeter to the truck. The black button turns the voltmeter on if the truck is off, otherwise it turns on automatically when the truck does via a small 12V relay I wired to the ignition. The voltmeter will also be helpful when I go off road, in the event I drive through a river and the alternator fails. Not entirely out of the question.


I stored the unit behind the passenger seat and ran all the wires under the center console.


Propped up in the bed. The tailgate can be lowered if the sun is lower in the sky.


The chain is because, as I mentioned, I live in South Florida. This also shows the special weatherproof MC4 connectors that came with the solar panel.

This was installed in my truck for about two weeks and worked great! It didn't even start any fires. It does charge the battery much better than it runs the fans though, so if I want to do that better I'll have to upgrade. For the future! I plan on building a custom panel that will produce more power and mount to the top of the toolbox (so it doesn't always waste bed space). Optionally I could have both panels running in parallel for around 130 watts of solar power. The next things I am going to work on are a maximum power point tracking circuit and a solar tracking device. I'm worried that solar tracking will consume more power than it creates, but maybe I can think of a more efficient way to do it. We will see!

Sunday, March 25, 2012

Videos?

A while back I posted a list of some of my favorite albums of all time. Notably, I left of Deja Vu by Crosby, Stills, Nash, and Young, but that's neither here nor there. Any way, in the same vein, I thought I would post my five favorite music videos to date. Just for a little fun.

Red Hot Chili Peppers - Otherside



I remember being blown away by this one in middle school, and probably the fact that I still find it so mind boggling is why it makes it to #1.

Goo Goo Dolls - Broadway



What are they trying to say? They feel like old men? Everyone is a rocker deep down inside? Whatever it is, I approve.

Coldplay - Strawberry Swing



The amount of time this probably took is mind numbing. Bonus points for the trippiness factor.

Weezer - (If You're Wondering if I Want You To) I Want You To



There's a lesson in here. One we should all follow!

N.A.S.A - Gifted (feat. Kanye West, Santigold & Lykke Li)



Trippy. With a twist ending?

Jay Clifford - Know When to Walk Away




I forgot about this one. BONUS! Very awesome. Points if you can find all the scenes that were shot at landmarks in Charleston.


Didn't think I forgot Third Eye Blind?

Sunday, March 11, 2012

Dual-channel Power Supply

I have a new project on the horizon that I think is going to be... interesting, to say the least. I won't go into that now, but I needed to build some tools before I can build what I actually want to build. This tool will be useful for much more, though.

First thing was to build an adjustable DC power supply. I had some LM317 chips around which are essentially variable voltage regulators if they're hooked up to a potentiometer, so that's exactly what I did first.


I had most of the parts lying around, I had to go to Radioshack for the 120/24V, 2A transformers and the rectifiers and some other odds and ends. Once I got this one working and made sure I could actually adjust the voltage with the potentiometer (knob) the second step was to build a second one.


Once the second one was built, I connected them together in series. Since they are not grounded to a common reference point, the idea was that two 0-34V adjustable DC power supplies could make one 0-72 V adjustable DC power supply, by connecting the positive rail of one power supply to the negative rail of the other. I got this idea from almost blowing apart a $300 power supply in one of my labs, thus proving the idea that if you're not making mistakes, you're not learning.


The next step was to solder it all together.


The two sets of prongs on the top are for the AC input. the red and yellow leads are the positive and negative rails for each power supply (I didn't have any black wire for ground wires so I used yellow).

Time to start assembling it all together. I didn't need it to be pretty, it just had to work. So I got a piece of scrap plywood and started screwing down all the parts. I decided I could save space by making the transformers "legs" by mounting them to the bottom, and attaching the rest to the top.


I screwed the power supply electronics to the top next and then set out to JB weld some of the smaller pieces to the board. The two switches on the bottom turn on the power supplies (so I can run just one if I don't need both) and the switch on the top left ties the two together for the one 74V DC supply. I also added the heat sinks to the LM317 chips.


Next I attached the output terminal (it's a former terminal for speaker hookups for an old stereo that stopped working) and the potentiometers to the board, also using JB weld.


The nearly finished product...


Once everything was together I could make sure it all worked before going farther. This shows my voltmeter hooked up to one of the supplies, outputting about 12V...


...and, with both power supplies turned on and the tie switch on, the power supply outputs about 70V. Looks like everything checks out.


Time to add the finishing touches. I found these little voltmeters on a site called Adafruit and decided to take a risk. They're about as big as my thumbnail and only draw 40 mA.


I got a piece of plexiglass and a DPDT center-off switch (from a previous project involving a former bathroom of mine, actually) and attached LEDs. The switch lets the voltmeter switch between monitoring one power supply or the other, thus saving me from having to install two voltmeters (the switch is MUCH cheaper than the voltmeters are) to monitor each power supply simultaneously. The two wire nuts on the left side of the image are the 120V AC hookups. The color coding is my own scheme, but if you come over to my apartment I would recommend not touching any of it unless I'm around and you're sure it's off.



That was the diagram I used for the power supplies. Pretty straightforward, I just took it slightly farther by building two and tying them together. Similar power supplies can be bought for around $300 but I decided I could build my own for a little less money. It's not as pretty but it does the same job, outputting 1.5A DC anywhere from 0-36V and 3.0A DC from 0-74V. Now that I'm done with this, I can start working on my next project, which I'm sure will be legendary.