23
Mechanical Engineering Professional Skills Stage 2 Mechatronics - Lab Notes University of Newcastle upon Tyne, School of Mechanical & Systems Engineering Stage 2 Mechatronics - Lab Notes 1

Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

  • Upload
    others

  • View
    6

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Stage 2 Mechatronics - Lab Notes

1

Page 2: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

Overview

2

Shunts

Wire Jumpers ICD2 ProgrammerU

SB (f

or p

rogr

amm

ing)

Serial [RS232] (for communication)

Do not connect unlessprogramming.

Page 3: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

Starting with an existing projectMPLAB IDE - Stage2MechLab

3

Open the Stage2MechLab project file (on the D: or E: drive).If MPLAB complains about write permission at this point, just click cancel.Use ‘Save Project As...’ to save the project to a folder on your H: drive.

Page 4: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

MPLAB IDE - Choosing the Programmer

4

Once the compiler has created the binary program, this needs to be transferred to the PIC.One tool for doing this is the MPLAB ICD 2 which can connect to the computer via USB.

Page 5: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

MPLAB IDE - Configuring the ICD2

5

Before continuing, check the settings.MPLAB may start the Wizard automatically. If so:• choose USB as the connection method• power is supplied to the device, not the ICD2, and• leave everything else as the default.

It is best if MPLAB does not connect automatically to the ICD 2 programmer.

Page 6: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

MPLAB IDE - Configuring the ICD2

6

Page 7: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

MPLAB IDE - Connecting to the ICD2

7

Since the MPLAB does not connect automatically to the ICD 2 programmer, we need to connect via the menu. Do this before programming the PIC, but only after connecting the ICD2 to the mechatronics board.If MPLAB starts to download an operating system, that’s okay. (Check that ‘PIC16F917’ is shown at the bottom of the MPLAB window; if not, follow the instructions at the end of this document.)

Page 8: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

MPLAB IDE - Successful Connection to ICD2

8

Page 9: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

MPLAB IDE - Stage2MechLab - Compiling

9

Page 10: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

MPLAB IDE - Stage2MechLab - Compiling

10

Page 11: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

MPLAB IDE - Programming the PIC

11

Page 12: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

MPLAB IDE - Programming the PIC

12

Carefully disconnect the ICD2 programmer from the Mechatronics board, and the program will start.

Page 13: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

putty - Starting the ApplicationPuTTY - Connecting via the serial port

13

Page 14: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

Step 1: Configuration - Connection - SerialPuTTY - Connecting via the serial port

14

Page 15: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

Step 2: Configuration - Session - LoggingPuTTY - Connecting via the serial port

15

PuTTY is a very useful program for communicating between computers, which may be connected over the internet or directly by a cable (as in this case).

The communication can be ‘logged’ (saved to a file); this is done automatically, so there is no need to press a save button.

You can choose where to save the session; the default is ‘putty.log’ in the same folder as the PuTTY program.

Page 16: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

Step 3: Configuration - SessionPuTTY - Connecting via the serial port

16

Page 17: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

Step 1: File - Open...Excel: Importing the session log

17

Page 18: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

Step 2: Text ImportExcel: Importing the session log

18

Page 19: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

Step 3: Text ImportExcel: Importing the session log

19

Page 20: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

General Notes

20

Page 21: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

MPLAB IDE - Creating a new project

21

Page 22: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

MPLAB IDE - Selecting the Chip (PIC)

22

The C code needs to be compiled into a binary form that the PIC microchip can understand.Since the C code does not define anything about the hardware, the compiler needs to know what PIC (‘device’) the final binary program will execute on.

Page 23: Stage 2 Mechatronics - Lab Notes - Newcastle University · Stage 2 Mechatronics - Lab Notes Step 2: Configuration - Session - Logging PuTTY - Connecting via the serial port 15 PuTTY

Uni

vers

ity o

f New

cast

le u

pon

Tyne

, Sch

ool o

f Mec

hani

cal &

Sys

tem

s Eng

inee

ring

Mec

hani

cal E

ngin

eeri

ng P

rofe

ssio

nal S

kills

Stage 2 Mechatronics - Lab Notes

MPLAB IDE - Selecting the Chip (PIC)

23