Loading...
Showing posts with label LCD. Show all posts
Showing posts with label LCD. Show all posts

Saturday, November 4, 2017

DS3231 RTC Clock mikro C Demo Code - 16F648A


LCD Clock
LCD Clock

Introduction:

The DS323x is a low-cost, extremely accurate I²C real-time clock (RTC) with an integrated temperature-compensated crystal oscillator (TCXO) and crystal. The device incorporates a battery input, and maintains accurate timekeeping when main power to the device is interrupted. The integration of the crystal resonator enhances the long-term accuracy of the device as well as reduces the piece-part count in a manufacturing line. The DS323x is available in commercial and industrial temperature ranges, and is offered in a 16-pin, 300-mil SO package.

DS3231 Block Diagram
DS3231 Block Diagram
The RTC maintains seconds, minutes, hours, day, date, month, and year information. The date at the end of the month is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with an active-low AM/PM indicator. Two programmable time-of-day alarms and a programmable square-wave output are provided. Address and data are transferred serially through an I²C bidirectional bus.

Most RTCs use an external 32kHz timing crystal that is used to keep time with low current draw. And that’s all well and good, but those crystals have slight drift, particularly when the temperature changes (the temperature changes the oscillation frequency very very very slightly but it does add up!) This RTC is in a beefy package because the crystal is inside the chip! And right next to the integrated crystal is a temperature sensor. That sensor compensates for the frequency changes by adding or removing clock ticks so that the timekeeping stays on schedule.

DS3231 module
DS3231 module

This is the finest RTC you can get, and now it in a compact, breadboard-friendly breakout. With a coin cell plugged into the back, you can get years of precision timekeeping, even when main power is lost. Great for data-logging and clocks, or anything where you need to really know the time.

The Circuit:

The circuit is very simple. It used PIC16F648A Pic micro, 16x2 LCD and DS3231 RTC module. The PIC used it's internal oscillator and run at 4MHz. Proteus and Hex file can download from the bottom of the page.

DS323x RTC Clock Circuit
DS323x RTC Clock Circuit


MikroC PRO Source Code:

/**************************************************************************

DS323x RTC Clock Demo
Copyright (C) 2017 Scorpionz

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.

>> Email: scorpionzblog@gmail.com
>> Blog : scopionz.blogspot.com

***************************************************************************/


// Software I2C connections
sbit Soft_I2C_Scl at RB2_bit;
sbit Soft_I2C_Sda at RB1_bit;
sbit Soft_I2C_Scl_Direction at TRISB2_bit;
sbit Soft_I2C_Sda_Direction at TRISB1_bit;
// End Software I2C connections

// LCD module connections
sbit LCD_RS at RB0_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;

sbit LCD_RS_Direction at TRISB0_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
// End LCD module connections

char seconds, minutes, hours, day, date, month, year, tem_l, tem_h; // Global variables

//--------------------- Reads time and date information from RTC (DS3231)
void Read_Time()
{
Soft_I2C_Start(); // Issue start signal
Soft_I2C_Write(0xD0); // Address DS3231, see DS3231 datasheet
Soft_I2C_Write(0); // Start from address 0
Soft_I2C_Start(); // Issue repeated start signal
Soft_I2C_Write(0xD1); // Address DS3231 for reading R/W=1

seconds = Bcd2Dec(Soft_I2C_Read(1)); // Read seconds byte
minutes = Bcd2Dec(Soft_I2C_Read(1)); // Read minutes byte
hours = Bcd2Dec(Soft_I2C_Read(1)); // Read hours byte
day = Bcd2Dec(Soft_I2C_Read(1)); // Read day byte
date = Bcd2Dec(Soft_I2C_Read(1)); // Read date byte
month = Bcd2Dec(Soft_I2C_Read(1)); // Read month byte
year = Bcd2Dec(Soft_I2C_Read(1)); // Read year byte

Bcd2Dec(Soft_I2C_Read(1)); // Alarm
Bcd2Dec(Soft_I2C_Read(1));
Bcd2Dec(Soft_I2C_Read(1));
Bcd2Dec(Soft_I2C_Read(1));
Bcd2Dec(Soft_I2C_Read(1));
Bcd2Dec(Soft_I2C_Read(1));
Bcd2Dec(Soft_I2C_Read(1));

Bcd2Dec(Soft_I2C_Read(1)); // Data
Bcd2Dec(Soft_I2C_Read(1));

Bcd2Dec(Soft_I2C_Read(1));

tem_h = Bcd2Dec(Soft_I2C_Read(1)); // Temp
tem_l = Bcd2Dec(Soft_I2C_Read(0));

Soft_I2C_Stop(); // Issue stop signal
}

