• No results found

High precision detection of multiple rotating objects

N/A
N/A
Protected

Academic year: 2021

Share "High precision detection of multiple rotating objects"

Copied!
112
0
0

Loading.... (view fulltext now)

Full text

(1)

High precision detection of

multiple rotating objects

(2)

Examensarbete TRITA ITM-EX 2018:197

Precisionsdetektering av multipla roterande

objekt

David Wallén

Godkänt

2018-08-17

Examinator

Lei Feng

Handledare

Bengt Eriksson

Uppdragsgivare

Humans since 1982

Kontaktperson

David Cox

Sammanfattning

Denna avhandling har skrivits i sammarbete med en Stockholmsbaserat konst- och designstudio

vid namn ''Humans since 1982'' som bygger och säljer modern högteknologisk konst till

marknader världen över. Studion ville utföra forskning kring att utveckla och implementera ett

system som detekterade och beräknade positionen av två roterande oberoende objekt monterade

på två stegmotorer via en växellåda. Produkten där lösningen skulle implementeras ställde olika

tekniska och designmässiga krav på implementationen. De viktigaste kraven var att lösningen

skulle klara en noggrannhet på ±1° med en precision på 99.95 %. Hastigheten för objekten som

detekterades var minst 50 [steg/sekund] och distansen mellan objekten och detektionsutrustning

var minst 20 [mm]. En barriär av ett ometalliskt material skiljde objekten och motorerna samt

den drivande elektroniken åt, vilket i kombination med en komplicerad växellåda förhindrade

användandet av IR baserade lösningar, rotationsenkoders eller mekaniska kalibreringsmetoder.

Olika möjliga tekniska lösningar i form av kapasitans- induktions- och radiobaserade

detektionsmetoder undersöktes. En lösning baserat på Hall-element och permanenta Neodymium

magneter föreslogs, designades, implementerades och testades. Två olika algoritmer för

automatisk detektion och kalibrering föreslogs och testades. Den första algoritmen var baserad

på att röra båda objekten samtidigt och den andra var baserad på att röra ett objekt i taget. Den

andra algoritmen visades vara mest optimal med avseende på tid, robusthet och noggrannhet och

efter implementation på hårdvaruplatformen (som bestod av en 32-bit ARM Cortex mikro

kontroller) åstadkom den en noggrannhet på ± 0.8° med en precision på 99.97 %.

(3)

High precision detection of multiple rotating

objects

David Wallén

Approved

2018-08-17

Examiner

Lei Feng

Supervisor

Bengt Eriksson

Commissioner

Humans since 1982

Contact person

David Cox

Abstract

This thesis project has been developed in conjunction with a Stockholm based art studio called

''Humans since 1982''. The studio builds and sells contemporary and highly technological luxury

art pieces all over the world.

The company wanted to perform research towards developing and implementing a solution that

detected and determined the position of two independent objects being rotated by two stepper

motors and a gearbox.

This thesis investigates possible proximity sensor solutions and their applicability and accuracy

for this application. The requirements of the solution are to perform detection of two rotating

loads driven by stepper motors at about 50 [steps/second] at a distance of 20 [mm] from any

sensing electronics within the accuracy of ±1° with a precision of 99.95 %. The loads were

mounted in such a way that they were not in line of sight from the driving motor or electronics

and a complex unmodifiable gearbox prevented simple solutions such as IR-based sensors, rotary

encoders and mechanical stoppers to be used.

(4)

Acknowledgements

For this project I would like to thank; Bengt O Eriksson, my academic supervisor, for guidance in my research and academic process. Your advice and remarks have helped me achieve good results and to produce an academic research report of high quality.

(5)
(6)

Nomenclature

Notations

Table 0.1: Notations Notation Meaning e Error r Actual position y Sensed position

|e| Absolute value of error ‡e Standard deviation of error

|e| Standard deviation of absolute error

I Current R Resistance L Inductance C Capacitance · Time constant O Oversamples

N Moving Average window size B Magnetic field

(7)

Table 0.2: Abbreviations

Abbreviation Expansion

AC Alternating current

ADC Analog to digital converter CAN Controller Area Network CPU Central processing unit

DC Direct current

DMA Direct memory access EMI Electromagnetic interference EMA Exponential moving average EMF Electromotive force

GPIO General-purpose input/output GUI Graphical user interface

I2C Inter Integrated Circuit

LSB Lease significant bit MCU Micro controller unit MOQ Minimum order quantity MTBF Mean time between failures

PCB Printed circuit board RAM Random access memory

(8)

Contents

1 Introduction 13 1.1 Background . . . 13 1.2 Research questions . . . 14 1.3 Requirements . . . 15 1.4 Limitations . . . 15

1.4.1 Component location constraints . . . 16

1.4.2 Cost constraints . . . 16

1.4.3 Methodology . . . 17

2 Frame of reference 21 2.1 Stepper motor types, control and feedback . . . 21

2.2 Proximity sensors . . . 28

2.3 Magnets . . . 33

2.4 Sensor and magnet placement . . . 35

2.5 Sampling, filtering and accuracy . . . 35

2.6 CPU Utilization and Memory consumption . . . 43

2.7 Component failure rate . . . 44

2.8 Summary . . . 45

3 Implementation 47 3.1 Requirements . . . 47

3.2 Hardware . . . 49

3.2.1 Sensor and magnet . . . 49

3.2.2 Logic module . . . 51

3.2.3 Fixation module . . . 51

3.2.4 Motor module . . . 55

3.2.5 Filter . . . 55

3.3 Software . . . 56

3.3.1 Test case monitor . . . 56

3.3.2 Embedded software . . . 58

3.4 Test case design . . . 60

3.5 Component failure rate . . . 64

(9)

4 Analysis and Result 71

4.1 Exploratory results . . . 71

4.2 Design driving results . . . 75

4.3 Multiple object detection . . . 81

4.3.1 CPU Utilization and Memory consumption . . . 86

4.3.2 Maximum distance and obstructing material . . . 86

(10)

List of Figures

1.1 A million Times 288 . . . 14

1.2 Load mounting . . . 14

1.3 Possible locations . . . 16

1.4 Load mounting, top view . . . 17

1.5 Load mounting, side view . . . 18

1.6 Test case design . . . 19

1.7 Test case execution . . . 20

2.1 Variable reluctance stepper motor [22] . . . 22

2.2 Permanent magnet stepper motor [23] . . . 22

2.3 Hybrid stepper motor [24] . . . 22

2.4 Phase activation during full stepping [21] . . . 23

2.5 Phase activation during half stepping [21] . . . 24

2.6 Phase activation during micro stepping [21] . . . 25

2.7 Torque-Frequency curve of different motor types [25] . . . 25

2.8 Torque-Frequency curve of stepper motor, image by Motor manufacturer, 2014. . . 26

2.9 Radio based sensor accuracy [8] . . . 29

2.10 Inductive sensor circuit diagram [27] . . . 29

2.11 Materials for inductive sensing [28] . . . 29

2.12 Capaticive sensor circuit [7] . . . 30

2.13 Hall element response to magnetic field [31] . . . 31

2.14 Hall effect circuit diagram [31] . . . 31

2.15 Hall sensor output [31] . . . 32

