Tuesday, February 14, 2012

Project (part 1)


Tuesday, October 18, 2011





Automatic Blind
Introduction

The aim of this project is to understand and gain the knowledge needed to design and build an automated system to control a venetian blind. This project consists of an automatic blind which will open and close with the use of a light to frequency converter and a temperature sensor. It will also be controlled with the use of a motion sensor and a remote control.

The light to frequency converter will detect outside Sun light levels and the temperature sensor will detect room temperature. At a predetermined light level the blinds will open or it can be set on a clock timer that will only allow the blinds to open at a certain time. At dusk, they will close in the same manner with a clock setting to indicate it been night time. The temperature sensor will also be set up so that temperature readings from inside the room can activate the device depending on daylight or night settings. All sensor setting can be over written by the use of the remote control to activate the device. The Automatic blind will run from a mains supply but will also have a battery back-up in case of a power outage.



Week 1
It's week 1 and we were assigned our projects today. I got my first choice which is an Automatic blind. The first thing I will have to research is how to write a new language called PBasic.
PBasic is the language for operating the Basic Stamp Microcontroller which I will be using in this project.
This weeks lab consisted of testing the circuit on the breadboard and interfacing it to the PC using PBasic. After having some problems with the circuit it was discovered that the Basic Stamp Microcontroller that was recieved last week was not working. When this was replaced everything worked fine. Testing the voltage regulator showed that there was 8.4V coming onto the breadboard and when passed through the regulator it showed to be 5.2V.



The Basic Stamp II
The Basic Stamp 2 is a very easy microcontroller to understand and use. It is made by Parallax Inc who also makes a number of peripherals that work with the microcontroller. It can control and monitor peripherals such as motors, sensors, relays, switches lights and more. To program the basic stamp microcontroller, an easy to use language called PBasic is used.
The Basic Stamp has its own processor on board as well as its own clock source, memory and power regulator. It stores code that is written to the stamp inside a serial EEPROM. This non-volatile storage retains memory of the code written without power. The Basic Stamp runs on 5V to 15V DC and has an on board 5 Volt regulator which converts power from anything above 6V back to 5V for its components. It has 16 Input/output pins as well as 2 dedicated serial port pins and can execute 4000 instructions per second.


 Features:

  • Power Supply Requirements: 5.5-15VDC (Vin) or 5VDC (Vdd)
  • Communication: Serial (9600 baud for programming)
  • Processor Speed: 20 MHz
  • Program Execution Speed: ~4,000 PBASIC instructions/sec.
  • RAM Size: 32 Bytes (6 I/0, 26 Variable)
  • EEPROM (Program) Size: 2 KBytes; ~500 PBASIC instructions
  • Number of I/O Pins: 16 + 2 dedicated serial
  • Current Draw @ 5 VDC: 3mA Run, 50 μA Sleep
  • Source/Sink Current per I/O: 20 mA / 25 mA
  • Source/Sink Current per unit: 40 mA / 50 mA per 8 I/O pins
  • PBASIC Commands: 42
  • Package: 24-pin DIP
  • Industrial-Rated since Rev J

Dimensions:
  • 1.20 x 0.63 x 0.15 in (30.0 x 16.0 x 3.81 mm)

Week 2
In order for this to work correctly, a circuit was bulit on a breadboard with a Basic Stamp microcontroller. To bring power to the board a 9V battery was used and regulated to 5V using a 7805 voltage regulator. A test programme was then written on PBasic was used to read in from the light to frequency sensor and send out a signal from the Basic Stamp to light up an LED -BAR in sequence. This will communicate with the board through a USB to serial (RS-232) adapter. Therefore connecting to the Basic Stamp microcontroller a USB lead to run from the breadboard with a 9 pin female connector had to be made. Pin 2 (RX) on the lead connects to pin 1(SOUT) on the stamp pin 3(TX) on the lead goes to pin 2(SIN) on the stamp, pin 4 (DTR) connects to pin 3 (ATN) on the stamp and pin 5 connects to ground, pin 4(VSS) on the stamp. Pins 6 (DSR) and 7 (RTS) on the lead are joined together to enable automatic port detection.


Week 3
This weeks lab consisted of getting the software to work proparly to communicate with the LED's on the board. The code is now working so that when the light to frquency sensor reads in a signal, depending on how bright or how dark it gets, it will light the LED's to match that frequency. This can now be used to program the individual controls for the blind, such as tilt the blind when it gets to a certain light, or lift the blind. A como drill (100:1) 1.5-3v DC motor will be used to control the blind. And to control the motions of the motor a H-Bridge circuit will control the flow of current which will send the motor forward or reverse. A H-Bridge is made up of a selection of PNP and NPN transistors along with some resistors and diodes.

TSL230 Light to Frequency converter

