0% found this document useful (0 votes)
9 views36 pages

MPMC

The document outlines an experiment to control a stepper motor's rotation direction using an ARM LPC2929 board and Keil-μ vision 4 software. It details the theory behind stepper motors, the algorithm for controlling the motor, and provides a program for implementation. Additionally, it includes precautions and results confirming successful motor operation in both clockwise and anti-clockwise directions.

Uploaded by

Sariki Santosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views36 pages

MPMC

The document outlines an experiment to control a stepper motor's rotation direction using an ARM LPC2929 board and Keil-μ vision 4 software. It details the theory behind stepper motors, the algorithm for controlling the motor, and provides a program for implementation. Additionally, it includes precautions and results confirming successful motor operation in both clockwise and anti-clockwise directions.

Uploaded by

Sariki Santosh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

EXPERIMENT – 7

STEPPER MOTOR

1) AIM: To perform the rotation of stepper motor in clockwise and anti-clockwise direction.

2) HARDWARE USED: ARM LPC2929 board, Interfacing Board and Stepper Motor.

3) SOFTWARE USED: Keil-μ vision 4.

4) THEORY:
A stepper motor or a step motor is a brushless, asynchronous motor which divides a full rotation
into a number of steps. Unlike a brushless DC motor which rotates continuously when a fixed DC
voltage is applied to it, a step motor in discrete step angles. The stepper motors therefore are
manufactured with steps per revolution of 12,24,72,144,180,200, resulting in stepping angles of
30,15,5,2.5,2 and 1.8 degrees per step. The stepper motor can be controlled with or without
feedback.

5) ALGORITHM:
Step 1: Start.
Step 2: Declare Dir as value as 0x00.
Step 3: Initialize GPIO3_OR value as 0x000000FF.
Step 4: Declare SFSP2_26 value as 0x03 << 2.
Step 5: Initialize GLCD.
Step 6: Clear GLCD.
Step 7: Set the LCD back color as blue, text color as white.
Step 8: Display first line of LCD as “GVPCOE”, second line as “ECE” and third line as
“EMBEDDED SYSTEMS LAB”.
Step 9: Set LCD back color as white and text color as blue.
Step 10: Display fourth line of LCD as “stepper motor”.
Step 11: Check the condition if condition is true, go to next step, otherwise go to
step 18.
Step 12: Check the condition “ Dir =1”. If the condition is true, go to next step
otherwise go to step 18.
Step 13: Initialize GPIO3_DR.
Step 14: Initialize “delay (50000)” function.
Step 15: Initialize variable r as random unsigned integer.
Step 16: Check the condition “x>0”; if it is true, go to next step otherwise go to step18.
Step 17: Decrement x and go to step 16.
Step 18: Return to next step.
Step 19: Initialize GPIO3_OR.
Step 20: Repeat steps from step 14 to step 18.
Step 21: Initialize GPIO3_OR.
Step 22: Repeat steps from step14 to step 18.
Step 23: Initialize GPIO3_OR.
Step 24: Repeat steps from step 14 to step 18.
Step 25: Initialize GPIO3_OR.
Step 26: Repeat steps from step 14 to step 18.
Step 27: Initialize GPIO3_OR.
Step 28: Repeat steps from step 14 to step 18.
Step 29: Initialize GPIO3_OR.
Step 30: Repeat steps from step 14 to step 18.
Step 31: Initialize GPIO3_OR.
Step 32: Repeat steps from step 14 to step 18.
Step 33: Check the condition if true go to next step otherwise go to step 41.
Step 34: Check the condition if true go to next step otherwise go to step 41.
Step 35: Initialize “direction ( )” function.
Step 36: Declare Dir =~ Dir.
Step 37: Check the condition, if true go to next step, else go to step 41.
Step 38: Display “clockwise” and go to step 41.
Step 39: Display “anti-clockwise” and go to step 41.
Step 40: Repeat steps from step 14 to step 18.
Step 41: Stop.
6) FLOW CHART:
7) PROGRAM:
#include <LPC29xx.H>
#include "GLCD.h"

static unsigned char Dir=0x00;


void delay(unsigned int x);
void Direction(void);

