foot step energy part no. 2216964 - jameco … step energy part no. 2216964 in this kit the...

18
Foot Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries the piezoelectric sensor, A.C ripples neutralizer, unidirectional current controller and 12V 1.3Amps lead acid DC rechargeable battery and an inverter is used to drive AC/DC loads. The battery is connected to the inverter. This inverter is used to convert the 12 Volt D.C to the 230 V A.C. This 230 V A.C voltage is used to activate the loads. We are using conventional battery charging unit also for giving supply to the circuitry. Here we are using 16X2 LCD to display the voltage values of the rechargeable battery using AT89S52. “An average person, weighing 60 kg, will generate only 0.1 watts in the single second required to take two steps across the tile”, but when they are covering a large area of floor space and thousands of people are stepping or jumping on them, then we can generate significant amounts of power which can be Stored in capacitors, the power can be channeled to energy-hungry parts of the station including the electrical lighting system and the ticket gates. Time Required: 10 days depending on experience Experience Level: Advanced Required tools and parts: Soldering iron and solder Wires and wire cutter Needle nose pliers 1000W Pure Sine Wave Power Inverter 12VDC to 220VAC- Aliexpress (Required only if your country rating is 23OV AC/50HZ) Bill of Materials: Qty Jameco SKU Component Name 16 1956784 Piezoelectric crystal A piezoelectric sensor is a device that uses the piezoelectric effect to measure pressure, acceleration, strain or force by converting them to an electrical signal. The sensors are either directly mounted into additional holes into the cylinder head or the spark/glow plug is equipped with a built in miniature piezoelectric sensor. 1 609553 A.C ripple neutralizer(use capacitive filter)c= 1000 f/50v Capacitive filter is used in this project. It removes the ripples from the output of rectifier and smoothens the D.C. Output received from this filter is constant until the mains voltage and load is maintained constant. However, if either of the two is varied, D.C. voltage received at this point changes. Therefore a regulator is applied at the output stage. 1 330473 Capacitor Electrolytic Radial 330 uF 50 Volt 85c 20% 10x16x5mm 1 330529 Capacitor Radial 100 uF 100 Volt 20% 85c 10x17x5mm 1 264065 Lead acid battery

Upload: doanthuan

Post on 08-Mar-2018

216 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

Foot Step Energy

PART NO. 2216964

In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries the piezoelectric sensor,

A.C ripples neutralizer, unidirectional current controller and 12V 1.3Amps lead acid DC rechargeable battery and an inverter is used

to drive AC/DC loads.

The battery is connected to the inverter. This inverter is used to convert the 12 Volt D.C to the 230 V A.C. This 230 V A.C voltage is

used to activate the loads. We are using conventional battery charging unit also for giving supply to the circuitry. Here we are using

16X2 LCD to display the voltage values of the rechargeable battery using AT89S52. “An average person, weighing 60 kg, will

generate only 0.1 watts in the single second required to take two steps across the tile”, but when they are covering a large area of

floor space and thousands of people are stepping or jumping on them, then we can generate significant amounts of power which can

be Stored in capacitors, the power can be channeled to energy-hungry parts of the station including the electrical lighting system and

the ticket gates.

Time Required: 10 days depending on experience

Experience Level: Advanced

Required tools and parts:

Soldering iron and solder Wires and wire cutter

Needle nose pliers

1000W Pure Sine Wave Power Inverter 12VDC to 220VAC- Aliexpress (Required only if your country rating is 23OV AC/50HZ)

Bill of Materials:

Qty Jameco SKU Component Name

16 1956784 Piezoelectric crystal

A piezoelectric sensor is a device that uses the piezoelectric effect to measure pressure, acceleration, strain or force by converting them to an electrical signal. The sensors are either directly mounted into additional holes into the cylinder head or the spark/glow plug is equipped with a built in miniature piezoelectric sensor.

1 609553 A.C ripple neutralizer(use capacitive filter)c= 1000 f/50v