The light to frequency converter measures light intensity using an array of photodiodes which then will output a square wave whose frequency will be proportional to light intensity which strikes the surface of the chip. It can provide three levels of sensitivity from the measurement of nearly any light intensity. The sensitivity is set by the appropriate levels on the control pins S0 and S1. Because the output frequencies can reach from 1Hz to over 1 MHz, pins S2 and S3 are used as a frequency divider on the TSL230 making it possible for the basic stamp to measure the frequencies. The operating voltages for the TSL230 are from 2.7V to 5.5V enabling it to be interfaced with a micro controller which operates within these voltages. This would include all microcontrollers that are produced from Parallax INC.



Week 4









H-Bridge
The H-Bridge that was created for this project is made up from 2 x TIP 125PNP Transistors, 2 x TIP 121 NPN Transistors, 4 x diodes and 4 x 1Kohm resisters. The NPN transistors connect the motor to GND and the PNP transistors connect it to VDC. The resistors prevent too much current from passing through the BASE pin of the transistors. A 1Kilohm resistor allows enough current to saturate the transistor; anything higher would cause the motor to receive less power. The Diodes create a safe path for the energy from the motor back to the battery when it is stopped.
From the picture below it shows the H-Bridge connected to the Basic Stamp circuit that was built earlier. The 2 x PNP's are on top and NPN's are on the bottom. R3 is connected to the left NPN and R1 connected to the one on the right. Where R4 is connected to the PNP to the left and R2 is connected to the one on the right. In order to make the motor go forward, R2 must be connected to GND and R3 to VDC, with R1 to GND or disconnected and R4 to VDC or disconnected. For reverse motion it is R1 to VDC and R4 to GND, with R2 toVDC or disconnected and R3 to GND or disconnected. When using this way to control the motor it is very important never to connect R1 to VDC and R2 to GND at the same time or it will short circuit the battery. And the same applies to R3 to VDC and R4 to GND.


The next step will be to make this circuit a bit tidier as there is alot more to do. There is still the thermistor to think about and a remote control sensor to be interfaced in this circuit, also if there is time and an easy solution, there will be a motion sensor to activate the closing of the blind as someone walks past the window.

Once the H-Bridge was proven to function correctly it was then interfaced with the rest of the circuit. From left to right we see the Basic Stamp microcontroller, next the light to frequency converter, the IC to the right of that is the DS1302 trickle charge time keeping chip. The DS1302 contains a real time clock and calendar with 31 bytes of static RAM. The clock/calendar provides seconds, minutes, hours, day, date, month and year information. It can operate in both modes of either 24 hour mode or 12 hour mode with an AM and PM indicator. After that the H-Bridge is included for the forward/ reverse control of the motor.




Discussion


Overall this project has come together without any major problems however there is a lot more to learn about the software in order to get it to function properly. After having some problems with the circuit it was discovered that the Basic Stamp Microcontroller that was received in the first week was not working. When this was replaced everything worked fine. There is still the thermistor to connect to the circuit and a remote control operation will need to be incorporated into the design.


Part 2 of this project will include bringing the remote control onto the board and the final testing before the development stages of the PCB design. From here the testing procedures as well interfacing it to the blind will begin. When the circuit is completed a full test will be carried out before the PCB design will go ahead. Once the PCB’s are complete there will be further testing carried out for continuity checks, functional tests as well as bench tests.

Saturday, February 4, 2012

Project (part 2)

