Anghel Drugarin Cornelia Victoria, PhD IT Engineer Stroia, Mihaela Dorica PhD IT Engineer Department of Electrics and Informatics Engineering Eftimie Murgu University of Resita Resita, Romania c.anghel@uem.ro ; m.stroia@uem.ro Draghici Silviu, PhD Student at Polytechnics Timisoara Department of Electrics and Informatics Engineering Eftimie Murgu University of Resita Resita, Romania s.draghici@uem.ro
AbstractPresent paper describes a research regarding driving industrial robots by using programmable applications for PIC microcontroller 16F877. Programs for PIC 16F877 microcontroller are written using assembler language, where code numbers are replaced by mnemonic codes. We intend to design a smart interface PIC type, ''Peripheral Interface Controller", for 16bit CPU with high capacity computing operations UAL. Program code used for driving and controlling of automated guided vehicle using microcontroller is autonomous in terms of energy supply through infrared sensors. Keywords- Automation; microcontroller; inbuild driver; programming; PWM frequency I. OPERATING GUIDELINES FOR AUTOMATIC DEVICE There is a series of publications considering possibilities of using microcontrollers for actuating function of vehicles with automatic driving. Concepts and designs differ especially by microcontrollers types and programming language. However, these robots are compelling not for reasons of mobility but because of their autonomy, and so their ability to maintain a sense of position and to navigate without human intervention is paramount [7]. Most commonly used language for programming microcontrollers is Assembly, but for this design we considered it would be most fitted for the control program to be written in C language, being much faster and easier than programming in Assembly or even a combination of languages. The aim of automation is to control driving process of designed mobile system implemented as an assembly (figure 1) of a platform carriage equipped with an emergency switch covered by a plastic case, battery charger, two independent DC engines and two gear decelerators. For an increased stability the platform is provided with three sliding sets. Device is planned to follow with high precision a white route marked on a plane surface, considered as reference point. Microcontrollers purpose is to keep device on track, being programmed to interfere with corrective procedures when a course deviation is signaled. Infrared sensors capture the light emitted by 5 diodes and give feedback regarding device position towards followed route. Diodes are infrared LED type mounted on a plate, in a linear pattern, alternating with infrared sensors. Sensors detect the trace, encode information captured and transmit it to a control circuit that has in its structure a PIC 16F877 microcontroller. The code is received through incoming port TRIS A. The circuit examines each bit of received information and according to logical values 0 and 1 processes the code.
Figure 1. Platform carriage of autonomous vehicle [2] The automatic driven vehicle has autonomy regarding power supplying. This vehicle is self-actuated and follows a path of white trails, using infrared sensors from endowment. DC engines operate by means of gear decelerators, each of them being driven by a circuit equipped with a PIC 16F877 microcontroller. White route has a breadth of 4 cm. The target is to follow with high accuracy marked trace. II. DESIGN SPECIFICATIONS A. PIC 16F877 Microcontroller PIC 16F877 (figure 2) is a 40-pin 8-Bit CMOS FLASH Microcontroller from Microchip. The core architecture is high- performance RISC (Reduced Instruction Set Computer) CPU. Instruction set has around 35 instructions (usually 37). These are used on a large scale due to the advantages they bring over microprocessor [1]. PIC 16F877 follows the RISC architecture, all single cycle instructions take only one instruction cycle except for loop instructions which take two cycles. 16F877 comes with 3 operating speeds with 4, 8, or 20 MHz clock input [4]. Since each instruction cycle takes four operating clock cycles, each instruction takes 0.2 when 20MHz oscillator is used. It has two types of internal memories: program memory and data memory. Program memory is provided by 8K words (or 8K*14 bits) of FLASH Memory, and data memory has two sources [5].
Figure 2. PIC 16F877 Microcontroller [3] It was chosen PIC 16F877 Microcontroller as a solution to drive the autonomous vehicle for its expidient features: it has low cost, it can be easily programmed and reprogrammed, the instruction code can be written in different programming languages, it is fast.
Figure 3. Internal architecture of PIC 16F877 [8] The internal architecture of PIC16F877 is minimal as shown in block diagram from figure 3. Its peripheral features include: Three time blocks: Timer0 for 8-bit timer/counter; Timer1 for 16-bit timer/counter; and Timer2: 8-bit timer/counter with 8-bit period registers, pre-scaler and post-scaler. Two Capture, Compare, PWM modules for capturing, comparing 16-bit, and PWM generation with 10-bit resolution. 10-bit multi-channel (max 8) Analog-to-Digital converter module. Synchronous Serial Port (SSP) with SPI (Master Mode) and I2C2 (Master/Slave) Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9-bit address detection Parallel Slave Port (PSP) 8-bits wide, with external RD, WR and CS controls Five I/O ports. B. Mechnical and Electrical Aspects of Device For building automatic device a platform type chassis was used, enclosed in a plastic housing. It was equipped with two DC engines, two wheels and sliding sets, in order to increase stability, rechargeable battery, two gear decelerators, electric power for engines and electronic management control, empowered with PIC 16F877 microcontroller. Platform is provided with an emergency circuit-breaker. LED diodes and infrared sensors are mounted at center bottom of platform. Infrared light emitted by diodes towards white line is reflected to all five sensors, these send a logical signal to PIC microcontroller using A TRIS port.
Control circuits drive engines using PWM technique and the control signals are sent from circuits to engine by means of USART serial protocol. III. PROGRAMING AUTOMATIC DEVICE Control algorithm provides a continuous evaluation of the five bits received and decides whether to change wheels directions or not. Vehicle command and control algorithm is achieved by means of automatic control techniques, using closed feedback loop. Algorithm uses logical truth table below (Table I). PORTA has 5 adjoining pins. The corresponding register for data direction is TRISA at address 85h. Like with port B, setting a bit in TRISA register defines also the corresponding port pin as input, and clearing a bit in TRISA register defines the corresponding port pin as output [3]. If automatic vehicle is situated on white line all five bits have the logical value of 1. If vehicle deviates from its route and one of diodes is not above white line, sensors transmit through TRIS port a 0 logical value to microcontroller. Control algorithm detects value changing and by means of command circuits shifts vehicles direction by modifying wheels angle to left or right direction, until all five bits have value 1, this device is back on white track. TABLE I. LOGICAL TRUTH TABLE Truth Table for Algorithm Bit B1 Bit B2 Bit B3 Bit B4 Bit B5 1 1 1 1 1 0 1 1 1 1 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 1 0 1 1 1 0 0 1 1 0 0 0 0 0 0 0 0
For testing and loading microcontroller, software provided by Microchip MPLAB is used (figure 4). The following code lines are used to flash a LED on one of the PORTA pins of the PIC microcontroller [6]:
Figure 4. Instruction code for LED flashing #include <stdlib.h> #include <pic.h> #include delay.h void main() { PORTA = 0x00; //set RA0-RA5 on low TRISA = 0x00; //configure PORTA pins as output while(1) { PORTA = !PORTA; // invert logic state of PORTA DelayMs(250); // 250ms delay } } Code example below is used for configuring input and output ports and initiating and setting a PWM signal. void InitMain() { ANSEL = 0; //configure port pins as digital I/O ANSELH = 0; PORTA = 255; // initial state of PORTA as input TRISA = 255; PORTB = 0; // initial state of PORTB as output TRISB = 0; PWM1_Init(5000); // Initialize PWM1 module at 5KHz } void main() { InitMain(); // call of initialization procedure current_duty = 16; // Initialize current duty cycle PWM1_Start() ;// start PWM1 PWM1_Set_Duty(current_duty);// Set PWM1 duty cycle to value of current duty While (1) { If (PORTA.F0==0) { Delay_ms(1); current_duty++; //incrementing duty cycle PWM1_Set_Duty(current_duty); } If (PORTA.F1==0) { Delay_ms(1); current_duty--;//decrementing duty cycle PWM1_Set_Duty(current_duty); } Delay_ms(10); } In case we need more than one PWM signal we can use imbricate loops to set or reset outputs, according to our necessities. IV. CONCLUSIONS AND CLOSURE Advantages of microcontrollers over microprocessors are obvious: microcontrollers are cheaper, have no need of extra peripherals, programing language is simple, instruction code is short, easy program debugging, simple wiring between components. As results of our work we used C language for programming PIC 16F877 microcontroller because it is easier and faster than Assembly language, and in this case, more suitable for designed application. Model in discussion can be a prototype for a transporter device in logistics departments of multinational companies. ACKNOWLEDGMENT The authors acknowledge the support of the Managing Authority for Eftimie Murgu University of Resita and Politehnica University of Timisoara. Anghel Drugarin,Cornelia Victoria is Phd Engineer in IT and Computers Science domains since 2001 on Politehnica University Timisoara and teach on Eftimie Murgu University of Resita since march, 1994. Is author and co-author on 21 books or chapters, 158 articles, and Vicepresident on Multidisciplinary Research Asociation on Vest Region in Timisoara, email c.anghel@uem.ro; Stroia, Mihaela Dorica is Phd Engineer in Mechanical Engineering domain since 2012 on Politehnica University Timisoara and teach since october 2008 on Eftimie Murgu University of Resita. Since october 2011 is Principal Process Engineer at Sumitomo Electric Bordnetze GmbH Romania, email stroia_mich_elle@hotmail.com; Silviu Drghici, is Ph.D student Politehnica University Timioara, section SYSTEMS ENGINEERING, registration number 2188, enrolled in October 2011. He would like to thank to my PhD advisors, Prof.univ.PhD.Eng. Octavian Prostean for supporting me during these past three years. Since October 2012 is associated assistant teacher on Eftimie Murgu University of Reia, Faculty of Engineering and Management, department Electrical Engineering and Informatics; Romania, email: s.draghici@uem.ro REFERENCES
[1] M.P. Bates, Interfacing PIC Microcontrollers. Embedded design by interactive simulation, Published by Elsevier, Great Britain, 2011. [2] http://www.generationrobots.com/en/ [3] T. Wilmshurst, Designing Embedded Systems with PIC Microcontrollers: Principles and Applications, Newnes, 2006. [4] C. Kim, Embedded Computing with PIC 16F877 Assembly Language Approach, 2006. [5] Y. Thommandru, Programming a PIC Microcontroller, Iowa State University EcpE, November 2006. [6] H. S. Sandhu, Running small motors with PIC microcontrollers, Published by McGraw-Hill, 2009. [7] Roland Siegwart and Illah R. Nourbakhsh, Introduction to Autonomous Mobile Robots, The MIT Press Cambridge, Massachusetts London, England, 2006. [8] Verle M., PIC Microcontrollers - Programming in C, Publisher mikroElektronika; 1st edition, 2009.