lab 1 edit

14
POLYTECHNIC of TUANKU SULTANAH BAHIYAH ELECTRICAL ENGINEERING DEPARTMENT EC 501 EMBEDDED SYSTEM APPLICATION EXPERIMENT 1 TITLE CIRCUIT SIMULATION OBJECTIVES And the end of this lab session, the student should be able to: 1. Know simulation environment in simulation software using ISIS. 2. Understand the method to test the design using software simulation software using ISIS. MATERIAL AND APPARATUS Personal Computer/Labotary computer with ISIS 6 Professional and MPLAB THEORY For the PROTEUS VSM , we use programs ISIS and MPLAB.It’s an interactive simulation and fun to use.This program combines mixed mode circuit simulation , microprocessor model , PIC and all interactive components model that we known in Electrical.For this program , we allowed to run simulation of complete micro-controllerbased design. The a architecture in ISIS is real things and it’s same with real time product.It’s simulation and system can be used before we make a real thing.We also can managing the object or the device that we need to use in project in ISIS.We run it’s first , if everything is can be run , then we can continud with our real project. In addition, a number of graph objects can be placed on the schematic to enable conventional time, frequency and swept variable simulation to be performed. For the MPLAB , we can edit the source code that what we need.We just write the code that we need for PIC before put it into PIC in ISIS. PROCEDURE: PART 1: Creating new project in ISIS 1. Before we start,we click on the Start Button and then Select Programs in Windows, Proteus 6 Professional, and ISIS 6 Professional option. 1/10

description

asdasd

Transcript of lab 1 edit

Page 1: lab 1 edit

POLYTECHNIC of TUANKU SULTANAH BAHIYAH ELECTRICAL ENGINEERING DEPARTMENT

EC 501 EMBEDDED SYSTEM APPLICATION

EXPERIMENT 1

TITLE CIRCUIT SIMULATION

OBJECTIVES And the end of this lab session, the student should be able to:1. Know simulation environment in simulation software using ISIS.2. Understand the method to test the design using software simulation software

using ISIS.

MATERIAL AND APPARATUS

Personal Computer/Labotary computer with ISIS 6 Professional and MPLAB

THEORY For the PROTEUS VSM , we use programs ISIS and MPLAB.It’s an interactive simulation and fun to use.This program combines mixed mode circuit simulation , microprocessor model , PIC and all interactive components model that we known in Electrical.For this program , we allowed to run simulation of complete micro-controllerbased design. The a architecture in ISIS is real things and it’s same with real time product.It’s simulation and system can be used before we make a real thing.We also can managing the object or the device that we need to use in project in ISIS.We run it’s first , if everything is can be run , then we can continud with our real project. In addition, a number of graph objects can be placed on the schematic to enable conventional time, frequency and swept variable simulation to be performed.For the MPLAB , we can edit the source code that what we need.We just write the code that we need for PIC before put it into PIC in ISIS.

PROCEDURE:

PART 1: Creating new project in ISIS1. Before we start,we click on the Start Button and then Select Programs in Windows, Proteus 6

Professional, and ISIS 6 Professional option.

Figure 1.1: ISIS main interface.

1/10

Page 2: lab 1 edit

POLYTECHNIC of TUANKU SULTANAH BAHIYAH ELECTRICAL ENGINEERING DEPARTMENT

EC 501 EMBEDDED SYSTEM APPLICATION

For largest area of the screen is called the Editing Window.It acts as a window on the drawing – this is where the components will place and wire up. We adjust the area of the drawing displayed in the Editing Window in a number of ways.

• To simply ‘pan’ the editing Window up, down, left or right, position the mouse pointer over the desired part of the Editing Window and we press the F5 key.

• We hold the SHIFT key down and bump the mouse against the edges of the Editing Window to pan up, down, left or right. We call this Shift Pan.

o If we want to move the Editing Window to a completely different part of the drawing, the quickest method is to simply point at the centre of the new area on the Overview Window and click left. We also can use the Pan icon on the toolbar.

To adjust the scale the drawing is displayed at in the Editing Window we • Point with the mouse where we want to zoom in or out and also we can press the F6 or

F7 keys respectively or else scroll the mouse wheel.• We press the F8 key to display the whole drawing• For Shift Zoom , we hold the SHIFT key down and drag out a box around the area we

want to zoom in.• We aslo can use the Zoom In, Zoom Out, Zoom Full or Zoom Area icons on the toolbar.

Part 2: Picking Devices from the library.

1. Firstly , we begin with pointing at the P button at the top left of the Object Selector and clicking left.

Figure 1.2: Pick Devices Window

2. After that , Device Library Selector Dialogue form has been appeared and then we select devices from the various device libraries. There are number of selectors labeled Objects, Libraries, Extension and a Browser, not all of which may be shown.

2/10

Page 3: lab 1 edit