main()
{
/*Configure GPIO pins as Outputs */
GPIO3_DR |= 0x000000FF; /* Configure the BUTTON(S1) GPIO pin as Input with internal
pull-up */
SFSP2_26 = (0x03 << 2);

GLCD_Init (); /* GLCD initialization */


GLCD_Clear(White); /* Clear the GLCD */
GLCD_SetBackColor(Blue); /* Set the Back Color */
GLCD_SetTextColor(White); /* Set the Text Color */

GLCD_DisplayString(0, 0, 1," GVPCOE ");


GLCD_DisplayString(1, 0, 1," ECE ");
GLCD_DisplayString(2, 0, 1," EMBEDDED SYSTEMS LAB ");

GLCD_SetBackColor(White); /* Set the Back Color */


GLCD_SetTextColor(Blue); /* Set the Text Color */

GLCD_DisplayString(4, 0,1," Stepper Motor " );


GLCD_DisplayString(6, 0,1," Demo " );
GLCD_DisplayString(8, 0, 1," Anti Clockwise "); /* Display "Anti Clockwise" on LCD */

while(1)
{
if(Dir) /* Clockwise Direction */
{
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | 0x00000088;
/* Write data for clock wise direction*/
delay(50000);
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | 0x00000044;
/* Write data for clock wise direction*/
delay(50000);
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | 0x00000022;
/* Write data for clock wise direction*/
delay(50000);
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | 0x00000011;
/* Write data for clock wise direction*/
delay(50000);
}
else /* AntiClockwise Direction */
{
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | 0x00000011;
/* Write data for anticlock wise direction*/
delay(50000);
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | 0x00000022;
/* Write data for anticlock wise direction*/
delay(50000);
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | 0x00000044;
/* Write data for anticlock wise direction*/
delay(50000);
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | 0x00000088;
/* Write data for anticlock wise direction*/
delay(50000);
}

if(!(GPIO2_PINS & (1 << 26))) /* Is Button S1 Pressed ? */


{
while(!(GPIO2_PINS & (1 << 26))); /* Wait until released */
Direction(); /* Call Direction Function */
}
}
}
void delay(unsigned int x) /* Delay Routine */
{
for(;x>0;x--);
}
void Direction(void)
{
Dir = ~Dir; /* Complement the Direction */
//GLCD_Clear(White); /* Clear the GLCD */

if(Dir)
GLCD_DisplayString (8, 0, 1," Clockwise ");
/*Display "Clockwise" on LCD */
else
GLCD_DisplayString (8, 0,1, " Anti Clockwise ");
/* Display "Anti Clockwise" on LCD */
delay(50000);
}
8) ANALYSIS : The rotation of a stepper motor in clockwise and anti-clockwise directions is
controlled by altering the pulse sequence sent to its windings via a motor driver. Using a
microcontroller, the direction can be changed by reversing the step sequence, ensuring precise
motion control.
9) PRECAUTIONS:
i) Ensure that the appropriate compiler version and project settings are selected to avoid
compilation errors and unexpected behavior.
ii) Check memory usage and stack allocation to prevent overflow issues that may cause
program crashes.
iii) Do not modify project files or configurations without proper understanding, as incorrect
changes may lead to debugging difficulties.

10) RESULT: Hence, performed the rotation of stepper motor in clockwise and anti-clockwise
direction.
EXPERIMENT – 8

POTENTIOMETER

1) AIM: To perform ADC Channel testing with a rotator potentiometer on LPC2929 board.

2) HARDWARE USED: ARM LPC2929 Board, Interfacing Board.

3) SOFTWARE USED: Keil-μ vision 4.

4) THEORY:

Analog to digital converter (ADC) is a digital converter that is used to converter analog
signal/voltage into its equivalent digital number. The conversion is required so that the micro
controller can process that numbers and make it human hearable. The ADC is characterized by
resolution, which indicates the number of digital valves that can be measured. In LPC2929
microcontroller, we have in-built 10 bit ADC i.e. resolution=10 bit and maximum value = 2^10 =
1024. Digital valve lies between 0 to 1023.one of the most important term relate ADC is step size.
Step size is minimum change in input voltage which can be resolved by ADC.

5) ALGORITHM:

STEP 1: Start

STEP 2: Define the AD0_value, AD2_val as short data type.

STEP 3: Initialize num, dir, AD_val old as integer data type.

STEP 4: Initialize ADC_CLK_CONF by performing shift and or operation.

STEP 5: Initialize the base CLK in MSCSS

STEP 6: Initialize MTIMO_PR, Match registers – MR0, MR2, MCR, EMR1 and TCR.

STEP 7: Initialize ADC_CLK_CONF by performing shift and or operation.


Step 8: Initialize REQUEST_16,2, ADCO_CONFIG, ADC0_CTRL, ADC0_ENABLE,