2.16 Magnetic field lines [32] . . . 33

2.17 Magnetic hysteresis [33] . . . 34

2.18 Flux density versus distance . . . 34

2.19 North and south poles towards sensor [31] . . . 36

2.20 One pole towards sensor [31] . . . 37

2.21 Low Pass filter design . . . 38

2.22 Low pass filter [45] . . . 39

2.23 Moving average filters [5] . . . 40

2.24 Accuracy vs. Precision [46] . . . 41

(11)

2.26 EMI interference [42] . . . 43

2.27 Product Life Cycle [41] . . . 44

3.1 Hardware architecture . . . 50 3.2 Hardware modules . . . 50 3.3 Fixation module . . . 52 3.4 Reference point . . . 52 3.5 Coordinate system . . . 53 3.6 Sensor measurements . . . 53

3.7 Sensor position measurements . . . 54

3.8 Low Pass filter design . . . 55

3.9 Low Pass filter frequency response . . . 56

3.10 Test Case Monitor . . . 57

3.11 Software architecture . . . 58

3.12 Mechanical stopper . . . 61

3.13 Detection using different polarity . . . 65

3.14 State machine for different polarity detection . . . 66

3.15 State machine for different movement detection . . . 67

3.16 State machine for different movement detection . . . 68

4.1 Motor movement, load passing sensor twice . . . 72

4.2 Low pass filter 1 . . . 72

4.3 Low pass filter 5 . . . 72

4.4 Different sensors comparison . . . 73

4.5 Background noise . . . 74

4.6 Background noise distribution . . . 74

4.7 Hardware filter . . . 75

4.8 Oversampling . . . 76

4.9 Distance increase . . . 77

4.10 Long distance from sensor . . . 78

4.11 Moving Averages comparison . . . 78

4.12 Error distribution . . . 80

4.13 Error distribution, load movement direction reversed . . . 80

4.14 Hour and minute passing . . . 81

4.15 Hour and minute different offset . . . 82

4.16 Phase adjustment system . . . 82

4.17 Hour and minute different offset same polarity . . . 83

4.18 Peak detection . . . 84

4.19 Peak detection zoomed . . . 85

4.20 One load vs. Two loads over sensor . . . 85

4.21 Sampling and filter calculation time consumption . . . 86

4.22 Apex calculation time consumption . . . 86

4.23 2D accuracy plot . . . 87

(12)

List of Figures

4.25 Acceptance test setup . . . 88

6.1 Test Case ID 38 . . . 105

6.2 Test Case ID 37 . . . 105

(13)

0.1 Notations . . . 5

0.2 Abbreviations . . . 6

2.1 Magnet material comparison chart [31] . . . 35

3.1 Technical requirements . . . 49

3.2 Stepper motor parameters . . . 55

3.3 Software tasks . . . 59

4.1 Sensitivity measurements . . . 73

4.2 Oversampling . . . 76

4.3 Oversampling load comparison . . . 76

4.4 Distance testing . . . 77

4.5 Moving average testing . . . 79

4.6 Acceptance test . . . 88

(14)

Chapter 1

Introduction

This section aims to give an introduction to the company that hosted the project, the problem that was solved including requirements and limitations and finally the method used to solve the problem and complete the project.

1.1 Background

(15)

Figure 1.1: A million Times 288

1.2 Research questions

The problem consisted of investigating possible proximity sensor solutions for de-tecting the two loads, as indicated in Figure 1.2, building the detection system and finally evaluate its performance in the given application.

Motors and gearbox

Load 1 Load 2 Plane of rotation

Figure 1.2: Load mounting

(16)

1.3. REQUIREMENTS

based on infrared proximity sensors, which proved not accurate enough, and image recognition using an external camera, which proved too expensive and logistically extensive for a large scale production.

In solving the problem at hand this thesis aimed to answer the following research questions:

1. Is it possible to detect a magnet to an accuracy below ± 1 [mm] at a distance of 60 [mm] from the motor shaft (corresponding to a rotational accuracy of ± 1 °) at a distance of 20 [mm] between magnet and sensor.

2. Is it possible to detect a magnet to the accuracy requirements in question 1 when a sheet of Corian is inserted between the sensor and the magnet?. 3. What is the maximum distance between magnet and sensor where it is possible

to achieve the accuracy requirements in question 1.

1.3 Requirements

The most important requirements for the implementation were related to accuracy and robustness of the system. The accuracy requirements were connected to the visual appearance of the product and were set by the design department at the company and the robustness and reliability requirements were set by the engineering department. The requirements were summarized as:

1. The accuracy of the position detection system must be within 1° 2. The system must have a reliability of over 99.95 %

3. The system must allow a gap between sensor and load of at least 20 [mm] 4. The system must be able to detect two loads

5. The system must be self calibrating

6. The system must be able to perform the self calibration in under 300 [seconds] 7. The components for the system must not cost more than 3 [USD] per load

pair at an order quantity of 100 pieces.

1.4 Limitations

(17)

1.4.1 Component location constraints

Due to the integrity of the art piece and the fact that the clean surface plays a big role in the presentation it was not allowed to place any components observable from the front side of the piece, as indicated by Figure 1.3. Neither was it allowed to make any alterations to the surface material such as drilling holes.

PCB Motor 1 Load 1 Load 2 Motor 2 Gearbox Material Material

VISIBLE CHANGES NOT PERMITTED HERE      

View of observer

Figure 1.3: Possible locations

1.4.2 Cost constraints

(18)

1.4. LIMITATIONS

factor opposing sensing based on the shafts was the mechanical connection between the shafts and the loads, which lacked a proper axial lock, instead relying on friction as indicated in Figure 1.4. This meant that if a shaft-based sensing method was implemented and the loads slipped on the shafts the sensing solution would present an offset and unable to correct itself.

Motor and gearbox

Load 1

Load 2 Shaft 1

Shaft 2

Figure 1.4: Load mounting, top view

Given the requirements and limitations a set of parameters presumed to affect the accuracy of the solution was selected and investigated during this project;

1. Type of sensor 2. Type of digital filter 3. Type of analog filter 4. Sample rate

5. Distance between sensor and shaft axis 6. Distance between sensor and sensed object

1.4.3 Methodology

(19)

and the method to solve it was chosen, which resulted in this chapter. Subsequently a pre-study was performed on existing proximity sensing solutions where their ac-curacy and limitations were investigated and together with other theoretical areas such as sampling and filtering which were used in the project. The pre-study and theoretical areas were summarized in the frame of reference chapter. Thirdly a demonstrator was built using the theories and practices posed and selected during the previous phased, which was described in the implementation chapter. Once completed, the demonstrator was used to test solutions against the requirements and either confirm it’s functionality or tweak the implementation to move closer to a working solution, this was done iteratively and was summarized in the Results chapter and discussed in the conclusion and discussion chapters.

The main measures of how well the solution was working was its accuracy (or its inverse, error) and the precision/reliability which were directly related to the error, e. The error was defined as the difference between the actual position, called r, and the sensed position, called y, of the load(s) as described in Equation (1.1) and illustrated in Figure 1.5 e= r ≠ y (1.1) Sensed position, r Actual position, y Error, e 0 position Sensor Load