void write_data(char address, char w_data)
{
Soft_I2C_Start(); // issue I2C start signal
Soft_I2C_Write(0xD0); // send byte via I2C (device address + W)
Soft_I2C_Write(address); // send byte (address of DS3231 location)
Soft_I2C_Write(w_data); // send data (data to be written)
Soft_I2C_Stop(); // issue I2C stop signal
delay_ms(50);
}

//-------------------- Output values to LCD
void Display_Time()
{
Lcd_Chr(2, 7, (hours / 10) + 48);
Lcd_Chr(2, 8, (hours % 10) + 48);
Lcd_Chr(2,10, (minutes / 10) + 48);
Lcd_Chr(2,11, (minutes % 10) + 48);
Lcd_Chr(2,13, (seconds / 10) + 48);
Lcd_Chr(2,14, (seconds % 10) + 48);

Lcd_Chr(2,16, (day % 10) + 48); // day
}

void Display_Date()
{
Lcd_Out(1,1,"Date: "); // Prepare and output static text on LCD
Lcd_Chr(1,9,'-');
Lcd_Chr(1,12,'-');
Lcd_Out(1,13,"20"); // start from year 2000

Lcd_Chr(1, 7, (date / 10) + 48);
Lcd_Chr(1, 8, (date % 10) + 48);
Lcd_Chr(1,10, (month / 10) + 48);
Lcd_Chr(1,11, (month % 10) + 48);
Lcd_Chr(1,15, (year / 10) + 48);
Lcd_Chr(1,16, (year % 10) + 48);
}
void Display_Temp()
{
Lcd_Out(1, 1,"Temp: +");
Lcd_Out(1,13,"ßC ");
Lcd_Chr(1,10,'.');

tem_l=tem_l*25;

Lcd_Chr(1, 8, ((tem_h & 127) / 10) + 48);
Lcd_Chr(1, 9, ((tem_h & 127) % 10) + 48);
Lcd_Chr(1, 11, (tem_l / 10) + 48);
Lcd_Chr(1, 12, (tem_l % 10) + 48);

if(tem_h & 128) Lcd_Chr(1, 7, '-');
}

//------------------ Performs project
void Init_Main()
{
PCON.OSCF = 1; //4MHz
CMCON |= 0x07; // Disable Comparators CMCON |= 7;
OPTION_REG = 0;

Soft_I2C_Init(); // Initialize Soft I2C communication
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear LCD display
Lcd_Cmd(_LCD_CURSOR_OFF); // Turn cursor off

Lcd_Out(1,3,".:Scorpionz:.");
Delay_ms(500);
Lcd_Out(2,1,"Ds3231 RTC Clock");
Delay_ms(1500);
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(2,1,"Time: ");
Lcd_Chr(2,9,':');
Lcd_Chr(2,12,':');

write_data(14,0x40); //SQWE output at 1 Hz
}

//----------------- Main procedure
void main() {
Delay_ms(500);

Init_Main(); // Perform initialization

while (1) { // Endless loop
Read_Time(); // Read time from RTC(DS3231)
Display_Time(); // Prepare and display on LCD
Display_Date(); Delay_ms(450);
Display_Temp();
Delay_ms(450);
}
}

Sunday, November 8, 2015

Digital LCD Speedometer and Odometer Circuit - 16F628

speedo odometer
Speedometer


In my previous post, I explained how to build a simple speedometer circuit using a micro-controller and seven segments. Read it from here. This is a further development of that circuit. This circuit indicates both speed and distance.

A speedometer or a speed meter is an instrument that measures and displays the instantaneous speed of a vehicle. An odometer or odograph is an instrument that indicates distance traveled by a vehicle.

speedo odometer circuit
Speedometer + Odometer Circuit


