Docsity
Docsity

Prepare-se para as provas
Prepare-se para as provas

Estude fácil! Tem muito documento disponível na Docsity


Ganhe pontos para baixar
Ganhe pontos para baixar

Ganhe pontos ajudando outros esrudantes ou compre um plano Premium


Guias e Dicas
Guias e Dicas

Robótica com microcontroadores, Manuais, Projetos, Pesquisas de Engenharia Eletrônica

Experiências de robótica utilizando microcontroladores

Tipologia: Manuais, Projetos, Pesquisas

2020

Compartilhado em 09/04/2020

ederson-batista-berti-7
ederson-batista-berti-7 🇧🇷

4.8

(5)

5 documentos

1 / 88

Toggle sidebar

Esta página não é visível na pré-visualização

Não perca as partes importantes!

bg1
Robotics experiment with PIC microcontrollerl1
Robotics experiment with
PIC microcontroller
based-on Robo-PICA robot kit
3rd Edition
(C) Innovative Experiment Co.,Ltd.
INNOVATIVE EXPERIMENT
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38
pf39
pf3a
pf3b
pf3c
pf3d
pf3e
pf3f
pf40
pf41
pf42
pf43
pf44
pf45
pf46
pf47
pf48
pf49
pf4a
pf4b
pf4c
pf4d
pf4e
pf4f
pf50
pf51
pf52
pf53
pf54
pf55
pf56
pf57
pf58

Pré-visualização parcial do texto

Baixe Robótica com microcontroadores e outras Manuais, Projetos, Pesquisas em PDF para Engenharia Eletrônica, somente na Docsity!

Robotics experiment with PIC microcontroller l 1

Robotics experiment with

PIC microcontroller

based-on Robo-PICA robot kit

3rd Edition

(C) Innovative Experiment Co.,Ltd.

INNOVATIVE EXPERIMENT

2 l Robotics experiment with PIC microcontroller

Contents

Chapter 1 Part list of Robo-PICA and Introduce software tools...............
1.1 Robo-PICA part list
1.2 Hand tools for making robot kit
1.3 Software development tools for Robot programming
Chapter 2 RBX-877V2.0 Robot Controller board...................................
2.1 Technical features
2.2 Circuit description
Activity 1 : Write programs for testing RBX-877 V2.0 Controller board
Chapter 3 Building Robo-PICA kit..............................................................
Activity 2 : Make the Robo-PICA
Chapter 4 Simple robot ’s programming control...................................
Activity 3 : Simple movement control
Activity 4 : Speed control of Robo-PICA
Chapter 5 Contactless object detection...............................................
5.1 PIC16F8875s A/D converter
5.2 ADC register
5.3 ADC configuration
5.4 A/D Conversion procedure
5.5 GP2D120 : 4 to 30cm. Infrared distance sensor
Activity 5 : Reading the Analog signal
Activity 6 : Testing GP2D
Activity 7 : Contactless object detection robot

4 l Robotics experiment with PIC microcontroller

Robotics experiment with PIC microcontroller l 5

Chapter 1

Part list of Robo-PICA and

Introduce software tool

1.1 Robo-PICA part list

There are 2 groups :
1.1.1 Mechanical parts
1.1.2 Electronic parts

1.1.1 Mechanical parts

Motor Gearbox – Uses a 4.5V (9V max.) and 180 mA DC motor with a ratio of 48:1; torque 4kg/cm; comes with the mounting.

Many sizes of Screw and Nut (Screw : 3x6mm.,3x10mm., 3x15mm.,3x25mm. and 3x35mm., 3mm. nuts), Flat head screws and Thumb screws. Set of Plastic Spacers (length : 3mm., 15mm. and 25 mm.) Hex Standoffs : 3x30mm.

Track wheel set - includes 3- lengths of Track wheel, many support wheels and sprockets, axels and shaft bases

The Plate set and 4-types of the color-mixed Plastic Joiner (10 of Straight Joiner, 10 of Right-angle Joiner, 10 of Obtuse Joiner and 3/5/12 Holes straight joiners)

Robotics experiment with PIC microcontroller l 7

1.3 Software development tools for Robot programming

The RoboPICA kit uses the PIC Micrcontroller PIC16F887. Builders can write the controlled program in assembly, BASIC and C language. Only BASIC and C program language requires the use of a compiler software.

