Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

Embed Size (px)

Citation preview

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    1/25

    UNIVERSITY OF OKLAHOMA

    DEPARTMENT OF ELECTRICAL ENGINEERING AND COMPUTER SCIENCE

    ECE-4973 SPECIAL STUDIES SEC. 23

    Dr. Sesh Commuri

    DEVELOPMENT OF A HEIGHT MEASUREMENT MODULE FOR A SMALL SCALE

    HELICOPTER BASED ON REFLECTIVE OBJECT SENSORS AND QUADRATURE

    DECODER

    By

    Jesyca Fuenmayor

    Norman, Oklahoma

    2013

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    2/25

    TABLE OF CONTENTS

    TOPIC Page

    1. Motivation 3

    2. Wide Explanation of the Module built 4

    3. Schmidt Trigger Circuit 9

    4. Quadrature Decoder 11

    5. Microprocessor 13

    6. LabView Program 14

    7. Post Processing Data 15

    a. Calibration Curve 15

    b.

    Matlab Program 20

    8. Results 21

    9. Conclusions 24

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    3/25

    MOTIVATION

    As a natural continuation of the developments the Autonomous Vehicles Group has

    made regarding Unmanned Aerial Vehicles (UAV), specifically in control systems, It is

    required to do the instrumentation and data acquisition for the helicopter BLADE 450 3D.

    This aircraft has been acquired in order to develop its complete automation. In order to doso, the group has constructed a safety structure to make some flying tests and has built

    modules for acquiring signals of the helicopter through GPS, IMU, Infrared Sensors,

    among others.

    The main interest is to be able to close the loop to control this helicopter. In order

    to do so, it is necessary to acquire other variables that help to determine the dynamics of

    this UAV. One of them, probably, one of the most important, is acquiring height data.

    In this line, the contribution of the current work is trying to develop a module that is

    able to measure the height of the helicopter when it is attached to the safety structure:

    Identifying the specific sensors to be used on the safety structure.

    Developing a design and fabrication proposal for an acquisition module to gethelicopters height data.

    Performing modular tests on breadboard to grant a good operation of the

    sensors and circuits to be used.

    Integrating the new module with the rest of the instrumentation system of the

    helicopter.

    1

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    4/25

    WIDE EXPLANATION OF THE MODULE BUILT

    The safety structure made for this helicopter allows the helicopter to have a 6DOF movement on

    a reduce span of height to be able to be used inside a lab room. The structure was designed in

    order to leave a space of around 1 meter from the ceiling to the helicopters blad es when the

    structure gets to its maximum height and around 1 meter from the ground to the helicopters legs

    when the helicopter hasnt risen. The structure consists in three concentric tubes. The outer one,

    hollow, has a diameter of 11.5 cm and a length of 82 cm. Its function is to protect and hide the

    inner poles and give support to the base where the helicopter is standing on top of the structure.

    The second tube, is also hollow and is made of carbon fiber, because this is the one that moves

    with the helicopter, therefore is necessary to minimize the weight and friction to affect the least

    the movement of the helicopter. Another important thing to note is that this tube has along a side

    a long groove that is crossed by a screw that is attached to the inner tube which function is to limit

    the maximum height of the helicopter. At a distance of around 1.5 cm from the bottom, this tube

    has a slot with a width and length of around 2 cm. Finally, the inner tube, made of metal besides

    having a hole for the screw has 16 slots each of them with a width of 1.5 cm and a length of 2 cm.

    These slots are the main reason to have chosen the sensors chosen. Given the nature of the

    structure, the sensors had to be able to change whenever they passed through the slots or when

    they were located in front of the solid parts of the inner tube.

    The structures characteristics mentioned above ledto pick photosensors, specifically reflective

    object sensors. The ones picked were the Fairchild QRD-114 Reflective Object Sensors because

    they presented several desired features:

    No contact surface sensing.

    Daylight filter on sensor.

    Phototransistor output.

    Compact Package.

    The idea was to use two sensors in an optimal configuration to detect the changes of states of

    the sensors when the sliding tube moved along the inner hollowed metal tube with the helicopter.

    Therefore, a decoder was chosen to interface the signals from the sensors to a microprocessor.

    The device used was the Avago HCTL-2022. That is a CMOS IC that performs a quadrature decoder,

    counter and a bus interface function.

    Given the specifications of the decoder with the inputs, the signals from the photosensors

    needed to be conditioned. For this, a single supply inverter Schmidt trigger circuit was designed.

    The threshold voltage levels were chosen in accordance to the sensors output. The non-conditioned output of one of the sensors wasnt clean and the low and high level varied,

    considerably; the difference between the high and low levels of the sensors was less than 1 V, but

    was always over 2.7 V. Therefore, the designed circuit had to take this into consideration. In order

    for the quadrature decoder to work properly it was extremely necessary that the inputs were

    above 4.5 V in high and below 1V in low. That implied that the OPAMP used in the Schmidt trigger

    circuit had to have a rail-to-rail response. For this reason, and because it included 2 different

    amplifiers inside, the OPA2340 was used.

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    5/25

    The quadrature decoders output was an 8 bit bus count that needed to be integrated with the

    rest of the helicopters instrumentation system. In order to do that, it had to be manipulated by

    the microprocessor on board: MCF51QE128. Nevertheless, as the quadrature output and

    microprocessor logic 1 levels didnt match, an 8 bit level converter was used between them. The

    microprocessors function for this sensor data was only acquiring it through wireless RS-232 serial.

    To save this data, a NI LabView program was designed and its function was to take the count fromthe microprocessor and assign to it a timestamp and save the information in a text file.

    Finally, the post processing part was made using MatLab and converting the count into cm using

    a calibration equation that was determined experimentally.

    The following parts of this work will explain in more details each part mentioned above, showing

    pictures and diagrams. Finally the results will be shown and analyzed.

    The following figure shows the updated energy connection card for the helicopter

    instrumentation when this module was added.

    Figure 1. Power Connection Diagram Updated

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    6/25

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    7/25

    Assuming the maximum forward voltage for the diode of VF=1.7V, a continuous forward current of

    If=50mA and Vcc=5 V. The value for the resistance to polarize the emitter was:

    =

    =

    5 1.7

    50 = 66

    The commercial value closer to the calculated value was chosen, in this case Rp=68. For the

    collector resistance of the sensor, any value in the order of k was good. The value chosen wasRC=1.2k.

    Figure 4 shows the voltage response of the sensors using the circuit described above. Note how

    the levels fluctuate when changing between high and low state.

    Figure 4. Output of one of the QRD-1114 (No Schmidt Trigger)

    After determining these values, the other important thing to consider was the position

    configuration of the sensors. After examining the tubes slots, the decision was to put the sensors

    one next to the other, trying to occupy a length smaller than 2 cm. After several tests, they were

    also put vertically because that configuration had a better out of phase quadrature response than

    the horizontal. Figure 5 shows the diagram with the final configuration used. This diagram

    corresponds to the final real configuration used. Note that each output of the sensor is identified

    with a different color. Given that they have to be in quadrature (90 degrees out of phase) it is

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    8/25

    important to note that when the helicopter is rising, the yellow one is ahead and when it is

    descending, the green one is ahead.

    Figure 5. Configuration Diagram for QRD-1114

    After implementing the real circuit, the obtained values for VFand IFwere measured and they

    are shown in table 1.

    Table 1. Measured parameters for sensors

    Variable Value

    Vf[V] 1.4V

    IF[mA] 50mA

    To obtain clean signals the Schmidt Trigger circuit needed to be implemented. Next section

    describes the parameters and specification used.

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    9/25

    SCHMIDT TRIGGER CIRCUIT

    As explained at the end of the last section. The Schmidt Trigger circuit needed to be

    implemented to obtain a clean and well defined signal that could be used as the input of the

    quadrature decoder. Given that the circuits used were single supply and that the output levels of

    the QRD-1114 in the low and high state were so close a very specific Schmidtt Trigger (ST) had to

    be used. The configuration diagram is shown in figure 6.

    Figure 6. Single Supply Inverting Schmidt Trigger Circuit and Hysteresis Cycle

    = (3)

    +3+3

    ()

    +3+3 Equation (1)

    = (3)

    +3+3Equation (2)

    Note that this variation of Inverting ST circuit uses 3 resistances instead of two as the regular ST

    circuits do. The intention of that resistance (R2in the figure) is to create a Virtual ground so the

    switching levels of the Schmidt Trigger are shifted up. The combination of the three of them make

    the hysteresis cycle wider or narrower. In this case, given the image shown in Figure 4, the values

    of VTHand VTLwere set to be below 4.7 V and above 4.1V respectively. Using these values and

    assigning R3=10k, R2 and R1 were cleared from equations (2) and (3), matching the values

    obtained with commercial ones, table 2 shows the values of the resistances for the circuit in figure

    6 and the specific VTHand VTLfor them.

    Table 2. Single Supply Schmidt Trigger Values

    VTH[V] 4.16

    VTL [V] 4.62

    R1[] 680

    R2[] 5.1k

    R3[] 10k

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    10/25

    All of these values were calculated assuming an ideal OPAMP, therefore a rail-to-rail single

    supply OPAMP had to be used. In this case the OPA2340 was used. The circuit tested on

    breadboard is shown in figure 7 and the correspondent response for just one of the sensors is

    shown in figure 8. Levels are well defined and the behavior corresponds to a square signal.

    Figure 7. Schmidt Trigger circuit on breadboard

    Figure 8. Sensor response after conditioning with Schmidt Trigger

    Finally, figure 9 shows the quadrature response of both sensors after been conditioned with the

    Schmidt Trigger signal. The signal in red corresponds to the yellow channel and the signal in blue

    corresponds to the green channel. It includes both when helicopter is rising (a) or descending (b).

    Figure 9. (a) Schmidt trigger outputs when Rising Figure 9. (b) Schmidt trigger outputs Descending

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    11/25

    QUADRATURE DECODER.

    For the AVAGO HCTL-2022 two things had to be conditioned, the Clock and the RESET signal,

    given that both came from the microprocessor and the levels were too low to make this chip work.

    Hence, a Non-inverting amplifier circuit was designed using the OPA 2340. The circuit is shown in

    figure 10 and shows the values of the resistances used. The Clock used was of 1ms of width (1kHz)

    and the RESET pin receives a rising pulse every time the circuits is on and stays in the high level to

    avoid any undesirable behavior of the chip during data acquisition and processing.

    Figure 10. Non-inverting amplifier circuit with OPA2340

    This circuit adds one to the count every time theres a change in the states of the inputs. Observe

    in figure 10 how does this chip perform the count when channel A is ahead channel B.

    Figure 11. Count up for Decoder

    This chip has the ability to count up to 4 bytes given the configuration of the pins SEL1 and SEL2.

    Table 3 shows the different configurations to get each byte.

    Table 3. HCTL-2022 BYTE SELECTOR CONFIGURATION

    BYTE SELECTED

    SEL1 SEL2 MSB 2ND 3RD LSB

    0 0 X

    1 0 X

    0 1 X

    1 1 X

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    12/25

    As the structures number of slots wont allow the count to reach more than 64, the

    configuration used was the correspondent to the LSB where SEL2=0 SEL1=1. Besides, the |OE pin

    needed to be connected to ground and to avoid any problem the INDEX and TEST too. Finally, the

    Quadrature Output was connected to a SN74LVC245 level converter to down convert from 5V to a

    3.3V logic level.

    Figure 12 the complete diagram for the card containing the Schmidt trigger, amplifier,

    quadrature decoder and level converter. The output of this card goes directly to port F of the

    microprocessor.

    Figure 12. New Card Circuit Diagram

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    13/25

    MICROPROCESSOR

    When using the Microprocessor to acquire the data, the idea was to try not to make it compute

    any calculation given the fact that when integrated with the rest of the instrumentation sensors,

    this module had to avoid to slow down the microprocessors homework that had been already

    assigned. Therefore, three more simple tasks were added:

    Configuration of the decoders clock and RESET pulse.

    Acquire the output data from the decoder.

    Send the data through RS-232 serial to interface with the LabView program.

    To do this, Port F was assigned to the decoders bus output, PTC1 to the Clock output and PT H7 to

    the RESET pulse output. This implied the existing microprocessor card had to be updated. The new

    diagram is shown in figure 12. Note that to be consistent with the others sensors transmission

    rate, the baud rate was set to 38400 baud/s.

    02220

    F1002igure 13. Microprocessor Card Updated

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    14/25

    LABVIEW PROGRAM

    Following the serial transmission for the other sensors, this program consisted in 2 while loops,

    one of them was used to read the data acquire via RS-232 and the other one was used to attach a

    timestamp to the data and save both indicators in a text file which name could be assigned by the

    user. Figures 14 and 15 show the block diagram and the front panel, respectively. Observe that the

    communication port, baud rate and text file name could all be altered by the user. Nevertheless,

    to use the same communication parameters than the rest of the sensors, the port had to be set as

    COM8 and the baud rate to 38400 to match the microprocessors one.

    Figure 14. LabView program blockdiagram

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    15/25

    Figure 15.LabView Program Front panel

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    16/25

    POST PROCESSING DATA

    After acquiring the count and store it with its correspondent time stamp in a text file, the next

    step was to read that count and based on a calibration curve trying to obtain the height values

    correspondent to each number of the count.

    CALIBRATION CURVE

    The first and most important thing to do was building this calibration curve. There are several

    methods to calculate calibration curves in this case the procedure consisted in the following steps:

    Acquiring the count number for a specific height value.

    Saving both the count and its correspondent height number into a table.

    Make a scattered plot count vs. height.

    Add a trendline and determine the one that describes better the relation.

    Experimentally get the values of the equation to obtain the best calibration curve

    using statistical methods.

    The first two steps needed to be done simultaneously because it was extremely important to see

    the exact height point where the count switched from a number to another, increasing or

    decreasing. As the maximum count value was known, 60, the decision taken was to get, for each

    value of the count its correspondent height switching value when ascending or descending and

    save that information into tables. Table 4 shows the results obtained.

    Table 4 Count vs Height data acquired

    Ascending Descending

    count 0. Height [cm] count Height [cm]

    01868 87.5 0 88.31 88.5 1 88.7

    2 89.6 2 90

    3 90.7 3 90.9

    4 91.7 4 925 92.7 5 92.8

    6 93.4 6 93.87 94.5 7 94.8

    8 95.5 8 95.8

    9 96.6 9 97.110 97.4 10 98.6

    11 98.9 11 99.412 99.6 12 100.3

    13 100.6 13 100.9

    14 101.2 14 102.6

    15 102.8 15 103.3

    16 103.5 16 104.3

    17 104.7 17 105.1

    18 105.2 18 106.319 106.4 19 107.2

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    17/25

    20 107.3 20 108.3

    21 108.4 21 109.1

    22 109.2 22 109.7

    23 110.5 23 111.324 111.3 24 112.4

    25 112.5 25 112.8

    26 113.1 26 114.427 114.6 27 115.3

    28 115.4 28 116.429 116.4 29 117.2

    30 117.3 30 118.5

    31 118.6 31 119.3

    32 119.4 32 120.3

    33 120.4 33 120.7

    34 121.5 34 122.2

    35 122.7 35 123.336 123.4 36 124.2

    37 124.3 37 124.838 125 38 126.5

    39 126.9 39 127.2

    40 127.4 40 128.441 128.7 41 129.2

    42 129.5 42 130.6

    43 131 43 131.3

    44 131.8 44 132.645 132.7 45 133

    46 133.2 46 134.9

    47 134.9 47 135.4

    48 135.8 48 136.6

    49 136.7 49 137.150 137.6 50 138.6

    51 138.8 51 139.2

    52 139.4 52 140.5

    53 140.9 53 141.1

    54 141.3 54 142.7

    55 143 55 143.4

    56 143.6 56 144.257 144.5 57 145

    58 145.6 58 146.559 147 59 147.5

    60 147.7 60 148.7

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    18/25

    Chart 1.Ascending movement

    Chart 2. Descending movement

    y = 1.003x + 87.456R = 0.9998

    0

    20

    40

    60

    80

    100

    120

    140

    160

    0 10 20 30 40 50 60 70

    Height [cm] vs. count ascending movement

    y = 1.0074x + 88.017R = 0.9998

    0

    20

    40

    60

    80

    100

    120

    140

    160

    0 10 20 30 40 50 60 70

    Height [cm] vs count descending movement

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    19/25

    Based on the data from table 4 and the graph from the chart it was determined that the relation

    between the count and height was linear, therefore, what is known as the most accurate statistical

    method: Least Squares Fitting Regression. The equations that describe this method are shown

    below:

    = Equation (3)

    = ( )

    [ ]Equation (4)

    = ( )

    [ ]Equation (5)

    Using these equations and the data from table one the equations for the ascending and

    descending movement were found and are shown below.

    Table 5. Curves Equations for ascending and descending movements

    Ascending movement = 1.002988 87.45627

    Descending movement = 1.007425 88.0166

    It is important to understand that this values consider the height of the helicopter related to its

    base or legs, not to his center of mass.

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    20/25

    MATLAB PROGRAM-Post Processing

    After this was determined the real post- processing needed to be done. To convert the count

    saved in the text files to the height physical unit, a MatLab program was designed. The program

    function was to extract the data from the text file created by the LabView program and transform

    the count into physical variables using the equations from table 5.

    Figure 16. Flow Diagram for Post- Processing the data

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    21/25

    RESULTS

    This section will show the results obtained after running the MatLab program. This program was

    run several times. In this report the 3 more important ones are shown. Figure 17 shows the curves

    Count vs. Time and Height vs. Time when the Helicopter was moved manually, this means, wasnt

    powered or moved using the RF remote control. Note how both curves behave in the same way,and the difference of height when is going up and when is going down. Note that whenever it goes

    back to the starting point (count=0), the height in cm has a variation of around half a cm. That is

    because the curves are based on the switching height value for each count number and, it could

    be observed in table 4, each count has a span of around 0.5 cm.

    Figure 17. Curves obtained when manually moving the helicopter on the safety structure

    Figures 18 and 19 correspond to the curves obtained when the helicopter movement was

    remotely controlled. The first one corresponds to the movement when the helicopter was trying

    to be maintained in a small range of movement. Note how the helicopter dynamic movement

    didnt introduce any noise to the signal, which behavior is till the one desired and observed in

    previous experimentations.

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    22/25

    Figure 18. Curves obtained whe moving the helicopter using the RF remote control and limiting its movement range.

    In Figure 18 the graphs show similar curved that end up in the highest value of the count, this isbecause, when running the experiment and trying to make the helicopter move its full range

    control was lost and it crashed. Nevertheless, it was possible to obtain a curve that reflected the

    helicopter movement. Note that the rising time of the helicopter was really fast and the sensors

    responded accurately. In order to show the correct behavior of the sensors and the module, a

    zoomed section of figure 19 is shown in figure 20. Note how the count still changes one by one.

    Note that the helicopter crashed, when it reached its highest possible position allowed by the

    safety structure; the communication was lost and thats the reason why the curves end on the

    highest number of the count.

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    23/25

    Figure 19.Curves obtained when flying the helicopter until crashed

    Figure 20. Zoomed in to region of interest for the curves of figure 19

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    24/25

    CONCLUSIONS AND FUTURE WORK

    Research Contributions

    The main contribution of this research is developing a low-cost solution for small scale

    helicopter height measurement module, particularly, when it is attached to a safety structure so it

    can be flown inside a room avoiding terrible damages to the aircraft or the room. The relevance of

    this work is related to the fact that height measurement plays a very important paper when trying

    to close the controls loop for Unmanned Aerial Vehicles.

    The module built represents an easy to build, small space method to measure the height

    of the helicopter. It also is useful when the processing wants to consume the less resources of a

    microprocessor given the fact that it doesnt add any complicated computation labor to it. Besides,

    its inputs dependence is not related to any microcontroller processing functions that could slow

    down the systems performance.

    Another important thing about this work is that it shows a really fast response which isdesirable for the application that it needs to be used for. As it could be observed in the results

    section, the counter response is almost immediate and this could be used in future works to do

    some real-time processing.

    It is very important to note that the module shows a very robust response to noise that

    the helicopter flying could introduce to the system.

    This module is integrated with other sensors to conform the Instrumentation System of a

    Small Scale Helicopter. The module is formed by photosensors, quadrature decoder and logic level

    converter, all of them light enough not to interfere with the helicopters flight and to beable to be

    integrated on board.

    Research Limitations

    Given the fact no one in the team was able to fly a helicopter, not many tested with the

    helicopter flying could be run. And even though the system showed a robust response to any noise

    introduce by helicopter flying mode, some uncertainty remains in this field.

    As the module built is based on the safety structure, some errors of height due to two

    main factors: The first one is because the calibration curve was made to give values related to the

    base of the helicopter and not to his center of mass, which means that if the helicopter rotates or

    flips up or down it might throw wrong results. The second one is the fact that wiring could always

    introduce noise that is not desired given to bad connections, or to over pressing them.

    The serial transmission velocity of the computer limited the data transmission, therefore,

    a software integration with the rest of the instrumentation system could be done because a

    processor with more capability needed to be used and given the short time a way to solve this

    problem couldnt be found.

  • 8/10/2019 Development of a Height Measurement Module Based on Reflective Object Sensors and Quadrature Decoder(1)

    25/25

    Future Work recommendations

    In order to keep improving this research a n important point to be consider is trying to

    actually integrate this module with the rest of the instrumentation system of the helicopter in

    order to see how it could be enhanced when referring to relating the rotor speed, IMU, GPS and

    other sensors with this one.

    An important thing to consider is developing a module that doesnt depend on the

    structure so it could measure the height of the helicopter when it is flying freely. An alternative

    will be using Digital Image Processing methods to actually obtain the location and height of the

    helicopter would be to use an onboard camera and some object identifications and tracking

    algorithms.