TMO_PR, MR0, MR2, TCR, enable and TMR_CLK_CONFIG.

Step 9: Initialize the GLCD value.

Step 10: Clear the GLCD Display.

Step 11: Set the back ground color as blue.

Step 12: Set the text color as white.

Step 13: Print the ADC value.

Step 14: Display the ADC values on the LCD.

Step 15: Initialize i as zero

Step 16: Check i&lt; 12000000 condition, if condition is true go to the next step, otherwise go to

the step 25.


Step 17: Check the infinity loop condition, if condition is true, go to the next step, otherwise go to

step 25.
Step 18: Check the if condition. If condition is true, go to the next step, otherwise go to step 25.

Step 19: Set the text as blue color.

Step 20: Print the ADC values.

Step 21: Display the ADC value LCD.

Step 22: Set the text color as red.

Step 23: Represent the analog values on LCD.

Step 24: Initialize the AD value_old as AD_value .

Step 25: Increment the i value.

Step 26: Check the if condition. If condition is true, go to the next step, otherwise go to step 29.

Step 27: Initialize clock as zero.

Step 28: Stop


6) FLOW CHART:
7) PROGRAM:

#include <stdio.h>
#include <LPC29xx.H>
#include "GLCD.h" /* LCD function prototypes */

#define TMR_CLK 96000000 /* In Hz */


#define ADC0 /* Comment this part to select ADC2 */
#define AD_VALUE_MAX 0x3FF /*10 bit resolution*/
#define LED_NUM 8 /* Number of LEDs used for blinking */

const unsigned intled_mask[] = { 1 << 16, 1 << 17, 1 << 18, 1 << 19, 1 << 20, 1 << 21 , 1 << 22, 1 <<
23 };
const unsigned intbut_mask[] = { 1 << 26, 1UL << 27 };
volatile short AD0_val, AD2_val;
char text[40]; /* Import external functions from Serial.c file */

extern void init_serial (void);


extern char Speed;
extern volatile unsigned char Clock;
extern volatile unsigned char Clock1s;

/* Change LED blinking speed depending on buttons pressed */


voidchange_speed (void)
{
if (!(GPIO2_PINS &but_mask[0]))
{ /* S1 - speed up */
if (Speed > 0) Speed --;
}
if (!(GPIO2_PINS &but_mask[1]))
{ /* S2 - slow down */
if (Speed < 10) Speed ++;
}
}

int main (void)