However in this kit all examples are in C language with mikroC compiler from mikroElektronika (mikroE : www.mikroe.com). The Robo-PICA robot kit can use this com- piler as well.

The demo version of Mikro C compiler is used for this robot kit. Builders who need to develop the advance program will need to purchase the full version from MikroE at their webiste. The demo version of mikroC can be downloaded from http:// www.mikroe.com. However in the Robo-PICA robot kit, this software is in the bundled CD-ROM. You must download the mikroC manual latest version from mikroElektronika website. This building manual does not describe all the instructions.

Another one tools is PIC microcontroller programmer software. The Robo-PICA provides a USB programmer. Its function is compatible Microchip’s PICkit2TM^ program- mer. The software can use PICkit2 TM^ programming software. Free downlaod the latest version at www.microchip.com.

1.3.1 mikroC Compiler (Demo version)

1.3.1.1 Overview

mikroC is a powerful, feature rich development tool for PICmicros. It is designed to provide the customer with the easiest possible solution for developing applications for embedded systems, without compromising performance or control.

mikroC provides a successful match featuring highly advanced IDE, ANSI com- pliant compiler, broad set of hardware libraries, comprehensive documentation, and plenty of ready-to-run examples.

mikroC allows you to quickly develop and deploy complex applications: l Write your C source code using the highly advanced Code Editor l Use the included mikroC libraries to dramatically speed up the development: data acquisition, memory, displays, conversions, communications…

Special thanks : All information about mikroC Compiler and PICkit2 Programming software are referenced from owner website and documentation (www.mikroe.com and www.microchip.com). Thanks for all free and open-source developement tools. User who need the full features of mikroC compiler can purchase on-line at www.mikroe.com.

8 l Robotics experiment with PIC microcontroller

l Monitor your program structure, variables, and functions in the Code Explorer. Generate commented, human-readable assembly, and standard HEX com- patible with all programmers.

l Inspect program flow and debug executable logic with the integrated Debugger. Get detailed reports and graphs on code statistics, assembly listing, calling tree…

l mikroE have provided plenty of examples for you to expand, develop, and use as building bricks in your projects.

l In Demo version, hex output is limited to 2k of program words.

1.3.1.2 Installation the mikroC compiler Demo version

Download the latest version from mikroElektronika website; www.mikroe.com. Run the installation file. Addition, you must download the 5 of necessary documentation files about compiler manual, Creating First Project in mikroC for PIC, Quick Reference Guide for C language, Compilers IDE document and Obtaining and Activating the Li- cense Key.

You can see all C syntax and all function details from the mikroC manual. In this manual would be describe about the robot activities only.

1.3.2 PICkit2 TM^ Programming Software

The PICkit™ 2 Microcontroller Programming software is capable of programming most of Microchip’s Flash microcontrollers. For specific products supported, see the README file or check with Microchip’s website.

The full featured Windows programming interface supports baseline (PIC10F, PIC12F5xx, PIC16F5xx), midrange (PIC12F6xx, PIC16F), PIC18F, PIC24, dsPIC30, and dsPIC families of 8-bit and 16-bit microcontrollers, and many Microchip Serial EEPROM products.

The PICkit™ 2 Microcontroller Programming software works with a PICkit2TM^ OEM USB programmer. The USB programmer is the in-system programming via ICD2 jack.

1.3.2.1 PICkit2 TM^ Programming Software installation
1.3.2.1.1 Install from PX-200 CD-ROM

The working software of the USB programmer is PICkit2TM^ Programming Software. The newer version is developed from Microsoft.NET. Thus, user must install the Microsoft.NET Framework first.

10 l Robotics experiment with PIC microcontroller

1.3.2.2 Using PICkit2 TM^ Programming Software
1.3.2.2.1 Testing hardware connection

(1) Connect the USB cable between the programmer and Computer’s USB port.

Open the software Pickit2 TM^ Programming Software by entering the Start à All programs
à Microchip à Pickit 2 V201. The main window will appear as shown in figure 1-.

(2) On successful connnection, the message PICkit 2 found and connected will appear in the Status box.

Figure 1-1 : The screen of Pickiit2 TM^ Programming Software
Command menu Status box
Progress bar
Short cut
button
Inform the
destination
of HEX file