Images of blind interface with frame

    Presently, work has begun on cadstar editor with the schematic designs of the main board containing the Basic Stamp microprocessor and two seperate boards for the H-bridge, one for each motor. Once they are complete they will be transfered to PCB design and built. 
    Click on images to enlarge
    Basic stamp control board schematic
    This is an image of the schematic drawing that was designed on cadstar. From the basic stamp to components it shows pins 1-4 are connected to 9pin RS232 for interfacing to the stamp to upload program. Pins 5-7 are connected to a Light to Frequency converter,  and pins 8-10 are going to the DS1302 trickle charge time keeping chip. Pins 11 and 12 are for a remote control over ride switch which will be interfacd at a later date. Pins 13-15 are for the up down motion of the blind and pins 16-18 willcontrol the tilting of the blind. Pin 19 is an input from the revolution sensor at the motor that controls the up/down and pin 20 is inputing from the tilt motor.
    H-Bridge schematic
    This is a schematic for one of the H-Bridge circuits that will either control the tilt motor or the up/down motor. The Opto-coupler is used to send control signals to the transistors on the H Bridge as the basic stamp cannot source or sink sufficient current to drive the transistor. The schematic design on the next page shows the actual H-Bridge with the Opto-coupler so when appropriate binary commands are sent to the H-Bridge, depending on which code, the internal LED's will activate it to determine which motion to take. The KB847 (4channel) is optically coupled isolators containing a GaAS light emitting diode and an NPN silicon phototransistor. Below is a schematic of what the internals look like inside the KB847 chip.


    Basic Stamp control board PCB artwork


    This is an image of the PCB design for the Basic Stamp control board, showing both sides of the board including the components.

    H-Bridge PCB artwork
    An image of the PCB artwork for one of the H-Bridge boards, again showing both sides and all components.  There are two of these, one for tilting the blinds and the other to control the motor for raising and lowering the blinds.


    In order to interface the motor to the blind, it proved difficult to find a suitable coupler nut so the idea I came up with was to strip the plastic off an electric joiner. Inside the plastic was the perfect soloution to the problem. As shown in the image's below, the way of the interfacing from the motor to the blind can be seen.

    Here we have a pair of electric wire connectors.

    Once the plastic was striped away, it shows a perfect part for the job. This will be used to lock the shaft of the blind to the dc motor.


    The motor that was used for the tilting motion was sufficient enough at 100:1 ratio. The motor for raising the blind needed to be 250:1 ratio. This allowed a better pull for raising the blind fully.  While raising the blind the 250:1 ratio drew current from 0.23 amps to .6 amps at its max point.


    The boards are now complete and all components are soldered in place. While debugging the H-bridge boards it was noticed that on the schematic design, the PNP transisters were not mirrored proparly. This caused some confusion but was easily fixed by twisting pin 2 to fit in pin 3's location and for pin 3's leg twisted to fit in pin 2's location. From furter testing this proved to fix the problem. A simple program was then written on the Basic Stamp editor to send a control for a forward motion and sent out through the RS232 connection on the main board, which proved successful. The same was done for the reverse motion. Now that the boards are working well together, the next thing will be to get the software up to scratch and to interface with the other components on the boards, such as the Light to Frequency converter and the time keeping chip. There is also a remote control over-ride to be interfaced and a thermistor.

    12V Remote control On/off 2 Channel momentary relay


    The Basic Stamp control board with the two H-bridge boards stacked on top of each other.



    The image above shows the two H-Bridge boards stacked on top of each other and the main control board. The multi-colored wires connecting into the H-bridge boards are for the FWD, REV, and ENA controls from the basic stamp. Directly left are two brown wires which go to the 12V Remote control On/off 2 Channel momentary relay for the A and B buttons.



    After creating some test programs to successfully run the motors on the blind the next step was to start mounting the boards in a housing unit. In the image below, you see a power supply coming into the board. This was made from a laptop lead that will transform the power from 240V down to 12V and 5V. The 12V is connected to the remote control receiver and the 5V will power the boards.


    The two H-Bridge boards are stacked on top of each other and fixed in to the back of the unit and the  basic stamp control board is then fixed to the lid so that the light to frequency sensor and the RS232 serial connector will be on the outside of the unit, thus allowing an easier program change or upgrade.



     The complete unit was then fixed to the back of the frame and the motors connected from the back. Below is an image of the completed automation system unit, ready to use.

    The main frame to display the blind was welded together with 20mm box iron and coated with red oxide paint to prevent rust before been sprayed matt black. A timber strut was fixed to the top rail of the frame to hold the blind. Once the blind was in place the motors were then positioned and fixed to the blind control mechanism.


    Below is a movie clip of the automatic blind working with a gas lighter to simulate the sunlight at the light to frequency sensor and the remote control raising and lowering the blind.



    Safety and Ethical Considerations of the Project

    A major safety concern for non-automated blinds in the home is the cord which is a choking hazard for young children. However with the automated blind there is no cord so this hazard is eliminated.

    Another hazard could be someone catching their hand in the blind when it was automatically moving. A simple over current protection circuit could be incorporated in the design that would cut off the power to the motors if such a scenario arose.

    The other issue which was noticed during testing was the noise generated from the motor. This would need to be much lower for productions of multiple units.

    It was also noted that different motor sizes would be needed depending on the size of the blind as a larger blind would require more current to drive the motor due to the weight of the blind as it was been raised. This would require a lot of research into standard blinds available on the market today and different motors that are readily available.

    Before production of multiple units the automated blind would need an electrical safety classification and a rigorous safety test to be carried out.

    A Final test procedure would need to be devised in order to have a Quality product.

    Protection codes would need to written into the software in order to have better control of the blind e.g. No tilt allowed when blind is fully up. Alternately a sensor could be built into the blind to detect end stop positions.

    Conclusions and Recommendations

    It was a fantastic experience to work on this project over the past 7 months. The automatic blind now works under certain conditions in the software but could be extended a lot further which would take a considerable amount of time to finalize.
    A thermistor circuit can be introduced at P14 and P15 on the BS2 which can be then used to read in the temperature with pre-set values. These values could then be implemented into the software code to control the blind motions depending on room temperature.
    While de-bugging the boards during the testing stages an error was found on the schematic design for the H-Bridge in Cadstar. The PNP symbols were not properly mirrored thus placing pin 2 where pin 3 should be and visa versa. This was quickly corrected by twisting the legs on the transistors as a temporally solution.  As time was running out it was not feasible to remake these boards.
    A lot was learned throughout this project and if it was to be re-designed, the following recommendations could be applied:
    The basic stamp could be multiplexed to allow for extra sensors and applications.
    PCB boards could be made a lot smaller and neater designs which would allow for a more convenient appliance to fit on the blind.
    The motors used in this design would not be sufficient for anything bigger than the display model and are very noisy. This would allow for more research into a real world scenario where these issues could be solved.