Figure 1.5: Load mounting, side view

where a small error corresponds to an accurate system. Due to the importance of the error it was natural the most of the requirements written and test cases were focused around the error. This section details the general approach used with test cases and their result as a part of the development process, the most significant test cases were explained in detail in Section 3.4 and the rest of the test cases and their procedures can be found in Appendix A.

(20)

1.4. LIMITATIONS

r was known and consistent throughout the test cases. In order to quantify the reliability of the system the consistency of the errors during the variation of the dif-ferent parameters was investigated. Statistical measurements such as average error and standard deviation of error were taken and used as a metric for the reliability. The absolute value of the error, hereby denoted as |e|, was considered the primary metric of the accuracy of the system and the standard deviance of the absolute error, hereby denoted as ‡e was used as the primary metric for precision. These

parameters are explained more in detail in the Implementation section.

The chosen scientific method was to state a hypothesis regarding a parameter, design and run a test case to verify or deny it using the metrics previously stated and subsequently adjust the parameters or theory towards the general goal of fulfilling all of the requirements. The development process was structured to fulfill the most important requirements first, so tests regarding accuracy and precision were the main focus for the beginning of the project, and the algorithm for self calibration was constructed after those requirements were fulfilled while simultaneously having an eye on the final component cost in order not to exceed the budget. This method was clearly quantitative [20] in nature since many of the results were based on numerical comparison and logic deducted from graphs produced by the collected data. In order to simplify the gathering of the data, secure its validity and minimize the errors in the data gathering process a test rig and a software platform for automating the testing was constructed. The basic test cases consisted of setting up the sensor relative to a known zero position, performing a series of tests and evaluate the results, as described in Figure 1.6

Figure 1.6: Test case design

Different types of test cases had different configurations and test conditions, but a majority of the test cases consisted of repeated measurements in order to capture deviances and perform statistical analysis on the results. The general process of test case execution was described in Figure 1.7.

(21)

Figure 1.7: Test case execution

(22)

Chapter 2

Frame of reference

This section contains the collection of existing research on the subject that was gathered as a part of the background study including stepper motor operation, control and feedback, possible technical solutions to the problem and the previously achieved accuracy, embedded system implementation constraints, hardware failure rates as well as brief technical descriptions on the components provided by the company.

2.1 Stepper motor types, control and feedback

Types

Stepper motors have ever since their invention in the 1930s by the United Kingdom Navy [35] stood for high precision and accuracy movement and have found its way into applications in industries such as factory automation, aerospace, automotive and many more. The basic functionality of a stepper motor is to convert electrical pulses to precise incremental mechanical movements with a high holding torque. In general there are three types of stepper motors;

1. Variable reluctance stepper motors, which consist of a multi-toothed rotor and stator which are energized with direct current, abbreviated DC, and attract the rotor, as indicated by Figure 2.1

2. Permanent magnet stepper motors, where instead of teeth the rotor consists of multiple magnets with alternating north and south poles, as indicated by Figure 2.2. The magnetic rotor is surrounded by two coils that are energized in order to move the rotor. This results in a lower resolution (generally 24-48 steps per revolution) than variable-reluctance, but generally higher torque performance at a reduced cost.

(23)

Figure 2.1: Variable reluctance stepper

motor [22] Figure 2.2: Permanent magnet steppermotor [23]

and they are also the most expensive type. The rotor is axially magnetized and has many teeth to help guide the magnetic flux towards the many stator coils surrounding it, as indicated in Figure 2.3. The coils can be individually energized and with the many teeth and precision guiding of magnetic flux this type of stepper motor can usually achieve a resolution of 100-400 steps per revolution.

(24)

2.1. STEPPER MOTOR TYPES, CONTROL AND FEEDBACK Motor control

In general, control of all types of stepper motors involves energizing the coils with varying phase and intensity, a task normally not handled directly by the micro controller unit, abbreviated MCU, as it can be very resource consuming. Instead this task is usually handled by a stand alone embedded circuit called a stepper motor driver. The stepper motor driver is normally configurable by setting pins corresponding to certain functionalities logically low or high or by communicating with the MCU over a serial interface. The stepper motor driver normally takes the control signal to the motor in the form of pulses on a specific pin where one pulse corresponds to one step (with the settings configured during initialization). Since one pulse to the motor controller corresponds to one step (irrespective of step resolution) the motor position becomes proportional to the number of pulses and the motor speed is proportional to the frequency of the pulses. Different stepper motor drivers support different ways of controlling the motor, such as full stepping, half-stepping and micro stepping.

Full stepping can be performed by either using one phase or two phases at a time depending on motor construction and design requirements as indicated in Figure 2.4. Using two phases when full stepping usually provides a larger holding torque at the cost of higher power consumption.

Figure 2.4: Phase activation during full stepping [21]

Half stepping is a mix of one and two phases and provides twice as many step intervals as full stepping as indicated in Figure 2.5.

(25)

Figure 2.5: Phase activation during half stepping [21]

can be achieved by applying a constant voltage on the coil (or both coils if two phase full stepping or one-two phase half stepping is used). Once the magnet (rotor) has rotated (i.e. taken one step) the driving circuit applies the same constant voltage to the next coil(s) in the sequence causing the rotor to take another step, this method of driving is called voltage mode control [48]. In order to know what voltage that needs to be applied to the motor coils, Vapplied, in order to get the wanted holding torque

(which is proportional to the wanted current, Itarget) an approximation model can

be used [49]. This model is based on the motor components consisting of the winding resistance, Rm, winding inductance, Lm, and back electromotive force, abbreviated

EMF, calculated by the motor constant, Ke, and is indicated by Equation system

(2.1). Vapplied = I Rm· |Itarget| + Kefel, when 2fifel< RLmm 2fifelLm|Itarget| + Kefel, when 2fifel> RLmm (2.1) which results in an open loop control since the current does not need to be mea-sured, simply calculated as a function of the wanted holding torque.

Additional step resolution can be achieved using a technique known as micro step-ping. Micro stepping is based on the same principle as half stepping, where multiple adjacent coils are used in order to gain a smoother transition between steps, with the difference of instead of having binary states for the voltage (and thus in the resulting current) in the coils the current can be regulated in finer steps, with a resolution dependent on the stepper motor driver, as indicated by Figure 2.6, this method is called current-mode control.

(26)

2.1. STEPPER MOTOR TYPES, CONTROL AND FEEDBACK

Figure 2.6: Phase activation during micro stepping [21]

in order to keep the currents in the phases at a 90 °offset between each other. An important design relation when comparing and understanding how different motors perform is the torque-frequency curve, which displays the motor torque as a function of its rotational speed. Most motors have a strictly declining torque-frequency curve, with the exception of some alternating current, abbreviated AC, variants, an example is shown in Figure 2.7.

(27)

For stepper motors the torque drop-off comes as a result of the inductance in the motor coils. The torque in a stepper motor is proportional to the magnetic field, B, generated by the coils which is proportional to the number of windings in the coils, n, and the current through the coils, I, as a result of Ampere’s Law as stated in Equation (2.2).

BÃ I · n

r (2.2)