Robotics experiment with PIC microcontroller l 11

(3) If the connection is incompleted. The message PICkit 2 not found. Check USB

connections and use Tools à Check Communication to retry will appear in the Status

box. Check the cables and connections.

(4) Go to Tools menu and select Check Communication command. If all’s cor- rect, the message PICkit 2 found and connected will be show in the Status box.

However if everytime during re-connection or checking hardware, it does not connect the target microcontroller at ICD2 jack and ICSP point or any mismatch in number, the warning dialog box will appear. It will warn you about any error supply voltage. You need not worry about this, click on the OK button to continue.

Robotics experiment with PIC microcontroller l 13

PROGRAMMER
  • Read Device – Reads the program memory, data EEPROM memory, ID loca- tions, and Configuration bits.
  • Write Device – Writes the program memory, data EEPROM memory, ID loca- tions, and Configuration bits.
  • Verify – Verifies the program memory, data EEPROM memory, ID locations and Con- figuration bits read from the target MCU against the code stored in the programming software.
  • Erase – Performs a bulk erase of the target MCU. OSCCAL and band gap val- ues are preserved (PIC12F629/675 and PIC16F630/676 only).
  • Blank Check – Performs a blank check of program memory, data EEPROM memory, ID locations and Configuration bits.
  • Verify on Write - Verifies program memory, data EEPROM memory, ID locations and Configuration bits read from the target MCU against the code stored in the pro- gramming software with word per word.
  • Full Erase (OSCCAL and BG erased) – Performs a bulk erase including the OSCCAL and Band Gap (BG) values (PIC12F629/675 and PIC16F630/676 only).
  • Regenerate OSCCAL – Regenerates the OSCCAL value (only for PIC12F629/ 675 and PIC16F630/676). The AUX line must be connected to the RA4/T1G pin.
  • Set Band Gap Calibration Value – Sets the band gap value.
  • Write on PICkit Button - Set for supporting of programming the target microcon- troller witth PROGRAM switch on the USB programmer board.
TOOLS
  • Enable Code Protect – Enables code protection for Flash program memory.
  • Enable Data Protect – Enables code protection for EEPROM data memory.
  • Set OSCCAL - Sets the OSCCAL value for alignment internal clock frequency.
  • Target VDD Source – Power target from the USB Programmer. Auto-Detect : Select to USB programmer turn on or off the supply voltage to target microcontroller automatically (not suggess to use this option).

Forced PICkit2 : Set the programmer to supply the suitable voltage to tar- get microcontroller. After select, LED at Targer position will light and at VDD PICkit2 box on screen will check atr On position. User can adjust the supply voltage from selection box in the right-hand (not suggess to use this option).

Forced Target : Select to inform the software knows about the target has voltage applied. Suggess to use this option for safty operation. Also in this option, user must apply the supply voltage to the target PIC microcontroller.

14 l Robotics experiment with PIC microcontroller

  • Fast Programming - Select the PX-200 to programs the Flash device with high speed.
  • Check Communication – Verifies communication with the USB Programmer and reads the device ID of the target MCU.
  • Download PICkit 2 Firmware – Performs a download of the USB Programmer firmware operating system. (this USB programmer is compatible PICkit2 TM^ Programmer). Sometime call this function to OS update.
Help

Displays all user manual, technical document and a dialog box indicating the version and date.

1.3.2.2.3 Important things to know in using the PICkit2 TM^ Programming Software
Editing memory value

The PICkit2 TM^ Programming Software supports the editing memory value in each address, both Flash program and data EEPROM memory. User can click at any address that need to change the value and input the new value directly.

Moreover user can select to access both memory types and only one.

(a) Access only EEPROM data memory

Click at Enabled box in Program Memory border to remove the mark. At EEPROM data border, it will show Write and Read EEPROM data only in red message. It means user can read and write only EEPROM data memory. See the illlustration below.

16 l Robotics experiment with PIC microcontroller

(3) Browse to the directory where the latest Operating System code was saved, Select the PK2*.hex file and click on the Open button as shown in figure below.

(4) The progress of the OS update will be displayed in the status bar of the pro- gramming software and the Busy LED on the USB Microcontroller Programmer will flash. When the update completes successfully, the status bar will display “Operating System Verified” and the Busy LED will go out. The operating system update is then complete.