For this circuit I used PIC16F628A micro-controller and 16x2 LCD. You can able to see speed in first line and distance in second line on the LCD. Distance will update every 100 meters and speed updates every one second. Value of distance writes to Eeprom in every 1 km. I also added a button to this circuit. The purpose is, reset the distance to zero.

Same as the Speedometer Circuit, micro-controller count the signals received to RA4 pin and then calculate speed and distance, then display information on LCD. 8 MHz resonator is use to generate clock signals. However, you can always use crystal for it and make sure to add 22pf ceramic capacitors if you use crystal oscillator.

Measure the radius of the wheel and enter it to Eeprom address 0x00. Default value for radius is 30cm (0x1E). I used two magnets to operate reed switch. Please refer my previous post for more details and circuit connection.

Maximum speed is 999 kmh
Maximum distance is 9999 km
Supply voltage is 5v

Monday, June 15, 2015

I2C FM Receiver Circuit with LCD - 16F88 BK1080

Digital FM Receiver
Digital FM Receiver


This is a simple stereo FM radio receiver circuit that can scan with 87.5 MHz and 108 MHz seamlessly between 100 kHz step and it use BK1080 as a receiver IC.

Main components of this receiver are a PIC16F88 micro-controller, 16x2 LCD and BK1080 FM receiver chip. This system is design to work with 5V DC power supply. User interface of this system consist with 6 push buttons and a 16×2 character LCD module. All the functions of this receiver can control by this buttons and necessary information displayed on the LCD.

Specifications of this receiver

  • Easy to build
  • Standby mode
  • Automatic gain control
  • Automatic frequency control
  • Automatic noise suppression
  • Preset memory stations up to 250 (default 20)

Schematic of BK1080 I2C FM Receiver
Schematic of BK1080

BK1080

The BK1080 FM receiver employs a low-IF architecture, mixed signal image rejection and all digital demodulation technology. The stations scan of BK1080 searches radio stations based on both the channel RSSI estimation and signal quality assessment, increases the number of receivable stations while avoids false stops. BK1080 enables FM radio reception with low power, small board space and minimum number of external components. All functions controlled through an I2C serial interface. See datasheet for more details.

Numbers of memory locations are determine by the value of Eeprom 1 (default value 0x14).
You can connect an earphone directly with BK1080’s output. However, do not connect speakers directly with IC. I recommended you to use amplifier if you wish to get more sound. In addition, be carefully when soldering BK1080. Because this IC more sensitive to electrostatic. Use DC soldering Iron to solder this IC or unplug your iron when solder. Micro-controller runs using its internal oscillator. RA0 and RA1 are configuring as SCL and SDA. RA2 is not connected. RA6 pin can directly connect with background light of LCD display. As well as it is also can used for the controlling another device like mute pin of power amp.

Selecting the station:
When we are in the power on mode, on the screen we can see "Frq:107.5 Ch:12" - tuned frequency of the station and then the number of the cell where the recorded frequency of the station. Pressing ‘CH_UP’ and ‘CH_DN’ we can move the recorded stations. Pressing ‘FR_UP’ and ‘FR_DN’ we can change the frequency. ‘STORE’ stored the current frequency to the current station and ‘PWR’ used to toggle standby mode and power on mode

Firmware of this system was written by using MikroC for PIC and schematic, hex and Proteus files are available for download.

Saturday, June 13, 2015

PLL Synthesized FM Receiver Circuit with LCD - 16F88 LM7001

FM Tuner
FM Tuner

This is high quality stereo digital PLL synthesized FM radio receiver circuit that can scan with 76 MHz and 108 MHz seamlessly between 100 kHz step, although the sensitivity is high.

Main components of this receiver are a PIC16F88 micro-controller, 16x2 LCD, LM7001 PLL Frequency Synthesizer, AN7223 IF Amp, TA7343 MPX and a FM Tuner. This system is design to work with 12V DC power supply and the LM7805 and 7808 regulators used to manage power requirements to the above-mentioned components.

User interface of this system consist with 6 push buttons and a 16×2 character LCD module. All the functions of this receiver can control by this buttons and necessary information displayed on the LCD.

Specifications of this receiver

  • High sensitivity
  • Standby mode
  • Preset memory stations up to 250 (default 20)
  • 3-user selectable frequency ranges (default 87.5-108)