{
inti;
intnum = 0;
intdir = 1;
intAD_valueOld = 0;
static short LEDState;

#ifdef _ ADC0
#define AD_value AD0_val
#else
#define AD_value AD2_val
#endif
Speed = 5; /* Initial speed at half */

/* Configure the BUTTON's GPIO pins as Inputs with internal pull-up */


SFSP2_26 = (0x03 << 2);
SFSP2_27 = (0x03 << 2);
GPIO2_DR &= ~(0x03UL << 26);

/* Configure the LED's GPIO pins as Outputs */


GPIO2_DR |= (0xFF << 16);

/* Configure MSCSS clock = PLL clock / 2 = 96 MHz (max allowed 125 MHz) */
MSCSS_CLK_CONF = (2UL << 24) | (1 << 11) | (1 << 2);
MTIM0_PR = (96000000/1000) - 1; /* Prescaler to drive timer with 1 ms */
MTIM0_MR0 = (10 - 1); /* Match value = 10 * 1ms = 10 ms -> ADC0*/
MTIM0_MR2 = (10 - 1); /* Match value = 10 * 1ms = 10 ms -> ADC2*/
MTIM0_MCR = (1 << 4); /* On Match 2 event reset timer */
MTIM0_EMR |= (3 << 4); /* Match 0 event generate logic 1 -> ADC0*/
MTIM0_EMR |= (3 << 8); /* Match 2 event generate logic 1 -> ADC2*/
MTIM0_TCR = 1; /* Start Timer 0 */

/* Configure ADC clock = FDIV0 / 1 = 4 MHz (max allowed 4.5 MHz) */


ADC_CLK_CONF = (5UL << 24) | (1 << 11) | (0 << 2);

/* Setup ADC2 IN0 to convert in 10-bit resolution and generate interrupt */


ADC0_CTRL = (1<<1); /* Stop ADC conversion */
SFSP0_4 = 5; /* Configure P0.4 as analog input */

/* Setup ADC0 interrupt generation */


INT_REQUEST_16 = (1 << 28) | /* Enable setting of priority level */
(1 << 27) | /* Enable setting interrupt target */
(1 << 26) | /* Write enable of new settings */
(1 << 16) | /* Enable interrupt request */
(1 << 8) | /* Interrupt target is IRQ interrupt */
(15 << 0); /* Priority level 15, disable nesting */

ADC0_ACC0 = 0x0000000A; /* Set ADC0 IN0 10-bit resolution */


ADC0_CONFIG = (1 << 14); /* ADC single scan, start on pos edge */
ADC0_CTRL = 4; /* Copy the configuration */
ADC0_INT_SET_ENABLE = 1; /* Enable end of scan interrupt */

ADC2_CTRL = (1<<1); /* Stop ADC conversion */


SFSP0_16 = 1; /* Configure P0.16 as analog input */

/* Setup ADC2 interrupt generation */


INT_REQUEST_18 = (1 << 28) | /* Enable setting of priority level */
(1 << 27) | /* Enable setting interrupt target */
(1 << 26) | /* Write enable of new settings */
(1 << 16) | /* Enable interrupt request */
(1 << 8) | /* Interrupt target is IRQ interrupt */
(15 << 0); /* Priority level 15, disable nesting */
ADC2_ACC0 = 0x0000000A; /* Set ADC2 IN0 10-bit resolution */
ADC2_CONFIG = (1 << 14); /* ADC single scan, start on pos edge */
ADC2_CTRL = 4; /* Copy the configuration */
ADC2_INT_SET_ENABLE = 1; /* Enable end of scan interrupt */

/* Configure timer clock = PLL clock / 2 = 96 MHz */


TMR_CLK_CONF = (2UL << 24) | (1 << 11) | (1 << 2);

/* Setup Timer 0 interrupt generation */


INT_REQUEST_2 = (1 << 28) | /* Enable setting of priority level */
(1 << 27) | /* Enable setting interrupt target */
(1 << 26) | /* Write enable of new settings */
(1 << 16) | /* Enable interrupt request */
(1 << 8) | /* Interrupt target is IRQ interrupt */
(15 << 0); /* Priority level 15, disable nesting */

/* Setup Timer 0 to generate interrupt every 10 ms */


TIM0_PR = (TMR_CLK /1000) - 1; /* Prescaler to drive timer with 1 ms */
TIM0_MR0 = (10 - 1); /* Match value = 10 * 1ms = 10 ms */
TIM0_MCR = 1; /* On Match 0 event reset timer */
TIM0_INT_SET_ENABLE = 1; /* Enable Match 0 to generate interrupt */
TIM0_TCR = 1; /* Start Timer 0 */

init_serial (); /* Init UART */


GLCD_Init (); /* GLCD initialization */
GLCD_Clear(White); /* Clear the GLCD */
GLCD_SetBackColor(Blue); /* Set the Back Color */
GLCD_SetTextColor(White); /* Set the Text Color */

GLCD_DisplayString(0, 0, " GVPCOE ");


GLCD_DisplayString(1, 0, " ECE ");
GLCD_DisplayString(2, 0, " EMBEDDED SYSTEMS LAB ");

GLCD_SetBackColor(White); /* Set the Back Color */


GLCD_SetTextColor(Blue); /* Set the Text Color */
sprintf(text, "AD value = 0x%04X", AD_value);
GLCD_DisplayString(4, 0, (unsigned char *)text);

for (i = 0; i< 12000000; i++); /* Wait for initial display */

for (;;)
{ /* Loop forever */
if (AD_value != AD_valueOld)
{
GLCD_SetTextColor(Blue); /* Set the Text Color */
sprintf(text, "AD value = 0x%04X", AD_value);
GLCD_DisplayString(4, 0, (unsigned char *)text);

GLCD_SetTextColor(Red);
GLCD_Bargraph (0, 120, 320, 24, AD_value);
AD_valueOld = AD_value;
}
if (Clock)
{ /* LED activate and deactivate */
Clock = 0;
LEDState ^= 0x01;
change_speed(); /* Check buttons to change LED speed */
if (LEDState)
{
GPIO2_OR |= led_mask[num]; /* Turn LED on */
}
else
{
GPIO2_OR &= ~led_mask[num]; /* Turn LED off */

/* Calculate 'num': 0,1,...,LED_NUM-1,LED_NUM-1,...,1,0,0,... */


num += dir;
if (num == LED_NUM) { dir = -1; num = LED_NUM-1; }
else if (num< 0) { dir = 1; num = 0; }
}
}
if (Clock1s)
{ /* Output AD value on UART every 1 sec*/
Clock1s = 0;
printf ("AD value = 0x%04x\n\r", AD_value);
}
}
}

