AVR1631 - Energy Meter Reference Design with ATxmega32A4  Rev 1.0
 All Data Structures Files Functions Variables Typedefs Macros
meter_lcd_module.h File Reference

Meter Calibration routine. More...

Go to the source code of this file.

Macros

#define LCD   PORTE
#define LCD_READ   8
#define LCD_CS   4
#define LCD_WRITE   2
#define LCD_DATA   1
#define LCD_CS_SET   LCD.OUTSET|=LCD_CS;
#define LCD_CS_CLEAR   LCD.OUTCLR=LCD_CS;
#define LCD_WRITE_SET   LCD.OUTSET|=LCD_WRITE;
#define LCD_WRITE_CLEAR   LCD.OUTCLR=LCD_WRITE;
#define LCD_READ_SET   LCD.OUTSET|=LCD_READ;
#define LCD_READ_CLEAR   LCD.OUTCLR=LCD_READ;
#define LCD_DATA_SET   LCD.OUTSET|=LCD_DATA;
#define LCD_DATA_OUT(a)   LCD.OUT = (LCD.OUT & ~LCD_DATA) | a;
#define LCD_COMMAND   0x04
#define LCD_DATA_WRITE   0x05
#define LCD_DATA_READ_WRITE   0x06

Functions

void lcd_disp_key (void)
void lcd_disp_date (void)
void lcd_disp_time (void)
void lcd_disp_active_power (void)
void lcd_disp_max_demand (void)
void lcd_disp_energy ()
void lcd_disp_power_factor (int16_t)
void lcd_disp_frequency (uint16_t)
void lcd_disp_apparent_power ()
void lcd_command (uint8_t, uint8_t)
void lcd_data (uint8_t, uint8_t, uint8_t)
void lcd_clear_all (void)
void lcd_show_all (void)
void lcd_disp_voltage (void)
void lcd_disp_current (void)
void lcd_read_write (uint8_t, uint8_t, uint8_t)

Variables

uint16_t number_arr [16]
 lookup table displaying the numbers to the lcd module
uint8_t key_flag

Detailed Description

Meter Calibration routine.

Application note:
AVR1631: Energy Meter Reference Design with ATxmega32A4
Documentation
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Author
Atmel Corporation: http://www.atmel.com
Support email: avr@a.nosp@m.tmel.nosp@m..com

$Revision: 1.0
$Date: 2012-07-01 10:10:10 +0530

Copyright (c) 2008, Atmel Corporation All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  1. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  1. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file meter_lcd_module.h.

Function Documentation

void lcd_clear_all ( void  )

brief This function clear the lcd

Definition at line 462 of file meter_lcd_module.c.

void lcd_command ( uint8_t  cmd1,
uint8_t  cmd2 
)

brief This function writes the command 'cmd2' to the LCD please refer the lcd datasheet for details

Definition at line 319 of file meter_lcd_module.c.

void lcd_data ( uint8_t  cmd,
uint8_t  lr_addr,
uint8_t  lr_data 
)

brief This function write the data 'lr_data' to the address lr_addr please refer the LCD datasheet for details

Definition at line 354 of file meter_lcd_module.c.

void lcd_disp_active_power ( void  )

brief This function display the active power in LCD

Definition at line 220 of file meter_lcd_module.c.

void lcd_disp_apparent_power ( void  )

brief This function display the apparent power in LCD

Definition at line 261 of file meter_lcd_module.c.

void lcd_disp_current ( void  )

brief This function display the current in LCD

Definition at line 300 of file meter_lcd_module.c.

void lcd_disp_date ( void  )

brief This function display the date in LCD

Definition at line 120 of file meter_lcd_module.c.

void lcd_disp_energy ( void  )

brief This function display the energy in LCD

Definition at line 170 of file meter_lcd_module.c.

void lcd_disp_frequency ( uint16_t  freq)

brief This function display the line frequency in LCD

Definition at line 204 of file meter_lcd_module.c.

void lcd_disp_key ( void  )

brief This function call the LCD display function based on the value in key_flag variable

 key_flag            function
     0               lcd_disp_time
     1               lcd_disp_date
     2               lcd_disp_voltage
     3               lcd_disp_current
     4               lcd_disp_active_power
     5               lcd_disp_apparent_power
     6               lcd_disp_power_factor
     7               lcd_disp_energy
     8               lcd_disp_max_demand
     9               lcd_disp_frequency
     10              lcd_show_all

clear the lcd display

shows the LCD page number

call the appropriate function based on the input from key_flag

Definition at line 69 of file meter_lcd_module.c.

void lcd_disp_max_demand ( void  )

brief This function display the max demand in LCD

Definition at line 239 of file meter_lcd_module.c.

void lcd_disp_power_factor ( int16_t  pf)

brief This function display the power factor in LCD

Definition at line 188 of file meter_lcd_module.c.

void lcd_disp_time ( void  )

brief This function display the time in LCD

Definition at line 145 of file meter_lcd_module.c.

void lcd_disp_voltage ( void  )

brief This function display the voltage in LCD

Definition at line 281 of file meter_lcd_module.c.

void lcd_read_write ( uint8_t  cmd,
uint8_t  lr_addr,
uint8_t  lr_data 
)

brief This function reads the address 'lr_addr' and add the 'lr_data' to the read data. The result is then written to the address 'lr_addr'

Definition at line 410 of file meter_lcd_module.c.

void lcd_show_all ( void  )

brief This function sets all the segments in the display

Definition at line 475 of file meter_lcd_module.c.