Automatic cooler and A.C. changeover

Summers have arrived.

We have A.C.s at home but the inverter or power backup can’t support that much of load.

When there is a power cut, we use cooler instead of A.C.

But when A.C is working there is no point  to keep the cooler running.

Thus we switch on cooler when there is a power cut and when power arrives the A.C. starts automatically but you need to switch off the cooler.

Now this poses a headache because of frequent power cuts in our lovely India.

So here’s the solution.

Assuming that you have one socket at home that only have main power lines connected inside it. The same one, to which you connect your A.C. And you have one more socket nearby which works on main power as well as power backup.

download - Copy

One more assumption is that you already know about relays and their working.
If you don’t, read this.

So we are going to connect A.C. to the main power socket and cooler to the main + backup socket but with a twist.

When Mains power active

When Mains power active

 

When Mains power inactive

When Mains power inactive


As you can see when there is main power, the 12v adapter switches the relay coil on, which leads to connecting of relay plate to the Normally Open (NO) terminal, thus disconnecting the supply to the cooler.

So actually we do not connect the cooler directly to the main+backup socket but to another socket which we have passed through a relay.

When there is no main power, the coil of the relay is OFF, thus the relay plate gets connected to the Normally Connected (NC) terminal, therefore connecting the cooler to the power backup socket.

The diode is used with the relay to dump the back EMF when the relay is discharged. It is a standard precaution that is used in almost all the relay applications.

This is how the actual setup looks like:

20140507_185636 20140507_185552

Summing it up, when there is main power, the relay is switched on, thus disconnecting the cooler from the power backup socket. When there is a power cut , the A.C. obviously gets switched OFF but the relay also gets switched OFF thus connecting the cooler to the power backup socket.

So enjoy your summer nights without having to swithch ON or OFF the cooler again and again.

TI ADC Update 3

It’s decided now. We are not going to use the mobile phone lcd anymore.
Even after considerable efforts, it is not working.
It is wasting our precious time.

Temporarily we are going to work on 128×64 graphical lcd.
Thanks to Shelly Rathee for lending it to us.

Meanwhile , we have ordered an ssd1289 based graphical lcd module from ebay. It is sufficient for our project, but it will take more then 10 days to be delivered.
We wonder why we didn’t find it and order it before.
Today, we are going to test our analog front end and work on the adc i.e. triggering it periodically with the help of timer.

One good news, the external SPI ADC ADS8330 is finally working.

TI ADC Update 2

No progress on LCD today.
We made a few functions for reading and writing commands and data to the lcd controller.
Then we send the value of a register and when we read it back it was all cruel 0s with no essence of even a single one.
That means problem.

Tried checking logic voltages on each pin, found that some pins are short circuited.

Sumir is now going to debug the connections and i have to assume that lcd is working fine and write more software for interfacing it.

Dinesh sir said that something which is just about to work, always create some problems.
That means it will soon be diaplaying butterfly pictures, I wish.

So, we will respawn tomorrow with a fresh mind.   
Time to go back home and have dinner.

TI ADC Update 1

So we are back, this time working on an oscilloscope.
That means, building one.
First thing is the display, we needed a high resolution one but at low cost.
Then we had a crazy idea to use a mobile phone one. But from where will we know how to use it.

Started digging internet for nokia 5233 lcd internals but did not get much data.
Then finally we encountered ‘ The Andy Brown’ blog.
And that was it. Now this guy is amazing, we must acknowledge him.

He has ‘reverse engineered’ lcds of so many mobile phones.
We went to the market and bought one according to our needs. Sony vivaz lcd 640×360.

Under the passive guidance of andy, we made the backlight circuit and the lcd power module. Special thanks to texas instruments for providing required ics for free as per their free samples program.

Now backlight is up and running.
Today we will try to send commands and receive some identification data to know that the lcd is responding.
Wish us luck

Snake Game on 32×32 Dot Matrix Display

First of all, the video:

Objective:

To use an LED Matrix to display animations, by using STM32-Cortex M Series Controller.

Block Diagram

block

Dot Matrix:

Working
It works on the principle of Persistence of Vision in human eye. Human brain retains the last image in the visual cortex for 1/25 of a second, therefore if an image is shown back within 1/25 of a second, it will look like if it was always there.

CircuitDot Matrix Circuit