Capacitive filter is used in this project. It removes the ripples from the output of rectifier and smoothens the D.C. Output received from this filter is constant until the

mains voltage and load is maintained constant. However, if either of the two is varied, D.C. voltage received at this point changes. Therefore a regulator is applied

at the output stage.

1 330473 Capacitor Electrolytic Radial 330 uF 50 Volt 85c 20% 10x16x5mm

1 330529 Capacitor Radial 100 uF 100 Volt 20% 85c 10x17x5mm

1 264065 Lead acid battery

Page 2: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

1 2207224 600 Watt Modified Sine Wave Power Inverter with 'Auto Restart' - 12VDC In / 110VAC Out

A pure sine wave inverter produces a nearly perfect sine wave output

1 2136382 16 x 2 LCD display

1 786138 Voltage regulator 5 volt

In this project, power supply of 5V and 12V are required. In order to obtain these voltage levels, 7805 and 7812 voltage regulators are to be used. The first number

78 represents positive supply and the numbers 05, 12 represent the required output voltage levels. These regulators can provide local on-card regulation,

eliminating the distribution problems associated with single point regulation. Each type employs internal current limiting, thermal shut-down and safe area

protection, making it essentially indestructible.

1 902127 Voltage regulator 12 volt

1 23000 Sample and hold

Sample-and-hold (S/H) is an important analog building block with many applications, including analog-to-digital converters (ADCs) and switched-capacitor filters.

The function of the S/H circuit is to sample an analog input signal and hold this value over a certain length of time for subsequent processing.

1 10170 ADC 0808

The converter features a high impedance chopper stabilized comparator, a 256R voltage divider with analog switch tree and a successive approximation register.

The 8-channel multiplexer can directly access any of 8-single-ended analog signals. The device eliminates the need for external zero and full-scale adjustments.

Easy interfacing to microprocessors is provided by the latched and decoded multiplexer address inputs and latched TTL TRI-STATE outputs. The design of the

ADC0808, ADC0809 has been optimized by incorporating the most desirable aspects of several A/D conversion techniques. The ADC0808 offers high speed, high accuracy, minimal temperature dependence, excellent long-term accuracy and repeatability, and consumes minimal power. These features make this device ideally suited to applications from process and machine control to consumer and automotive applications

1 662637 Microcontroller AT89S52

Pin 1 to 8 (Port 1) is an 8-bit parallel port of a two-way (bidirectional) that can be used for different purposes (general purpose). Pin 9 is a pin reset, reset is active if

a high ration. P3.0 (10): RXD (serial port data receiver) P3.1 (11): TXD (serial port data sender) P3.2 (12): INT0 (external interrupt 0 input, active low) P3.3 (13): INT1 (external an interrupt input, active low) P3.4 (14): T0 (external input timer / counter 0) P3.5 (15): T1 (external input timer / counter 1) P3.6 (16): WR (Write, active low) control signal from port 0 write data to memory and input-output data externally. P3.7 (17): RD (Read, active low) control signal of the reading of input-output data memory external to the port 0. XTAL pin 18 as the second, the output is

connected to the crystal oscillator. XTAL pin 19 as the first, high input to the oscillator, connected to the crystal. Pin 20 as Vss, is connected to 0 or ground on the circuit. Pin 21 to 28 (Port 2) is 8 bits parallel ports in both directions. This port sends the address byte when accessing external memory is carried on. Pin 29 as the PSEN (Program Store Enable) is the signal used for reading, move the program the external memory (ROM / EPROM) to microcontroller (active

low). Pin 30 as the ALE (Address Latch Enable) to hold down the address for accessing external memory Pin 31 as the EA (External Access) to select the memory to be used, the internal program memory (EA = Fcc) or external program memory (EA = Vss), Pin 32 to

39 (Port 0) is an 8-bit parallel port in both directions. Under which functions as a multiplexed address data to access an external program and data memory. Pin 40 as Fcc, connected to +5 V as a ration to the microcontroller. All single chips in the family division of MCS-51 have the address space to programs and data.

