Welcome

Thanks for visiting the Mike's Make blog. It is a compilation of many of my interests. I hope you find the articles in this blog helpful and entertaining. Leave a comment and let me know what you think.

Wednesday, June 5, 2013

Mounting Design for Harbor Freight Solar Panels

  Mounting Design for Harbor Freight Solar Panels
by Michael Shaw, May 2013

Harbor Freight sells an economical solar energy kit that I bought several years ago for less than $200. This kit is advertised as a 45 watt DC system that contains three solar panels, a charge controller/DC supply unit, two 12VDC lamps and all the wiring needed. The only thing you need to supply is a 12VDC car battery. For several years I used it as an auxiliary power source after several hurricanes struck south Florida in 2005 (see my June 2012 blog post “Notes on Surviving a Hurricane”). But what I really wanted to do is get more use from them, so I decided I would use the system to create power for a remote utility shed in the back yard. It could be used for interior or exterior lights, or to power an outdoor fountain or even for 12VDC ventilation fans inside the shed. The only problem was the mounting brackets that came with the kit were really only meant for temporary use and not for a permanent setup. What I needed was an inexpensive and secure way to mount the three panels on the roof of a corrugated aluminum roof shed. 

I decided to make my own mounts after searching the web for affordable PV mounting brackets. Most of the mounting hardware I found on the web was for mounting standard PV panels with higher wattages and dimensions of around 39”X64”. What I wanted didn’t exist, so I decided to make my own. What I needed was a design that was light-weight, wouldn’t rust and could be mounted on a corrugated shed roof, and, oh yeah, cheap. After wandering the local Home Depot store I came across some aluminum metal stock that would do the trick.

What my wife and most females don’t understand about men is that when we walk the isles of a store, in particular a hardware store, our minds are in “tool acquisition” mode. What we are doing in this mode is looking at everything available in the store and deciding if it is A) something that looks cool, B) could it be useful as a weapon or a tool and C) can be turned into something that could be useful as a weapon or a tool. That is why it can take us hours to pick up “some screws” at the local hardware store. So now you know, deal with it.

The aluminum C channel stock I bought would be used as the rails to mount the panels on and the square stock I bought would be used as mounting brackets and act as spacers between the corrugated sections of the roof. I put it all together using stainless steel nuts, washers and screws. The following drawings show how it all came together:







A 96” length of “C” channel stock was cut to span the length of the 3 panels with about .25” between the panels for the ¼ X 20 screws.  I cut 4 pieces of the ¾” X 1/16” square tubing at about 0.89” in length for the end stand-offs, and 4 more pieces about 1” in length for the mounting brackets.  Then I used 4 1/4X3” lag screws and washers to secure the rails to the roof of the shed as in the picture below.




I mounted the rails so they were conveniently located over the center of the roof support beams (this is identified by the location of the roofing screws securing the roofing panels). Then I caulked the bottom of the mounting brackets and used aluminum tape around the bottom of the mounting bracket to act as flashing to keep the mounts from leaking when it rains.
With the rails mounted it was time to install the panels. It’s easier to put the ¼ X20 screws between the panels in before installing the panels, that way all you have to do is slide the panel under the screw. It’s hard to screw the nut, lock washer and flat washer onto the end of the screw after the panels are in place.  

Once the panels were in place, I ran the individual wires from the panels to the junction box where I connected them in parallel using a terminal strip I bought at Radio Shack and mounted inside the junction box.



Then I ran a cable from the junction box up under the roof and down to the controller inside the shed.
   

In the completed mounting design, as a safety measure I attached a bare copper wire to the solar panel mounting rails and to a grounding rod driven 6’ into the ground at the corner of the shed (not shown). This protects the system from the possibility of lightning.



The system has only been in place for about a month, but it should last for many years to come.

Saturday, February 16, 2013


I have done many improvements to PTZ decoder design 
described in my previous posts and you can now get it as a kit 


Wednesday, July 11, 2012

Making a Camera PTZ Decoder


Making a Camera PTZ Decoder

by Michael Shaw, July 2012

 This article explains the design of a Pan-Tilt-Zoom (PTZ) decoder that is used with a camera surveillance system. These systems are used for remotely positioning surveillance cameras and uses twisted pair RS485 for the physical connection. I made this decoder for use with a Maxwell MP-101 electronic power panner, and since this unit only has pan and tilt capability, this article is really about making a pan/ tilt decoder.