8) ANALYSIS : ADC channel testing on the LPC2929 board using a rotatory potentiometer
involves varying the input voltage and reading the corresponding digital values through the ADC
module. The microcontroller converts the analog input to a digital value, which can be monitored
for calibration and signal accuracy.
9) PRECAUTIONS:
i) Ensure that the appropriate compiler version and project settings are selected to avoid
compilation errors and unexpected behavior.
ii) Check memory usage and stack allocation to prevent overflow issues that may cause
program crashes.
iii) Do not modify project files or configurations without proper understanding, as incorrect
changes may lead to debugging difficulties.

10) RESULT : ADC channel testing is done with a rotator potentiometer using LPC2929 Board.
EXPERIMENT – 9

SEVEN SEGMENT DISPLAY


1) AIM: To interface the 7 segment display to LPC2929 board and display the required contents on
7 segment display.

2) HARDWARE USED: ARM LPC2929 board, Seven Segment Display board.

3) SOFTWARE USED: Keil-μ vision 4.

4) THEORY:
Seven Segment Displays is the most common devices used for displaying digits and alphabet.
You can see the seven segment display devices in TV shows counting down to ‘0’. Use of
LEDs in seven segment displays made it more popular. The binary information can be
displayed in the form of decimal using this seven segment display. Its wide range of
applications is in microwave ovens, calculators, washing machines, radios, digital clocks etc.
The seven segment displays are made up of either LEDs or LCDs. Light emitting diode is P-N
junction diode which emits in the form of heat. These LEDs or LCDs are used to display the
required numeral or alphabet. Single seven segment or number of segments arranged in an
order meets our requirements.

5) ALGORITHM:
Step 1: Start.
Step 2: Calling and delay function.
Step 3: Declare I as unsigned long integer.
Step 4: Initialize i=0.
Step 5: Check i<15000000 condition, if true go to next step, otherwise go to step 7.
Step 6: Declare i, j, m, k, s as unsigned char.
Step 7: Initialize char display[6][4].
Step 8: Initialize GPIO2_DR 1 = 0x00010000.
Step 9: Initialize GPIO3_DE 1 = 0x0000100.
Step 10: Initialize the GLCD
Step 11: Clear the GLCD value.
Step 12: Set the GLCD back color as blue.
Step 13: Set the GLCD text color as white.
Step 14: Display GLCD first string as GVPCOE, second string as ECE, third string as EMBEDDED
SYSTEMS LAB.
Step 15: Set GLCD back color as white.
Step 16: Set GLCD text color as blue.
Step 17: Display GLCD fifth string as 7 segment display, eighth string as demo.
Step 18: Check while condition, if true go to next step otherwise go to step 34.
Step 19: Initialize i=0.
Step 20: Check i<6 condition, if true go to next step otherwise go to step 34.
Step 21: Initialize j=0.
Step 22: Check j<4 condition, if true go to next step, else step 33.
Step 23: Initialize s= display[i][j].
Step 24: Initialize k=0.
Step 25: Check k<8 condition, if true go to next step, otherwise go to step33.
Step 26: Initialize m=s.
Step 27: Perform operation on m=m&0*80.
Step 28: Check m == 0 condition, if true go to next step, otherwise go to step 30.
Step 29: GPIO3_DR = (GPIO_OR & 0xFFFFFEFF).
Step 30: Initialize the GPIO3_OR = (GPIO3_OR & 0xFFFFFEFF)|0X00000100.
Step 31: Initialize the GPIO2_OR = GPIO_OR & 0Xfffeffff.
Step 32: Initialize s << 1.
Step 33: Call the delay function.
Step 34: Stop.
6) FLOW CHART:
7) PROGRAM:
#include <LPC29xx.H>
#include "GLCD.h"

void delay(void) /* Delay routine I between the Groups*/


{
unsigned long i;
for(i=0;i<5000000;i++);
}