1.3.2.4 Short cut button

The PICkit2TM^ Programming Software has 7 short cut buttons as follows : (1) Read : Read data from target MCU. (2) Write : Write or program the code into target MCU. (3) Verify : Verify programming. (4) Erase : Erase data in target MCU. (5) Blank Check : Check blank data in target MCU. (6) Import Hex File + Write Device : Open the HEX file and program into target MCU automatically

(7) Read Device + Export Hex File : Read device and save as the HEX file automatically.

1.3.2.5 ICD2 cable assignment

The USB Programmer comes with an ICD2 cable for connecting between the pro- grammer and the target board. The wire assignment of this cable is shown below.

Vpp

GND

PGMPGD PGC Vdd

Top view

Vpp Vdd

GND

PGC PGDPGM Vdd Vpp GND PGDPGMPGC

6"

ICD2 jack (^) ICD2 cable RBX-877 V2.0 Robot Controller board

USB Programmer side

Vpp

GND

PGMPGD PGC Vdd

ICD2 jack pin assignment on target board

Robotics experiment with PIC microcontroller l 17

1.4 Programming devleopment for Robo-PICA

The summary of steps of program the Robo-PICA robot kit are as follows :

  1. Create the C project file with mikroC IDE software.
  2. Compile the project file.
  3. If any error occurs, edit the C program to fix the error and compile the project file until all are correct.
  4. The HEX file would be created after the compilation is completed.
  5. Open the PICkit2 TM^ Programming software. Connect the USB programmer with USB port and connect the ICD2 cable between the USB Programmer and the RBX- 877 V2.0 Controller board at ICD2 jack.
  6. Download the HEX file to the RBX-877 V2.0 Controller board of Robot- PICA.
  7. Run the program and check the hardware operation. If it is not correct, go back to edit the C program, compile and download again. Do these steps unitl the operation are completed.

1.5 Getting Start

From here, we will describe about the getting start of programming development for the Robo-PICA. This robot kit is controlled by the RBX-877 V2.0 Robot Controller board. The heart of this controller board is PIC16F887 chip. The programming development in- cludes 2 main steps as C programming development and Download the HEX file to microcontroller.

The C programming development will be using mikroC IDE included C compiler and the other provides support tools and libraries. However this kit will work with the demo version. You can purchase the full version for more programming at www.mikroe.com.

You can develop the C project file and test the operation of the Robo-PICA’s hard- ware from these procedures below.

1.5.1 Install the mikroC software tools following the instruction manual. See this docu- ment in Robo-PICA’s CD-ROM or download the update document from www.mikroe.com.

1.5.2 Install the PICkit2 Programming software for USB programmer. 1.5.3 Open the mikroC IDE by clicking at Start à Programs à Mikroelktronika à mikroC à mikroC. The main window will appear. The Figure 1-1 shows the main window of mikroC IDE and the important components.

Robotics experiment with PIC microcontroller l 19

1.5.4 Create the new project file by entering to menu Project and select New Project...

1.5.5 The New Project window will appear. You must set the important parameter as follows :

20 l Robotics experiment with PIC microcontroller

(a) Project Name : Put the project name. mikroC IDE will create the folder to support your project file which includes the C sourcecode. For example is Blink_LED project file.

(b) Project Path : Select the location of your project file. Click the Browse button to select the location. For example is D:\ROBO-PICA

(c) Description : Put the information of your porject file. For example is “Robo PICA Code Blinking LED on RB3”

(d) Device : Select the target microcontroller. For the Robo-PICA kit and RBX-877V2.0 Controller board must select to PIC16F

(e) Clock : Select the clock frequency for the target microcontroller. For the Robo-PICA kit and RBX-877V2.0 Controller board use 20MHz clock. Put the value 020.000000.

(f) Device Flags : Set the configuration for the target microcontroller. Developer

can set very easy by Default button. The Default will set the 3 main configurations

as follows :

High Speed Oscillator enabled (HS_OSC) for 10MHz and above clock frequency.

Watchdog timer disabled (WDT_OFF) Low Voltage Programming disabled (LVP_OFF) After the configuration is being set, click on the OK button. mikroC IDE would close the New Project window and create the Blink_LED.C file with the blank editor area for writing the C program.