where r is the radius of the coil. Since r and n are fixed mechanical design parame-ters of the motor the only parameter that varies with normal operational conditions are the current I through the coils, where a large current corresponds to a large magnetic field, and the maximum current through the coil, which is dependent on the winding resistance, R. The rise time of the current through a coil is well known to be determined by the RL constant of the circuit given by Equation (2.3) and thus for very low speeds where the current is able to saturate the torque is constant.

· = L

R (2.3)

But as the step frequency is increased the current is not able to fully saturate thus causing a decline in the torque. For the stepper motor used in this project the torque-frequency curve is indicated in Figure 2.8.

(28)

2.1. STEPPER MOTOR TYPES, CONTROL AND FEEDBACK Missed steps and feedback

Under normal operating conditions in a correctly dimensioned system a stepper mo-tor should not miss any steps and the controller can maintain its position (relative to the starting position) simply by counting the number of pulses that has been sent out. But in many applications the starting position of the motor can vary depend-ing on previous operatdepend-ing states, power failures or other external conditions. In applications where the position relative to a known mechanical location is needed it is common to install a mechanical stopping point past the motors normal operating range and during initialization of the system driving the motor and load past this mechanical stop in order to calibrate the position. An example of this is 3D printers upon power-up moving the printer head to the corner of the build plate until it hits the wall.

In an incorrectly dimensioned system a stepper motor can loose steps for a number of reasons. If the load on the stepper motor has a too high moment of inertia the system could start to act like a spring/mass rotary pendulum, and if the system is only lightly dampened the load could overshoot the equilibrium point for each step followed by a recoil back towards the equilibrium point (now moving in the opposite of the intended direction). If the recoil after the overshoot is timed with the next step of the motor the load could slip into an adjacent cycle of movement causing a loss of 4 steps [50]. This phenomenon is usually called low-frequency resonance and is commonly present around 150 to 500 steps per second.

Another possible reason for lost steps, often called medium-frequency resonance, can occur in the speed register where it is not entirely obvious where current- or voltage-mode drive should be used. This edge-case could cause the motor driver to oscillate between driving modes with undefined behavior and possible lost steps as a consequence [50].

At high motor speeds (in the realm of 2000 steps / second) the back EMF starts to oscillate and as a result the equations used to compensate for back EMF becomes inaccurate, if voltage mode drive is selected this could cause the motor to loose steps and eventually stall completely.

(29)

2.2 Proximity sensors

The fact that the loads are not in line of sight of the printed circuit board (PCB) and the limitation of not being able to alter the material combined with the cost limitations (which basically prevents any extensive modifications to the gear box) or shafts limits the possible sensor solutions to non-line-of-sight based sensor solu-tions, which concluded the limitations for the research on proximity sensors. With this scope defined, the possible options that were deemed probable contenders were; radio-, inductive-, capacitive- and Hall effect-based proximity sensors. These proba-ble contenders were evaluated with respect to their accuracy and operational range. Since the accuracy requirements of the system to be built are in the rotational domain and the proximity sensors are in the linear domain it is not possible to di-rectly translate the number and categorize the different options as suitable or not, but rather see if they are within probable chances of fulfilling the requirements. The real investigation and evaluation is done by the empirical test cases conducted later in the project.

Radio based sensors

Radio based sensors for proximity detection work by having a receiver and trans-mitter on each location of the object to be sensed, called O, and the sensor, called S. The transmitter at S would emit a signal to the receiver at O which would re-spond with a different signal picked up by the receiver at S. The system at S would compute the time difference between the emitted message and the response from O and using the known wave propagation speed of a radio signal of 3 · 108 [m/s] the

distance between the objects can be calculated. It is easy to understand that small timing errors will result in large range errors and in order to capture distances in the millimeter spectrum (which is the scope of this project) the processor would need to be able to measure time differences in the pico-second range. Existing research shows that a low-cost application with this technique using multiple reference nodes achieve an accuracy of 1-3 [m] in real-world ranging and localization experiments [8] as indicated in Figure 2.9. As a result of the poor accuracy combined with the heavy computational requirements radio based sensor solutions were deemed not suitable for this application.

Induction based sensors

(30)

2.2. PROXIMITY SENSORS

Figure 2.9: Radio based sensor accuracy [8]

Figure 2.10: Inductive sensor circuit diagram [27]

changes in current or voltage [26]. A key factor in the sensing range and accuracy is the type of metal to be detected and the content of iron in the metal. A relative coefficient, Km, symbolizing the reduced effect of materials containing less iron is listed in Figure 2.11

Figure 2.11: Materials for inductive sensing [28]

(31)

vi-ability of the technology. It was not possible to determine how surrounding ferrous materials such as screws, motors, housing, printed circuit board, abbreviated PCB, or other components would impact the sensor solution at this stage, it required empirical investigation.

Capacitance based sensors

Capacitance based sensors work by measuring the capacitance between two plates (at different potentials) housed in the case of the sensor, as indicated by Figure 2.12

Figure 2.12: Capaticive sensor circuit [7]

As a conductive or partially conductive object comes near the plate the mutual capacitance between the plates and the target object changes. The change in ca-pacitance is registered by the control unit in the sensor which changes the voltage or current output depending on the sensors sensitivity, a common sensitivity for a capacitive sensor is in the range of 1 V/0.1 [mm]. Since both conductive and non conductive surfaces can hold charges the loads would not need to be retrofitted with any type of object (such as magnet or strip of metal for inductive or hall based types of sensors). An immediate drawback is that the capacitive sensor becomes sensitive to other things in the surroundings, such as screws PCBs and most importantly the material barrier between the sensor and loads. For this reason capacitive sensors were not considered for this application.

Hall effect sensors

The Hall effect was discovered by Dr. Edwin Hall in 1879 and is based on the fact that when a current carrying conductor is exposed to a magnetic field a voltage is generated perpendicular to the flow of the current and the lines of the magnetic field [31] as indicated in Figure 2.13. This is the result of a Lorentz force [2] which is exerted on the current which disturbs the current distribution and results in a potential difference, VH, that can be measured. The potential difference is called

the Hall voltage and its relation is described by Equation (2.4)

(32)

2.2. PROXIMITY SENSORS

Figure 2.13: Hall element response to magnetic field [31]

and is usually in the order of 1µv

Vs/Gauss where

v

Vs is the radio of output voltage

as a fraction of the supply voltage and Gauss represents the magnetic flux density. Hall sensors exist mainly in two variations;

1. Threshold sensors, which produce a constant voltage when the external mag-netic field reaches a certain threshold. They are used mainly to produce pulse trains in order to measure speed of rotation or movement.

2. Linear sensors, which produce a voltage proportional to the strength of the magnetic field around it. These are more suitable for our application In the linear sensor applications a differential amplifier, with gain dependent on the sought after sensitivity of the sensor is commonly used in order to give the sensor an output measurable by an external circuit as indicated in Figure 2.14.

Figure 2.14: Hall effect circuit diagram [31]

(33)

Figure 2.15: Hall sensor output [31]

Given this linear relation the output of the sensor, v

Vs, is proportional to the strength

of the magnetic field, B, which is inversely proportional to the square of the distance, d, between the source of the magnetic field and the Hall element (sensor) according to Equation (2.5).

v Vs Ã

1

d2 (2.5)

