Translate

Friday, 27 June 2014

Room Management System – Project Summary

Room Management System – Project Summary

Overall, it was a fun project to do and quite a challenge to get it up to the state as it is now. The originating request was just simple controlling the lights for 4 rooms using PIR's and a few momentary switches, which was done very quick. Than there where additional ideas and also a few upcoming requests and so I took the challenge and the final result is now controlling the light of 10 rooms and 4 AC units independently using PIR's, a photocell, a temperature sensor and a few momentary switches. Implemented is a automated light control to switch lights automatically in a programmable sequence to hide a vacant home controlled through a real time clock. Also implemented a user interface with LCD display to make it more user friendly and to adjust it to different needs.

Prototyping on a breadboard:
Using breadboards for prototyping is a great thing since circuits can be changed and adjusted very quick and easy. The downside is that loose connections produce noise and components like the RTC and LCD displays are very sensitive in that matter. Just a little noise can stop the rtc- module responding or get the LCD to display a heap of garbage instead of the wanted information. Also very noise sensitive are the 74HC595 shift registers. To avoid disappointment and long fault searching, great care has to be taken in wiring your circuit on a breadboard. To make sure the connections are as good as they can be to avoid noise by bad contacts, use dupont wire connectors. Since I was using lots of connections I used also some other rigid wire but with plenty of noise producing contact problems. Since I am running my LCD of a shift register, I had to add a few components. Starting out on a breadboard the noise problems drove me kind of crazy so I just soldered everything together on a pref board and the noise problems I had with the LCD where reduced to a minimum. Even building your own RTC will work on a breadboard but not very reliable. The RTC is also best, soldered straight to a pref board or use a ready made shield. You will encounter the same problems with running the Atmega chip of the breadboard. Even here is best to use the original ARDUINO board or if you really need or want to run it independent, solder everything on a pref board. It also helps later with designing the final circuit board for your project.

Button input through Arduino's analogue inputs
Sure it is a nice idea to connect several buttons separated by a resistor and read the analogue input to determine which button was pressed.
However, be aware that the readings change depending on the load drawing of the Arduino's digital I/o pins. I used only 10K resistors to separate the buttons and it proofed not enough, since the readings jump about 100 points. The centred readings of the buttons are only about 45 points apart which causes on extreme jumps the button not to work while completely out of range. In my next project, I would rather add another CD4021B shift register to extend the inputs than using a analogue input to read multiple buttons of it.

Power supply
Great care has to be taken also in choosing the power source used. For small projects controlling a few LED's, the power drawn from a USB port is more than enough. However, the absolute maximum current which can be drawn from a Arduino pin is 40 mA not exceeding a total current draw of 200 mA which we have already reached lighting up 10 standard 3 or 5mm LED's. Running a few shift registers, a RTC and a LCD of the same power source, through the Arduino board we come pretty fast to the over all limit. Even if we get the current 5V output, which is not running through the chip but than we still have to check the limitations of the voltage regulator. I tried once running 1A on a 12 Volt input through a 7805 voltage regulator and it got untouchable hot within seconds. Another reason for having a steady and reasonable dimensioned power supply are analogue readings. Reading a photocell, a temperature sensor or a button shield depends on a steady power supply. Just see what happens to your readings, running the Arduino board of your USB port and than plug in a 9V power supply, giving at least 1 A of current. You definitely have to recalibrate your temperature sensor and recheck the centre points for your buttons.
A small advise out of own experience and hours of looking for faults which turned out to be power related. Calculate the estimated power consumption of your project and add a little reserve right from the beginning. Depending a little on your computer, USB ports can deliver only
500 mA 4.4 to 5.25 Volts on a USB 2.0 port
900 mA 4.4 to 5.25 Volts on a USB 3.0 port

Your computer will not turn in to smoke on a slight overload but your analogue readings will change if you need to read sensors like temperature, photo cells or reading a button shield through a analogue input.

It's just a simple calculation. The analogRead read the voltage on the port from 0 to1023 corresponding with 0 to 5 Volt.

OK, using a USB 2.0 port, being able to give as a power of 5.25 Volts * 0.5A = 3.125 W
3.125 Watts is the power the USB port can give us.
If we no try to draw 800 mA out of our USB port the following will happen:

3.125 Watts is a constant in this case and it will not change. But we draw 800 mA. Lets do the calculation:

3.125 Watts / 0.8A = 3.09 Volt

The available Voltage will drop to 3.09. Our analogue reading where based on a available voltage of about 5.

Got the point?

Debugging
Since it was my first large project, it's far away from being perfect and I already know a few things which could have been done better. However, if you are looking through the sketch and you see something which can be done differently, or something jumps in your eye where I have goofed or what I've missed please feel free to drop me a note. I am always happy to hear constructive critics.

Updates and requests
I keep on working on this project and I will post updates in the future as I go along. Since I am doing this project in my free time in between work, family and various other duties, any posted question will be answered eventually but please be patiend with me especially during summer when I am most busy.

Some final words
A great thanks to the guys from the Arduino forum which did a great deal in pointing me in right directions when I was stuck and giving a hand in finding some major bugs.
Another great thanks to everybody from the Arduino blog adding suggestions and helping in improving and cleaning up parts of the code.
Not to forget to mention the kind support and all the likes on google which where quite encouraging at times to carry on and finding solutions when I was stuck.

Again, Thank you to all of you!

Upcoming projects:
A real world time clock including automatic compensation for day light saving time
and 
a Solar charger which doesn't fry the batteries

2 comments:

  1. Why are you using different IC's for SHIFT IN than for SHIFT OUT?

    ReplyDelete
    Replies
    1. Well, there are only a few ICs being able to handle input and output. And at the time I started the project the 74HC595 and the CD4012/CD4024 where the best documented. By now I know that there are different solutions for the problem and for sure, there are better ones as well.

      Delete