Schematic of PLL and Power circuit
Schematic of PLL and Power circuit

Schematic of micro-controller and user interrface
Schematic of micro-controller and user interrface

LM7001

The LM7001 is a PLL frequency synthesizer LSIs for tuners, making it possible to make up high performance AM/FM tuners easily. These LSIs are software compatible with the LM7000, but do not include an IF calculation circuit. The FM VCO circuit includes a high-speed programmable divider that can divide directly seven reference frequencies. Serial input circuit for data input (using the CE, CL, and DATA pins)

Tuner 

Anticipating the objection that these tuners do not find, I assure you that if you do not be lazy and go through the repair shops where repair radio. In addition, you can get this tuner from old audio system and car set. There are 3 types.

Types of tuner
Types of tuner

  1. FM Front End only (you need to build IF Amp, MPX circuit)
  2. FM Front End with IF (you need to build MPX)
  3. FM Front End IF and MPX

IF Amp and MPX

For IF amp I used AN7223 because it need few external parts and it has high sensitivity and stability. If you cannot find FM quad coil then you can use 2pin 10.7MHZ ceramic resonator for that (see datasheet for more details). However, it is possible to use another IC for this as AN7220, TA7640 and KA2297 etc.

For MPX decoder here I used TA7343. This IC decode mono signal to stereo. This is an optional part. If you wish to work with mono, then omit this part and connect amplifier input with ‘AF’.

IF and MPX circuit
IF and MPX circuit

Complete circuit pcb
Complete circuit

Operation

Numbers of memory locations are determine by the value of Eeprom 1 (default value 0x14) and frequency range is determine by the value of Eeprom 2 (default value 0x00).
  • If value is 1 then range is 76-108MHz
  • If value is 2 then range is 76-90MHz
  • Else, range is 87.5-108 MHz

Selecting the station:
When we are in the power on mode, on the screen we can see "Frq:106.5 Ch:15" - tuned frequency of the station and then the number of the cell where the recorded frequency of the station. Pressing ‘CH_UP’ and ‘CH_DN’ we can move the recorded stations. Pressing ‘FR_UP’ and ‘FR_DN’ we can change the frequency. ‘STORE’ stored the current frequency to the current station and ‘PWR’ used to toggle standby mode and power on mode

Micro-controller runs using its internal oscillator. RA6 pin can directly connect with background light of LCD display. As well as it is also can used for the controlling another device like mute pin of power amp. For VCC (tuning voltage) you can use up-to 12v.

Firmware of this system was written by using MikroC for PIC and schematic, hex and Proteus files are available for download.

Thursday, November 13, 2014

DS1302 Real Time LCD Clock Circuit - 16F88

DS1302 Real Time Clock circuit
Clock Schematic

This clock use DS1302 as timekeeping chip and this was my first time I used this IC for my project. It used three wires for communication. It communicates with a microprocessor via a simple serial interface. Three wires are required to communicate with the clock/RAM: CE, I/O (data line), and SCLK (serial clock). The real-time clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The DS1302 will run with a voltage from 2.0V to 5.5V.

Here I used PIC16F88 micro-controller and 16x2 LCD. No switches were added to edit time and date. To add switches you have to modify the code and it is not difficult. The DS1302 uses an external 32.768kHz crystal. The oscillator circuit does not require any external resistors or capacitors to operate. The accuracy of the clock is dependent upon the accuracy of the crystal and the accuracy of the match between the capacitive load of the oscillator circuit and the capacitive load for which the crystal was trimmed. Please refer datasheet for more information.

DS1302 Features

  • Real-Time Clock Counts Seconds, Minutes, Hours, Date of the Month, Month, Day of the Week, and Year with Leap-Year Compensation Valid Up to 2100
  • 31 x 8 Battery-Backed General-Purpose RAM
  • Serial I/O for Minimum Pin Count
  • 2.0V to 5.5V Full Operation
  • Uses Less than 300nA at 2.0V
  • Single-Byte or Multiple-Byte (Burst Mode) Data Transfer for Read or Write of Clock or RAM Data
  • Simple 3-Wire Interface
  • DS1202 Compatible

MikroC used as programming language but you can easily convert it to MikroC Pro. Micro-controller is running by its internal clock at 8MHz.The project files can be download from below with Source files, Proteus and Hex file.