The accuracy of the Hall sensor solution is dependent on the placement and imple-mentation. Hu el al.[9] proved that it is possible to achieve an error of 1.8 [mm] at a distance of several centimeters while using a cubic magnetic sensor array. U. Marschner and W.J. Fischer [10] showed that it is possible to achieve high accu-racy with a 1D-array as well and F. Burger el al. [11] achieved a ± 0.3 ° precision in angular position measurement with a 3-D magnetic sensor. These were some promising results regarding the accuracy, but since the intended application had a combination of constraints different from the ones posed in those studies further empirical studies were needed in order to confirm the accuracy. Hall based sensor solutions also require a magnet to be attached to both of the loads, but that could be fit within the requirements of the applications.

(34)

2.3. MAGNETS

2.3 Magnets

The Hall based sensor system and its design parameters stretched beyond the type of sensor, its output and sensitivity. The magnet that is to be detected also plays a fundamental role in the system as its physical properties impact the behavior of the system and its downstream components. In order to further understand and design the Hall sensor solution in addition to understanding the sensor itself a background study on magnets and magnetism was also conducted. A magnet produces a magnetic field consisting of electric charges that travels from the North pole to the South pole as indicated in Figure 2.16.

Figure 2.16: Magnetic field lines [32]

The strength of the magnetic field, usually noted H, is measured in amperes per meter, and the total amount of magnetic field through a 2-dimensional slice is the ”flux” in units of Weber. Weber per square meter describes flux density or magnetic induction, usually noted B, in units of Tesla [T] or Gauss [G] where 1 [T] = 10 000 [G]. The basic properties of a magnet and some common annotations can be explained by looking at the magnets BH curve, as indicated in Figure 2.17 which has the magnetic field strength, H, of an iron core on the x-axis and magnetic flux density, B, on the y-axis, starting with a non-magnetized iron core with B = 0 and H = 0 at the origin of the graph. As a magnetization current is applied through a coil surrounding the core the field strength and magnetic flux density increases towards point a (and eventually saturation). If the magnetization current is reduced to zero the field strength around the core also reduces to zero but the flux density will settle at point b, called the residual magnetism, BR. The magnetic flux can be

reduced to zero by applying a negative magnetization current, and the magnetizing force as a result of this is called the coercive force, HC. Another common metric

(35)

point on the magnetization curve. The maximum energy product corresponds to the maximum amount of energy that can be stored in a magnet with respect to its volume.

Figure 2.17: Magnetic hysteresis [33]

When taking into account properties of the magnet the relation in Equation (2.5) could actually be extended to include a rough proportion to the surface area of the magnet as well where a larger area, A, of the magnet is linearly proportional to its flux density. The equation can be extended to Equation (2.6)

v Vs Ã

A

d2. (2.6)

and with a constant value on A the expected relation between the flux density and the distance from the magnet is illustrated in Figure 2.18 which corresponds to an inverse quadratic relation between sensor reading and distance from magnet.

0 2 4 6 8 10

Distance from magnet 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Flux density

(36)

2.4. SENSOR AND MAGNET PLACEMENT

The material of the permanent magnet also affects the maximum flux density and the most common materials are summarized in Table 2.1. In addition to the physical characteristics previously discussed another important property of magnets which differ between materials is its ability to maintain its flux density when the temper-ature changes. An increase in tempertemper-ature corresponds to a decrease of magnetic flux density, annotated as BRTC in units of percent per 100 degrees Celsius above

25 °C. As an example a magnet made of Alnico will have 2% less flux at 125 °C, while a Neodymium magnet loses 12 % of its flux at the same temperature.

Table 2.1: Magnet material comparison chart [31]

Class of Material BR HC BDHD Cost Stability BRTC

Alnico High Low Med. High Med -0.02

INDOX Low High Low Low High -0.2

Ferrite Med Med Med Low High -0.04

Rare Earth High High High High High -0.12

NdFeB High High High Med High -0.12

Which led to the most appropriate candidate to be NdFeB, or more commonly known as Neodymium magnets due to its high flux density, high stability and low cost.

2.4 Sensor and magnet placement

After the type of sensor was chosen, the last set of physical design parameters which affected the system performance and subjected to some research was the placement of the sensor and magnet. Since most Hall element sensors are directionally sensi-tive dependent on the flux lines different sensor and magnet placements will yield different results of graphs during movement of the loads. Placing a bar magnet with both north and south poles parallel to the sensor would cause the sensor readings to change from positive to negative as the magnet passes by, as indicated in Figure 2.19 and the middle would be marked by the inflection point, which is a computa-tionally difficult but doable problem.

The magnet could also be placed with one pole facing the sensor and the other facing away causing a simpler pattern to read, as indicated by Figure 2.20. This would result in the middle point being marked by the maximum (or minimum depending on magnet orientation) point, a computationally simple problem.

2.5 Sampling, filtering and accuracy

(37)

Figure 2.19: North and south poles towards sensor [31]

to other research papers and books.

Sampling

The signal from the sensor can be either digital or analog depending on the sensor type used. A digital sensor would itself perform the conversion of the data to the digital domain and communicate it to the MCU using protocols such as Inter Integrated Circuit , abbreviated I2C, or a Serial Peripheral Interface, abbreviated

SPI. These types of sensors often provide the ability to adjust settings (such as sample rate, sensitivity, buffer length etc.) via data communicated from the MCU over the same protocol. Analog sensors simply provide an analog output on its output pin and thus the signal conversion to the digital domain needs to be handled by the MCU itself. This is achieved in the MCU in an analog to digital converter, abbreviated ADC, where the analog signal, VIN is compared to several thresholds

based on a reference voltage value VREF and a digital value, D is written to a

location in the memory as described by Equation (2.7)

D= VIN(2 N≠ 1)

(38)

2.5. SAMPLING, FILTERING AND ACCURACY

Figure 2.20: One pole towards sensor [31]

where N is the resolution of the ADC in bits. Different MCUs support different ways of reading the values from the ADC such as direct memory access, abbre-viated DMA, or poll based reading. With DMA the ADC outputs the converted values to a known memory location, which the central processing unit, abbreviated CPU, can access directly at any chosen frequency. Using a polling system the MCU repeatedly polls the ADC for values at the wanted frequency and the ADC needs to convert the values when the CPU asks (polls) for them. This results in DMA being faster than a poll based system since the CPU can do other things while the ADC is handling the conversions.

(39)

Filtering

Any signal originating in the non-digital world will always come with a certain amount of noise and the purpose of filtering is to reduce noise while maintaining the useful parts of the signal. One of the most common measures is the signal to noise ratio, abbreviated SNR, which measures the power of the signal, Psignal,

against the power of the noise, Pnoise. It can also be measured by their respective

root mean square, abbreviated RMS, amplitude, A, as described in Equation (2.8)

SN R= Psignal Pnoise =

A2signal

A2noise (2.8)

where a higher SNR correspond to a less noisy signal.