PTZ Decoder Interfaced with the Maxwell MP-101 Power Panner
The serial communications format that’s used to talk to the PTZ decoder has been standardized over the years, with the most popular format being the Pelco “D” protocol. I got the specifics of the Pelco D protocol from the website at CommFront,  http://www.commfront.com/RS232_Examples/CCTV/Pelco_D_Pelco_P_Examples_Tutorial.HTM. The picture in figure1 shows a DVR 4 camera system with the PTZ control in the bottom right panel. The DVR system controls a particular PTZ positioning device using a specific address for each decoder. Up to 255 different addresses can be assigned.   

Figure 1, example of a DVR Pan Tilt control panel



The Pelco “D” serial protocol will work with baud rates from 300 baud  up to 9600 baud. The protocol consists of a 7 byte control message that contains the information needed for controlling a PTZ device. The information in this control message contains the address of the device being controlled and the direction and speed of motion. The format of the command is as follows: (note: all values in hex)


Byte 1
Byte 2
Byte 3
Byte 4
Byte 5
Byte 6
Byte 7
Sync
Camera Address
Command 1
Command 2
Data 1
Data 2
Checksum


Byte 1 (sync), the synchronization byte, fixed at FF
Byte 2 (Camera Address), defined range is between 1-FF

Byte 3 (Command 1), first set of control parameters (explained below)

Byte 4 (Command 2), second set of control parameters (explained below)

Byte 5 (Data 1), pan speed parameters ranging from 00 (stop) to 3F (high speed) and FF for turbo (maximum speed of device)

Byte 6 (Data 2), tilt speed parameters ranging from 00 (stop) to 3F (maximum)

Byte 7 (Checksum), sum of bytes (excluding sync byte) then modulo 100
Bytes 3 and 4 are used for the Command 1 and Command 2 control information and are encoded in the following format:

Bit 7
Bit 6
Bit 5
Bit 4
Bit 3
Bit 2
Bit 1
Bit 0
Command 1
Sense
Reserved
Reserved
Auto/Manual Scan
Camera On/Off
Iris Close
Iris Open
Focus Near
Command 2
Focus Far
Zoom Wide
Zoom Tele
Tilt Down
Tilt Up
Pan Left
Pan Right
Fixed to 0

The Maxwell MP-101 electronic power panner has a connector that is used by a remote control to control the position of the camera. This connector will be used for interfacing the decoder to the Maxwell power panner. All the Maxwell power panner needs is a contact closure to activate the desired pan or tilt motion. The decoder uses relays to provide this contact closure, so all that’s needed is to detect the Tilt up/down and Pan left/right commands in the Pelco D message.
I used a PICAXE 18M2 chip as the controller in this decoder design. The PICAXE 18M2 chip is real easy to work with and provides enough I/O pins to do what I want to do. I’ll need 4 outputs for the relays that will be controlling the direction of motion; these are tilt up, tilt down, pan left and pan right. I also want to be able to provide a way for assigning an address to the decoder, so I’ll need 8 pins for that.  To make it easy, I’ve fixed the baud rate at 4800, but I’ll need a pin for the serial input coming from the RS485 transceiver chip and an output pin for a status LED. The schematic for the decoder is pictured in figure 2.

Figure 2, PTZ Decoder Schematic
The software for the decoder is pretty straight forward. When it first starts, it reads the unit address switches then waits for a serial message to arrive. When a serial message is received, it verifies that the checksum is correct and then checks the unit address for a match. If the addresses match then it checks for the pan and tilt commands in the command 2 message.
The software checks for a total of 8 conditions for the pan tilt operations since pan and tilt control could be combined in a single message. The following is a truth table and the resulting values for the various pan/tilt conditions:
Command 2
Tilt Down
Bit 4
Tilt Up
 Bit 3
Pan Left
Bit 2
Pan Right
Bit 1
Fixed to 0
Bit 0

16
8
4
2
1
2



X

4


X


8

X



16
X




10

X

X

18
X


X

12

X
X


20
X

X


 
The design prototype was constructed in about a day on a PC board from Radio Shack. The components were purchased from several different suppliers. The average cost to build the decoder was around $50.

Picture of the PTZ Decoder Prototype




The Decoder Parts List