POLYTECHNIC of TUANKU SULTANAH BAHIYAH ELECTRICAL ENGINEERING DEPARTMENT

EC 501 EMBEDDED SYSTEM APPLICATION

3. And than , we double click on each part from the Parts selector to select each part. The devices that we have picked, appeared in the Object Selector.

Part 3: Circuit Construction & AssemblyAfter that, we continued with part 3 , prior to circuit construction, we firstly identify the necessary components required in the circuit. For example, we execute an 8-bit running light, the components needed are:

i. PIC16F877 ii. LED iii. Resistor iv. Capacitorv. Power Supply Terminals / Grounding

The final circuit diagram that we contstructed look like the figure below.

Figure 1.3: Circuit to be drawn in Protues.

3.1Selecting Componentsa. For choosing the components, we click on Library > Pick Device/Symbol or just press “P”.

3/10

Page 4: lab 1 edit

POLYTECHNIC of TUANKU SULTANAH BAHIYAH ELECTRICAL ENGINEERING DEPARTMENT

EC 501 EMBEDDED SYSTEM APPLICATION

Parts Keywords in “Pick Devices” Window

PIC16F877 PIC16F877

LED LED-BIBY

Resistor RESISTOR

Capacitor CAPACITOR

Button BUTTONb. For the selected component can be located on the left side window of the design diagram.c. And then , To put the component to the design sheet,we just left click the component and

put it to the sheet.d. If we want to move the components,we just simply right click on the component (the

component will be red-lighted), and left click and drag the component to the desired location.

e. For power terminal and ground, the component is NOT selected from the library. We just select the “inter-sheet terminal” icon at the left-side toolbar.

Figure 1.4: Inter-sheet Terminal

f. We just select POWER for our Vcc and GROUND as ground.

3.2 Component Parameter Settingsa. For our experiment , each component that we used need to be set according to the

specifications. For example the resistor or capacitor value need to define before any simulation can be done.

b. We just edit the component, we select the component (right-click) and left-click to open the Edit Component dialog.

c. The dialog for the device that we use is different. Figure below shows the Edit Component Dialog of a resistor.

4/10

Page 5: lab 1 edit

POLYTECHNIC of TUANKU SULTANAH BAHIYAH ELECTRICAL ENGINEERING DEPARTMENT

EC 501 EMBEDDED SYSTEM APPLICATION

d. After dialog appeared , we set the resister value in the resistance box.

3.2 PIC16F877 Parameter Settings

a. This is the most important part of Proteus simulation , setting up the microcontroller.We must configure it correctly to cross out any setting error in time for program simulation.

b. We must edit the parameter for PIC,we just right click on the PIC to select the component and then left-click.

c. After that Edit Component dialog will pop up. In this dialog,there are two things that need to be set :

5/10

Page 6: lab 1 edit

POLYTECHNIC of TUANKU SULTANAH BAHIYAH ELECTRICAL ENGINEERING DEPARTMENT

EC 501 EMBEDDED SYSTEM APPLICATION

• Program File :• Our program’s hex file location• Processor Clock Frequency :• The oscillator frequency that we used

d. If we want to load program file, we must create the hex file for the pic16f877 using MPLAB. There are the following steps that we used to create it.

i) Open MPLAB IDE v8.85, Choose File > New. Untitled file will be open. ii) Open this directory C:\Program Files\Microchip\MPASM

Suite\Template\Code, Double Click on 16F877TEMP will be open

iii) And than, the Code will pop ups , we just select all the template source code using Ctrl-A, and then Copy and Paste in the untitled file in the MPLAB.

iv) After Copy and Paste the code , we starting writing the source code after the words “main”. We just write the given source code.

Banksel TRISB ; selects bank containing TRISB

6/10

Page 7: lab 1 edit

POLYTECHNIC of TUANKU SULTANAH BAHIYAH ELECTRICAL ENGINEERING DEPARTMENT

EC 501 EMBEDDED SYSTEM APPLICATION

Clrf TRISB ; All port B pins are configured as outputsBanksel PORTB ; selects bank containing PORTB Movlw B’01010101’ ; moves number 01010101 to WMovwf PORTB ; moves number 01010101 from W to PORTB

(When switching on (We do it in PROTEUS), every other LED diode on the Port B emits light (RB0, RB2, RB4, RB6 – will emits light. That is enough to indicate that the microcontroller is properly connected and operates normally)

v) After write the code , we save the untitled file (e.g. Lab 1); First we must make our own folder (e.g. Haruan)on the dekstop.We save the code as Assembly Source Files (.asm)

vi) After we save the document, the below screen will be displayed

vii)We must make sure that we open the same note that we write before viii) After that , we need to compile the source code. We just press the button F10. If there is no error, BUILD SUCCEEDED will appear at the output window. That means the Hex file is

7/10

Page 8: lab 1 edit