Adaptive filtering has previously been categorized into signal estimation, state es-timation and fault detection[6], and under the category of signal eses-timation there are many filters developed which seemed applicable to this project such as Low pass filters, Bandpass filters, Kalman filters and Hidden Markov models. Kalman filters seemed like a possible candidate due to they ability to deal with a high amount of noise and the fact that they take advantage of knowing the dynamics of the signal to be tracked. Looking at the other end of the spectrum, a simple Lowpass filter might be enough for the task. The simplest first-order Low pass filter simply introduces a -20 [db/decade] attenuation at a certain frequency, Êc or fc, chosen by the designer,

where the -3 [dB] attenuation point is called the cutoff frequency. An analog Low pass filter can be designed using a resistor, R, and capacitor, C, set up as indicated by Figure 3.9 R VIN GND C VOUT GND

Figure 2.21: Low Pass filter design which results in a cut-off frequency given by Equation (2.9).

fc = 1

2 · fi · R1· C1 (2.9)

Low pass filters can also be implemented digitally. In order to pursue a digital implementation the Laplace domain of the Low pass filter, as indicated by Equation (2.10)

H(s) = 1

1 + s/Êc (2.10)

(40)

2.5. SAMPLING, FILTERING AND ACCURACY

s¥ 2(z ≠ 1

Ts(z + 1) (2.11)

As indicated by Figure 2.22 the output of a first order Low pass filter also comes with a phase delay, which has to be taken into consideration in the filter design. A high amount of smoothening causes a bigger phase delay.

Figure 2.22: Low pass filter [45]

Another variant of Low pass filters that can be implemented digitally are Moving Average filters [5], which simply takes an average over N samples of input values and averages them (in different ways depending on the type of moving average filter) them into a final output value. As highlighted by Smith [5] the Moving average filter is the most optimal filtering solution to reduce random white noise while keeping the sharpest step response. A common subset of moving average filters is to exponentially weight the input values giving less weight to values further back in time, this type is called Exponential Moving Average, abbreviated EMA, filters and are commonly implemented as indicated by Equation system (2.12).

S(t) =

I

s1, when t = 1

–· st+ (1 ≠ –)st≠1, when t < 1

(41)

is extremely simple to implement in software, but it introduces a lag in the output. But the type of moving average filter which is most efficient in reducing white noise is the simple moving average, abbreviated SMA, which uses the same weights over a defined range. The SMA has the transfer function in the Laplace domain as stated by Equation (2.13)

H(z) = 1 N

1 ≠ z≠N

1 ≠ z≠1 (2.13)

and the frequency response as stated by Equation (2.14).

H(Ê) = 1 N

1 ≠ e≠jÊúN

1 ≠ e≠jÊ (2.14)

which results in the frequency response as indicated by Figure 2.23 which indi-cates its poor performance as a general low-pass filter. But the fact that it is the most optimal way to reduce pure white noise still makes it a good candidate for implementation.

Figure 2.23: Moving average filters [5]

(42)

2.5. SAMPLING, FILTERING AND ACCURACY

implementation) and enough data points are stored it allows for compensation of the lag by observing a sample, s, which is N

2 discrete time units ahead of the time

point we are interested in. This technique is similar to running a normal Low pass filter twice, once forward and once backward, with the exception that it results in a second order filter.

Accuracy and precision

Both the accuracy and precision of the system to be implemented are important measures in the feasibility of this project. The accuracy was determined by the ab-solute value of the error and the precision by its standard deviation, their respective relations are illustrated in Figure 2.24. The factors that affect the accuracy of the

Figure 2.24: Accuracy vs. Precision [46]

sensor solution, such as errors in the values produced by the ADC, both internal and external and are generally named in notations of least significant bit, abbreviated LSB, which is described by Equation (2.15)

1LSB = Vref

212 (2.15)

The main internal errors are offset- and gain errors. They are caused by the ADC’s not being ideal (a theoretical ADC should switch output values in the input range 0.5 to 1.5 LSB) but the digital output could vary with the result in an error of max-imum 1 LSB. The more impactful errors which must be taken into consideration in this application are errors caused by factors external to the ADC, such as;

(43)

2. ADC range scaling errors, or rather loss of resolution, comes from an improp-erly scaled analog input in relation to the range of the ADC. To propimprop-erly use the full resolution in the ADC it is important that the signal to be sampled consumes as large part of the ADC range as possible, i.e. keep the unused ADC transition range as small as possible, as indicated in Figure 2.25. To accommodate this an analog amplifier with appropriate gain can be used.

Figure 2.25: ADC dynamic range [42]

3. Temperature influence, which can cause major errors in both offset and gain caused by variations in temperature. This can be countered with calibration as temperature changes or by offsetting for the drift and gain errors by measuring the temperature using a sensor.

4. Parasitic capacitance, which can canuse errors due to higher than expected input capacitance to the ADC. The PCB and the tracks from the sensor to the ADC adds a parasitic capacitance which could cause the input voltage at the internal ADC comparator to rise slower than expected, and thus prove a lower reading. This places a limit on the sampling speed.

(44)

2.6. CPU UTILIZATION AND MEMORY CONSUMPTION

Figure 2.26: EMI interference [42]

Such crosstalk could be countered by minimizing track length, isolating differ-ent parts of the PCB (with respect to frequency) from each other etc. These aspects are not covered in detail in this project.

2.6 CPU Utilization and Memory consumption

CPU Utilization corresponds to how much time the CPU spends executing instruc-tions and is measured as a percentage where 80 % utilization corresponds to exe-cuting instructions 80 % of the time and being idle the other 20 %. In its formal definition CPU utilization does not include time spent in a stalled state while wait-ing for memory read/write operations, but for the purpose of discusswait-ing algorithm efficiency on embedded systems there is no need to differentiate between the dif-ferent non-idle states of the CPU. For this reason the total CPU utilization, U, partially describing the efficiency of the algorithm can be calculated as the sum of the time taken for each calculation task, tn, divided by the total time elapsed

(including non-calculation related operations), T , as described by Equation (2.16).

U =

qN n=1tn

T (2.16)

A modern-day MCU comes with both Flash memory, for storing the code and read-only memory allocation, and Random Access Memory, abbreviated RAM, for storing read-write data. In embedded applications both of these memory resources could be the limiting factor depending on the application, but in general RAM memory is the most scarce resource. If no dynamic memory allocation is performed the memory consumption can be investigated at compile time by observing the sizes of the segments of the compiled binary and calculated as shown in Pseudo-equations (2.17) and (2.18), where the denominator parameters are shown by the compiler at compile time of the program.

(45)

Flash consumption = Code + RO data + RW dataTotal Flash size (2.18)

2.7 Component failure rate

Failure of an electrical component of system is described by its failure rate, ⁄, which describes the probability of failure per unit of time which makes the failure rate strongly linked to the reliability of the system. All electrical components fail eventually and the causes can be everything from electrolyte in capacitors drying up or internal metalization failures inside the embedded processors to electrostatic discharges or mechanical stresses on PCBs. The failure rate plotted over the Product Life Cycle can generally be divided into three stages; early life, useful life and wear out, as indicated in Figure 2.27.

Figure 2.27: Product Life Cycle [41]

Early life: Products or components fail as a result of random manufacturing

de-viances, the failure rate is declining as these issues are ”washed out”.

Useful life: This section constituted the main focus of electronics stability

assess-ment where failures are relatively constant. The failures that appear during this period are a result of the design of the component where a poorly designed system or component can still have a constant, but high, failure rate during its useful life.

