* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download an efficient locomotion system for autonomous robots
Negative feedback wikipedia , lookup
Electrification wikipedia , lookup
Switched-mode power supply wikipedia , lookup
Buck converter wikipedia , lookup
Distributed control system wikipedia , lookup
Electric machine wikipedia , lookup
Voltage optimisation wikipedia , lookup
Electric motor wikipedia , lookup
Rectiverter wikipedia , lookup
Opto-isolator wikipedia , lookup
Immunity-aware programming wikipedia , lookup
Brushless DC electric motor wikipedia , lookup
Control theory wikipedia , lookup
Pulse-width modulation wikipedia , lookup
Rotary encoder wikipedia , lookup
PID controller wikipedia , lookup
Control system wikipedia , lookup
Stepper motor wikipedia , lookup
Induction motor wikipedia , lookup
AN EFFICIENT LOCOMOTION SYSTEM FOR AUTONOMOUS ROBOTS Viviana Pappalardo, Gianfranco Interdonato, Matteo Pietro Russo, Alessandra Vitanza Engineering Faculty, Catania University Catania, Italy Abstract This paper describes the development of an autonomous robot and in detail its locomotion system. It focuses on its hardware and software subsystems, describing different alternatives and our solution. The hardware section illustrates components chosen and their functionalities. Instead, the software part deals with motor management policy and the algorithm used. Some figures illustrate schematic circuit and others show the different tasks used to perform proper motor control. Finally, a graph represents system closed-loop response; it shows a really good control, indeed the PID loop reduces efficiently the rise time and helps the system to reach target speed. Index terms: PID, locomotion, PWM, DC motors, speed. I. INTRODUCTION This work wants to spread the importance of "waste recycling" and describes an autonomous robot, made by the authors, which has been developed for participation to Eurobot 2007 competition. The robot has the task of finding and taking some garbage on a table, which simulates the working area, transporting it to the correct bin and finally depositing it. There are three kind of waste to sort: bottles, cans and batteries; each one has a different colour so that the robot can distinguish the object through its colour and shape. Different components cooperate one another in order to allow the robot to reach its objective; the most important components are: Vision Module, to distinguish the different objects; Locomotion Module, to move the robot; Beacon Module, to help the odometry task; Embedded Module, that represents the robot's brain. The Vision module processes some images from a webcam, extracting information about the position of the objects that are inside robot's visual area. The Locomotion module changes motor's velocity and controls trajectory, by means of a closed-loop control, thus allowing the robot to reach the desired object or position. The Beacon module uses a laser sensor and, by means of a triangulation, it computes the robot's position helping the Locomotion module to control the movement. Finally, the aim of Embedded module is based on the management and organization of full system control, giving the best trajectory sequence, integrating vision information and activating so the right actions. This paper deals with the locomotion task and explains all the potential approaches, then it shows the specific choice in detail, such as microcontroller chosen or power driver used and finally software tasks management. The paper is structured as follows. Section 2 presents the state of the art in wheel control for autonomous robots. Section 3 presents the solution realized from the hardware point of view. Section 4 describes in-depth the functionalities of the firmware. Section 5 reports the results of some measurement tests. Finally Section 6 gives our conclusions and the lesson learned. II. OVERVIEW We have developed a robot whose movement is based of two separately driven wheels placed on either side of the robot body. The basic idea is that the robot can change its direction by varying the relative rate of rotation of its wheels and hence does not require an additional steering motion. This block diagram describes the general structure of the system that we have developed. It is composed of: embedded system, microcontroller, h-bridge and motor. 81 An embedded system is a special-purpose system in which the computer is completely encapsulated by or dedicated to the device or system it controls. Unlike a general-purpose computer, such as a personal computer, an embedded system performs one or a few predefined tasks, usually with very specific requirements. Some embedded system have realtime constraints that must be met, for reasons such as safety and usability; others may have low or no performance requirements, allowing the system hardware to be simplified to reduce costs. An embedded system is not always a separate block, very often it is physically built-in to the device it is controlling. A microcontroller is a highly integrated chip which includes, on one chip, all or most of the parts needed for a controller. In contrast to general-purpose CPUs, microcontrollers do not have an address bus or a data bus, because they integrate all the RAM and nonvolatile memory on the same chip as the CPU. Because they need fewer pins, the chip can be placed in a much smaller, cheaper package. It typically includes : CPU (central processing unit), RAM (Random Access Memory), EPROM/PROM/ROM(Erasable Programmable Read Only Memory), I/O (input/output) – serial and parallel, timers, interrupt and controller. When a microcontroller is used to drive the movement of a robot, some additional hardware is required. Indeed, microcontrollers do not have enough current or voltage to spin a motor. Also, motors tend to be electrically noisy (spikes) and can slam power back into the control lines when the motor direction or speed is changed. So, there are specialized circuits, called H-bridge, that have been developed to supply motors with power and to isolate the other ICs from electrical problems. The great ability of an H-bridge circuit is that the motor can be driven forward or backward at any speed, optionally using a completely independent power source. Let's say that the motor runs forward when its "+" terminal is connected to "Motor V+" and its "-" terminal is connected to ground. It will run in reverse when the opposite is true. Turn on switch A and switch D and the motor will run forward. Turn on switch B and switch C and it will run in reverse. If the terminals of the motor are open, the motor will freewheel and if the terminals are short circuited, the motor will brake. An H-bridge can be implemented with various kinds of components (common bipolar transistors, FET transistors, MOSFET transistors, power MOSFETs, or even chips). We used the brushed DC motor, because they are inexpensive, easy to drive, and are readily available in all sizes and shapes. A brushed DC motor is a type of electric motor that has two static electric contacts ("brushes") that come in contact with different sections of a commutator at different times, spinning the motor through electromagnets. Magnet Shaft Windings By only including the features specific to the task (control), cost is relatively low. A typical microcontroller has bit manipulation instructions, easy and direct access to I/O (input/output), and quick and efficient interrupt processing. Microcontrollers are a "one-chip solution" which drastically reduces parts count and design costs. 82 Laminations The speed of a brushed DC motor is proportional to the voltage applied to the motor. When using digital control, a pulse-width modulated (PWM) signal is used to generate an average voltage. The relation between average voltage, the supply voltage, and duty cycle is given by: make the transient response worse. A derivative control (Kd) will have the effect of increasing the stability of the system, reducing the overshoot, and improving the transient response. Vaverage = D × Vsupply The frequency of the PWM waveform is an important consideration. In fact too low a frequency will result in a noisy motor at low speeds and sluggish response to changes in duty cycle. Too high a frequency lessens the efficiency of the system due to switching losses in the switching devices. Though the speed of a brushed DC motor is generally proportional to duty cycle, no motor is ideal. If speed control is required, it is a good idea to include some sort of feedback mechanism in the system. Speed feedback is implemented in one of two ways. The first involves the use of a speed sensor of some kind (encoders and hall effect sensors). The second uses the BEMF(Back Electro Magnetic Flux) voltage generated by the motor. The software implementation of the feedback is managed by а РШ controller, which is sketched in Figure: Literature describes PID control by transfer function: 1 Gs k 1 sTd sTi The control signal is a sum of three terms: the P-term (proportional), the I-term (integral) and the D-term(derivative). The controller parameters are proportional gain K, integral time Ti, and derivative time Td. The integral, proportional and derivative part can be interpreted as control actions based on the past, the present and the future. The variable (e) represents the difference between the desired input value (target) and the actual output (output). This error signal (e) will be sent to the PID controller, and the controller computes both the derivative and the integral of this error signal. The signal (u) just past the controller is now equal to the proportional gain (Kp), plus the integral gain (Ki), plus the derivative gain (Kd). This signal (u) will be sent to the motor, and the new output will be obtained. This new output will be sent back to the sensor again to find the new error signal. The controller takes this new error signal and computes its derivative and its integral again. A proportional controller (Kp) will have the effect of reducing the rise time and will reduce ,but never eliminate, the steady-state error. An integral control (Ki) will have the effect of eliminating the steady-state error, but it may III. HARDWARE DESIGN According to the conceptual model, we realized a solution to manage two independent motors with an unique microcontroller. The following figure represents schematic circuit of motor controller module. Our microcontroller is the PIC18F2431; it was chosen to achieve high performance, power control and safety management. In fact, it's equipped with some special peripherals as: Motion Feedback Module (MFM) with 3-channel Input Capture Module and Quadrature Encoder Interface; 14-bit resolution Power Control PWM (PCPWM) Module with programmable dead-time insertion, complementary outputs. The MFM Quadrature Encoder Interface provides precise rotor position feedback and/or velocity measurement. The 3-channel Input Capture can be used to detect the rotor state using Hall sensor feedback: in particular, Input Capture can measure edgetrigger, period or pulse signal and it is equipped with programmable prescaler to set periodicity of increase of the counter. The PCPWM can generate up to six complementary PWM outputs with dead-band time insertion. For this reason, we used Locked AntiPhase configuration (LAP mode) to control the H-Bridge. The STMicroelectronics L298N was selected to deliver power to the motors. The L298N chip is a high voltage, high current dual full-bridge driver designed to accept standard TTL logic levels and drive inductive loads such as relays, solenoids, DC and stepping motors. Two enable inputs are provided to enable o disable independently of the input signals. The figure below represents the H-Bridge (LAP mode) module's schematic circuit: 83 We used Locked Anti-Phase mode so that motors aren't in Free Running Mode, when dutycyle is set 50% (to stop motors). H-Bridge outputs is connected to Shottky diodes allowing the chip to drive inductive load (i.e. DC-brushed gearmotors with Reduction Ratio of 76.84:1 and No Load Speed of 81 RPM). The motors have Hall-Effect sensors onboard: each device includes a voltage regulator, quadratic Hall voltage generator, temperature stability circuit, signal amplifier, Schmitt trigger and open collector output on a single silicon chip. A pull-up restistor is connected to encoder output, allowing pulses calculation by microcontroller. In particular, it measures rotation speed with "Input Capture" interface. Finally, we use MAX485CPA to communicate using RS-485 standard; it is a transceiver for communication. It contains one receiver and one driver and allow to transmit up to 2.5Mbps. This is a schematic circuit of communication module. The "ENABLE_485" signal permits to select a data direction (transmission or reception). IV. SOFTWARE DESIGN The creation of software code was inspired by an idea to organize the work in many different parts. The main tasks are: speed evaluation and control; calculation of the absolute position of the robot; interaction with the outside (RS485). The following flow diagram explains the most important steps performed in the main loop of the Motor Controller firmware. 84 The Motor Controller Software, as shown in the figure, can be split into three different sections each of which have their own specific functions. The first sub-function is the Speed Evaluation Task which uses the motors' encoders to find the actual speed of the system that will be used for the PID Task in comparing the actual speed to desired speed. Pid Task, which describes the PID algorithm and how error correction for the motor controller system will work. Odometry, which using encoder ticks determines the correct absolute robot's position. Finally, Handler Command Task, which describes how movement is achieved through the motors corresponding to the received commands. Among all components within the software design the most important element, which has to mentioned is: • t_motor_info – this struct is a store location for variables and data that any of the other blocks in the system may need. In other words, it is a data dictionary which is a central location for storing many kinds of data. typedef struct { int8 number; float current_speed; boolean current_direction; int16 target_speed; int16 minimum_speed; boolean target_direction; int16 encoder; boolean on; boolean pid; boolean encoder_enabled; boolean target_reached; boolean skip_first; float Kp; /* 'P'proportional gain */ float Ki; /* T integral gain float Kd; /* 'D'derivative gain float Control_old; float Old_error_G; float Sum_G; } t_motor_info; */ */ PID gains. The output of the PID task is directly a value representing the PWM Duty Cycle to be applied to the motor. These are the following variables or data that will be stored into t_motor_info: Current Speed – calculated speed coming from the Encoders; Current Direction – the actual direction of the motors; Target Speed – the new desired speed that has been applied; Boolean Encoder enabled, on and pid – flags used to activate or disable the respective controls; Proportional, Integral and Derivative gain – constants used in the PID control. V. SOFTWARE SUBSYSTEMS Sp eed E va l uat io n This block uses the encoder ticks to calculate the speed of the motor. This is performed by means of a built-in feature of PIC18F2431, called MOTION FEEDBACK MODULE and designed for motion feedback applications; this feature is able to determine the period between two different pulses of the motor encoder, thus permitting to compute motor's speed. It uses a special timer, called Timer5, that we programmed to increment at a frequency of Tclock/8, and two input pins, called CAP1 and CAP2, that we connected to the output of the encoders of motor 0 and 1, respectively. The working scheme of the module is quite straightforward: when an edge appears on the CAP1 (resp. CAP2) pin, the value of Timer5 is copied into a special register called CAP1BUF (resp. CAP2BUF); then an interrupt is also generated, called IC1 (resp. IC2). In particular, at the first detected edge captures the Timer5 value is stored in an apposite register, called CAPx-BUF, and then, when the new timer value is captured on the edge thereafter, these two different values are subtracted to obtain as output the desired measurement. After the speed is found it is then saved into t_motor_info. The Encoder Interrupt Service Routine monitors any counter overflow from the counter. If an overflow occurs the Encoder ISR will take in the current count from the Encoders and will take that count and subtract it from the current calculated count in order to get the correct speed. P ID T as k After computing the speed of both motors, the next operation performed in the main loop of the firmware is the PID control. This task entails to compare the current speed of a motor to the desired speed, and to reduce the error through the use of the As the code listing shows, the first operation is the determination of the error; here, we considered a "dead band", that is needed in order to avoid instability in the control: if the error is less than a given threshold (1 in our case, we are working with integer speed values), we reset it to zero. The next steps entail to include integral and derivative terms. In the formula used for proportional calculation (line 10): the term motorX->Control_old picks out a problem, in fact, when the error was zero the PID output shouldn't be consequently zero, but it must only remain constant , for this reason in order to eliminate this inconvenient in the formula the control value are added at the old value. In lines 19–29, are shown the anti-windup control, values are maintained in an appropriate range to avoid the saturation condition. This situation can get so bad that the system never settles out, but just slowly oscillates around the target position , in this condition, in fact, all the time spent 85 in saturation can cause the integrator state to grow (wind up) to very large values. Od o met r y T as k This task determines the absolute position of the robot, in term of x, y and θ (θ is the orientation with respect to the y axis) by using the values obtained by counting encoder ticks. This is achieved by using two internal timers of the PIC, Timer0 and Timer1, in counting mode, and connecting encoders outputs also to the pins that drives external counting of such timers. Therefore, Timer0 will count the ticks of the left wheel and Timer1 will do the same for the right wheel. Obtained ticks from both wheels and introducing many hypothesis about speed (its value, in fact, is supposed that remains constant in every iteration) and some terms as: L = distance between contact points of wheels and ground; N = tick number for every complete wheel rotation; W = wheel diameter; D= W N linear distance covered by a wheel in a tick; ns = tick number of left wheel; nd = tick number of right wheel. It was possible to use a general method, though cinematic equations, for evaluate the correct robot's position and orientation, supposing that robot goes in a rectilinear motion, with linear speed ν ed circular motion with angular speed ω the equation are in form: dk dt dxk dt dyk dt v cos 2 k v sin k v sin 2 k v cos k Cinematic Model 86 Considering a sampling time Ts in order to ν and ω remain constant, it's possible to integrate the equations with Eulero method to obtain: k k 1 k 1Ts xk xk 1 vk 1Ts sin k yk yk 1 vk 1Ts cos k Seeing that velocity ν and ω are evaluated by encoder's values with equations: v 1 Dns nd Ts 2 1 Dns nd Ts L The previous formulas become: Dns nd L Dns nd xk xk 1 sin k 2 Dns nd yk yk 1 cos k 2 k k 1 Anyway, an important hardware problem arose in our practical tests. We observed a strange behaviour in the output signal from encoders of the motors we used: since they use Hall sensors, due to a perturbation provoked by the magnetic field of the motors, the output edge of the encoder signals present by a time shift that sensibly affect the calculation of the orientation, introducing an error that make the odometry calculation not reliable. A method to reduce this error is thus mandatory: for this reason, we decided to install a compass on the robot. The aim was to produce a precise number to represent the direction the robot is facing. The compass uses two magnetic field sensors, which are sensitive enough to detect the Earths magnetic field, mounted at right angles to each other in order to correctly compute the direction of the horizontal component of the Earths magnetic field. Anyway, the code was keep to have a general plan to permit, for example with more reliable encoders, to make evaluation without the compass assistance. In order to take this scope the code are structured in this form: As figure shows, using only proportional term we have a good time response. compass = read_compass (); #ifdefUSE_COMPASS theta = TO_RADIANTS(ceil(compass -compass_zero)) + theta_zero; if (theta > PI) theta = -(2* PI- theta); if (theta < -PI) theta = 2 * PI + theta; #else theta = theta + (TICK_DISTANCE * (ns-nd))/ WHEEL_DISTANCE; #endif x=x + (TICK_DISTANCE *(ns+nd)*sin(theta))/2; y=y + (TICK_DISTANCE * (ns+nd)*cos(theta))/2; REFERENCES VI. CONCLUSIONS In this paper, we presented a locomotion system to be used in autonomous robot. To evaluate system perfomance and above all PID action quickness, we have tested it setting : target speed = 80 [tick/time]; initial speed = 0 [tick/time]; [1] [2] [3] [4] [5] ST Microelectronics, "ST-L298N Datasheet" Microchip, "AN970" - Application Note Microchip, "PIC18F2431 Datasheet" James Mentz, "Motion control theory needed in the implementation of practical robotic system", 4 April 2004. Pierfrancesco Foglia, "Implementazione tramite microcontrollori Kp=6; Ki = 0; Kd=0. 87