int main()
{
unsigned char i,j,k,m,s;
/* Look Up Table To Display */
unsigned char display[5][4]= { 0xff,0xff,0xff,0xff, 0x86,0xc7,0x86,0xc6, 0x87,0xde,0xc0,0xbf,
0x92,0x91,0x92,0xff,
0x87,0x86,0xc8,0x92 }; /* Values passed to 7 Segment */

GPIO2_DR |= 0x00010000;
GPIO3_DR |= 0x00000100; /* Configure GPIO pins as Outputs */

GLCD_Init (); /* GLCD initialization */


GLCD_Clear(White); /* Clear the GLCD */
GLCD_SetBackColor(Blue); /* Set the Back Color */
GLCD_SetTextColor(White); /* Set the Text Color */

GLCD_DisplayString(0, 0, 1," GVPCOE ");


GLCD_DisplayString(1, 0, 1," ECE ");
GLCD_DisplayString(2, 0, 1," EMBEDDED SYSTEMS LAB ");

GLCD_SetBackColor(White); /* Set the Back Color */


GLCD_SetTextColor(Blue); /* Set the Text Color */

GLCD_DisplayString(4, 0,1," 7 Segment Display " );


GLCD_DisplayString(6, 0,1," Demo " );

while(1)
{
for(i=0;i<5;i++) /*Number of Groups(5) */
{
for(j=0;j<4;j++) /* Number of LEDs(4) per Group*/
{
s = display[i][j]; /* code to Display */
for(k=0;k<8;k++) /* Number of Segments Per LED */
{
m = s;
m = m & 0x80;
if(m == 0)
/* Send Data */
GPIO3_OR = (GPIO3_OR & 0xFFFFFEFF);

else
GPIO3_OR = (GPIO3_OR & 0xFFFFFEFF) | 0x00000100;
GPIO2_OR = (GPIO2_OR & 0xFFFEFFFF) | 0x00010000; /*
Send Clock */
GPIO2_OR = (GPIO2_OR & 0xFFFEFFFF);
s <<= 1;
}
}
delay();
}

}
}

8) ANALYSIS : Interfacing a 7-segment display with the LPC2929 board involves connecting the
display to GPIO pins and controlling segment illumination via appropriate logic signals. The
microcontroller sends digit-specific signals to display the required content, either using direct pin
control or a decoder IC.

9) PRECAUTIONS:
i) Ensure that the appropriate compiler version and project settings are selected to avoid
compilation errors and unexpected behavior.
ii) Check memory usage and stack allocation to prevent overflow issues that may cause
program crashes.
iii) Do not modify project files or configurations without proper understanding, as incorrect
changes may lead to debugging difficulties.

10) RESULT: Hence performed the interface of the 7 segment display to LPC2929 board and displayed
the required contents on 7 segment display.
EXPERIMENT – 10

PWM WAVE GENERATION

1) AIM: To generate square wave or control Pulse Width Modulator using LPC 2929 board.

2) HARDWARE USED: ARM LPC2929 board, CRO.

3) SOFTWARE USED: Keil-µ vision 4 Software.

4) THEORY:
Pulse width modulation (PWM), or pulse-duration modulation (PDM), is a method of reducing the
average power delivered by an electrical signal, by effectively chopping it up into discrete parts.
The average value of voltage (and current) fed to the load is controlled by turning the switch
between supply and load on and off at a fast rate. The longer the switch is on compared to the off
periods, the higher the total power supplied to the load. Along with maximum power point
tracking (MPPT), it is one of the primary methods of reducing the output of solar panels to that
which can be utilized by a battery PWM is particularly suited for running inertial loads such as
motors, which are not as easily affected by this discrete switching, because their inertia causes them
to react slowly. The PWM switching frequency has to be high enough not to affect the load, which
is to say that the resultant waveform perceived by the load must be as smooth as possible.

5) ALGORITHM:
Step 1: Start.
Step 2: Configure GPIO pins as output.
Step 3: Initialize GLCD.
Step 4: Clear the GLCD.
Step 5: Set the back color.
Step 6: Set the text color.
Step 7: Display the string on the GLCD.
Step 8: Set the back color.
Step 9: Set the text color.
Step 10: Display the string on the GLCD.
Step 11: Loop for high amplitude.
Step 12: Delay routine.
Step 13: Loop for high amplitude.
Step 14: Delay routine.
Step 15: Stop.
6) FLOW CHART:
7) PROGRAM:
#include <LPC29xx.H>
#include "GLCD.h"
void delay(void) /* Delay Routine */
{
unsigned char i;
for(i=0;i<100;i++);
}

