![]() ![]() ![]() |
![]() ![]() ![]() |
![]() ![]() ![]() |
![]() ![]() ![]() |
![]() ![]() ![]() |
 
 
![]() GENERAL BLOCK DIAGRAM FOR MOTOR DRIVE CONTROL Basically, the microcontroller acts as the control unit: it compares the actual position with the reference value and calculates the output control voltage with a specific digital control algorithm. We considered to different ways of controlling: a digital PID controller and a control using pulsed voltage signals. The latter was to be implemented in case the PID controller would fail to handle the effects of static friction. In the long run we dropped it, because the mechanical structure runned the risk of being damaged by the pulsed drive. In order to fit the digital controller in the electronic circuit we have to realize some information exchange between the controller and 3 units: the process control computer ( simulated by a set of potentiometers ), the position sensor ( potentiometers ) and the power converter ( a power operational amplifier ), which all operate by means of analog voltages. A digital-to-analog and analog-to-digital converter should manage the exchange. How to cope with the other units? Our main objective was to preserve what was already present ( the power supply for instance ) and rather using the existing hardware instead of trying to 'reinvent' things. Consequently, analizing and understanding the systems structure and operation was part of the process. We decided to try to incorporate the entire electronic circuitry inside the robots case except the microcontroller, because there was a lack of space and all the more because it would complicate things, instead of making things easier or more user friendly. After having thouroughly tested the electronic circuits and encountering strange phenomena, we conceived printed circuit boards as prototypes, but we took into account that they should fit in properly, if they end up as 'final products'. Finally, the circuit boards had to be fixed properly inside the robots case. The final test was quite depressing: the manipulator arm was looking somewhat hyperkinetic to say the least. We were not planning to give up THAT soon. Due to a disconnected decoupling capacitor pin, appearently, the whole circuit went unstable. A quick repair and the case was closed... The result of our efforts can be seen and read in "SO?", the conclusive chapter. A more detailed description of all the steps taken can be found in the chapters about the components of the general block diagram. Feel free to wander through... >>back to general block diagram  
|
|
THE ROBOT The robot, a cast-off from the medical sector, has four degrees of freedom to be controlled: a manipulator arm is able to rotate in a horizontal plane and to perform a linear motion along the horizontal and the vertical axis, all three by using a system of guided cables and wheels. Finally, a rotation around the horizontal axis of the manipulator arm itself can be carried out, which adds up to 4 DOF’s, thus 4 DC-motors. The robot had already been examined and tested earlier on, after litterally being picked up from a dusty rack. A great deal of the original hardware, the motor drive electronics included, still remained untouched up to that moment. To start with, the electronic hardware, except the internal power source, the potentiometers and their signal routings had to be removed, because of no use.  
![]() THE ROBOT WITHOUT ITS CASE  
![]() CLOSER LOOK OF THE MECHANISM  
![]() MOTOR AND POTENTIOMETER FOR THE ROTATION AROUND THE HORIZONTAL AXIS   >>back to general block diagram  
|
|
THE POWER SOURCE The robot contains an internal power supply which generates a rectified +25 and -25 DC-voltage and a +13,8 and -13,8 DC-voltage. The +25 and -25 voltages act as ‘unregulated’ input voltages to a +15V and a -18V voltage regulator to supply the differential amplifier circuit, the bipolar output circuit and the DAC. The +13,8 and -13,8 volt supply the power operational amplifiers, at the same time being connected to +5 and -5 voltage regulators, providing the ADC and the DAC with the required supply voltage. The picture below shows the circuit board with the regulated voltage supply and the socket connecting it to the internal power source of the robot.
![]() REGULATED VOLTAGE SUPPLY Some persistence, time and energy was required to sort out the power supply issue. We had to determine whether the existing power supply was able to meet the needs of the DC motors as well as the electronic circuitry. Separating low and high current circuits appeared to be a wise decision. Besides we've almost scientifically proven the failure of the 7915 voltage regulator series. Having thouroughly tested almost 10 pieces, we found them at the least 'unreliable' and finally came up with a -18V voltage regulator. ATTENTION: the middle pin of the 78xx and 79xx series voltage regulators is connected to the heat sink! As for the 79xx series, the middle pin is NOT the ground pin ( 78xx series ), BUT the negative voltage input pin. >>back to general block diagram  
|
|
THE POTENTIOMETERS The position of the manipulator arm is detected by a set of 4 potentiometers, one corresponding with each degree of freedom. The output delivers a variable voltage, depending of the position of the corresponding degree of freedom. Usually, a potentiometer is connected to the mechanical point of interest in a way its output relates to the position of that point in a linear way. In this part we faced an unforeseen and tricky problem: a coupling between the horizontal and vertical degree of freedom, due to the cable system connecting them to their respective motors and potentiometers. From the beginning, we were aware of this mechanical coupling , but we didn't expect it to have any effect on the potentiometers' behaviour. A movement along the vertical axis, while keeping the position along the horizontal axis steady, results in a variation of the output of the potentiometer corresponding to the horizontal degree of freedom. This means that the potentiometer in question detects a movement which has never taken place, or, to put it in a different way, fails in detecting the horizontal motion that occurs when the vertical degree of freedom moves. The illustration below gives a better view on the problem. Of course this type of false measurement prevents the control algorithm from effectively imposing any 'control' whatsoever. Find more about this problem within chapter 'the differential amplifier circuit'. As a final configuration, we chose to supply the two pots for rotational motion with 15V and to decouple the two linear motion pots, originally wired in parallel. The pot for vertical motion is connected to -18V and +15V, the pot for horizontal motion to the ground and to +15V. >>back to general block diagram  
|
|
THE DC MOTORS The different degrees of freedom of the robot are actuated by 4 small DC-motors. In each case the rotation of the motor axis is converted according to the type of motion to be carried out, either with cables and pulley wheels or only cog wheels. Power supply ratings indicate a voltage range from -12V to +12V DC. >>back to general block diagram  
|
|
THE POWER OPERATIONAL AMPLIFIERS We are not able to connect the outputs of the DAC circuits directly to the motors: the current these electronic components can supply is far too small. Therefore, each output of the DAC-circuit is applied to a power OPAMP, configured as a buffer. In this part of the circuit, we get large currents that are not constant! Inductive effects and pollution of the power supply resulted in a failure of the electronic circuit. This problem was solved by putting capacities at the power supply pins of the electronic components and separating the power supply of the power opamps from the low current electronic circuit. ATTENTION: The used power OPAMPs (LM675) put a negative voltage on their heat sink! >>back to general block diagram  
|
|
THE MICRO CONTROLLER The MOTOROLA 68HC11E micro controller was put at our disposal. This device has an 8-bit CPU with a nominal bus speed of 2 MHz, 8 Kbytes of ROM, 512 bytes of EEPROM and 256 bytes of RAM. It also has various on-chip peripheral functions, such as a 16-bit timer system, an 8-bit A/D-converter and an asynchronous as well as a synchronous serial communications interface. For this project, another 32 Kbytes of external RAM were connected to the microcontroller. For more details on this microcontroller, see the Motorola website: http://e-www.motorola.com We used the internal RAM for the program variables and the external RAM to store the program itself. The timer system was implemented to ensure a constant sampling time. The synchronous serial peripheral interface (SPI) was used to communicate with the other microchips we worked with, namely an 8-channel/12-bit/Analog-to-Digital converter (ADC) and a 4-channel/12-bit/Digital-to-Analog converter (DAC). The Serial Peripheral Interface (SPI) SPI is a serial communications protocol supported by many devices. It enables the microcontroller, which acts as a master in our case, to exchange data with its slave devices, namely the ADC and the DAC. Generally, four pins of the microcontroller have to be connected to each slave device. Three of these microcontroller pins are common for all slave devices, namely the MISO-pin (Master In Slave Out), the MOSI-pin (Master In Slave Out) and the SCK-pin (Serial ClocK). The fourth is the SS-pin (Slave Select), which has to be unique for each slave device because it serves to select the device the microcontroller has to communicate with. Any data-exchange using SPI takes place as follows: first, the SS-pin of the slave is set to low. Before the exchange, the data from each device (master and slave) are stored in a register in the corresponding device (8-bit registers in our case). With each rising (or falling) slope of the clock signal, the data are shifted one bit via the MISO and the MOSI connection. This way, the slave data will be in the master register and the master data will be in the slave register after 8 clock cycles, thus completing the data transfer. >>back to general block diagram  
|
|
THE ANALOG-to-DIGITAL CONVERTER The MAX1270 - Multirange, +5V, 8-Channel, Serial 12-Bit ADC serves the purpose. We made use of free on line sample request possibilities at www.maxim-ic.com. In order to meet the specifications a 12-bit converter was preferable to the 8-bit adc present within the microcontroller-chip. The 4 analog voltage signals, representing the mechanical status of the robot (4 DOF's), and the 4 analog reference values, imposed by the user through bnc-cables, are converted into twelve bit digital numbers. The digital actual and reference values are then to be sent to the microcontroller by means of a data transfer protocol called SPI (...read more about it in chapter "the micro controller" and " the assembler code" ). The MAX1270 has software-controllable input ranges for each channel. >>back to general block diagram  
|
|
THE DIFFERENTIAL AMPLIFIER CIRCUIT In order to achieve maximal accuracy, the voltage sweep - or output range - of each potentiometer should nicely fit the chosen input range of each ADC input channel. We’ve chosen 3 quite straightforward ways to do so. The first one is adjusting the potentiometer’s voltage supply to have an output variation of approximately 10 V. The second and third one, shifting and ‘fine tuning’ the voltage range, is being done by differential amplifiers. As you noticed in the chapter about the potentiometers, we tried out an adc input channel range of [-10,+10]V. A malfunction appeared, so we concluded that the 8 input channels of the MAX 1270 should be configured in the same range [0,+10]V. The initial circuit consisted of 4 differential amplifiers with input signals directly connected. Due to the amplifiers low input impedance, currents vary with changing potentiometer impedance, causing an additional voltage drop and thus distorting the amplifiers input voltage. We beared in mind that this problem could occur, but having tested the rotational degree of freedom and the lineair motion in the horizontal plane the robot seemed to behave nicely , so we carried on. The potentiometer for horizontal motion, however, suffered from the unforeseen coupling, explained before, which did not appear until we altered the vertical position. Its voltage sweep at the amplifiers output varied from [0,+10]V below to [-10,0]V with the manipulator arm in it's highest vertical position. We assumed the coupling to be lineair and tried to implement a correction in assembler code, to the horizontal position signal, depending on the vertical position signal value. We noticed that the voltage sweep varied with the vertical position as well. We then measured the variation of the horizontal potentiometer signal at the output of the differential amplifier when altering the horizontal position. The fit gave us a parabola. Initially, we inclined to blaming the mechanical part. Maybe the square in the equation emerged from Phytagoras'theorem and the geometry of the system of cables was its logical proof? It began to look like a worst case scenario, leaving us with two ultimate solutions.Trying to find - by calculation or by measurement - the complex relationship between the voltage signal and the actual position and using the inverse function to implement a correction in the software part, or fixing another 'brand new' potentiometer on the manipulator. Ir. Ronald Van Ham, teaching assistant, took care of the latter, as you can see below.  
![]() WHEEL FOR THE NEW POTENTIOMETER   Measurements of the potentiometers impedance variation and an examination of the system of cables and wheels however, reveiled that the electronic circuit HAD to be the main cause. The figures below explain the input impedance problem in further detail. The most straightforward solution was to add a buffer amplifier for each signal, Vpot and Vpotref. Therefore we designed a new circuit board.  
![]() FIRST PROTOTYPE OF DIFFERENTIAL AMPLIFIER CIRCUIT  
![]() CALCULATION OF THE INFLUENCE OF THE AMPLIFIERS INPUT IMPEDANCE  
![]() IMPROVED DIFFERENTIAL AMPLIFIER CIRCUIT  
![]() HOW TO TUNE THE CIRCUIT?  
![]() THE ORIGINAL DESIGN  
![]() THE ADDITIONAL BUFFER CIRCUIT   Finally, we connected the horizontal motion pot to the ground and to +15V.The horizontal sweep is now reduced to [0,+5]V below and [+5,+10]V at the top. The numerical voltage signal correction, taking place in the microcontroller, solves the mechanical coupling problem. In spite of the slight loss of resolution and a few imperfections, we managed to solve the problem at last. If altered due to vertical motion, we clearly notice the horizontal reference position being restored. The controller controls after all... >>back to general block diagram  
|
|
THE DIGITAL-to-ANALOG CONVERTER This converter is a MAX536 - Calibrated, Quad, 12-Bit Voltage-Output DAC. Again, we made use of free on line sample request possibilities on www.maxim-ic.com.It's purpose is to convert the digital controller output signal to an analog voltage driving the DC motors. The latter should cover the desired range of -10V to +10V for proper driving capabilities. In a typical operating circuit the ADC output channels however, vary from 0V to the full-scale output voltage, set by a user defined reference voltage (maximum Vcc-4V). We chose 10V as a reference and configured the outputs for bipolar operation by using operational amplifiers in a voltage-shifter circuit. >>back to general block diagram  
|
|
THE BIPOLAR OUTPUT CIRCUIT As mentioned in the chapter about the DAC, this circuit shifts the voltage output range. The following diagram explains it's operation and structure. The circuits outputs are connected to the input pins of the power opamps.  
![]() VOLTAGE SHIFTING CIRCUIT DIAGRAM AND OPERATION   >>back to general block diagram  
|
|
THE ASSEMBLER CODE THE PROGRAM The microcontroller programming language is Motorola 68HC11 assembler. This is a low-level-language which is a little more difficult to use and to read than high-level-languages, and which is specific for this type of microcontroller. In the following, the main program and the subroutines are briefly discussed. More detailed explanation on the subroutines can be found in the comments in the program code. - Main program In the main program, the variables are initialised and various subroutines are called upon to configure the timer and the SPI, to get data from the ADC, to process this data and to send the processed data to the DAC. There is also some code that corrects the value of the measured position of the horizontal Degree Of Freedom (DOF), using the value of the measured position of the vertical DOF. This is necessary because the value of the measured position of the horizontal DOF varies when the vertical DOF moves, due to a coupling between these two DOF's, as explained in the chapters about the hardware. - InitSPI subroutine This subroutine enables and configures the Serial Peripheral Interface for communications with the slave devices. - InitRTI subroutine This subroutine configures the Real Time Interrupt (RTI). RTI is a function of the timer system that periodically generates an interrupt. Here it is configured to generate the interrupt every 4.10 milliseconds. Each time this interrupt occurs, a counter is increased. This counter is then compared with a certain value in the main program. When it reaches this value, data is sent to the D/A-converter, thus obtaining a constant sampling time. - GetFromADC subroutine This subroutine implements the SPI to get data from the A/D-converter. The input variable adccb is used to select the ADC-channel. The received data is stored in the variables adlsb (Least Significant Bits or LSB's) and admsb (Most Significant Bits or MSB's). - SendToDAC subroutine This subroutine implements the SPI to send data to the D/A-converter. The input variables damsb and dalsb contain the data to be sent (dalsb and damsb 4 LSB's) as well as the output channel selection (damsb 4 MSB's). - Multiplication subroutine This subroutine multiplies two 16-bit unsigned numbers. The output of this subroutine is a 32-bit number. This subroutine was written because there was only an instruction available to multiply two 8-bit numbers, while we needed to be able to easily multiply at least 12-bit numbers. - Addition subroutine This subroutine adds two numbers, whose absolute values are stored in two input variables and whose signs are stored in a separate input variable. This subroutine does not check for overflows, because normally it can't occur in this program that the result exceeds the 32-bit capacity. This subroutine was written to be able to easily add and subtract the results of the Multiplication subroutine. - PIDController subroutine
This is the most important subroutine, as it processes the input data,
namely the reference and actual value of the position of a DOF of the robot,
to obtain a value for the signal which is applied to the DC-motors on the robot.
This subroutine is, as its name says, a digital implementation of a classical analogue PID-controller (Proportionate-Integral-Differential).   THE CODE The complete assembler code, comments included. If you prefer to download an easy to read and more structured .txt file CLICK HERE . |
|
***************************************** * Kris Van den Abeele - 22/04/2004 * ***************************************** ************************************************* * Register Names * ************************************************* REGBLK EQU $1000 * Starting address for 68HC11 register block PORTD EQU $08 * PORT D memory location DDRD EQU $09 * PORT D Data Direction Register memory location SPCR EQU $28 * Serial Peripheral Condition Register memory location SPSR EQU $29 * Serial Peripheral Status Register memory location SPDR EQU $2A * Serial Peripheral Data Register memory location TMSK2 EQU $24 * Timer interrupt MaSK register 2 memory location TFLG2 EQU $25 * Timer interrupt FLaG register 2 memory location PACTL EQU $26 * Pulse Accumulator ConTroL register memory location
*************************************************
ORG $0000 * internal RAM used for data
*************************************************
ORG $8000 * External RAM used for program
*****************************************
* PID-controller 1
*****************
InitSPI
InitRTI
GetFromADC
PSHX
SendToDAC
PSHX
LDX #REGBLK * load Index Register X with starting address of register block (= 1000)
PIDController
PSHA
*********************************************************************************
*************************
*********************************
*************************
*****************************************************************
*****************************************************************
*****************
PULB
Addition
LDAA bools
PULB
Multiplication
PSHA
PULB
*********************************
RtInt
ORG $FFF0 * Real Time Interrupt vector location
ORG $FFFE   >>back to general block diagram  
|
|
  |
|
SOURCES
Microcomputer engineering, Gene H. Miller, 1993, Prentice Hall
The art of control engineering, Dutton, Thompson, Barraclough, 1997, Prentice Hall
Power electronics, Mohan, Undeland, Robbins, 1995, John Wiley & Sons
Mechatronica : inleiding tot de 68HC11 microcontroller, by Ronald Van Ham (in Dutch)
M68HC11E Technical Data
M68HC11E Reference manual
   
 
 
 
 
 
 
|
|
 
 
 
 
 
 
   
|