10 36012 Unidirectional current controller(D=IN4007)

In this project we are going to use diode as Unidirectional Current control device. As we are already familiar with the most common function of a diode is to allow

an electric current to pass in one direction (called the diode's forward direction).While blocking current in the opposite direction (the reverse direction). Thus, the

diode can be thought of as an electronic version of a check valve. The diode used in this project is D=1N4007.

1 206587 Prototype Builder Board

4.3" X6.8" PCB Pre-Etched Drilled PCB Epoxy Glass 0.062" Thick 0.1" Hole Spacing 0.08" Pad Size

1 20812 3220-Point Solder less Breadboard 7.3"Lx7.5"W

5 421315 Test Leads Breadboard 20 Pack 5.9 Inch (150mm) Wire Pin Contacts

1 2173845 18 AWG 2 Conductor PVC Zip Automotive Speaker Cable - 100 Feet

Page 3: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

Step 1 - Making of piezoelectric transducer array

1. Check the piezos to determine whether they already have two-inch wire leads soldered to them. If not, you will need to wire these.

2. Cut two pieces of thin-gauge copper wire, 5 to 6 inches in length, for each piezo element you need to wire. Strip about 1/8 inch of

insulation off the ends of each wire.

3. Apply two small beads of electrical solder to both the metal and the ceramic portions of the piezo disc. Apply a good amount of

solder to the ends of the thin-gauge wire.

4. Place the stripped end of the wire against the solder beads. Touch the soldering iron tip to the wire and hold it there until the solder

melts and the wire sinks into the solder bead. Hold the wire steady for a few moments while the solder hardens.

5. Connect the wire soldered to the metal on one piezo to the wire soldered to the ceramic on the piezo next to it. Twist the two wires

together. Solder them together and insulate the connection with electrical tape.

6. Connections should be made on a hard board as we have to stand on it.

7. Repeat this procedure for all of the piezos until all are soldered together in series and only two wires (one on each end of the piezo

string) are not connected. You now are ready to connect the series of piezos to the rest of the circuit.

Step 2 - Run the low voltage AC through a rectifier

1. Take 4 diodes (D=1N4007) and connect them as shown in figure.

2. Connect piezo array output to the input as shown in figure to 1 and 2 terminal.

3. A rectifier usually consists of 4 diodes arranged in a diamond shape called a bridge rectifier.

4. A diode only allows current to pass in 1 direction; the diamond configuration allow 2 diodes to pass the positive half of the current

and the other 2 diodes to pass the negative half.

5. The output of both sets is a current that climbs from 0 volts to the maximum positive voltage.

Page 4: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

Step 3 - Add a large electrolytic capacitor (1000 uf) to output of bridge rectifier

Connect 1000uF /50v electrolytic capacitor to output of rectifier

(TERMINAL 3 AND 4)

Connect ground terminal and positive terminal

Step 4 - Add 7812 voltage regulator

1. See the numbering 1,2,3,4 at the figure at bridge rectifier.

2. Voltage regulator numbering 1, 2, and 3 has no relation with diode numbering.

3. 1000uf/50v capacitor has already placed.

4. Now place 7812 voltage regulator.

5. See pin diagram from figure.

6. Place 330uf/50v capacitor now as shown in figure.

7. 7812 configuration is over.

Page 5: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

Step 5 - Add 7805 voltage regulator

1. Connection is similar to step 4.

2.330uf/50v capacitor was placed to out terminal of 7812 which is in terminal of

7805.

2. Only 100uf/50v capacitor is placed at out terminal of 7805.

3. Positive terminal and ground are maintained.

Step 6 - Connect 7812 output to the battery 12v

1. Where 7812 connection ends there we get a regulated voltage of 12v.

2. Connect the positive end to positive end of battery.

3. Connect the negative end to negative end of battery.

4. As the battery is connected this will charge by proper connection of terminals.

Page 6: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

Step 7 – More connections

1. Connection as per the terminal shown in figure.

2. Red: positive

3. Black: negative

Step 8 – Interface LCD, ADC and microcontroller

1. Interface microcontroller, LCD and ADC according to the circuit diagram.

2. Analog signal (rechargeable battery + ve end) is the input to ADC.

3. 5v power supply can be given to components from voltage regulator 7805 output.

4. External power supply can be given.

3. First make the schematic in software (Proteus)

4. Run program in software Keil.

5. Then see result.

6. Then make on breadboard.

8. All codes and schematic are with me.

9. Comment if required.

Page 7: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

8051(AT89S52) Microcontroller is interfaced with ADC 0808 IC to show the output value of ADC on LCD Screen, for a given variable

input voltage of 5Volts at ADC0808 Channel 0. Its code is written in C language using Keil uvision 4 compiler and circuit simulation is

done using Proteus7.7,Using which you can verify this ADC code and can be changed it according to your needs.

EXPLANATION

In the circuit below, 8 bit data bus of ADC0808 is attached with 8051 on Port 0. And control signals of ADC0808 are attached on Port

2 of 8051 microcontroller. LCD is attached on Port 1, LCD is used here just to show the output value of ADC.

ADC0808 has 8 input channels. You can use any channel for ADC purposes in the code. A potentiometer (i.e.

variable 10k resistor) is attached on IN1 of ADC0808 just to demonstrate how to use this code. Input voltage at

IN1 is read in the code and displayed on the LCD. Since, ADC0808 gives an output of 8bit value, so a voltage

value of 0v at IN1 will mean ADC value of 0 and a voltage of 5v at IN1 pin means ADC value of 255. In the

above figure, it is clear that a when voltage of 2.5v is applied on IN1 pin and ADC value of 127 (i.e. half of 255)

is displayed on the LCD correctly.

A crystal of 12MHz value is used in this circuit, which makes this 8051 (i.e. AT89C51) run at a speed of 1MIPS

(Millions of instructions per second). You can use any other value of crystal (From 3 to 24 MHz value only)

with 8051 as well.

Page 8: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

CIRCUIT

CODE

C:

//Pin description

/*

P1.4 to P1.7 is data bus

P1.1 is RS

P1.0 is E

*/

#include<reg52.h>

//Defines Pins

sbit RS = P1^1;

sbit E = P1^0;

//Constants

#define E_Delay 250

//Function Declarations for LCD

void delay_sec(unsigned int);

void __delay_us(unsigned int);

void InitLCD(void);

void WriteCommandToLCD(int);

void WriteDataToLCD(char);

void WriteStringToLCD(const char*);

void ClearLCDScreen(void);

// Function Declarations for ADC

void InitADC(void);

unsigned char ReadADC(unsigned char);

Page 9: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

/

// Define ADC0808 Channels

#define AN0 0

#define AN1 1

#define AN2 2

#define AN3 3

#define AN4 4

#define AN5 5

#define AN6 6

#define AN7 7

// Define Pins

sbit Add_A = P2^0; // Address Pin A

sbit Add_B = P2^1; // Address Pin B

sbit Add_C = P2^2; // Address Pin C

sbit ALE = P2^3; // Address Latch Enable

sbit EOC = P2^4; // End Of Conversion

sbit OE = P2^5; // Output Enable

sbit START = P2^6; // Start Conversion

sbit CLK = P2^7; // Clock for AD0808

// Define Data Bus

#define Data_Bus P0

#define HalfCycleDelay 10 // usecs

////////////////// Main function//////////////////

void main()

{

unsigned char ADC_Value = 0; // To capture ADC value

unsigned char Digit[3] = { 0,0,0 }; // To make digits to display on LCD

InitADC(); // Initialize ADC

InitLCD(); // Initialize LCD display

WriteStringToLCD("Starting..."); // Show Welcome Message

delay_sec(1); // 1 Sec delay

ClearLCDScreen(); // Clear LCD

while(1)

{

ADC_Value = ReadADC(AN1); // Read ADC value from Channel 1

Digit[2] = (unsigned char)( ADC_Value/100); // Find out first digit

Digit[1] = (unsigned char)( ADC_Value/10) - Digit[2]*10; // Find out second digit

Digit[0] = ADC_Value - Digit[2]*100 - Digit[1]*10; // Find out third digit

ClearLCDScreen(); // Clear LCD

WriteStringToLCD("ADC value = "); // Display string

WriteDataToLCD(Digit[2]+0x30); // Display first digit

WriteDataToLCD(Digit[1]+0x30); // Display second digit

WriteDataToLCD(Digit[0]+0x30); // Display third digit

delay_sec(1); // Delay of one second

}

}

//////////////////End of Main Function //////////////////

//Function for Initialization of ADC0

void InitADC(void)

{

Add_A = 0; // Make output

Add_B = 0; // Make output

Add_C = 0; // Make output

ALE = 0; // Make output

EOC = 1; // Make input

OE = 0; // Make output

Page 10: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

START = 0; // Make output

CLK = 0; // Make output

Data_Bus = 0xFF; // Make Inputs

}

unsigned char ReadADC(unsigned char Channel)

{

unsigned int i = 0;

unsigned int ADC_value = 0;

/*Selecting analog Channel by providing respective

bits to A,B,C addresses*/

switch(Channel)

{

case AN0: Add_C = 0; Add_B = 0; Add_A = 0; break;

case AN1: Add_C = 0; Add_B = 0; Add_A = 1; break;

case AN2: Add_C = 0; Add_B = 1; Add_A = 0; break;

case AN3: Add_C = 0; Add_B = 1; Add_A = 1; break;

case AN4: Add_C = 1; Add_B = 0; Add_A = 0; break;

case AN5: Add_C = 1; Add_B = 0; Add_A = 1; break;

case AN6: Add_C = 1; Add_B = 1; Add_A = 0; break;

case AN7: Add_C = 1; Add_B = 1; Add_A = 1; break;

}

__delay_us(HalfCycleDelay); // 250kHz Frequency

ALE = 1; // Enable Address Latch

CLK = 1; / Make CLK High

__delay_us(HalfCycleDelay); // 250kHz Frequency

CLK = 0; // Make CLK Low

START = 1; // Start ADC Conversion

__delay_us(HalfCycleDelay); // 250kHz Frequency

CLK = 1; // Make CLK High

ALE = 0; // Disable Address Latch

__delay_us(HalfCycleDelay); // 250kHz Frequency

CLK = 0; // Make CLK Low

START = 0; // Complete the start pulse

for(i=0;i<2000;i++)

{

CLK = !CLK; // Toggle Clock

__delay_us(HalfCycleDelay); // 250kHz Frequency

if(!EOC) // Wait for EOC to be low

break;

}

for(i=0;i<2000;i++)

{

CLK = !CLK; // Toggle Clock

__delay_us(HalfCycleDelay); // 250kHz Frequency

if(EOC) // Wait for EOC to be High

break;

}

CLK = 0; // Make CLK Low

OE = 1; // Enable Output

__delay_us(HalfCycleDelay); // 250kHz Frequency

CLK = 1; // Make CLK High

__delay_us(HalfCycleDelay); // 250kHz Frequency

CLK = 0; // Make CLK Low

__delay_us(HalfCycleDelay); // 250kHz Frequency

CLK = 1; // Make CLK High

ADC_value = Data_Bus; // Read value

__delay_us(HalfCycleDelay); // 250kHz Frequency

OE = 0; // Disable Output

CLK = 0; / Make CLK Low

__delay_us(HalfCycleDelay); // 250kHz Frequency

Page 11: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

return ADC_value; // Return ADC value

}

// Function for approximate delay in Secs.

void delay_sec(unsigned int d)

{

unsigned int i;

for(i=0;i<(d*20);i++)

__delay_us(50000);

}

// Function for approximate delay in given uSecs.

void __delay_us(unsigned int d)

{

unsigned int i, limit;

limit = d/15;

for(i=0;i<limit;i++);

}

void ToggleEpinOfLCD(void)

{

E = 1; // Give a pulse on E pin

__delay_us(E_Delay); // so that LCD can latch the

E = 0; // data from data bus

__delay_us(E_Delay);

}

//Function for Writing Data to LCD

void WriteDataToLCD(char t)

{

RS = 1; // This is data

P1 &= 0x0F; // Make P1.4 to P1.7 zero

P1 |= (t&0xF0); // Write Upper nibble of data

ToggleEpinOfLCD(); // Toggle E pin to send data

P1 &= 0x0F; // Make P1.4 to P1.7 zero

P1 |= ((t<<4)&0xF0);// Write Lower nibble of data

ToggleEpinOfLCD(); // Toggle E pin to send data

}

//Function for Writing COmmand to LCD

void WriteCommandToLCD(int z)

{

RS = 0; // This is command

P1 &= 0x0F; // Make P1.4 to P1.7 zero

P1 |= (z&0xF0); // Write Upper nibble of data

ToggleEpinOfLCD(); // Toggle E pin to send data

P1 &= 0x0F; // Make P1.4 to P1.7 zero

P1 |= ((z<<4)&0xF0);// Write Lower nibble of data

ToggleEpinOfLCD(); // Toggle E pin to send data

}

//Writing Function for Initializaing of LCD

void InitLCD(void)

{

RS = 0; // Make pin zero

E = 0; // Make Pin zero

///////////// Reset process from datasheet /////////

__delay_us(15000);

P1 &= 0x0F; // Make P1.4 to P1.7 zero

P1 |= 0x30; // Write 0x3

Page 12: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

ToggleEpinOfLCD(); // Toggle E pin to send data

__delay_us(4500);

P1 &= 0x0F; // Make P1.4 to P1.7 zero

P1 |= 0x30; // Write 0x3

ToggleEpinOfLCD(); // Toggle E pin to send data

__delay_us(300);

P1 &= 0x0F; // Make P1.4 to P1.7 zero

P1 |= 0x30; // Write 0x3

ToggleEpinOfLCD(); // Toggle E pin to send data

__delay_us(650);

P1 &= 0x0F; // Make P1.4 to P1.7 zero

P1 |= 0x20; // Write 0x2

ToggleEpinOfLCD(); // Toggle E pin to send data

__delay_us(650);

WriteCommandToLCD(0x28); //function set

WriteCommandToLCD(0x0c); //display on,cursor off,blink off

WriteCommandToLCD(0x01); //clear display

WriteCommandToLCD(0x06); //entry mode, set increment

}

//Function for Writing String to LCD

void WriteStringToLCD(const char *s)

{

while(*s)

WriteDataToLCD(*s++); // print first character on LCD

}

// Writing Function for Clear the LCD Screen and return cursor to zero position

void ClearLCDScreen(void)

{

WriteCommandToLCD(0x01); // Clear the screen

__delay_us(2000); // Delay for cursor to return at zero position

}

In the main function, firstly pins attached with ADC0808 are initialized using InitADC(); statement, then LCD

is initialized using InitLCD() function. Then “Starting…” is displayed on the LCD for one second. After that

LCD screen is cleared.

In the while(1) loop, ADC_Value = ReadADC(AN1); statement reads value from IN1 pin of ADC0808 and

assigns this value to ADC_Value variable. Next 3 statements are converting ADC_Value in to digits, which will

be displayed on the LCD screen. After that, LCD screen is cleared and ADC value is displayed on the LCD.

SOFTWARE:

The code was compiled in Keil micro-vision4 (Portable) and simulation was made in Proteus v7.7

Page 13: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

Make project in keil software selecting 89c51 microcontroller.

Now next, right click on target 1 and add a group "headers".

Now create this headers files as told below:

1. To make header files create a new file - > save the file in format "filename.h"

2. Add the files to header group in project workspace.

3. Do the above 2 steps for below codes.

This helps in debugging faster.

Now add this files as show above. Keep them all blank and with same names.

Now open the blank 16_2lcd.h file and enter the code below and save it:

///////////////////////////////////////////INSIDE 16_2lcd.h FILE////////////////////////////////

#include "AT89X51.H"

#include "delay.h"

#include "stdio.h"

#define RW P0_1

#define RS P0_0

#define EN P0_2

#define DATA P2

int lcd_inst(void); //Instruction sel

int lcd_data(void); //Data sel

int lcd_latch(void); //Latch the bus

int lcd_write_str(char *str, int str_len, int line); //Write string

int lcd_write_int(int num, int num_len, int line); //Write integer

int lcd_write_float(float num, int num_length, int line); //Write float

int lcd_clear(void); //clears lcd screen

int lcd_linsel(int line); //Lcd line sel

int lcd_initialize(void); //Initialize the LCD

///////////////////////////////////////////INSIDE 16_2lcd.h FILE END////////////////////////////////

Now open the blank adc0808.h file and enter the code below and save it:

///////////////////////////////////////////INSIDE adc0808.h START////////////////////////////////

#include "AT89X51.H"

#include "delay.h"

#define OE P3_0

#define ALE P3_1

#define A P3_2

#define B P3_3

#define C P3_4

#define ADC_DATA P1

int read_ain(int ain_pin);//Reads ext. Analong in

int set_analongin(int ain_pin);// Sets in0 to in7 pin select.

///////////////////////////////////////////INSIDE adc0808.h END////////////////////////////////

Now open the blank delay.h file and enter the code below and save it:

///////////////////////////////////////////INSIDE delay.h START////////////////////////////////

void delay(int n); //Universal delay routine

///////////////////////////////////////////INSIDE delay.h END////////////////////////////////

Now open the blank 16_2lcd.c file and enter the code below and save it:

///////////////////////////////////////////INSIDE 16_2lcd.c START////////////////////////////////

#include "16_2lcd.h"

int lcd_inst(void) //Instruction select

{

Page 14: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

RS=0;

RW=0;

return 0;

}

int lcd_data(void) // Data select

{

RS=1;

RW=0;

return 0;

}

int lcd_latch(void) // Latch routine

{

EN=1;

delay(100);

EN=0;

delay(100);

EN=1;

delay(100);

return 0;

}

int lcd_initialize(void) //Initialize the LCD

{

RS=0;

RW=0;

EN=1;

delay(100000);

lcd_inst();

DATA=0X38; //This instruction will Enable 8-bit Databus, Set 2 lines, and Select font size 5x7

lcd_latch();

lcd_latch();

lcd_latch();

lcd_latch();

DATA=0X0c; //It will display the characters, will not display the cursor

lcd_latch();

DATA=0X80; //Set cursor on line 1

lcd_latch();

DATA=0X01; //Clear screen

lcd_latch();

lcd_data();

return 0;

}

int lcd_clear(void)

{

lcd_inst();

DATA=0X01; //Clear screen

lcd_latch();

lcd_data();

return 0;

}

int lcd_linsel(int line) //Lcd line sel

{

lcd_inst();

if(line==1)

{

DATA=0X80; //Set cursor on line 1

lcd_latch();

}

if(line==2)

{

DATA=0XC0; //Set cursor on line 2

lcd_latch();

}

Page 15: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

lcd_data();

}

int lcd_write_str(char *str,int str_len, int line)

{

int i;

lcd_linsel(line); //Lcd line sel

lcd_data();

for(i=0;i<=str_len-1;i++)

{

DATA=str[i];

lcd_latch();

}

return 0;

}

int lcd_write_int(int num,int num_len,int line) //Write integer

{

int i;

char str[16];

str[0]=0;

str[1]=0;

str[2]=0;

lcd_linsel(line); //Lcd line sel

lcd_data();

sprintf(str,"%3.0d",num);

for(i=0;i<=num_len-1;i++)

{

DATA=str[i];

lcd_latch();

}

return 0;

}

int lcd_write_float(float num,int num_len,int line) //Write integer

{

int i;

char str[16];

str[0]=0;

str[1]=0;

str[2]=0;

lcd_linsel(line); //Lcd line sel

lcd_data();

sprintf(str,"%3.3f ",num);

for(i=0;i<=num_len-1;i++)

{

DATA=str[i];

lcd_latch();

}

return 0;

}

///////////////////////////////////////////INSIDE 16_2lcd.c END////////////////////////////////

Now open the blank adc0808.c file and enter the code below and save it:

///////////////////////////////////////////INSIDE adc0808.c START////////////////////////////////

#include "adc0808.h"

int read_ain(int ain_pin)// Reads adc value at given pin

{

int num;

ADC_DATA=0xFF;

OE=0;

Page 16: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

set_analongin(ain_pin);

OE=1;

num=ADC_DATA;

OE=0;

return num;

}

int set_analongin(int ain_pin)// Sets in0 to in7 pin select.

{

ALE=0;

switch(ain_pin)

{

case 0: A=0;B=0;C=0;break;

case 1: A=1;B=0;C=0;break;

case 2: A=0;B=1;C=0;break;

case 3: A=1;B=1;C=0;break;

case 4: A=0;B=0;C=1;break;

case 5: A=1;B=0;C=1;break;

case 6: A=0;B=1;C=1;break;

case 7: A=1;B=1;C=1;break;

default:break;

}

ALE=1;

delay(100);

ALE=0;

return 0;

}

///////////////////////////////////////////INSIDE adc0808.c END////////////////////////////////

Now open the blank delay.c file and enter the code below and save it:

///////////////////////////////////////////INSIDE delay.c START////////////////////////////////

#include "delay.h"

void delay(int n) //Universal delay routine

{

int i=0,j=0;

for(i=0;i<=n;i++)

for(j=0;j<=10;j++);

}

///////////////////////////////////////////INSIDE delay.c END////////////////////////////////

Now open the blank main.c file and enter the code below and save it:

///////////////////////////////////////////INSIDE main.c START////////////////////////////////

//Programmed by Macjan Camilo Fernandes

//Test Version 1.0.0

#include "16_2lcd.h"

#include "adc0808.h"

#include "delay.h"

#include "REGX51.H"

#include "stdio.h"

int main(void)

{

float calc;

int test,i;

char mac[16];

P3=0;

//Initialize LCD

lcd_initialize();

lcd_clear();

//write title

//i can be from 0 to 7 since only 8 channel select

i=3; // to read analog input at pin in3 of ADC0808

sprintf(mac,"ADC Data %d in V",i+1);

lcd_write_str(mac,15,1); //Write string

Page 17: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries

while(1)

{

test=read_ain(i); //reads analog input of channel i

calc= test*0.0195; //calculates voltage for vref=5v vref-=0v

delay(100);

//Write_adc data on LCD

lcd_write_float(calc,5,2); //Write adc data

}

return 0;

}

///////////////////////////////////////////INSIDE main.c END////////////////////////////////

After doing this above process. Compile and program the microcontroller.

Check the ADC value.

The adc0808.h and adc0808.c was done by me so that you can make use of adc easily if you include this header files in main code

as shown above.

Use this function

int read_ain(int ain_pin);// Reads adc value at given pin

eg: x=read_ain(3);

This instruction above will store value of adc input IN3 value into x variable which you can then process into your desired calculations.

You can go though the header files and source files for deeper details.

Page 18: Foot Step Energy PART NO. 2216964 - Jameco … Step Energy PART NO. 2216964 In this kit the conversion of the force energy into electrical energy occurs. The control mechanism carries