Saturday, August 30, 2014

LM35 Simple Thermometer Circuit with LCD - 16F818

Thermometer
Thermometer

In modern world, analog equipment and device are converting in to digital format. To do this mostly used sensors. There are many cool sensors available now days, ranging from IR distance sensor modules, accelerometers, humidity sensors, temperature sensors etc. but many of these sensors are analog in nature. That means they give a voltage output that varies directly (and linearly) with the sensed quantity. For example in LM35 temperature sensor, the output voltage is 10mV per degree centigrade. That means if output is 300mV then the temperature is 30 degrees. Or else, if the temperature changed one degree then its output voltage varied by 10mv.

In this post, I show you how to build temperature sensor (Thermometer) circuit easily. It uses the PIC 16F818 micro-controller, LM35 temperature sensor and a 16x2 LCD.

LM35 Temperature Sensor Schematic Diagram
Schematic Diagram

LM35

The LM35 series are precision integrated-circuit temperature sensors, whose output voltage is linearly proportional to the Celsius (Centigrade) temperature. The LM35 thus has an advantage over linear temperature sensors calibrated in ' Kelvin, as the user is not required to subtract a large constant voltage from its output to obtain convenient Centigrade scaling. The LM35 does not require any external calibration or trimming to provide typical accuracies of 1/4°C at room temperature and 3/4°C over a full -55 to +150°C temperature range. It can be used with single power supplies, or with plus and minus supplies.

Features
  • Calibrated directly in Celsius (Centigrade)
  • Linear + 10.0 mV/°C scale factor
  • 0.5'C accuracy guarantee-able (at +25°C)
  • Rated for full -55° to +150°C range
  • Operates from 4 to 30 volts

Operation


The LM35 outputs an analog voltage proportional to the temperature. This analog voltage then read by the PIC and processed to display the corresponding temperature value on the LCD. The PIC ADC module does the analog to digital conversion. The PIC MCU’s ADC gives us the value between 0-1023 for input voltage of 0 to 5v. So if the reading is 0 then input is 0v, if reading is 1023 then input is 5v.In the code, I have used the mikroC library function for ADC.

The temperature range for this circuit is 0°C to 150°C.
You can download project files form below and it used MikroC

/************************************************************************

    LM35 Temperature Sensor
    Copyright (C) 2015 Scorpionz

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

  >> Email: scorpionzblog@gmail.com
    >> Web  : scopionz.blogspot.com

************************************************************************/

char temp;

void main()
{
OSCCON= 0x70; // 8MHz internal osc
ADCON0=1;
ADCON1=0b10001110;
TRISA = 0x01; // AN0 input
TRISB = 0x00;
PORTA = 0;
PORTB = 0;

Lcd_Init(&PORTB);

Lcd_Cmd(Lcd_CLEAR);
Lcd_Cmd(Lcd_CURSOR_OFF);
Delay_ms(10);

Lcd_Out(1, 3, ".:SCORPIONZ:.");
Delay_ms(1000);
Lcd_Out(2, 2, "Temp is 000.0ßC");

while(1) {

temp = Adc_Read(0)/2.048;

Lcd_Chr(2, 10, ((temp/100)%10 +48));
Lcd_Chr(2, 11, ((temp/10)%10  +48));
Lcd_Chr(2, 12, ( temp%10      +48));
Delay_ms(100);
}
}


Friday, August 29, 2014

Simple LCD Spectrum Analizer Demo Circuit - 16F628



Spectrum analyzers are widely used within the electronics industry for analyzing the frequency spectrum of radio frequency, RF and audio signals. Looking at the spectrum of a signal, they are able to reveal elements of the signal, and the performance of the circuit producing them that would not be possible using other means.

Audio spectrum analyzer shows you a detailed picture of what you are hearing in real-time, that is, as it happens. You can easily built very cheap spectrum analyzer circuit using below diagram. However, this is not a real-time and it is just a visualizing model. But this work as real one and you can add this to your audio projects to get a nice appearance and add extra value for it.

You can able to download MikroC source and other files from the below link

Simple Spectrum Analizer circuit
Schematic Diagram of Analyzer

Thursday, August 28, 2014

Digital Combination Lock Circuit with Keypad and LCD - 16F628