Any single LED can be switched on by providing positive voltage at it’s corresponding row and negative voltage at it’s corresponding column.

To make a 2-Dimensional picture, one column is given negative voltage and the rows, corresponding to the dots in that column of the picture, are given positive voltage.

In this way, each column is switched on, once in a cycle, for a short period of time and the time of one cycle is less than the time of PoV (1/25 seconds).

matrix

Interfacing with Microcontroller:

interface

74164 (Shift Register)

A shift register is a cascade of flip flops, sharing the same clock, in which the output of each flip-flop is connected to the “data” input of the next flip-flop in the chain, resulting in a circuit that shifts by one position the “bit array” stored in it.

 shift4-Bit_SIPO_Shift_Register

ULN2803( Darlington Pair Array)

It is an array of switches which allow the current to pass though ground terminal, if the corresponding switching pin is high.

uln2803

To switch between columns, a ‘1’ is entered into to shift register and at each clock pulse this ‘1’ is shifted to next column, where the corresponding darlington pair switch becomes activated, thus activating that column.

This ‘1’ has to be entered at every 8th clock or we could find a way to automatically enter it by using some arrangements in the microcontroller. This is discussed later.

Instead of one shift register and one darlington pair array, a cascade of 4 shift registers is used which enables to run a matrix of 32 x 32 LEDs. In that case, ‘1’ has to entered at every 32nd clock.

Microcontroller:

ARM

-ARM is an RISC Based processor architecture designed and licensed by ARM Holdings.

-Widely used in most of the portable computing applications such  as Cell-phones, Smart-TVs, Set-Top Boxes, Digital Cameras, Printers etc.

-ARM holdings is an IP core company i.e. they do not manufacture chips, instead they sell the architecture to other companies such as ST Microelectronics, Texas Instruments, nVidia, Qualcomm etc.

 

ARM_powered_Badge.svg

ARM Family:

Different versions with different cores :

family


STM32-F100RB

  • It is based on ARM 32-bit Cortex-M3 CPU (max. freq. 24 MHz).
  •  Comes in LQFP64 and TFBGA64 packages
  •  128 Kbytes of Flash memory
  •  8 Kbytes of SRAM
  •  1 Advanced Timer, 6 General Purpose Timers, 1 Systick Timer for OS
  •  2 SPI and 2 I2C Modules
  •  3 USART Modules
  •  One 12-bit 16 channel ADC
  •  Two 12-bit DACs
  •  51 GPIO Pins
  •  On – Board  Temperature Sensor
  •  Real Time Clock
  •  Nested Vector Interrupt Controller ( External Interrupts, CPU Interrupts etc.)
  •  DMA Etc.

STM32 Value Line Discovery Kit

block diagram

 

It consists of :

// ST-Link Programmer and Debugger

//STM32F100RB Microcontroller

//Two demonstration LEDs

//Two  Push Buttons (Reset and Wake-Up/User )

Timer synchronization

As was discussed in the dot matrix section that we need to enter ‘1’ to the shift register at every 32nd clock, Timer synchronization is used for this purpose.
In STM32F100RB, Timers can provide clock to other timers.

PWM pulses of both timers can be used to create a system in which PWM high pulse of one timer (slave timer i.e. getting clock from another timer) occurs after a specified number of high PWM pulses of another timer (master timer i.e. providing clock to a slave timer).

Timer

 

Software

 

Snake Structure

The body of the snake is made by a 2-D array which stores the locations of each block of the snake body.

Each row of the array contains 2 variables which contains the x-coordinate and y-coordinate. The value lies between 0 and 31.

body

Drawing the snake body

  • Body drawn on Matrix according to the snake body 2-D array.
  •  The body is drawn only till the snake length block.
  •  Therefore when the snake length increases, the blocks to be displayed on the screen increases .

Snake Direction

direction

Updating the snake Body

After each frame, the body of the snake is updated.
For this, the data of each block is copied to the next block and the value of the first block (head) is entered according to the current direction of travel of snake. The value of the last block is

updating

Controlling the snake

  • The snake body automatically updates after a specified of time.
  • Whenever the user wishes to control the snake, she/he pushes the control buttons. On the push of a button, an interrupt is generated in which the snake direction variable is updated.

controlling