main()
{
unsigned char i=0,j=0;
GPIO3_DR |= 0x0000FFFF; /* Configure GPIO pins as Outputs */

GLCD_Init (); /* GLCD initialization */


GLCD_Clear(White); /* Clear the GLCD */
GLCD_SetBackColor(Blue); /* Set the Back Color */
GLCD_SetTextColor(White); /* Set the Text Color */

GLCD_DisplayString(0, 0, 1," GVPCOE ");


GLCD_DisplayString(1, 0, 1," ECE ");
GLCD_DisplayString(2, 0, 1," EMBEDDED SYSTEMS LAB ");

GLCD_SetBackColor(White); /* Set the Back Color */


GLCD_SetTextColor(Blue); /* Set the Text Color */

GLCD_DisplayString(4, 0,1," PWM DEMO" );


GLCD_DisplayString(6, 0,1," SQUARE WAVE " );

while(1)
{
for(i=0; i<0x0FF; i++)
{
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00)| 0x000000FF;
GPIO3_OR = (GPIO3_OR & 0xFFFF00FF)| 0x0000FF00;
delay();
}
for(j=0xFF; j>0; j--)
{
GPIO3_OR = (GPIO3_OR & 0xFFFF00FF) ;
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00);
delay();
}
}
}
8) ANALYSIS : Generating a square wave or controlling PWM on the LPC2929 board involves
configuring its PWM module to produce pulses with adjustable duty cycles. This is useful for
motor speed control, LED dimming, and signal generation by varying pulse width and frequency.

9) PRECAUTIONS:
i) Ensure that the appropriate compiler version and project settings are selected to avoid
compilation errors and unexpected behavior.
ii) Check memory usage and stack allocation to prevent overflow issues that may cause
program crashes.
iii) Do not modify project files or configurations without proper understanding, as incorrect
changes may lead to debugging difficulties.

10) RESULT: Hence, demonstration of PWM using LPC 2929 board is performed and observed.
EXPERIMENT -11

GLCD INTERFACING

1) AIM: To perform GLCD interfacing on LPC2929 Board.

2) HARDWARE USED: ARM LPC2929 Board.

3) SOFTWARE USED: Keil-μ vision 4.

4) THEORY:
A liquid-crystal display (LCD) is a flat-panel display or other electronically modulated optical device
that uses the light-modulating properties of liquid crystals combined with polarizers. A Graphics LCD
(GLCD) is a type of LCD display that can display both text and graphics, allowing for more flexible
and visually rich presentations compared to character LCDs. GLCDs typically use a dot matrix format,
meaning the display is composed of a grid of individual pixels (dots) that can be individually
controlled. The GLCD typically interfaces with the microcontroller using a parallel or serial
communication protocol (e.g., SPI).

5) ALGORITHM:
Step 1: Start.
Step 2: Initialize GLCD.
Step 3: Clear the previous data on the GLCD Display.
Step 4: Set the GLCD background color as blue.
Step 5: Set the GLCD text color as white.
Step 6: Display GLCD first line as “GVPCOE”
Step 7: Display GLCD second line as “ECE”
Step 8: Display GLCD third line as “SECTION-4”
Step 11: Set the GLCD background color as white.
Step 5: Set the GLCD text color as blue.

Step 8: Display GLCD 5th line as “Embedded Systems Lab”

Step 8: Display GLCD third line as “Demo”

Step 13: Stop

6) FLOW CHART:

Start

Initialize GLCD

Clear the previous data on Display

Set the GLCD background color as blue

Set the GLCD text color as white

Display “gvpcoe” ,”ECE”, “Section4”

Set the GLCD background color as white

Set the GLCD text color as blue

Display “embedded system class”, “demo”

Initialize i=0

Check false
i<12000000

true

increment ‘i’ value

stop
7) PROGRAM:
#include <LPC29xx.H>
#include "GLCD.h"
int main() /* Delay routine i between the Groups*/
{
GLCD_Init (); /* GLCD initialization */
GLCD_Clear(White); /* Clear the GLCD */

GLCD_SetBackColor(Blue); /* Set the Back Color */


GLCD_SetTextColor(White); /* Set the Text Color */

GLCD_DisplayString(0, 0, 1," GVPCOE ");


GLCD_DisplayString(1, 0, 1," ECE ");
GLCD_DisplayString(2, 0, 1," SECTION-4 ");

GLCD_SetBackColor(White); /* Set the Back Color */


GLCD_SetTextColor(Blue); /* Set the Text Color */
GLCD_DisplayString(4, 0,1," Embedded Systems lab " );
GLCD_DisplayString(6, 0,1," Demo " );

while(1)
{
}
}

8) ANALYSIS : GLCD interfacing with the LPC2929 board involves connecting the display to the
microcontroller’s GPIO or SPI interface and sending graphical data commands. Proper initialization
and control signals are required to display text, images, or patterns on the screen