Digital Lock
Digital Lock

Now day’s ordinary locks are replace with digital locks. Those have very advanced features such as digital display, keypad, fingerprint recognized etc. Therefore, I decided to build basic digital lock with LCD display and keypad.

This is a micro-controller based digital lock circuit and it used PIC16F628A. 16x2 LCD is used for the display information and keypad is used for enter the code. (#) will clear the code and (*) will enter the code to initialize process.

Default code for this lock is 2468 and this code was stored in device Eeprom memory. You can change the default code by changing value of device Eeprom memory. Address 1 for first number, Address 2 for 2nd number, so on. You can change Eeprom value from zero to nine.

Digital Lock circuit
Schematic Diagram of Digital Lock

Lock code = Eeprom Address 1 & …. & Eeprom Address 4

Ex:
Eeprom Address 1=3,  Address 2=1,  Address 3=0,  Address 4=7 then,
Lock code  =>  3 & 1 & 0 & 7  => 3107

Eeprom Address and lock code
Eeprom Address and lock code

Thursday, May 22, 2014

Multi Function Digital Meter Demo Circuit - 16F88

Multi Function Meter
Generic Multi Function Meter

This project is about a build simple digital multi function meter using a PIC16F88 micro-controller and a 16x2 LCD display. The range of voltage can measured is 0 - 50V, but you can change it easily. This circuit, operation and below code was not tested and only simulated one using Proteus software. you can download full project files including MikroC source file and Proteus schematic. This is only a model of multi function meter and below code for educational purpose. but you can modify and used this code any time for your future projects.


/**************************************************************************

Multi Tester (V, I, F, R)
Copyright (C) 2015 Scorpionz

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.

>> Email: scorpionzblog@gmail.com
>> Blog : scopionz.blogspot.com

***************************************************************************/

int v_in, i_in, r_in;
unsigned f_in;

char *vin = "V=00.0v I=00.00A";
char *fin = "F=00,000Hz 00%";

void main()
{
OSCCON = 0x70; //8MHz
ANSEL = 0x07; // AN0, AN1
T1CON = 0x0A; //1:1
OPTION_REG = 0x80; //WPUB

TRISA = 0x07;
TRISB = 0x40;

PORTA = 0;
PORTB = 0;

Sound_Init(&PORTA, 6);
Lcd_Config(&PORTB, 0, 1, 7, 5, 4, 3, 2);
delay_ms(10);

Lcd_Cmd(LCD_CURSOR_OFF);

Lcd_Out(1, 3, ".:SCORPIONZ:.");
Lcd_Out(2, 1, "Lab Multi Tester");
delay_ms(2000);
Lcd_Cmd(Lcd_Clear);

while(1) {

TMR1H=0;
TMR1L=0;
T1CON.TMR1ON=1;
Delay_ms(1000); // Wait for 1 sec
T1CON.TMR1ON=0;

f_in = 256*TMR1H+TMR1L;
v_in = Adc_Read(0);
i_in = Adc_Read(1);
r_in = Adc_Read(2);

if(v_in>1020 || i_in>1000) PORTA.F3=0;
else PORTA.F3=1;

v_in = v_in/2.05;
vin[2] = (v_in/100)%10 + 48;
vin[3] = (v_in/10) %10 + 48;
vin[5] = (v_in%10) + 48;

i_in = i_in/.2;
vin[10] = (i_in/1000)%10+ 48;
vin[11] = (i_in/100) %10+ 48;
vin[13] = (i_in/10) %10+ 48;
vin[14] = (i_in%10) + 48;

fin[2] = (f_in/10000)%10+ 48;
fin[3] = (f_in/1000)%10 + 48;
fin[5] = (f_in/100) %10 + 48;
fin[6] = (f_in/10) %10 + 48;
fin[7] = (f_in%10) + 48;

r_in = r_in/.205;
r_in = (4790/r_in);
if(r_in) Sound_Play(r_in*30, 100);
fin[13] = (r_in/10) %10 + 48;
fin[14] = (r_in%10) + 48;

Lcd_Out(1,1,vin);
Lcd_Out(2,1,fin);
}
}


 

on line

Labels

Recent comment

Visitors

Free counters!
Copyright © 2012 - Scorpionz™.,All rights reserved | Powered by Blogger