Making Random Dots

  • Start a Timer and keep it running at low prescaler value so that the timer counter’s value changes rapidly.
  •  After the previous event (selecting difficulty from start menu or eating a dot ), the user will take indefinite amount of time to get to the next event.
  •  In that time the value of the counter will be indefinite as the timer counter is changing rapidly.
  •  When an event occurs, take the value of counter and perform mod of 32 on it.
  •  Use this value as the co-ordinate for DOT.
  • To get two random co-ordinates, use two timers with different auto-reload values having minimum common factors.
  • If co-ordinates lie in the body of the snake, take another value from timer and check whether the new value lies in the body.

Eating the DOT

At each frame the values of the coordinates of the head and the DOT are compared to detect the event of passing through (or eating ) the DOT.

eating

Increasing the length

  • Whenever the snake head passes through the dot, the coordinates of the dot  are  stored in a queue (Eaten Dots Queue) and a new dot is created.
  • Whenever the snake tail passes through the earliest eaten dot from the Eaten Dots Queue, the snake length increases.

increasing

Detecting Intersection

Check whether the next head coordinates, according to the snake direction, are not equal  to any block of the body.

detecting

Possible Additions

  • Interface SD Card and read a 32 x 32 bitmap image from it and display it on the Dot Matrix
  •  Send the bitmap from computer  and display it on Dot Matrix
  •  More Games – Tetris, Tic Tac Toe etc.

Quiz Buzzer System

First of all, the video:

Objective:

The main aim is to automate the process, of detecting the first call for answer, among many calls with very less time difference.
This could be done by asking the participants to raise their hands but that would be too inaccurate. Therefore, we created an electronic device to detect the first press of a button among 6 buttons given to 6 different teams.

Physical Structure:

There is 1 main unit and 6 button units for 6 different teams and 1 reset button unit to reset the circuit.
The main unit consists of:
– 6 LEDs corresponding to different teams
– 1 Piezo-Buzzer for sound alert
– 6 USB ports for connecting the 6 button modules
– 1 Switch for power on/off
– 1 Switch for Piezo-Buzzer on/off
– One connection to the reset button

Image

Image

A button unit consists of:
– One yellow push button
– One Green LED which glows only while the button is pressed
– One Red LED which glows if the button has been pressed before all the other buttons in the
other 5 button units
– 8 metre wire connection with USB Pin at the other end, which is to be connected to the main
unit.

Image

Image

The reset button is just a button installed on a handy cylindrical shell with a fixed wired connection to the main unit.

Operation:

When the question is asked, the participants push the button for requesting the attempt to answer the question.

When a team presses the button on their unit before anyone else, the Red LED on the team’s button unit starts glowing and keeps on glowing, even if the button is released. Also the corresponding LED (LEDs are numbered 1 to 6 according to the team number) of the team starts glowing on the main unit.
After that, all other button presses, cannot change the state of the circuit. Thus, the number corresponding to the team, which pushed the button first, is locked.
The green LEDs on all the units are to check whether the button on that unit is working properly or not. It glows, on the push of the button in the unit and shuts off when it is released.

To reactivate the circuit to detect the first press, the reset button is pressed by either the Quiz Master or a separate buzzer operator.

Functioning

block diagram

Breathing LEDs (better than Blinking Ones)

 

In this one, I used two output channels of Timer 3 in PWM Mode.
The basic steps are:

Configure PWM mode for two channels.

Configure the GPIO Pins for Alternate Function Out

:loop0

:loop1

Increase the duty cycle of 1st channel and decrease the duty cycle of 2nd by 1;

wait for a small time

if the duty cycle of any one channel is 100%, go to (loop1)

:loop2

Increase the duty cycle of 2nd channel and decrease the duty cycle of the 1st by 1;

wait for a small time

if the duty cycle of any one channel is 100%, go to (loop2)

go to (loop0)

This is just the rough idea, the whole code is here:

Breathing LEDs

Dot Matrix Display by principle of Persistence of Vision using STM32F100RB

Recently, I got my hands on the 32-bit Microcontroller STM32F100RB. It took some time to understand the architecture but eventually, I could make it work using KEIL uVision IDE and the library functions provided for ARM Architecture.

 

So Firstly, as usual I made blinking LED Program, then I made the Dot Matrix Alphabet Display.

 

 

What is Persistence of Vision principle?

 

According to the PoV Principle our mind persists the image last seen for 1/25th of a second.

 

If within this time period, a new image is shown, the two images appear to be continuous. Thus, if new images are being shown in a sequence with a difference of less than 1/25 second within every two images, the picture appears to be moving.

 

http://en.wikipedia.org/wiki/Persistence_of_vision

 

You can see the description of the Dot Matrix Display here:

 

http://embedded-lab.com/blog/?p=2478

This is my code:

PoV Code

 

Battery is a wild animal.

A speaker at a battery conference said, “The battery is a wild animal and artificial intelligence domesticates it.” (Quote taken from batteryuniversity.com)

DISCLAIMER: I AM NOT ENCOURAGING YOU TO OPEN IT. IN CASE OS ANY MISHAPPENING, IF YOU TRY TO OPEN YOUR BATTERY, I AM NOT RESPONSIBLE.

Battery = BTP-52EW

Well this is the picture of the intact battery.    images

This was there in a very old laptop of my brother. (Some WIPRO Laptop)

Opening it was a cumbersome job, as there were no plastic locks or screws. I had to forcibly, crack open all of the packaging.
So these are the inside pictures. DSCN2480

DSCN2483

(Click o the pictures to view full size)

Also pay attention to this Circuit Board.

DSCN2484

I will talk about this circuit later.

I numbered the individual cells 1 to 8 and made an arrow from –ve to +ve terminal of each. This helped to make the circuit diagram easily.

DSCN2490

Image (21)

As you can see, there are ‘pairs of cells’ that are connected in parallel, and these pairs are connected in series.

The final terminals of the cells are connected to the main circuit board, but the “in between” junctions between two cell pairs are also connected to the board. (This is used for cell balancing. Later in the article.)

Another connection is of the thermal sensor which I have shown you in picture also.
Well take a closer look. Looks like a burnt matchstick.DSCN2493

So what are these circuit boards for?
Why not directly give the battery terminals to the laptop?

This is because lithium ion batteries are very sensitive and you laptop’s motherboard too.
What if there are some sudden impulses coming from the battery?
How do you know, how much battery charge is left?
How do you recharge the battery (by just giving the opposite high voltage, battery will wear out after 5-6 charges)?

All this is done by a system called SMART BATTERY SYSTEM (SBS).
I got to know this when I googled the IC numbers.
On Circuit Board 1, there are two ICs bq2085 and bq29311.
bq29311 is the overall control IC which records:

1.The State of Charge(SoC)

2.The State of Health(SoH)

This also does the “Cell Balancing” (remember the circuit diagram ?), and communication part (SMBus communication to the computer) for letting the computer know about the charge left.

SMBus= Supply Management Bus . A protocol based on I2C Protocol.
There are tons of other things to do in a battery – Voltage regulation, Temperature Monitoring, Charging algorithm, Wear out analysis etc.

The battery charge measurement is done by the bq2085 “battery gauge” IC.

The Circuit Board 2 is this:

DSCN2494

From Behind (Sorry for that animal’s back, it was roaming on my register)

DSCN2501

From Front

In the above picture you can see the port that goes into your laptop’s battery section.

You can clearly see in the Circuit 2 (from behind) picture, the Pin Names

P- P-(power –ve)  C(clock)  D(data)  T(thermal reading)  P+ P+(power +ve)

C and D are for SMBus Communication.

Well this SBS system is quiet cool, but it has some limitations:
The main limitation is that, to correctly predict the charge available in the battery, the charge and discharge cycles have to be complete i.e. Do not connect the charger until, battery dies to 7% and do not remove the charger until battery is 100%.
But practically, normal users do not follow this. This leads to some errors in the records tracked by the SBS system. And when these errors accumulate with time, they lead to faulty implementation of charging algorithms and also false charge percentage readings.

So, the battery technology is developing day by day. Let’s hope for better battery backups and battery life in the future batteries.
Well this is it.
If you found it interesting, you should go to these links too:
http://batteryuniversity.com/learn/article/the_smart_battery

http://batteryuniversity.com/learn/article/inner_workings_of_a_smart_battery

http://batteryuniversity.com/learn/article/charging_lithium_ion_batteries

http://en.wikipedia.org/wiki/Battery_balancing

http://en.wikipedia.org/wiki/System_Management_Bus

Datasheets:

http://www.ti.com/lit/ds/symlink/bq2085.pdf

http://www.ti.com/lit/ds/symlink/bq29311.pdf

Thank You for Reading.