Starting from:

$35

EE2016- Lab 4: ARM C-Interfacing - Emulation of Switch LED and Stepper Motor Control Solved

1           Aim
Using C-interfacing, use C-programming, to implement the following tasks:

(i)         Read the status (binary position) of the switch and use the LEDs (8 LEDs are provided) to display the status ofeach of the 8-bit DIP switch

(ii)       Stepper motor control using Vi Microsystem’s ViARM 7238 development board. Due to ongoing pandemic, onlyemulated version of this experiment is intended here.

2           Equipments, Hardwares / Softwares Required
The list of equipments, components required are:

1.        ARM ViARM 2378 development board and accessaries

2.        RS-232 cable

3.        Keil microvision 5

4.        USB- serial converter (this is a must when the PC loaded with keil doesnt have a serial port).

5.        ash magic

6.        Burn o-mat

7.        Stepper motor

The hardware components are given here just not to loose the context of the experiment. Otherwise it is a purely emulation based experiment (due to the ongoing pandemic).

3           Background Information
In this Section we would discuss the following background information which are very much essential to do the above experiment

1.    ViARM-2378 Development Board

2.    LED Interfacing in LPC 2378 ARM processor

3.    Stepper motor control by LPC 2378 ARM processor

4.    Demo programs (which could be used to understand and write the code for the tasks de ned at the end).

3.1           ViARM-2378 development board - Anatomy
 

ViARM-2378 Development Board Parts Details

 

1.       NXP LPC2378 Micro controller (TQFP-144 Packaging).

2.       Power supply section.

3.       UART.

4.       CAN Port.

5.       Stepper Motor.

6.       Relay.

7.       USB 2.0 Device Connector.

8.       10/100 Base T Ethernet Connector.

9.       PS2- Keyboard connector.

10.   Stereo Jack for USB Audio Device.

11.   Prog/Exec Switch.

12.   Joystick.

13.   TFT LCD.

14.   4 x 4 Matrix Keypad.

15.   8 Way DIP switch.

16.   LED.

17.   SD Card Socket.

18.   Analog input Trimmer.

19.   128 x 64 Pixels Graphics LCD.

20.   Jtag Connector.

21.   ADC, DAC and PWM Expansion slot.

22.   50Pin Expansion Header.

23.   J-Trace.

24.   Seven Segment Display.

25.   Serial EEPROM.

26.   Speaker.

27.   Temperature Sensor

3.2           LEDs ans DIP switches in ARM-2378
LEDs and DIP switches are most common in development boards.

3.2.1         LEDs

Light Emitting Diodes are the most commonly used components usually for displaying Pin’s digital state. ViARM-2378 has 8 LED’s that are connected to the microcontroller port line. One has to close the jumper J38 to use LEDs.

 

Used port lines:                LED0 - LED7 : P3.0 - P3.7

3.2.2        Switches

Switches are devices that have two positions - ON and OFF, which have a toggle to establish or break a connection between two contacts. The ViARM-2378 development board has one 8-way Dip switch.

 

Used port lines:               SW0 - SW7 : P4.0 - P4.7

3.3           Stepper Motor
A stepper motor simply rotates by a            xed angle when the voltage is applied.

A stepper motor is a brushless electric DC motor with a large number of poles (on both rotor and stator), such that a full rotation is divided into a number of equal steps. The motor’s position can then be commanded to move and hold at one of these steps without any position sensor for feedback (an open-loop controller), as long as the motor is carefully sized to the application in respect to torque and speed.

 

Stepper motors e ectively have multiple "toothed" electromagnets arranged around a central gear-shaped piece of iron. The electromagnets are energized by an external driver circuit or a micro controller. To make the motor shaft turn, rst, one electromagnet is given power, which magnetically attracts the gear’s teeth. When the gear’s teeth are aligned to the rst electromagnet, they are slightly o set from the next electromagnet. This means that when the next electromagnet is turned on and the rst is turned o , the gear rotates slightly to align with the next one. From there the process is repeated. Each of those rotations is called a "step", with an integer number of steps making a full rotation. In that way, the motor can be turned by a precise angle.

 

The circular arrangement of electromagnets is divided into groups, each group called a phase, and there is an equal number of electromagnets per group. The number of groups is chosen by the designer of the stepper motor. The electromagnets of each group are interleaved with the electromagnets of other groups to form a uniform pattern of arrangement. For example, if the stepper motor has two groups identi ed as A or B, and ten electromagnets in total, then the grouping pattern would be ABABABABAB.

 

Electromagnets within the same group are all energized together. Because of this, stepper motors with more phases typically have more wires (or leads) to control the motor.

3.3.1          Used Port lines

P3.24 & P3.26

3.3.2                Stepper Motor Driver in ViARM-2378

In the ViARM-2378 development board, there are many peripherals and stepper motor driver is one of them. The stepper motor driver itself is a peripheral interface controller (PIC - as mentioned in the class). The connection diagram for the IC (which is incorporated in ViARM-2378 development board) is given below. One of the main function of the driver is to map the input control digital signals from the ARM2378 into controlling power signal to the motor.

 

3.3.3           Jumper Position

 

Closed 1 & 2 - Internal voltage for stepper motor

Closed 2 and 3 - External voltage for stepper motor

3.4           Demo Programs
These programs are presented here to enable the students write their own program independently, given an engineering problem of similar type.

3.4.1             DIP Switch & LEDs

<generate .png       le of the .c     le>

3.4.2            Stepper Motor Control

The demo program (StpprMtrCntrl.c) is uploaded in the moodle, controls the stepper motor (angle to which it has to be turned etc).

/* ARM C program to run Stepper Motor */

#include "LPC23xx.h" void delay(void)

{ int i,j; for(i=0; i<0xff;i++) for(j=0; j<0XFF;j++);

} int main(void)

       {                IODIR0 = 0XFFFFFFFF;

while(1)

{ IOPIN0=0X00000280; delay();

IOPIN0=0X00000180; delay();

IOPIN0=0X00000140; delay();

IOPIN0=0X00000240; delay();

}

return 0;

}

4           Problem De nitions
Following are the tasks you need to take up for this lab session:

1.    Write a program (in C) to dis-assemble a byte into two nibbles from the DIP switch states, multiply and display theproduct in the LED.

2.    Modify the demo code (StpprMtrCntrl.c) supplied to demonstrate the control of stepper motor to rotate in oppositedirection.

(a) Identify the signal to the stepper motor and demonstrate it to your TA.

5           Procedure
Stepper Control

1.    Write a C program, which could control the stepper motor

2.    Edit the above program le in Keil software. In Keil software one can edit, recompile and run etc. Compile it in Keil platform

3.    Connect the serial cable from ViARM 2378 and PC

4.    Dump it in ViARM 2378

5.    Connect the stepper motor [Lab sta s / TAs would have done all these including jumper wire settings, so that youneed not worry about these].

6.    Run the program on the development kit by resetting the ViARM-2378.

For emulation you only need to do the following:

1.    Write a C program, which could control the stepper motor

2.    Edit the above program le in Keil software. In Keil software one can edit, recompile and run etc. Compile it in Keil platform

3.    Identify the (digital) signal and demonstrate it to the TA

6           Results
1.    Run the program and ask the TA to see the output

2.    Take a snapshot using your mobile and make a report

More products