Vous êtes sur la page 1sur 13

Design Document

Version 1.0

DDC Firmware
Author: ANUPAM

Distribution is subject to copyright.

Disclaimers
The information contained in this document is the proprietary and exclusive property of Allgreen
Ecotech except as otherwise indicated. No part of this document, in whole or in part, may be
reproduced, stored, transmitted, or used for design purposes without the prior written permission
of Allgreen Ecotech.
The information contained in this document is subject to change without notice.
The information in this document is provided for informational purposes only. Allgreen Ecotech
specifically disclaims all warranties, express or limited, including, but not limited, to the implied
warranties of merchantability and fitness for a particular purpose, except as provided for in a
separate software license agreement.

Privacy Information
This document may contain information of a sensitive nature. This information should not be given
to persons other than those who are involved in the BMS project or who will become involved
during the lifecycle.

Version History
REVISION CHART
Version

Author(s)

Description of Version

Date
Completed

Contents
Contents.................................................................................................................................................. 3
1.

Introduction ............................................................................................................................. 4

1.1.

Document Overview............................................................................................................. 4

1.2.

Scope ................................................................................................................................... 4

2.

LCD Module ............................................................................................................................. 4

2.1.

Background Information....................................................................................................... 4

2.2.

System Evolution Description ............................................................................................... 5

2.3.

Lcd_drv.C ............................................................................................................................. 5

2.4.

Sending data/command in 4-bit Mode ................................................................................. 6

2.5.

Interface .............................................................................................................................. 7

2.6.

Flow chart LCD initialization ................................................................................................. 8

2.7.

Lcd_app.c ............................................................................................................................. 8

3.

Martix Keypad Module (4x4) .................................................................................................. 10

3.1.

Scanning a Matrix Keypad .................................................................................................. 10

3.2.

Flow chart Matrix Keypad ................................................................................................... 11

3.3.

System Evolution Description ............................................................................................. 12

3.4.

Interface ............................................................................................................................ 12

4.

Logic flow for the Actuator and Return air .............................................................................. 13

1.

Introduction

Provide a brief introduction to the firmware developer about the different module of the BMS
firmware and the concept of that module.
1.1. Document Overview

Description of LCD module


Description of Keypad module
Description of Configuration file module
Description of Winter logic for the Actuator Valve operation

1.2. Scope
This document is entirely for the firmware development of the BMS project. All concepts are
designed only for BMS project.

2. LCD Module
This section will give an idea about the interface of 20x4 LCD with our RCM6710 based
hardware.
2.1. Background Information
To design this module a developer should have the knowledge of LCD data and command. Also
pin description of the LCD.
We will use the LCD in 4bit mode to save the I/P line of the controller. Total 8 GPIO will be used
to control the LCD.

2.2. System Evolution Description


Dynamic C 10.7 support multiple c file in a single project. We will use two different .C file for
this module. lcd_drv.C and lcd_app.C.
Use LCD datasheet for command set. Also refer hardware schematic for the pin configuration.
2.3. Lcd_drv.C
lcd_drv.C is the driver file for the LCD. It contains all the functions for handling the LCD module.
It uses two Macros for writing data and commands.
#define WRITE_DATA(x); - it will put data to the LCD module
#define WRITE_CMD(x); - it will put command for LCD module
LCD also needs an initialization process to start. There will be a function called LCD_INIT (), into
the driver file.
All macro related to command and data should also be on driver file.
Following functions are also defined in lcd_drv.c:

void LCD_Data(unsigned char data)


+---------------------------------------+
| Prototype:
void LCD_Data(unsigned char data)
| Return Type:
void
| Arguments:
Character to be displayed
| Description: This Function displays the character passed to it on the |
LCD. This function makes use of WRITE_DATA macro. Since the LCD is |
connected in 4 bit interface, the upper four bits of the data to be |
displayed, is written first followed by the lower four bits.
|
+---------------------------------------+

void LCD_Cmd(unsigned char data)


+---------------------------------------+
| Prototype:
void LCD_Cmd(unsigned char data)
| Return Type:
void
| Arguments:
Command to be written to LCD module
| Description: This Function writes the command on the LCD. This function
makes use of WRITE_CMD macro. Since the LCD is connected in 4 bit
Interface, the upper four bits of the command is written first
followed by the lower four bits.
|
+---------------------------------------+

void PulseEnablePin ()
+---------------------------------------+
| Prototype: void PulseEnablePin ()
| Return Type:
| Arguments:

void
None

| Description: This function toggles the Enable pin. After a command or a


data is written, this function should be called.
+---------------------------------------+

void LCD_Init();
+---------------------------------------+
| Prototype: void LCD_Init();
| Return Type:
| Arguments:

void
None

| Description: Initialize the LCD module for the lcd operation.


+---------------------------------------+

void Go_Location_X_Y(unsigned char loc_X,unsigned char loc_Y)