Wear-out: End of life mechanisms on components in the system start to occur

and the failure rate increases.

Some common indicators for useful lifetime indications [40] from different industries are:

1. Telecommunication equipment: 15 years

2. Industrial controllers in factory electrical supply systems: 15 years 3. Military industry: 20-25 years

(46)

2.8. SUMMARY

Generally the probability of failure of a system, Pf, after a certain amount of time

consists of the sum of probabilities of failure of individual components, p, if they are redundant (similar to being connected in parallel) and the product of the individual components if they are non redundant (similar to being connected in series), as indicated by Equation (2.19) and Equation (2.20) respectively. The scope of failure analysis in this project is limited to the components used by the sensor solution.

Pf,parallel= n Ÿ n=1 pn (2.19) Pf,series= n ÿ n=1 pn (2.20)

Another common metric used is Mean time between failures, abbreviated MTBF, which corresponds to the average time between failures during the useful life part of the product life cycle, or the inverse of the failure rate, “ as stated by Equation (2.21)

M T BF = 1

(2.21)

If the failure rate is constant the failure density as a function of time, f(t), can be calculated by Equation (2.22)

f(t) = ⁄e≠⁄t (2.22)

and corresponding failure probability, F (t), by Equation (2.23) F(t) =

f(t)dt = 1 ≠ e≠⁄t (2.23)

which results in a 63.2 % risk of failure at MTBF.

2.8 Summary

(47)
(48)

Chapter 3

Implementation

This section describes the application of the theory and background studies as well other solutions and systems that were developed in order to complete the project.

3.1 Requirements

In order to know if the proposed solution would be feasible or not it was necessary to further break down the requirements from the company. Mainly using statistics and general logic the requirements were broken down into technical requirements that were associated with measurable parameters.

Accuracy Requirement 1 from the company was an accuracy related requirement.

The required accuracy of ± 1 ° corresponded to 12 micro steps of the stepper motor after the gearbox reduction ratio, and the technical requirement TR1 of absolute error |e| < 12 [steps] was formed.

Precision The required system reliability in Requirement 2 of 99.95 % was clearly

a precision related requirement. Since precision is a measurement of repeatability it was suitable to form the technical requirement in terms of standard deviation of the error, e. With the aforementioned definition of failure (one of the loads being out more than 12 micro steps in any direction) and an assumption that the errors would be of a normal distribution, which was proven later in the project, it was possible to define the reliability requirement using the standard deviation of the error, ‡e. With a limit on the probability of an error larger than the maximum pe,max= 0.0005 the Z value was calculated using the normal inverse of the

Cumu-lative distribution function [39] to z = 3.29.

Knowing the z-score the allowed a limit on the standard deviation could be calcu-lated using Equation (3.1)

‡e=

emax≠ x

(49)

to ‡|e| < 3.45 [steps] where the standard deviation of the absolute error ‡|e| was calculated using the absolute error |e| as stated by Equation (3.2).

‡e=

Û qN

i=1(|ei| ≠ ¯|e|)2

N≠ 1 (3.2)

over the iteration of N test cases.

Distance: The minimum gap between the sensor and magnet in Requirement 3

of 20 [mm] was translated to a requirement on the reference coordinate, h, which was adopted in the testing rig for simplicity to h > 9 [mm]. This reference system is explained and illustrated further in the Fixation module chapter.

Speed: The speed requirement on the calibration process to complete within 300

[seconds] would ideally place requirements on the motor stepping speed, but the relation is not direct, since it depends on the chosen movement path of the loads during the calibration process which is determined by the ability to get accurate readings. A conservative assumption on the algorithm was that two passes for each load would be needed resulting in a speed requirement of 75 [seconds] for a full rotation of one load. This speed requirement could be translated into a motor stepping frequency by calculating the number of steps per full revolution, sf ull.

Using the number of micro steps per degree, smicro, the gear ratio ÷ and combining

Equation (3.3)

sf ull= 360

smicro· ÷ (3.3)

with motor data from Table 3.2 to sf ull = 4320 [steps/rotation] the required load

speed, ˙◊, of ˙◊ = 60

75 [rpm], or fload = 751 [rotations/second] was set. In order to move

the load at that required speed a requirement on the motor driving frequency was calculated using Equation (3.4)

fstep= ˙◊ · sf ull (3.4)

to fstep = 57.6 [Hz] which was chosen as the requirement on the motor driver

function. According to the Nyquist sampling theorem [43] the required filter on the sensor solution that had to pick up the signal of the rotating load had to be at least fsample,load= 2 ·fload = 752 [samples/second] or 0.0267 [Hz]. But since the real value

(50)

3.2. HARDWARE

last of the technical requirements on the systems, which were summarized in Table 3.1.

Table 3.1: Technical requirements

Requirement ID Description Parameter Value

TR1 Max. absolute error |emax| 12 [steps]

TR2 Max. standard deviance of absolute error |e,max| 3.45 [steps]

TR3 Min. distance from sensor rmin 9 [mm]

TR4 Min. motor driving frequency fstep 57.6 [Hz]

TR5 Hardware filter cutoff frequency fc 1-10 [Hz]

TR6 Maximum self-calibration time t 300 [s]

TR7 Maximum cost of components ≠ 3 [USD]

3.2 Hardware

The hardware for the project was, in addition to the sensor and magnet, categorized in several modules; , motor-, and fixation-module. The hardware for the logic-and motor-module existed prior to the project whereas the sensor interface, fixation module and the test rig were developed to support the research. The architecture was built according to Figure 3.1 and the technical drawing of the entire test rig can be seen in Figure 3.2

3.2.1 Sensor and magnet

(51)

Figure 3.1: Hardware architecture

Fixation module Logic module Motor module

Test rig

(52)

3.2. HARDWARE 3.2.2 Logic module

The Logic module was a proprietary design, but the main components and their functionality are not subject to secrecy. The Logic module consisted of a PCB with a power management stage, a micro controller and some hardware interfaces such as pin headers, testing points and custom connectors for interfacing with the other modules. The MCU of choice was an STM32F107V, a 32-bit micro controller manufactured by STM with built in Controller Area Network, abbreviated CAN, Universal Serial Bus, abbreviated USB, and several ADC channels and General purpose input output, abbreviated GPIO, ports. The processor had 64 [kB] of non volatile flash memory and 256 [kB] of static RAM, which placed indirect require-ments on the control software, but no hard requirerequire-ments were set by the company on program size or memory consumption.

3.2.3 Fixation module

The fixation module (as well as the entire test rig framework) was built using 15x15 [mm] aluminum profiles locked together with plastic angles, M3 bolts and nuts provided by the company. Together they provided a solid construction that was easy to assemble and didn’t flex. The fixation module needed to have the following features:

1. Variable positioning of the sensor(s) 2. Ability to mount multiple sensors 3. Easy to install and remove the sensor(s)

4. Accurately measure the position of the sensor(s)

(53)

Sensor

Terminal block Laser

Grid for reading laser Adjustable positions

Figure 3.3: Fixation module

Reference point

(54)

3.2. HARDWARE