Ref
Quantity
Description
Part Number
Vendor
RLY1-RLY4
4
SPDT 5V Relay
275-0240
RadioShack
PCB1
1
Prototype PC Board
276-168
RadioShack
U2
1
RS485 transceiver, 5V, 8pin DIP
LTC485CN8#PBF-ND
Digi-Key
U3
1
5V voltage regulator
COM-00107
SparkFun
U1
1
PICAXE 18M2 Microcontroller
COM-10187
SparkFun
SOCKET1
1
18 pin DIP Socket
PRT-07940
SparkFun
SOCKET2
1
8 pin DIP Socket
PRT-07937
SparkFun
J1
1
DC Power Jack
PRT-00119
SparkFun
J2
1
2-pin PCB mount Spring Terminal
PRT-08073
SparkFun
C2
1
Capacitor, 100uf, 50VDC
272-1044
RadioShack
C3
1
Capacitor, 10uf, 10VDC
55047371
RadioShack
C1,C4
2
Capacitor, .1uf, 50VDC
399-4266-ND
Digi-Key
R5
1
330 ohm 0.25W resistor
271-1315
RadioShack
D5
1
Green LED
COM-09592
SparkFun
RN1
1
10K ohm, 9 resistor network
CSC10KY-ND
Digi-Key
R1-R4
4
10K ohm, 0.25W resistors
271-1335
RadioShack
SW1-SW8
1
8 position DIP switch
COM-08034
SparkFun
Q1-Q4
4
2N3904 NPN Small Signal Transistors
COM-00521
SparkFun
D1-D4
4
1N4005 Diodes
276-1104
RadioShack
PWR1
1
Wall Adapter Power Supply, 9VDC
TOL-00298
SparkFun
AR
24 AWG hookup Wire




This decoder design works as expected with a typical DVR setup and is relatively inexpensive to make. You no longer have to be satisfied with a single camera view and can position the camera remotely to view the area of interest. In the next design I will incorporate PWM controlled motors into the circuit, and eliminate the relays. This will allow me to create a complete PTZ unit.

Below is a copy of the PICAXE code
 'PTZ Decoder FOR PICAXE 18M2
 'decodes Pelco "D" type signals
 'By Mike Shaw 7/2012
 'Settings Baud 4800,8,N,1
 Symbol LED    = C.2
Symbol Relay1 = C.6     ' Tilt Up
Symbol Relay2 = C.7     ' Tilt Down
Symbol Relay3 = C.0     ' Pan Right
Symbol Relay4 = C.1     ' Pan Left
Symbol stx   =      b0
Symbol adr   =     b1
Symbol cmd1  =   b2
Symbol cmd2  =   b3
Symbol dat1  =     b4
Symbol dat2  =     b5
Symbol chks  =     b6
Symbol my_adr = b7
Symbol tmp   =     b8

Symbol RX_PIN = C.5                 'Input from RS485 chip
Symbol RX_BAUD = T4800       'Baud fixed at true 4800
Gosub GetADD
Do
 Gosub GetPacket
 If adr = my_adr Then
 Gosub HandlePacket
 End If
 Loop
 GetPacket:
 Do
 SerIn RX_PIN,RX_BAUD,stx,adr,cmd1,cmd2,dat1,dat2,chks
 tmp = adr + cmd1 + cmd2 + dat1 + dat2
 Loop Until tmp = chks
 Return

 GetADD:  ' Read then Display Unit Address
 my_adr = pinsB ^ 001111     'invert address
 for b0 = 1 to my_adr
 high LED
 pause 300 
 low LED
 pause 300
 next b0
 high LED
 Return

 HandlePacket:
 low LED
 if cmd2 = 2 then high Relay3 End If     'Pan Right
 if cmd2 = 4 then high Relay4 End If     'Pan Left
 if cmd2 = 8 then high Relay1 End If      'Tilt Up
 if cmd2 = 10 then high Relay3 End If    'Relay1 Pan Right & Tilt Up
 if cmd2 = 12 then high Relay4 End If    'Relay1 Pan Left & Tilt Up
 if cmd2 = 16 then high Relay2 End If'   'Tilt Down
 if cmd2 = 18 then high Relay3 End If    'Relay2 Pan Right & Tilt Down
 if cmd2 = 20 then high Relay4 End If    'Relay2 Pan Left & Tilt Down
 pause 1000   ' 1 sec delay
 low Relay1,Relay2,Relay3,Relay4
 high LED
 Return