POLYTECHNIC of TUANKU SULTANAH BAHIYAH ELECTRICAL ENGINEERING DEPARTMENT

EC 501 EMBEDDED SYSTEM APPLICATION

successfully created.After that , we check at the directory whether the HEX file is there or not.

ix) And then compile , we open back our experiment , and we just open the dialog box for our PIC16F877.

x) Lastly , the HEX file that we created is ready to load to the PIC16F877. From the Edit Component menu, click the and then browse for the HEX file created before (Lab1.HEX).

8/10

Page 9: lab 1 edit

POLYTECHNIC of TUANKU SULTANAH BAHIYAH ELECTRICAL ENGINEERING DEPARTMENT

EC 501 EMBEDDED SYSTEM APPLICATION

Part 4: Simulation

For the last step , after we complete the circuit assembly and configuration, we should verify whether the source code compiled is virtually accurate or not.To start simulation, we just press the play button at the bottom toolbar.

The final result is LED will ON. When the button is pressed, LEDs OFF.We stop the simulation by pressing the stop button or press ESC.Result :

9/10

Page 10: lab 1 edit

POLYTECHNIC of TUANKU SULTANAH BAHIYAH ELECTRICAL ENGINEERING DEPARTMENT

EC 501 EMBEDDED SYSTEM APPLICATION

Question :a. Which LED is lit when you RUN the simulations.

D1,D3,D5 and D7.

Discussion :

For this experiment , first of all there is very complicated for our first time in ISIS.We must known the components that we want to use.Before start the experiment , our lecturer give a siple project that use use Source and LED.We must make the LED ON.Firstly , we select the Vcc as our source ,switch and LED RED from directory.And then we constructed.It’s very simple thing so it’s run smoothly.And then our lecturer ask us to put motor in our simple project.It’s also can run but after lecturer ask us to make two LED , one motor , one power and one button.When the button is click , the LED is nothing happen, it just keep ON.In that project , we find it’s to difficult so we keep trying until it’s can run.

After the simple project , we continued with our real experiment ; Lab 1.First of all , we must constructed the circuit as diagram given.The most difficult job is to find the PIC.Because in directory , there is to many device so we must click one-by-one to find our components.After found the PIC folder , there is to many type of PIC.We must must find PIC16F877.After found the PIC , we right click and put it in our directory.And then we continued find the other component such as LED , switch button , transistor and LED.There is many color of LED ; Red , Blue , Green and Yellow.So we pick all of them to make it more fun.After all components are found , include Ground and Power , we continued constructed the diagram.

10/10

Page 11: lab 1 edit

POLYTECHNIC of TUANKU SULTANAH BAHIYAH ELECTRICAL ENGINEERING DEPARTMENT

EC 501 EMBEDDED SYSTEM APPLICATION

After finish build the diagram , we must edit the parameter for our components such as our Resistor need to use 10k ohm and 220 ohm.At the components , we right click and left click to open it’s dialog box.At there we can change resistor value according what we need.After that , for the Vcc , in the diagram , it’s says that need 9V but our lecturer told to ignore the information.

After finish edit the diagram , now the most fun and difficult part.We must make source code for PIC. We must find the PIC source code before we can edit.To open the PIC File , :\Program Files\Microchip\MPASM Suite\Template\Code, and double click at PIC16877TEMP. After the codes pop ups , we just select all and copy and paste the code into the file that we create before that in MPLAB.In Embedded , we use two different programs ; ISIS and MPLAB.In ISIS , we can build the diagram , in the MPLAB , we can edit the source code for our PIC.

After copy and paste the code , we start writing a source code after the words main.The code you can see in our procedure.After finish writing the code , we compile the code.We just press the F10.First we compile the code , the build is error.And then we open back the code and search the mistake.After found it , it just semicolon is missing.In making coding , you lost one semicolon , your source code will be ruined.After repair the code , we make a new folder at the desktop , and named it as HARUAN.We save the file under the name LAB1.asm.Why me must use .asm? This is because we use Assembly Language for our code.After we compile , the LAB1.hex file should be appeared in our folder HARUAN.

After finish for our coding , we open back ISIS , and need to put the source code in PIC.At the PIC ,we open its directory and browse the file LAB1.hex.After click OK , the simulation can run smoothly .For the result , only LED 2,4,6,8 are ON.This is because if we look at our source code , we use 01010101.It’s binary so it’s mean LED number 2,4,6,8.After finish and print screen the result , we try change the code.We put 11111111 , and the result that appeared are all LED are ON.This is because 1 means HIGH , and 0 means LOW.Our experiment and simulation succed.

Conclusion :

For this conclusion, we know the simulation environment in simulation software using ISIS. After that, we must understand the method to test the design using software simulation software using ISIS. Then,we must know how tu use the personal computer with ISIS 6 Professional and MPLAB.

11/10