A coordinate system was implemented where the coordinate r represented the dis-tance from the sensor to the known reference position and h represented the disdis-tance from the front of the sensor to the same reference positionas indicated schematically in Figure 3.5 and graphically indicated in Figure 3.6

d Magnet Sensor                       Stepper motor h reference position r C sensor position

Figure 3.5: Coordinate system

h

r

Sensor Reference position

Grid to measure r, h

Figure 3.6: Sensor measurements

The relation between the distance between reference position and sensor, h, and the distance between magnet and sensor, d, is dependent on the mechanical dimensions of the stepper motor and load is given by Equation (3.5)

d= C ≠ h[mm] (3.5)

(55)
(56)

3.2. HARDWARE

3.2.4 Motor module

The motor module was a PCB containing the stepper motor, motor driver and connector to interface with the Logic module. The stepper motor itself was a pro-prietary design of the permanent magnet type, so it will not be discussed in detail, allowing for 15 ° rotation per micro step which translated to 24 steps per revolution. To increase the resolution a proprietary gearbox, also custom made by a partner supplier for the company, with a gear ratio of 180:1 increased the final resolution on the output shafts to 4320 steps per revolution. The Motor module was not modi-fied, but a custom fastening system was designed and produced (using a 3D printer) in order to mount both the Logic module and the Motor module to the fastening rig. The most important characteristics of the stepper motor and the gearbox were listed in Table 3.2.

Table 3.2: Stepper motor parameters

Parameter Symbol Value

Gear ratio ÷ 180:1 [-]

Step size (full) sf ull 1 [°]

Step size (micro) smicro 1/12 [°]

Load max torque Tmax 0.025 [Nm]

3.2.5 Filter

In order to smoothen the input from the sensor to the MCU a Low pass filter was constructed in order to meet Technical Requirement 5. The filter was built using components available at the company with values C1= 28 [µF] and R1 = 1 [kOhm]

resulting in a cutoff frequency of fc = 7.2 [Hz] as per Equation (2.9). In order to

keep a stable input voltage (which was very important since the input voltage is used as a reference for the sensor and any fluctuations will cause a fluctuation in the output) a filter capacitor CIN was added as well as indicated by Figure 3.9.

R VIN GND C VOUT GND

Figure 3.8: Low Pass filter design

The transfer function, G(s), of the first order low-pass filter was derived using Ohm’s law [18] as indicated by Equation (3.6)

G(s) = 1

(57)

and using the values on R and C the frequency response was indicated in Figure 3.9 and the phase delay of 0.2° which corresponded to 2.4 [steps] which was compensated for in the offline filtering process.

-25 -20 -15 -10 -5 0 Magnitude (dB) 10-1 100 101 102 -90 -45 0 Phase (deg) Bode Diagram Frequency (Hz)

Figure 3.9: Low Pass filter frequency response

3.3 Software

This section contains the software that was developed in order to complete the project. The main parts consisted of a Test case monitor written in Matlab [37] and the embedded systems controller code written in C using System Workbench [38] which was an Eclipse based integrated development environment tool-chain developed specifically for STM chip sets. There were also some Python and Bash scripts developed in order to ease the information gathering, processing and general testing procedures, but they will not be covered in this report.

3.3.1 Test case monitor

(58)

3.3. SOFTWARE

environment with text input and buttons to select and toggle the most important parameters to be tested in order to streamline the test case configuration and data collection process, it was displayed in Figure 3.10

Figure 3.10: Test Case Monitor It supported the following main features:

(59)

3. Post-processing filtering of sensor readings 4. Calculation of errors in sensor readings 5. Saving of sensor readings to log files 6. Test case automation

In addition to the features explained above a series of calculation programs were developed in order to analyze and graph the data from the large amount of test cases produced by the automated testing feature, but they were not made available through the GUI.

3.3.2 Embedded software

The software for the MCU on the Logic module was developed to run on the FreeR-TOS kernel [36] which supported many important features such as a task handler for switching between different tasks according to their priority, a message queue to send data between tasks and a well documented hardware abstraction library for simplified access to GPIO pins. There were two configurations of the software: a test environment configuration and a proof of concept configuration. This section of the report details the test environment configuration and the proof of concept configuration is discussed in the ”Multiple object detection” section. The test envi-ronment configuration took instructions from the Test case monitor, executed the tests and output the data. In order to meet the requirements of the test cases the software was divided into three tasks; Data output task, Test case manager task and Motor control task as indicated in Figure 3.11.

(60)

3.3. SOFTWARE

The different tasks were configured according to Table 3.3.

Table 3.3: Software tasks

Task name Priority Frequency [Hz]

Motor control 1 200

Test case manager 2 100

Data output 3 30

Motor control task: One of the assumptions in the Implementation section of

the calibration algorithm the motor was assumed to move at a constant speed of minimum 1/75 [rps] which constituted TR2 of a minimum motor driving frequency of 57.6 [Hz]. In order to achieve this, and add some margin the motor control task, which had the main purpose of controlling both stepper motors, was set as the highest priority task. The interface towards the stepper motor driver consisted of 3 pins; M1 STEP, M2 STEP, DIRECTION (excluding power supply to the driver chip and the motor). The DIRECTION pin was set HIGH or LOW depending on the direction of the motor and a single pulse on M1 STEP or M2 STEP was used to perform a micro step on each motor. Since the main purpose of the project was to determine the load position as a function of motor position it made sense to sample the sensor right after the motor had completed one step. This resulted in a subrou-tine in the Motor control task which took care of the sensor signal sampling, how this was done is discussed further in the ”Signal sampling and processing” section.

Test case manager task: The purpose of the test case manager task was to

parse messages from the controlling computer and instruct the embedded system to perform the tests specified by the system. It also read messages from the Message Queue and output the extracted data to the controlling computer for later evalua-tion.

Data output task: The data output task handled communication with the

com-puter controlling the test cases which consisted of a few subroutines: 1. Parsing of incoming messages from the Test case monitor. 2. Setting of state machine variables based on incoming messages.

3. Sending messages containing test data from a buffered queue to the Test case monitor.

4. Controlling LEDs to indicate states.

References

Related documents

I “ Acoustic noise improves motor learning in spontaneously hypertensive rats, a rat model of attention deficit hyperactivity disorder ” aimed to investigate if acoustic

Always having had a strong interest in the natural sciences, Daniel enrolled in the Pharmacy program at the University of Gothenburg. He found neuroscience to be of

I. Göran Söderlund*, Daniel Eckernäs*, Olof Holmblad and Filip Bergquist. Acoustic noise improves motor learning in spontaneously hypertensive rats, a rat model of

But instead of using simple differential equations the systems will be described stochastically, using the linear noise approximation of the master equation, in order to get a

46 Konkreta exempel skulle kunna vara främjandeinsatser för affärsänglar/affärsängelnätverk, skapa arenor där aktörer från utbuds- och efterfrågesidan kan mötas eller

The increasing availability of data and attention to services has increased the understanding of the contribution of services to innovation and productivity in

The purpose of the current study is to investigate whether there is a difference in how acute noise affects encoding compared to recall, and how the effect of noise on

12 To facilitate a comparison between the results from Odeon at different frequencies with the scale measurement, the sources in the simulated model should excite pink noise, thus