9) PRECAUTIONS:
i) Ensure that the appropriate compiler version and project settings are selected to avoid
compilation errors and unexpected behavior.
ii) Check memory usage and stack allocation to prevent overflow issues that may cause
program crashes.
iii) Do not modify project files or configurations without proper understanding, as incorrect
changes may lead to debugging difficulties.

10) RESULT: GLCD Interfacing is executed and observed on LPC2929 Board.


EXPERIMENT – 12

WAVEFORM GENERATION WITH DAC


1) AIM: To control Digital to Analog Converter (DAC) using LPC 2929 board.

2) HARDWARE USED: ARM LPC2929 board, DAC driver, CRO.

3) SOFTWARE USED: Keil-µ vision 4 Software.

4) THEORY:
In electronics, a digital-to-analog converter (DAC, D/A, D2A, or D-to-A) is a system that converts
a digital signal into an analog signal. An analog-to-digital converter (ADC) performs the reverse
function. There are several DAC architectures; the suitability of a DAC for a particular application
is determined by figures of merit including: resolution, maximum sampling frequency and others.
Digital-to-analog conversion can degrade a signal, so a DAC should be specified that has
insignificant errors in terms of the application. DACs are commonly used in music players to
convert digital data streams into analog audio signals. They are also used in televisions and mobile
phones to convert digital video data into analog video signals. These two applications use DACs at
opposite ends of the frequency/resolution trade-off. The audio DAC is a low-frequency, high-
resolution type while the video DAC is a high-frequency low- to medium-resolution type.

5) ALGORITHM:
Step 1: Start.
Step 2: Configure GPIO pins as output.
Step 3: Initialize GLCD.
Step 4: Clear the GLCD.
Step 5: Set the back color.
Step 6: Set the text color.
Step 7: Display the string on the GLCD.
Step 8: Set the back color.
Step 9: Set the text color.
Step 10: Display the string on the GLCD.
Step 11: Loop for high amplitude.
Step 12: Delay routine.
Step 13: Loop for high amplitude.
Step 14: Delay routine.
Step 15: Stop.

6) FLOW CHART:
7) PROGRAM:
#include <LPC29xx.H>
#include "GLCD.h"
void delay(void) /* Delay Routine */
{
unsigned char i;
for(i=0;i<100;i++);
}
main()
{
unsignedinti,j;
GPIO3_DR |= 0x0000FFFF; /* Configure GPIO pins as Outputs */

GLCD_Init (); /* GLCD initialization */


GLCD_Clear(White); /* Clear the GLCD */
GLCD_SetBackColor(Blue); /* Set the Back Color */
GLCD_SetTextColor(White); /* Set the Text Color */

GLCD_DisplayString(0, 0, 1," GVPCOE ");


GLCD_DisplayString(1, 0, 1," ECE ");
GLCD_DisplayString(2, 0, 1," EMBEDDED SYSTEMS LAB ");

GLCD_SetBackColor(White); /* Set the Back Color */


GLCD_SetTextColor(Blue); /* Set the Text Color */
GLCD_DisplayString(4, 0,1," DUAL DAC DEMO " );
/* Display Triangular Wave on LCD */
GLCD_DisplayString(6, 0,1," TRIANGULAR WAVE" );
while(1)
{
for(i=0; i<0x0FF; i++)
{
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00)| i;
GPIO3_OR = (GPIO3_OR & 0xFFFF00FF) | (i<< 8);
delay();
}
for(j=0x0FF; j>0; j--)
{
GPIO3_OR = (GPIO3_OR & 0xFFFF00FF) | (j << 8);
GPIO3_OR = (GPIO3_OR & 0xFFFFFF00) | j;
delay();
}
}
}
8) ANALYSIS : GLCD interfacing with the LPC2929 board involves connecting the display to the
microcontroller’s GPIO or SPI interface and sending graphical data commands. Proper
initialization and control signals are required to display text, images, or patterns on the screen.

9) PRECAUTIONS:
i) Ensure that the appropriate compiler version and project settings are selected to avoid
compilation errors and unexpected behavior.
ii) Check memory usage and stack allocation to prevent overflow issues that may cause
program crashes.
iii) Do not modify project files or configurations without proper understanding, as incorrect
changes may lead to debugging difficulties.

10) RESULT: Hence, Control Digital to Analog Convertor (DAC) using LPC2929 board is performed

and performed and observed.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy