Thursday, October 15, 2009

Marquee Display

24x8 LED matrix marquee display is implemented around the PIC16F877 with three DS7221 as the LED drivers. Each DS7221 can drive 8x8 matrix therefore three are needed to drive 24 columns. A clock module using DS1307 is also being used and a temperature sensor will also be added later. Soldering the LED matrix consumed a lot of time; it took 15-20 minutes to solder a single column. I had to spend more than a week to finish the soldering. Coding the program is still in early stages. After a couple of revisions I managed to scroll a text massage but still have to go a long way.


Matrix - Front



Matrix - Back


Final product - Component side



Final product - Wire side


Marquee in action

Thursday, July 02, 2009

Father & Son: Conversation

I was traveling in the car with my kid (who is 2 years and 9 months old) on the way to his pre-school. A thick black smoke came from a double-cab in front of us, he couldn’t see the vehicle but he saw the smoke. And here is the conversation between us,

“Thatha (father) what’s that smoke?”

“It’s coming out from that double-cab”

“What double-cab?”

“The one in front of us”

“Why is it smoking?”

“Because it is old”

“Why?”

“Since that uncle bought it a long time back”

“What uncle?”

“That uncle who is driving the double cab”

“What double cab?”

“The one which smoked a while ago”

“Why was it smoked?”

“Because it is old”

“Why?”

……..

Friday, May 15, 2009

Hygrometer: Back on track

I've explained what has happened to my humidity sensor (SHT11) due to an accident in one of my previous posts. I told the same story to S*nsirion and they were kind enough to send 'four' of them, couriered to my doorstep, free of charge. Wow, what a company. So, thanks to them, I'm back on my project once again. I soldered the new one to the same board and attached it to my Altimeter. Surprisingly, PIC16F88 could handle both sensors in its 4k code space. Actually it used only 80% so 20% is left for some improvements.

Here it is in action;



It shows temperature, relative humidity, atmospheric pressure and height from sea level.

If you could refer my previous photo of the hygrometer, the reading was around 62% and that was in January. After 5 months, the reading is 76% for the same temperature. This explains the hot humid condition we are experiencing currently.

I have to format the output in a suitable way which I'm working on currently. At the same time, I must think a way to use the other three sensors too...

Tuesday, April 21, 2009

Altimeter - Contd...

MAX187 12-bit ADC with 3v external reference provided a sufficient resolution for the altimeter. To make the calculation accurate, a temperature sensor (DS18S20) is also attached to the microcontroller. The following picture shows the Altimeter in action displaying pressure, height, temperature and output voltage of the pressure sensor.

Thursday, March 19, 2009

Altimeter

I got four pressure sensors (two MPX4250 and two MP3H6115A) from freescale sometime back. I tried the two 4250s but they didn’t work for some reason. MP3H6115A is a surface mount device (SMD) which can measure pressure from 15kPa to 115kPa. Since I have previous experience working with SMDs, (SHT11, humidity sensor) I decided to work with this. The output (pressure) is reported as a voltage ranging from 0 to 2.8 v. I used PIC16F88 since it has an internal 10-bit ADC (analog to digital converter) and 4k code space.

Pressure is given by
P = (Vout/Vs+.095)/0.009 kPa

Where Vs, supply voltage = 3v
Vout, Output voltage measured from ADC

Altitude is given by

H = -ln(P/Po)*R*T/g

Three variables have to be measured:
T - average temperature in degrees Kelvin
Po - atmospheric pressure at ‘zero’ level
P - atmospheric pressure at current level

Remaining values are fixed constants:
R – universal gas constant = 286
g – gravitational acceleration = 9.81

Assuming Po=101.325 kPa and T=303.15K (30C)
The device reported H = 52.5m

Accuracy of this value is largely depending on the resolution of the ADC.
10-bit resolution of the ADC is not even near to get a reasonable accuracy of the altitude. One unit change in the ADC measurement will change 10m of height. To obtain 1m sensitivity, I need at least 12-bit ADC. So I ordered 12-bit ADCs from Maxim-IC and waiting until they arrive for the final product.





Tuesday, March 03, 2009

PIC Relay – 230v

This simple PIC circuit can be used to pre-program the on/off time of 230v electrical appliances. The PIC is programmed as a clock and at specified times, it can turn on/off a relay to control the appliance. I found a broken power guard (which protects electrical equipments from over and under voltage) in my old parts ‘yard’ at home. It was good source for the relay, diods,  step down transformer, voltage regulator, the plastic container and even the LEDs. This relay is having good characteristics since these power guards were produced mainly to protect refrigerators. Only drawback in this design is that it doesn’t have a user interface. If you want to change the on/off time, you have to do it using the program. (I was too lazy to add a display unit for the device) It is being tested with our refridegerator and is working fine. I put the fridge to turn off at midnight for about four hours. 








/*
* Project name:
PIC Relay
* Copyright:
Chandana Inc.
* Description:
PIC Relay - 230v
* Test configuration:
MCU: PIC16F88
Oscillator: XT, 04.0000 MHz
SW: mikroC v8.0
* NOTES:
Time might not be accurate.
*/

unsigned int countdown ; // interrupt counter
unsigned char update ; // update output
unsigned char secs, mins, hrs ; // tally variables

unsigned char ticks, correction,mode;
char oldstate_min, oldstate_hr, PowerOK, Powerchange, OutputStatus;

void interrupt()
{
if (--countdown == 0)
{
countdown = 8000; // 8000 x 125us = 1 second
update = 1; // flag to update clock output
}
PIR1.TMR2IF = 0; // clear interrupt flag

}

void Clock24()
{
if (++secs == 60) // check each tally for rollover
{ secs = 0;
if (++mins == 60)
{ mins = 0;
if (++hrs == 24)
hrs = 0 ;
}
}
update = 0;
}

void Initialize()
{

CMCON=7;
secs = 255;
mins = 23;
hrs = 15;
update = 1;
countdown = 8000;

INTCON.GIE = 1; // enable GIE
INTCON.PEIE = 1; // enable PEIE
T2CON = 0; // prescaler=0; postscaler=0; Timer2=off
TMR2 = 0; // clear timer2
PR2 = 124; // TMR2 resets when matching PR2
PIE1.TMR2IE = 1 ; // interrupt enabled
PIR1.TMR2IF = 0 ; // interrupt flag cleared
T2CON.TMR2ON = 1 ; // start Timer0
}

void main() {
Initialize();

PORTA = 0;
TRISA =0b00010;
PORTB = 0;
TRISB = 0;

oldstate_min=0;
oldstate_hr=0;
mode=0;
PowerOK=0;
Powerchange=0;
OutputStatus=1;

do
{
if (update == 1) // advance seconds?
Clock24(); // yes...then output


if (Button(&PORTA,1,1,1))
{
PowerOK=1;
//mode=0;
}

if (PowerOK && Button(&PORTA,1,1,0))
{
PowerOK=0;
PowerChange=1;
mode=1;
}

if (Powerchange && PowerOK) //power restore
{
Powerchange=0;
mode=0; //back to normal
}

if (mode==0)
{

if (OutputStatus==0) //turn off
{PORTA.F0=1;
PORTA.F2=1;
PORTA.F3=0;}
else
{PORTA.F0=0; //Turn ON
PORTA.F2=0;
PORTA.F3=1;}

}
else
{
PORTA.F0=0;
PORTA.F2=0;
PORTA.F3=0;


}



} while(1); // endless loop
}//~

Thursday, January 29, 2009

Oops...

Electronic components are very sensitive. Anything beyond the tolerable range within a fraction of a second is enough to destroy most of them. I learned this lesson in the hard way. A tiny piece of exposed metal of a hanging wire touched the high voltage side of the voltage regulator and destroyed the OLED 20x2 LCD Display (I bought this from eBay for $20) and the SHT11 Humidity Sensor (I got this free but worth more than $40). I can live without the display since there are alternatives but loosing the humidity sensor is a real blow. Buying a new one at this moment is very unlikely. It seems I have to postpone (abandon ?) my weather station. I was about to finish it by adding the barometer module using an atmospheric pressure sensor.

But hey... I got a new project... this time, I have to be extra cautious because it involves 230v. A small mistake can be deadly. Will post the details later...