+---------------------------------------+
| Prototype: void Go_Location_X_Y(unsigned char loc_X,unsigned char loc_Y)
| Return Type:
void
| Arguments:
X & Y locations .Where X can be within 1 to 4 and Y can
be within 1 to 20.
| Description: This function takes the cursor on LCD at the X,Y locations
passed. Different checks are used so that user does not enter invalid
locations.
+---------------------------------------+

2.4. Sending data/command in 4-bit Mode


We will now look into the common steps to send data/command to LCD when working
in 4-bit mode. As i already explained in 4-bit mode data is sent nibble by nibble, first we
send higher nibble and then lower nibble. This means in both command and data
sending function we need to separate the higher 4-bits and lower 4-bits.
The common steps are:
Mask lower 4-bits
Send to the LCD port
6

Send enable signal


Mask higher 4-bits
Send to LCD port
Send enable signal
We are done with the theory part now, In the next section we will take a look at the
programming microcontroller to control LCD in 4-bit mode.

2.5.

Interface
A single function will be used for the entire application. This api will handle the user
interface. Only the string and location should be passed.
void write_string_to_lcd ( unsigned char x , unsigned char y , unsigned char* str , int
len )
+---------------------------------------+
| Prototype: void Go_Location_X_Y(unsigned char loc_X,unsigned char loc_Y)
| Return Type:
void
| Arguments: Locations (X & Y), where X can be within 1 to 4 and Y can be
within 1 to 20.String to be displayed. Length of the string.
| Description: This function displays a string passed at the location X & Y.
This function makes use of Go_Location_X_Y() function.
+---------------------------------------+

2.6.

Flow chart LCD initialization

2.7.

Lcd_app.c

This is an application based file and contains all the functions needed for our application. The
different parameters to be displayed on the LCD are categorized in Pages. A Page refers to the
data on the 20x4 LCD that gets displayed at a time.
Parameter
Companys profile &
Date-Time
Analog Inputs 1,2,3,4

Page no
1
2
8

Analog Inputs 5,6,7,8


Digital Input & Digital
Output
Socket Port Status
Firmware Number & SD
card Status
Analog Output 1,2,3,4

3
4
5
6
7

3. Martix Keypad Module (4x4)


Keypads are a part of HMI or Human Machine Interface and play really important role in a
small embedded system where human interaction or human input is needed. Martix keypads
are well known for their simple architecture and ease of interfacing with any microcontroller.

3.1.

Scanning a Matrix Keypad

Here are many methods depending on how you connect your keypad with your controller, but
the basic logic is same. We make the columns as i/p and we drive the rows making them o/p,
this whole procedure of reading the keyboard is called scanning.
In order to detect which key is pressed from the matrix, we make row lines low one by one and
read the columns. Lets say we first make Row1 low, then read the columns. If any of the key in
row1 is pressed will make the corresponding column as low i.e. if second key is pressed in
Row1, then column2 will give low. So we come to know that key 2 of Row1 is pressed. This is
how scanning is done.
So to scan the keypad completely, we need to make rows low one by one and read the
columns. If any of the buttons is pressed in a row, it will take the corresponding column to a
low state which tells us that a key is pressed in that row. If button 1 of a row is pressed then
Column 1 will become low, if button 2 then column2 and so on...
The state machine is initialized to start with fast scan which outputs zeroes to all rows
and detects all keys at the same time. When a key is pressed, a low level is applied to
the corresponding column and causes a PIO interrupt to detect the first edge. Once any key is
detected, debouncing is started. The attempt to press a key on a physical keypad and have this
10

activity detected can fail as a result of several noise sources, glitches, spikes, etc., to mention
some of the possible causes of debounce problems. The timer is used to eliminate all noise of
less than a few milliseconds. Normally this is dependent on the mechanical characteristics of
the keys. 20ms programmable debouncing time is fine for this.
After debouncing is completed, a detailed scan is executed. A second fast scan is done to assure
that any detection made during the first fast scan stage was not just noise.
(Refer to Figure below.) Then, rows are configured as inputs. When a key is pressed a high level
is applied in the corresponding row. .

3.2.

Flow chart Matrix Keypad

11

3.3. System Evolution Description


There will be single c file for this keypad module .i.e. keypad_drv.c
All the port definition will be on this single file. There will be two simple functions for the key
module.
void key_init(void);
+---------------------------------------+
| Prototype: void key_init(void);
|
| Return Type: void
|
| Arguments: None
|
| Description: Initialize ports and
|
|
Keypad. make Rows as o/p
and cols are i/p
|
+---------------------------------------+

unsigned char get_key(void);

/*
+-----------------------------------------------+
| Prototype: unsigned char get_key(void);
|
| Return Type: unsigned char
|
| Arguments: None
|
| Description: To read key from the keypad,
|
+-----------------------------------------------+
*/

This function will return the key value.


3.4. Interface
On application part we will use the function, get_key(); Scanning of key will be performed using
a separate task .

12

4. Logic flow for the Actuator and Return air

13

Vous aimerez peut-être aussi