scieee AI-readable full text Open interactive document viewer

Motorized microscope stage for smartphone

João Carlos Viseu Oliveira

Full text

MOTORIZED MICROSCOPE STAGE FOR SMARTPHONE JOÃO CARLOS VISEU OLIVEIRA DISSERTAÇÃO DE MESTRADO APRESENTADA À FACULDADE DE ENGENHARIA DA UNIVERSIDADE DO PORTO EM MESTRADO INTEGRADO EM ENGENHARIA ELECTROTÉCNICA E DE COMPUTADORES M 2014 PORTO CCLID FACULDADE DE ENGENHARIA 1 ~ UNWERSIDAOC DO PORTO A Dissertação intitulada “Motorized Microscope Stage for Smartphone” foi aprovada em provas reaLizadas em 18-07-2014 o júri Presidente Professor DoutolUPaulo José Cëí~queira Gomes da Costa Professor Auxiliar do Departamento de Engenharia Eletrotécnica e de Computadores da Faculdade de Engenharia da Universidade do Porto Professor Doutor az da Silva Fidalgo Professor Adjunto do Departamento de Engenharia Eletrotécnica da Instituto Superior de ~ Professor Doutor Dirk Christian Elias Professor Catedrático Convidado do Departamento de Engenharia Eletrotécnica e de Computadores da Faculdade de Engenharia da Universidade do Porto O autor declara que a presente dissertação (ou relatório de projeto) é da sua exclusiva autoria e foi escrita sem qualquer apoio externo não explicitamente autorizado. Os resultados, ideias, parágrafos, ou outros extratos tomados de ou inspirados em trabalhos de outros autores, e demais referências bibliográficas usadas, são corretamente citados. Autor - João Carlos Viseu Oliveira FacuLdade de Engenharia da Universidade do Porto FACULDADE DE ENGENHARIA DA UNIVERSIDADE DO PORTO Motorized Microscope Stage for Smartphone João Carlos Viseu Oliveira Mestrado Integrado em Engenharia Eletrotécnica e de Computadores Supervisor: Dirk Christian Elias Co-Supervisor: Carlos João Rodrigues Costa Ramos Co-Supervisor: Jorge Manuel de Matos Reis July 28, 2014 c João Carlos Viseu Oliveira, 2014 Abstract Every year malaria kills millions of people because the time between a blood test and the result is too much to allow an effective treatment. To respond to this limitation Fraunhofer AICOS presented the idea of creating an fast, cheap and autonomous system, fully replicable in third world countries, and capable of giving a preliminary result to this test by analysing 100 spots in the blood smear (as recommended by World Health Organization). This translated to a project were a smartphone was used as the brain and controlled a XY Table while taking the necessary pictures of the smear. This thesis focused in the table part. It needed to be capable of under 500µm steps in each direction and be fully powered by the USB connection of the smartphone. Several actuators were studied and tested and two solutions were presented: one based in piezoelectric benders and other based in common DC motors. Both solutions feature Arduíno based electronic drivers and are fully controlled by an Android smartphone application, components fully developed during this thesis. To allow the replication, a 3D printer was used to produce most of the parts for the solution. The DC motor solution used old CD drives and was capable of steps under 300µm. The piezoelectric solution featured a novel design fully 3D printed and featured steps below 250µm. An ingenious method to measure the steps was used. It was composed by an high DPI optical mouse and a computer software that measured the displacement as pixels on the screen. This research project was fully successful and proved that the idea is possible and valid. It presented two different valid paths with its pros and cons complying with all objectives and requirements bringing a lot of value to the host company and to the whole project. i ii Agradecimentos Antes de mais nada quero agradecer à Fraunhofer AICOS e um dos seus diretor e meu orientador, o professor Dirk Elias por me terem dado esta oportunidade de me integrar numa empresa de referência na área de investigação e me terem dado uma inestimável experiência que certamente pesará bastante no meu futuro. Quero agradecer também a toda a equipa da Fraunhofer AICOS que me tratou como se fosse da casa e principalmente aos cientistas Luís Rosado, que sempre disponibilizou o seu tempo quando necessário, e Manuel Monteiro que me foi aturando ao longo de todo processo, ajudando-me em tudo o que foi necessário. Agradeço também ao professor Carlos Ramos, meu co-orientador, que me disponibilizou o seu tempo e inegável experiência no mundo da eletrónica apontado-me o caminho a seguir. Deixo também um sincero agradecimento ao Engenheiro Jorge Reis pela paciência e sincera boa vontade que demonstrou ao aceitar ajudar-me apesar da sua vida bastante ocupada, pela sua infinita fonte de conhecimento e pela valiosa ajuda prestada que, sem ela, o projeto não chegaria onde chegou. Fica apenas o amargo na boca de não o ter contactado mais cedo, certamente o resultado seria ainda melhor. Agradeço também à empresa Igus que me disponibilizou o material necessário para testar algumas das ideais apresentadas. Agradeço sinceramente e o mais humildemente que consigo aos meus pais que sempre me deram tudo e, principalmente, me deram esta possibilidade de me instruir e trabalhar a fazer o que mais gosto. É uma grande felicidade puder deixá-los orgulhosos e felizes pelo meu sucesso. Não posso também esquecer a minha irmã, um das raparigas mais fortes e trabalhadoras que conheço. Sem ela, quem me distrairia durante a escrita desta dissertação? Tenho de agradecer também à minha namorada que aturou todos os meu humores e devaneios sem pestanejar e sempre me deu todo o apoio que precisei e ainda mais que isso. Sem ela, certamente, não estaria onde estou. Como prometido, deixo também o meu agradecimento à minha tia que me aturou e leu tudo de fio a pavio à procura das inúmeras gralhas inseridas pelas noitadas de escrita. Deixo também uma palavra de apreço a todos os verdadeiros amigos que me acompanharam ao longo deste percurso, alguns adquiridos ao longo do caminho, outros amigos à tanto tempo que nem me lembro de lá não estarem, e me foram dando a força necessária para continuar, no meio de jantaradas e cafezadas no DEEC. Não poderia terminar e esquecer a instituição que me instruiu e desenvolveu ao longo destes 5 anos. Deixo então os meus sinceros agradecimentos à FEUP e a todos os professores que me acompanharam desde o primeiro ano em que não passava de um miúdo com sonhos até agora onde continuo um miúdo com sonhos mas um bocado mais conhecedor do mundo que me rodeia. João Oliveira iii iv “Does this unit have a soul?” Mass Effect 3 v xii LIST OF FIGURES 2.34 Claw Poles stepper motor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 2.35Hybridsteppermotor................................. 33 2.36Unipolarsteppermotor................................ 33 2.37Bipolarsteppermotor. ............................... 34 2.38 Stepper motor driver block diagram. . . . . . . . . . . . . . . . . . . . . . . . . 34 2.39 Unipolar stepper power driver circuit. . . . . . . . . . . . . . . . . . . . . . . . 34 2.40 Bipolar stepper power driver circuit. . . . . . . . . . . . . . . . . . . . . . . . . 35 2.41CDdriveexamples.................................. 37 2.42 Printer example. Picture from HP Inkjet mechanism patent. . . . . . . . . . . . . 38 2.43 Miniature Drylin T systems. Picture by Igus. . . . . . . . . . . . . . . . . . . . . 39 2.44 Example application results. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 3.1 BA4510PZTbender. ................................ 42 3.2 Proposed driver circuit diagram. . . . . . . . . . . . . . . . . . . . . . . . . . . 43 3.3 1 - Coil charging, 2 - Capacitor charging. . . . . . . . . . . . . . . . . . . . . . 44 3.4 Coilcurrentwaveform ............................... 44 3.5 Capacitor current waveform . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 3.6 PSIMconvertermodel................................ 48 3.7 PWM waves. Vcont1is the PWM for the first stage and V cont2is the PWM for thesecondone. ................................... 49 3.8 Coil currents. Il1is the current from the first coil and Il2is the current from the secondone. ..................................... 49 3.9 Capacitor currents. Ic1is the current from the first capacitor and Ic2is the current fromthesecondone. ................................ 49 3.10 Output waveforms. Vo1is the output voltage of the first stage, Vo2is the output voltage of the second one and Iout is the output current. . . . . . . . . . . . . . . 50 3.11Asimplevoltagedivider............................... 52 3.12 Semiconductor preferences according International Rectifier [9].......... 53 3.13 Mixed channels MOSFET h-bridge. . . . . . . . . . . . . . . . . . . . . . . . . 54 3.14Driverschematics. ................................. 57 3.15PCBlayers. ..................................... 58 3.16 Stripper Boost Converter PCB. . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 3.17BoostConverter. .................................. 60 3.18 Wave response of the driver. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 3.19 Output voltage of the driver. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 3.20GSAMBatteryMonitor. .............................. 64 3.21 Li-Ion battery discharge plot [10]. ......................... 65 3.22 PZT bender driver consumption plots. . . . . . . . . . . . . . . . . . . . . . . . 65 3.23DCmotorh-bridge.................................. 66 3.24 L293Eh-bridgecircuit................................ 67 3.25DCmotordrivercircuit................................ 69 3.26DCmotordriver. .................................. 70 3.27 L293E step waveform. Notice the 5Vpeakvoltage. ................ 71 3.28 DC motor driver consumption plots. . . . . . . . . . . . . . . . . . . . . . . . . 72 4.1 Same figure presented in 2.2.4.2, see 2.25 ..................... 76 4.2 Studiedrubbers.................................... 78 4.3 MakerbotReplicator2x. .............................. 78 4.4 Buildplatespringscrews............................... 80 LIST OF FIGURES xiii 4.5 Failedcubeprint. .................................. 80 4.6 Newglassbase.................................... 81 4.7 Cube comparison. Notice the curled bases and the improved resolution of the red cube.......................................... 81 4.8 Google Sketchup 3D model of the triangular tip topology motor. . . . . . . . . . 82 4.9 Lever theory applied to the triangular tip topology. . . . . . . . . . . . . . . . . 82 4.10 Google Sketchup 3D model of the triangular tip topology. . . . . . . . . . . . . . 83 4.11 Triangular Tip topology printed pieces. . . . . . . . . . . . . . . . . . . . . . . . 84 4.12Sampleprintedpiece................................. 85 4.13 Triangular tip topology assembled system. . . . . . . . . . . . . . . . . . . . . . 85 4.14 Applied voltage to the actuator. Note the dead zone of the converter. . . . . . . . 86 4.15 Igus drylin T miniature system. . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 4.16 Google Sketchup 3D model of the claw/lever tip topology actuation system. . . . 88 4.17 Google Sketchup 3D model of the claw/lever topology using an Igus system model. 89 4.18 Claw/lever topology assembled system. . . . . . . . . . . . . . . . . . . . . . . 89 4.19 Applied voltage to the actuator. . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 4.20Examplecd-romsystem. .............................. 91 4.21 Grid movement implementation for the DC motor topology. The values represent acellposition..................................... 92 4.22 DC motor XY Table with a microscope slide. . . . . . . . . . . . . . . . . . . . 93 4.23 Google Sketchup model of Y Axis support. . . . . . . . . . . . . . . . . . . . . 94 4.24 Mousotron screenshot. The "X Coord" and "Y Coord" are important fields. . . . 95 4.25 System assembled to measure the DC motor topology displacement. A black cardboard was used to enable the measure. . . . . . . . . . . . . . . . . . . . . . . . 96 4.26 DC motor topology validity test. . . . . . . . . . . . . . . . . . . . . . . . . . . 96 4.27 Position of the DC motor table. . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 4.28 DC motor topology resolution test step sizes. . . . . . . . . . . . . . . . . . . . 97 4.29Thirdbendercircuit. ................................ 99 4.30 Three bender table, top view without the moving platform. . . . . . . . . . . . . 100 4.31 Three bender table, side view. . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 4.32 Three bender table y axis principle. . . . . . . . . . . . . . . . . . . . . . . . . . 101 4.33 Three bender table x axis principle. . . . . . . . . . . . . . . . . . . . . . . . . . 102 4.34 Google Sketchup three bender table. . . . . . . . . . . . . . . . . . . . . . . . . 102 4.35 Grid movement implementation for the Three bender topology. The values represent a cell position and can be compared with figure 4.21.............. 103 4.36 Assembled three bender table. . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 4.37Detailofoneofthetip................................ 104 4.38 Detail of the small additions to the design. . . . . . . . . . . . . . . . . . . . . . 104 4.39 System assembled to measure the three bender topology displacement. . . . . . . 106 4.40 Position of the three bender table. . . . . . . . . . . . . . . . . . . . . . . . . . 106 4.41Threebenderstepsizes................................ 107 5.1 EclipsewithADTplugin............................... 110 5.2 Samsung Galaxy S4 Zoom. Foto from GSMArena.com. . . . . . . . . . . . . . . 110 5.3 ArduinoIDE. .................................... 111 5.4 Arduino Leonardo. Foto from Arduino.cc. . . . . . . . . . . . . . . . . . . . . . 112 5.5 Masterpacketsmodel. ............................... 114 5.6 A simple request chain. This is just an example, the OPEN and CLOSE transactions just need to be made once, not at every transaction. . . . . . . . . . . . . . 116 xiv LIST OF FIGURES 5.7 High level UML class diagram of the USB Serial f or Android library. . . . . . . 117 5.8 High level UML class diagram of the MicroStage Serial library. . . . . . . . . . 119 5.9 Structure of the DC motor topology loop(). . . . . . . . . . . . . . . . . . . . . 126 5.10DCmotortopologyFSM............................... 128 5.11 Structure of the PZT motor topology loop(). . . . . . . . . . . . . . . . . . . . . 129 5.12PZTmotortopologyFSM. ............................. 130 5.13Appwelcomescreen................................. 131 5.14 PZT motor controller screen. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131 5.15 DC motor controller screen. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 5.16 XY table controller screen. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132 5.17 PZT motor control JAVA application running on a Windows PC. . . . . . . . . . 133 List of Tables 2.1 PZT Stack driven stage pros and cons. . . . . . . . . . . . . . . . . . . . . . . . 11 2.2 PZT Worm driven stage pros and cons. . . . . . . . . . . . . . . . . . . . . . . . 13 2.3 Comb Actuator driven XY stage pros and cons. . . . . . . . . . . . . . . . . . . 16 2.4 Stepper Motor driven XY stage pros and cons. . . . . . . . . . . . . . . . . . . . 18 2.5 Summary of all topologies shown. . . . . . . . . . . . . . . . . . . . . . . . . . 20 2.6 Piezoelectric solution versus Stepper motor solution. . . . . . . . . . . . . . . . 36 3.1 Piezoelectric driver ratings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 3.2 Piezoelectric driver capacitor and inductance values. . . . . . . . . . . . . . . . 48 3.3 Componentratings.................................. 53 3.4 Ordered components in Mouser Electronics. . . . . . . . . . . . . . . . . . . . . 55 3.5 H-bridge logic. Taken from the datasheet, property of Texas Instrument. . . . . . 60 3.6 Components need for the DC motor driver if ordered in Mouser. . . . . . . . . . 68 4.1 Measurementscomparison.............................. 84 5.1 Everyrequestdetailed. ............................... 115 5.2 Slavepossibleresponses............................... 116 6.1 Proposed solutions pros and cons. . . . . . . . . . . . . . . . . . . . . . . . . . 137 xv xvi LIST OF TABLES xvii xviii ABBREVIATIONS AND SYMBOLS Abbreviations and Symbols DC Discrete Current AC Alternating Current PZT Piezoelectric Javadoc Java documentation UML Unified Modelling Language DSP Digital Signal Processor PI Proportional-Integral USB Universal Serial Bus PCB Printed Circuit Board 3D Three Dimensions PWM Pulse-width modulation I/O Input/Output OTG On-the-Go PSIM PowerSim software BJT Bipolar Junction Transistor MOSFET Metal–Oxide–Semiconductor Field-Effect Transistor IGBT Insulated-Gate Bipolar Transistor IC Integrated Circuit ADC Analog-to-Digital Converter ABS Acrylonitrile Butadiene Styrene PLA Polylactide STL Stereolithography bps bits per second DPI Dots Per Inch DPmm Dots Per millimetre ADT Android Development Tools GUI Graphic User Interface XML Extensible Markup Language FSM Finite-State Machine Units of Measure Hz Hertz A Ampere V Volt W Watt s Second g Grams F Farad H Henry Chapter 1 Introduction 1.1 Motivation and Context According to World Heath Organization, malaria is the second [11] leading cause of death in African continent. One of the main reasons for that is the time that it takes to get a result from a blood sample analysis (in the order of days). That time severely limits what any doctor can do in order to try to cure or save the patient, often leading to fatal results due to the late administration of an appropriate drug. Despite that great disadvantage today, the lack of viable alternatives (costwise) makes it the current best option to deal with malaria diagnosis. One of the main fields for decreasing the percentage of deaths with malaria is the diagnosis: “Despite an obvious need for improvement, malaria diagnosis is the most neglected area of malaria research, accounting for less than 0.25%($700,000)of the $323million investment in research and development in 2004.” [12, Introduction] If some method of cheap and fast diagnosis (at least, preliminary) was developed, it could really help saving millions of lives and change this paradigm. The main problem is the junction of the qualities cheap and fast. Fast malaria diagnosis tools already exist as we can see in [12], named Rapid Diagnose Test (RDT) kits but they are cost prohibitive, averaging $0.55 to $1.50 per test. Multiplying this for millions of tests, we easily reach the conclusion that something else should be used. We must take account of the possibility of fake positives that represent 15% of all RDT tests [12] and the over-diagnosis can quickly decimate any pharmacy budgets. Nowadays, the used diagnosis option is the microscope analysis. The estimated cost for each microscope test is $0.12˘$0.40 [12] which represents an average of five times less the cost of RDT kits. But the main problem is that there are almost no laboratories near high-transmission areas leading to the problem enumerated before (the delay between the blood collection and obtaining the result). Hereupon, the main idea is to eliminate that delay between the collection and the result using a portable system that can perform the analysis in the field and give a preliminary result. That idea is presented next. 1 2Introduction 1.2 Project Presentation Fraunhofer Portugal is a non-profit private organization that aims to create scientific knowledge oriented towards the social well-being of its end-users. With that in mind, Fraunhofer was proposed a project inserted in ICT4D MalariaScope, a system that can perform an automated blood analysis. A part of this project (the electronic and mechanical) was inserted as a thesis proposal at FEUP. Since this was a very specific problem, the project concept and its main objectives were easy to identify. We needed to develop a tool that could lead to a fast, preliminary and fully autonomous analysis of blood smears in order to give an approximate answer to the question: "Is the patient’s blood infected with malaria?" in an understandable way for a person with basic training. It should be as cheap as possible and replicable without engineering knowledge. With everything said above in mind, we sketched the following concept: to develop a motorized XY microscope stage driven by a smartphone and that will use its imaging processing abilities to perform the analysis. Figure 1.1: Fraunhofer’s conceptual idea. The first thought that comes to mind is how will this perform to make a reliable analysis of the blood smear. The concept is really simple and can be explained by imagining a ten by ten grid on top of the blood smear. Each cell represents an image that the system will analyse. The total number of tests is one hundred and that is the minimum needed to provide a reliable answer according to World Health Organization [13]. The placement within the cell doesn’t have to be really precise but it has to ensure that the analysis will be performed in one hundred different points. As a direct consequence, repeatability is optional too but if it can be implemented without any loss for the main objectives it would be a big plus. For the physical movement, the intention is to use a small XY-Stage system based in piezoelectric or stepper motors with an electronic driver controlled by an Arduíno based board. As said 1.2 Project Presentation 3 above, the system will be controlled by a smartphone so this implies that a library will have to be developed in order to make possible the communication between the Arduíno board and the smartphone. The motor choice will be based on the ratio of energy consumption/reliability/monetary cost and in the fact that piezoelectric based motors will need to be custom made for the application (making the question "Is it worth it?" really important). Tying all up is the idea of this project being as cheap as possible. This will define every move of the development process together with the idea of robustness and relative reliability. Since the full implementation is too ambitious for only one person and in such short time, the project is divided in two parts: the image processing part and the mechanic and control part. The image part is not a subject of this specific thesis. The main emphasis of this project will be the physical design of the application. Figure 1.2: Block diagram of the concept. Figure 1.2 represents the block diagram of the concept system. All blocks in blue are the subsystems that will be developed by this thesis. The result will be integrated in the ICT4D MalariaScope [14] project, as said above, that aims to develop a full automated solution to diagnose malaria disease. 1.2.1 Requirements, Guidelines and Limitations Although some requirements and guidelines were presented in previous points, in this section they are summarised for a better organization. Joining the requirements, some limitations need to be considered too. •Requirements: 10 State of Art Figure 2.4: PZT Stack driven stage hinges [1]. Figure 2.5: Open loop (a) and closed-loop (b) response to step motion [1]. in range of motion. 15µmper axis is a very small dimension and makes this design only useful for really specific applications. The decoupling of the axis ensures that there is almost no parasitic theta movement. To accomplish that, a complex and precise hinge is needed, making it difficult and very expensive to produce. Using a PZT stack actuator is a big plus. Its precision and very low power consumption (see Chapter 2.2) makes it a very attractive solution. Although depending on the distributor, it can be 2.1 XY-Stages 11 Pros Cons Precision, 1ηmresolution Small range of motion, only 15µmper axis Decoupling of each axis movement Complicated kinematic chain PZT Actuator Commercial driver used Closed loop control Cost of the system Table 2.1: PZT Stack driven stage pros and cons. really expensive. The cheaper ones start from $60 and the most expensive can go up to thousands of dollars (Prices by PiezoDrive [20]). Joining a commercial drive, the cost can go really high really fast. Looking now for the objectives of this specific thesis, some ideas can be taken from this topology: •The PZT actuator is really precise. Using one might be a great solution if one cheaper actuator alternative can be found. An amplifying system must be developed if the actuator is used directly; •If more precision is needed, a closed-loop PI controller can be used to drive the actuators; •Might be a good idea to decouple the axis. This can bring gains in terms of actuation velocity and precision; •Precision is equal to complexity. Since the thesis objectives don’t require maximum precision, it is a good idea to keep the design simple. 2.1.2.2 Piezoelectric Worm Actuator driven XY Stage As in the previous example, a presentation of a PZT worm actuator is the first focus point. It is composed by three extensive PZT actuators (stacks for example) that use the concept of clamping as illustrated in Figure 2.6. The control is achieved by applying a voltage differential to each actuator. Figure 2.6: PZT Worm actuator step sequence [2]. This example is aimed at generic micro-applications and uses a modified worm actuator. A piezoelectric component was mixed with mechanical clamps as a way to achieve simplicity and 12 State of Art increased force. One of them is naturally clamped (with low voltage) and the other one is the opposite. The complimentary clamps make possible to drive the motor with a 2-channel controller, using one channel for the clamps and another for the piezoelectric actuator [2, Piezoworm Motor Designs]. Figure 2.7: PZT Worm Motor concept [2]. The motor actuation drags the stage along a supporter slide. To achieve XY movement, two of this systems were used. One of the them moves with the stage in order to achieve independent actuation. To drive the motors, a computer with Labview was used. It received feedback from 2 encoders that were placed in each motor implementing a Two-Stage controller. The first stage is the Regulatory control that generates the signal for the piezoelectric component. The second stage is the Supervisory control and generates the clamp’s signal [2]. A commercial electronic driver was used (DSM VF-500 [21]) and it was capable of supplying 200Vand 500mA. This controller, along with the feedback, achieves performance with a maximum error of 10ηm, displacement of 10mm in each axis with a sample frequency 10kHz and a speed of 8.5mm/s. Results can be observed in Figure 2.8. Figure 2.8: PZT Worm driven stage example results [2]. Pros and cons analysis for this implementation can be observed in Table 2.2. 2.1 XY-Stages 13 Pros Cons Good precision, 10ηmresolution Use of mechanical clamps High displacement, 10mm in each axis Commercial electronic driver Simple but effective design of the actuator Use of a proprietary software running in a commercial PC High actuation force (maximum of ∼35N[2, Image 3.8] Use of encoders (limited resolution) Expensive Table 2.2: PZT Worm driven stage pros and cons. Some good ideas were presented in this work. The actuator topology is very ingenious surpassing the natural low displacement of the PZT stack and turning the stage into a virtually infinite displacement system. This capacity comes with a cost of using mechanical parts in the design that are subject to wear and need maintenance to keep the performance. That wear can be a problem for the control mechanism because the system response will change over time. In favour of the clamps is the fact that they provide an increased force to the actuator. The use of the commercial driver is a big con. Those drivers have high performance but are really expensive. If the cost is not a concern, those should be used. Otherwise, custom drivers give a lot more flexibility because they can be built to meet the requirements of the application without having excess functions. Another big con is the use of encoders. Cheaper ones don’t have a good resolution and since the control is based on their signal, if a good resolution is needed and that will not be cheap. Finally, the use of a commercial PC and software is a really weak solution. Processing needs are not critical in this project because the quantity of data to be processed is low (2 encoders and some simple PI calculations). A dedicated solution (DSP, micro-controller, etc.) was a better fit for the project. As shown, money was not a concern in this example so, some solutions might be impractical if we take it into account. Nevertheless some ideas are really relevant for the thesis in progress: •Again, PZT actuators were chosen to build the mechanism of movement. This seems to be the rule in XY-Stages; •Low displacement (and force if it is an issue) of the PZT actuators can be surpassed with good imagination and creativity; •Use of commercial electronic drivers is really common too. Might be a good idea to make a market survey; •Closed-loop control can be achieved with different sensors. But using one limits the system resolution to its precision. 14 State of Art 2.1.2.3 Comb-drive Actuator driven XY Stage This example is the first presented that an PZT actuator is not chosen to drive the stage. A electrostatic comb-drive is used but its principle is not very different. Figure 2.9 represents a schematic of the presented actuator. A comb-drive actuator comprises two electrically isolated conductive combs with a set of fingers equally spaced. One of the combs is moving and is guided by a flexure mechanism with really low stiffness. The other is the opposite (fixed, high stiffness). As said above, the actuation principle is really close to PZT actuators. When a voltage differential is applied between the combs, an electrostatic force is generated and the moving comb is pulled to the fixed comb along the Y axis. A parasitic movement is induced in X axis that is compensated by the flexure mechanism. Maximum displacement is limited by the finger width and by the flexure mechanisms [3]. Figure 2.9: Electrostatic Comb-drive actuator [3]. This stage (aimed at generic micro-applications) uses an altered comb-drive actuator in each axis. It is composed by two comb-sets to provide bi-directional actuation capability. To achieve total decoupling, intermediate stages were used as shown in Figure 2.10. In the proposed topology, the comb-drives are placed between ground and their intermediate stage to provide guidance between both combs of the actuator [3]. To drive the actuators, a commercial controller and electronic driver is used (a Keithley 4200SCS). It can provide up to 210Vand 1A. This is a test suite, not a final implementation of the controller and no feedback is used. With this topology, a displacement of 228ηmis achieved with a resolution of 1ηm. An image of the results can be observed in Figure 2.11. Table 2.3 gives an overview of the pros and cons analysis. The solution developed in this example features high resolution but a low displacement. The classification of the displacement as low is subjective because the thesis in progress is used as term of comparison but can be really high depending the specific application. 2.1 XY-Stages 15 Figure 2.10: Electrostatic Comb actuator driven stage topology [3]. Figure 2.11: Electrostatic Comb actuator driven stage results [3]. Since this was clearly a work in progress, the solution for the controller and driver should be despised. What was used was only a testbench machine, not representative of a developed solution. The actuator has a simple principle but its application is difficult. A high precision in the development is needed because the flexure mechanisms are the bottleneck in terms of force and repeatability and that’s a big con. Tying everything up, is the cost. No specific pricing was found but the need of intermediary stages and mechanical components joined by the comb actuator price, makes this a costly solution. 16 State of Art Pros Cons High precision, 1ηmresolution Complex design, high precision needed in implementation Decoupling of each axis movement Commercial electronic driver and controller Low displacement, 228ηm Low force, limited by mechanical components Expensive Table 2.3: Comb Actuator driven XY stage pros and cons. Relating the previous information with the work in progress, we reach the following conclusions: •Electromechanical actuators exist and can be used for this project. A trade-off exists between using them and increasing complexity due to the mechanical components; •Using mechanical parts in the design turns it more expensive. They should be avoided if possible. 2.1.2.4 Stepper Motor driven XY Stage In the examples shown so far, only PZT and electromechanical actuators were used. In a more traditional way, this example uses simple circular stepper motors. This was not found in published work but in a hobbyist website [5]. First, a brief overview of stepper motors is in order. It uses electromagnetic properties to convert digital pulses into mechanical rotation [4]. It is composed by windings that, when energized in sequence, provide movement in steps whose size is dependent of the physical components. Figure 2.12: Stepper Motor [4]. 2.1 XY-Stages 17 A more detailed insight of the stepper technology can be found in Section 2.3. Moving to the topology, this example represents a microwell plate [22] that features an enthusiast build with really cheap components. This is interesting because all other examples found in literature feature expensive designs and are focused in precision. The idea here is to get the work done as cheap as possible. The design features two unipolar stepper motors to provide fully decoupled movement in each axis. The stage is guided by stainless steel rods along with linear ball bearing holders. To move the stage, a toothed belt is used along with sprockets [5]. Figure 2.13: Stepper Motor driven stage topology [5]. An Arduíno [23] is used as a controller. To drive the motors, a simple circuit based in an ULN2003A chip (is an array of transistors) is used and everything is powered by the Arduíno (USB connection, maximum of 500mA). No information of the resolution is presented but it will be roughly the same of the stepper motor with a bit of error inserted by the mechanical parts and friction. The step size is limited too by the motor although an algorithm of micro-stepping [4] can be used that divides each step in micro-steps at cost of repeatability. In the example, the motor used rotates 360◦in 4096 steps. To traduce that in metric dimensions, the mechanical belt and the sprocket specifications must be known and no information is given. The design completes a run of a twelve by eight cm grid in less of four minutes. A video of its functionality can be observed in the project website. A pros and cons analysis of this design can be observed in Table 2.4. This example features a cheap, fully working stage with a large travel range and simple control. The use of a 3D printer is a really nice solution as shown because everything can be customized and fit every requirement. The use of sprockets and toothed components can be a problem if a more precise design is need. 18 State of Art Figure 2.14: Stepper Motor driven stage results [5]. Pros Cons Simple design Low resolution (can be surpassed) Really cheap project (∼$100) Use of mechanical components (sprockets, screws, toothed belt) Structure 3D printed Slightly slow Simple controller and electronic driver (Arduíno based) Very high displacement, 120x80mm Table 2.4: Stepper Motor driven XY stage pros and cons. This is a very good solution for some applications but the bottleneck is in the motor and resolution of the 3D printer. Looking now to the thesis objectives, a lot of good solutions and remarks can be achieved: •The use of a 3D printer improves development time and reduces project cost. Preferably, it should be used; •Stepper motors can be a solution if enough resolution can be achieved. The use of complimentary mechanical parts can be a setback; 2.1 XY-Stages 19 •A controller based in Arduíno is really powerful and cheap. This example shows that it was a good choice for the thesis; •If the actuator used consumes little power, a electronic driver powered by the Arduíno can be used; •Closed loop control is not needed for good performance. 2.1.3 Remarks Some examples were presented in the subsections above that were representative of some ideas and solutions which can be used in the project in hands. As shown, PZT actuators are the preferred to drive the stage because of its high resolution and low power consumption. But they are limited in terms of displacement and for the thesis that’s a big con. Electromechanical actuators are used too but they are excluded because they bring unnecessary complexity, high cost and maintenance. The other valid actuator found in literature was the stepper motor that is really simple and cheap but with limited resolution. The fact that the electronic driver can be implemented using only the power from the controller (Arduíno) is really relevant. In Table 2.5 a summary of all topologies is presented showing the relevant points of each one as a way to choose the actuators that are worth a deeper study. Analysing the table, one can see that if a intermediate solution with the characteristics of the PZT actuators and the cost of the stepper motors can be found, it will be one of the best solutions available. So, a deeper analysis of the PZT technology is needed to address this possibility and it can be found in Section 2.2. As a backup plan, a solution based in stepper motors is really relevant. Its characteristics make it a valid solution if paired with a good imagination to overcome the low resolution problem. A analysis of this technology is presented in Section 2.3. Regarding other implementations and topologies, every written work studied presented solutions based in electromechanical actuators like the one shown in Subsection 2.1.2.3. The option to present only one example was taken because every one had the same cons i.e. really high difficulty of implementation (as a result of it, very high price too), expensive drivers, high maintenance needed, etc. (see Table 2.5) and that violates the principles of the thesis. Because of this fact, electromechanical actuators are excluded for now (as said above) and considered not suitable for a in depth analysis leaving the battle for the PZT and Stepper technologies. 26 State of Art Figure 2.22: Simple PZT stack displacement amplifier. Another way to amplify the displacement is using the diamond flexure system. It can be observed in Figure 2.23. This kind of actuator can produce high displacement, force and frequency. Usually, more than ten times the displacement can be achieved with this system. Figure 2.23: Diamond actuator system by Noliac [8]. An example of an actuator based on a PZT bender is shown in Figure 2.24. The hydraulic fluid is actuated by the bender actuator and drives a small piston cylinder. It is hydraulic connected to a larger one to produce the amplified displacement. Figure 2.24: Hydraulic amplification system. 2.2 Piezoelectric Technology 27 2.2.4.2 Inertial-based actuator This method uses the connection between friction and inertial forces to produce the displacement. A good example is the stick and slip actuator shown in Figure 2.25. Each step movement consists in a slow deformation of the legs followed by an abrupt jump backward [28]. Figure 2.25: Stick and slip principle by PI [7]. Another example is shown in Figure 2.26. Here, the use of friction is fundamental. The force applied by the used point of contact (a rough material helps to improve the movement) is divided in x and y force. If Fx>Fyand Fx>P+Fawhere Pis the weight in Nand Fais the friction force (contrary to the movement), the system will move in little steps. A PZT bender or stack can be used as actuator. Figure 2.26: Friction slide principle. 28 State of Art 2.2.4.3 Worm actuator PZT worm actuators are composed by a set of three PZT stacks that work together to achieve theoretically infinite displacement. Two of the actuators work as clamps and the other one as an extensional element. In Figure 2.27 can be observed a typical step loop. First, one of the clamps contracts leaving the actuator supported by the other clamp (2). Then, the extensional element expands (3) and the clamp extends (4). Afterwards, the other clamp contracts (5) and the extensional element returns to its original size dragging the clamp (6) [2]. This cycle can be repeated as many times as needed. Figure 2.27: Worm motor actuation cycle. 2.2.4.4 Ultrasonic motor Figure 2.28 shows an example of a ultrasonic linear PZT motor. The moving table is driven by bending actuators. They are excited with the same electrical source with same frequency but with a controlled phase difference. At the vibration tip, an elliptical motion is created. A vibration circuit working at the resonant frequency is used to cause the ceramic components to vibrate [19]. Figure 2.28: Ultrasonic motor example. 2.2 Piezoelectric Technology 29 2.2.5 How to drive a Piezoelectric Actuator? For this subsection, some guidelines must be defined. The best solution based in this technology is the PZT bending actuator as a step motor (see 2.2.6) and here only will be shown the driver topologies for it. For the other actuators, a full analysis can be found in [29] and [30]. Relating to the step motor, the control can be with constant tension because the frequency is not relevant (can have a delay in the order of seconds). Making use of the natural charge and discharge of the PZT actuator (it can be simplified by assuming it is a capacitor), only the maximum tensions need to applied because a step cycle is composed by displacing the actuator to one side and then to the other. The discharge of the actuator guarantees that it passes by all positions. It is assumed that the bender actuator is rated at 100V. Because of the different types of the bending actuator (two or three wires), two driver topologies must be developed. The first type is the serial. As stated in 2.2.3.2, it features two wires. To achieve full displacement for each side a voltage of −100Vand 100Vis needed. Since the available source is of 5V, the following driver can be sketched: Figure 2.29: Power Driver for a serial PZT bender. First thing that the driver needs is to be able to perform is to elevate the tension from 5V to 100V. To achieve this a double stage DC-DC converter is used and it can be observed in Figure 2.30. The micro-controller controls the output tension by adjusting the duty cycle of the switch. A staged topology is used because one converter won’t be able to elevate directly to 100V. The capacitor represented in the full topology is the one from de second DC-DC converter. The coil is used to prevent big variations in the current while the transitions happen. Then a H-bridge is used. Adjusting its switches in opposite pairs applies +100V(switches 1-4) or −100V(switches 2-3) to the actuator. 0Vcan be applied if switches 2 and 4 are closed at the same time. For the parallel one, a DC-DC converter is needed too. The difference is that in this case the tension needs to go to 200Vbecause the outermost connectors need to be constantly at +100V and −100V. Then, a half-bridge is used. If the switch 1 is on, the tension on the central conductor will be +100V. If the switch 2 is on, the tension will be −100V. All capacitors need to have, at least, ten times the capacity of the actuator to ensure that they can charge it. 30 State of Art Figure 2.30: Step-up converter. Figure 2.31: Power Driver for a parallel PZT bender. 2.2.6 Remarks The properties of this actuators are really relevant for the thesis. Their low power consumption and easy drive allows an easy application. The big difficulty is to find a way to obtain displacement amplification. Some solutions were discussed in previous sections but the ones that seem more interesting go around the problem completely (worm or inertial) providing steps instead of trying to provide direct displacement. This is a really ingenious approach because it provides virtually limitless displacement but needs to be well executed, otherwise the resolution or even the complete functionality is in in danger. If a PZT technology solution is to be used, the better option is clearly the PZT bending actuator as a step motor (friction-based slip motor). If well planed and developed, a good resolution and step size can be achieved with a really low cost (just the actuator for ∼$15 and the structure that can be produced in a 3D printer). Other options use expensive stack actuators and applying directly the bender doesn’t provide enough displacement (needs to be higher than 10 mm, mechanical lever isn’t an option because of the low force of the actuator). 2.3 Stepper Motor Technology 31 2.3 Stepper Motor Technology This section discusses stepper motors technology and starts by giving a brief overview of their history, explaining the principles behind the technology, then moving to a full review of the different motor topologies, addressing next how to drive them and then finishes with a subsection dedicated to remarks and conclusions. A brief introduction was made in 2.1.2.4 and here is presented a more detailed analysis. 2.3.1 Historic Review Stepper motor technology history can be traced back to the 19th century with the name of Electromagnetic engines. Modern motors are due to Walker to whom was awarded a patent in 1919 by the invention of the tooth structure on both the stator and the rotor. This opened the field for the invention of the nowadays stepper motor by Thomas and Fleischauer in 1957 [31]. Since then, this motor concepts haven’t changed much and they are used in several fields. The first industrial user was Fujitsu Fanuc in their world famous Fanuc series of CNC systems. As the technology was maturing, the size of the motors was diminishing and now we can find an exemplar in almost any printer. Examples of this technology are used in camera lenses, slot machines, scanners and compact discs drives. 2.3.2 Types and Operation Related to construction, stepper motors can be divided in two major classes: with and without permanent magnets [31]. In those classes we can find various topologies but the most representative ones can be observed in Figure 2.32. Each class and its operation is described next. Figure 2.32: Stepper motors classes. 2.3.2.1 Variable Reluctance Stepper Motor This type of motor does not use a permanent magnet. All the windings are located in the stator and the rotor moves without constraint. This solution is optimal for applications that don’t require a high degree of motor torque. 32 State of Art Figure 2.33: Variable Reluctance stepper motor. The motor shown in Figure 2.33 has three points of winding energization (A, B, C) set 15◦ apart. Energizing pole A through the winding causes a magnetic attraction and the rotor teeth align with the teeth of the pole. Next, de-energizing pole A and energizing pole B causes the rotor to move 15◦to align its teeth with the pole. Repeating this procedure to pole C and then restarting the cycle causes the clockwise movement. If the order of the cycle is reversed (A, then C and then B), it causes a counter-clockwise movement [31] [4]. 2.3.2.2 Claw Poles Stepper Motor This is a permanent magnet motor and is also referred as "canstack" motor [31]. It features a relatively low speed and torque with step angles of 45◦or 90◦. Its main advantage is its low manufacturing cost making it perfect for non industrial applications [4]. Figure 2.34: Claw Poles stepper motor. The motor shown in Figure 2.34 has four phases. Unlike the previous example, applying current to each phase in sequence causes the rotor to adjust to the magnetic field (providing steps of 90◦). This configuration features a relatively high torque and low speed. 2.3 Stepper Motor Technology 33 2.3.2.3 Hybrid Stepper Motor This is the most popular type of stepper motors, combining the best characteristics of variable reluctance and permanent magnet variations. They are constructed with teethed stator poles and a permanent magnet rotor. Normally, they feature 200 rotor teeth and rotate at 1.8◦per step. This is the best configuration, providing high torque and speed. Figure 2.35: Hybrid stepper motor. 2.3.3 How to drive a Stepper Motor? To drive a stepper motor, first thing to know is if it is unipolar or bipolar: •Unipolar - it only has one winding per stator pole (Figure 2.36). Its movement can be reversed without inverting the current. Normally has four wires (both ends of the winding) but can have six (an extra wire per winding can be used for half stepping); •Bipolar - features two identical sets of windings per pole (Figure 2.37). To obtain reverse movement the current must be inverted. Normally has six or eight wires. Figure 2.36: Unipolar stepper motor. Depending on the type, different drivers can be designed. Figure 2.38 represents a typical configuration used to drive a stepper motor. Normally, a micro-controller is used to send the 34 State of Art Figure 2.37: Bipolar stepper motor. control signals to the power driver. The problem resumes to energize a winding and depending of the type, the driver might need to be able to reverse the current. Figure 2.38: Stepper motor driver block diagram. In Figure 2.39 we have an example of a L Rdrive for an unipolar motor. It is suitable for a low current stepper, of a few hundred mA, (if a stepper is to be used in the thesis work, it’ll fall in this case) because some power will be lost in Rs(it is used to improve the rising time of the current). The micro-controller sends its signal to the transistor gate turning it on and off as needed [31]. One of this driver is needed for each winding. The control should be performed closing each transistor in the order of the movement wanted, so one signal per phase is needed. More complex control can be used like half-stepping or microstepping for smaller steps. Figure 2.39: Unipolar stepper power driver circuit. 2.3 Stepper Motor Technology 35 In Figure 2.40 we have an example of a H-bridge driver for an bipolar motor. It is suitable for any motor with any rated current because it can be adjusted easily. If SW1 and SW4 are closed and the other ones are open, the current is positive and the motor rotates clockwise (if coupled with correct actuation of the other windings). If the opposite is verified, the motor rotates counterclockwise [31] The control should be performed closing each pair of transistors in the order of the movement wanted. Contrary to the unipolar example, two signals are needed per phase due to the four transistors (they are controlled in pairs). This driver is not worth doing with individual components, there are integrated circuits that already come with the H-bridge for each winding of the motor and their cost is really low (i.e. L6506D costs ∼6ein Farnell and features SMD package). Figure 2.40: Bipolar stepper power driver circuit. 2.3.4 Remarks This type of actuator is an interesting solution for the work in progress. It is very easy to drive (simple power drivers) and cheap. One big concern is the power consumption because the torque is proportional to it and that means an increased power supply if high torque is needed. To surpass this limitation, the load should be as low as possible. Another issue is the step size that can be too high for this application. Higher resolution steppers cost more money and that can make this option not viable. If this solution is to be used the best option is the hybrid motor because it has the best characteristics from the other options and features steps of 1.8◦. Between unipolar or bipolar the option to take is to get the cheapest because the difference is only in the power driver. If an unipolar is used, the driver is really simple and can be made from individual components. If a bipolar is used, 42 Electronic Driver •All companies were contacted. Using for reference a bender of 1mm of deflection, ±100V and 2Nof blocking force, the cheapest found was a serial bender (bimorph) by Piezo Drive priced at 13.52e; The chosen actuator is a BA4510 [34] by Piezo Drive. It features a 2mm range of displacement at ±100Vand 2Nof blocking force. Its capacity is 65nF, physical dimensions of 45x30x10mm 1.61gand a resonance frequency of 170Hz. This is a good solution because features high displacement at relatively low voltage and capacity. Since it is sold in an online store is easy to buy. The big con is that it is shipped from Australia making this a solution to be replaced in the future. Figure 3.1: BA4510 PZT bender. At least, two of this actuators are needed, one per axis. 3.1.1.2 Controller Choice As said in 1.2, the controller that will be used must be Arduino based. This brings numerous advantages: •Big online community. A big pro when problems arrive; •Cheap and complete boards: features several ADC channels, lots of IO’s, built in USB communication, etc; •Very easy to program, with simplified C language and lots of libraries. The only difficulty is to chose the version. The circuit will need at least 2 ADC channels (ideally 6) , 12 IO’s and built-in USB communication (to be able to communicate directly with the smartphone). It must work with 5Vtoo. Analysing all the available Arduinos, the Leonardo proves to be the right choice. It has 6 ADC channels, 20 IO’s, built-in USB communication, works at 5Vand 16MHz. Costs 18e+VAT in the Arduino Store. 3.1 Piezoelectric Bender Driver 43 3.1.1.3 Boost Driver Again, as shown in 2.2.5, the proposed solution for a bimorph bender is a two-stage boost converter followed by two h-bridges (one per actuator). This belongs the DC/DC converters class and the circuit diagram without the h-bridges can be observed below. Figure 3.2: Proposed driver circuit diagram. To analyse this circuit, we can just look to one stage because both work the same way, only with different components. Looking for the first stage (ends in the resistors in front of C1), we can see that SW 1 is the heart of this circuit and uses the principle of the power transfer between a coil and a capacitor that, contrary to a resistor, can store energy. The transistor is acting as a switch. Ignoring SWP,RF1, RH1, RL1, RGSW1 and RGSWP for now (they aren’t important for the converter’s operation) and assuming that the SW 1 and SW 2 are working as switches (refer to figure 3.3): •If the switch is closed, two circuits are formed: one composed by the 5Vand the coil L1 and one composed by C1. The coil is charged by the input voltage and, because of the diode, the capacitor can only discharge for a load or, if no load is applied, theoretically, maintain its charge (1); •If it is open, the full circuit is operating. The energy stored in the coil is used to charge the capacitor (2); If the switch is operated fast enough, the capacitor doesn’t discharge much and the coil never enters in the discontinuous mode (negative coil current) maintaining the desired voltage in the capacitor. The parameter used to control this circuit is the duty cycle of the switch that is nothing less than the time that it is open, in percentage, over a control cycle. This type of control is called pulse-width modulation (or PWM). Before passing this information to valid equations and waveforms, some remarks should be made about this circuit: 44 Electronic Driver Figure 3.3: 1 - Coil charging, 2 - Capacitor charging. •The power supplied to an eventual load is always less or equal to the power consumed in the input stage. Ideally is equal but since we have components along the way (diode, mosfet, coil, wires, etc.) that generate voltage drops, the output power will be always lower. Usually, the efficiency is about 80% [35]; •The current consumed by the driver is in spikes. Normally, this is bad for the power source; •The control is really easy by a microcontroller. Only a PWM output is needed; Figure 3.4: Coil current waveform To deduce all the equations, the coil current waveform needs to be studied. In figure 3.4 we can observe the control of the switch and the reaction of the coil current. During the coil charge phase (when the switch is closed, numbered 1 in the wave) and assuming that Ilmin =0 to prevent discontinuities, the current goes to a maximum value, Ilmax, and follows the equations: 3.1 Piezoelectric Bender Driver 45 Vl =L∗δIl δt(3.1) Il =1 L∗Zd∗T 0Vl ∗dt (3.2) Ilcharge =Vi L∗d∗T(3.3) Where Lis the inductance of the coil, dis the duty cycle and Tis the period of control. As said before, the duty cycle is a value between 0% and 100%. During the coil discharge phase (when the switch is closed, numbered 2 in the wave), we have: Il =1 L∗ZT d∗T Vl ∗dt (3.4) Ildischarge =Vi −Vo L∗(1−d)∗T(3.5) Assuming that the converter works in steady-state mode, the energy stored in the coil is the same at the start and end of the period. This only means that Ilcharge =Ildischarge and: Ilcharge =Ildischarge (3.6) Vi L∗d∗T=Vi −Vo L∗(1−d)∗T(3.7) Vo =Vi 1−d(3.8) d=Vo −Vi Vo (3.9) This is the base formula of the converter and guarantees that the output voltage is always higher than the input voltage. Theoretically, this equation allows an infinite output voltage but the duty cycle will be excessively high. A maximum valid value for it is around 85% [35]. Using again the idea of the energy conservation, we can deduct the remaining equations needed to understand the functionality of the converter: Ilmed =Ilmax −Ilmin 2Ilmin =0 (3.10) Ilmed =Ilmax 2(3.11) Pi =Po Vi ∗Ilmed =Vo ∗Iomed (3.12) Where Ilmed is the medium coil current, Pi/Po the input/output power and Iomed the medium output current. 46 Electronic Driver After the duty cycle and power equations reached, now the equations for the capacity of the capacitor and the inductance of the coil need to be deducted. For the coil, is really easy. Using the equations in 3.3 and evidencing L: L=Vi ∗d∗T Ilmax (3.13) Choosing the maximum current consumed in the input, Lcan be adjusted as desired. For the capacitance, the capacitor current waveform must be studied. It can be observed in figure 3.5. Figure 3.5: Capacitor current waveform The area marked with 1 represents the discharge to the load. The area marked with 2 represents the charge provided by the coil. In steady-state, the two areas need to be equal. With the use of some knowledge in electromagnetism: Zdq =Zi∗dt (3.14) Where qrepresents charge. The integral represents an area and the equation for the capacitor current is Ic=C∗d∗Vc dt so: ∆Qc=C∗∆Vc(3.15) C=d∗T∗Iomed ∆Vc (3.16) The ∆Vcrepresents the ripple in the output voltage. This can be chosen and adjusted as desired. This concludes the formula deduction for the converter. For the second stage, everything is the same except that the input source is the previous stage. Nothing else changes. 3.1 Piezoelectric Bender Driver 47 As shown, several parameters must be defined before any component calculation. After that definition, everything can be calculated and that is presented next. 3.1.1.4 Boost Driver Basic Components Several parameters need definition. They are the converter frequency, the output voltage (and its ripple) and the maximum current consumed: •Frequency - It must be as high as possible to improve the driver response and efficiency. It is limited by the microcontroller’s ADC speed (slowest part of the digital processing chain). The Arduino Leonardo works at 16MHz and the ADC channels can work at a maximum of 1MHz [36] but the higher the speed, lower the resolution. Choosing a value of 500KHz and knowing that each ADC read takes about 13 cycles (according to the datasheet), this represents ∼38000 samples/second. If we set a frequency of 10KHz for the converter, this means that we can make at least 3 ADC reads per cycle. This will be important and will be discussed later in this document; •Output voltage and ripple - since the PZT bender works at ±100V, that could be the output voltage. But since that, at maximum voltage, the force of the bender is almost 0N (see 2.2.2), the chosen output voltage is 50Vthat guarantees half of the blocking force. Using equation 3.9, this gives a duty cycle of 90%. This is too high and, if more voltage needed, the converter wont be able to provide it. This is the main reason for using two stages. The first stage will up the voltage to 25V(d=80%). The second will provide the 50Vwith a duty cycle of 50% that is acceptable and gives room for higher voltage values. An acceptable ripple is about 0.5V, up or down; •Maximum current consumed - since there isn’t a standard maximum current for USBOTG, this driver needs to be as flexible as possible to provide the chance to change smartphones if needed. Over 80% of the OTG-ready provide only a constant 100mA [37] and that is the value to be taken in account. Using 100mA and the equations 3.11 and 3.12 , Ilmed =50mA,Pinput =5V∗50mA =0.25Wand Iomed =10mA. As for the second stage, since the input voltage comes from a capacitor, it can have an Il2max =Io1med ∗2 without too much voltage drop. So Il2max =20mA; •The Arduino consumption needs to be taken in account too but since the converter consumption is in spikes, the power bus just "sees" the medium current. This leaves 50mA for each component. To sum everything up see the table 3.1. Next step is to calculate the capacitors and inductances of the converter. Since all the formulas were already presented, this is just a mathematical exercise. The values are presented in table 3.2. With all those components defined and calculated, there is enough information to perform some simulations to verify everything presented. 48 Electronic Driver F(KHz)Vo(V)d(%)∆Vo(V)Ilmax Iomed P(W) Stage 1 10 25 80 0.5 100mA 10mA 0,25W Stage 2 50 50 0.5 20mA 5mA Table 3.1: Piezoelectric driver ratings. C(F)(3.16)L(H)(3.13) Stage 1 4µ4m Stage 2 1.25µ65m Table 3.2: Piezoelectric driver capacitor and inductance values. 3.1.1.5 Boost Driver Simulations For this preliminary simulation, a program named PSIM was used. This software performs a simulation different from the normal SPICE. It just focus in the more general aspects, ignoring, for example the transistor gate current needs. With that in mind, the model used is presented in figure 3.6. Figure 3.6: PSIM converter model. Some configurations were made to guarantee that the converter was working in steady-state: •Set the capacitor initial voltages to 25Vand 50Vrespectively; •Force a constant output current of 5mA with a 10KΩresistor; •Set a square wave with the required duty cycles and frequency in the gate of the transistor. With this model and configurations, waveforms can be observed in the next figures. Looking at the figures, some conclusions can be taken: 3.1 Piezoelectric Bender Driver 49 Figure 3.7: PWM waves. V cont1is the PWM for the first stage and Vcont2is the PWM for the second one. Figure 3.8: Coil currents. Il1is the current from the first coil and Il2is the current from the second one. Figure 3.9: Capacitor currents. Ic1is the current from the first capacitor and Ic2is the current from the second one. 50 Electronic Driver Figure 3.10: Output waveforms. Vo1is the output voltage of the first stage, Vo2is the output voltage of the second one and Iout is the output current. •In figure 3.7 are presented the waves of control. The duty cycle is represented by the time that this wave is in the value 1 over a cycle. Comparing both waves, one can see that Vcont2 has a lower duty cycle and around 50% as desired; •In figure 3.8, can be observed that Il1max is 100mA,Il2max is almost 20mA and both never go below 0 as expected; •In figure 3.9, the phases of charging and discharging can be observed clearly. When the current is negative, the capacitor is discharging to the load and in Ic1, the current wave is spiked because the second stage consumes it in spikes too whereas Ic2is constant (resistor). When the current is positive, the behaviour is almost the same in the two stages and represents the trade of energy from the coil to the capacitor; •Finally, in figure 3.10, the output waveforms can be observed. Vo1presents some ripple as expected but stays around 25Vwhile Vo2performs the same and with less ripple. Iout is constant. With that simulation, the converter was validated and is ready to be implemented. The simplicity and flexibility was the main idea in choosing this topology. Since the control of the PZT bender is not well defined (it depends of the mechanical implementation of the stage), this converter allows the output of any tension from 5Vup to 100Vor even higher, allowing an adaptable control of the actuator. It allows re-usability for other applications too (stepper motors, changing the coils for example), making this a safe bet. Nevertheless, this flexibility comes with a price because it might not be the best choice for the stage depending of the actuation of the bender. This was a fair trade-off and was with that in mind that it was implemented, as presented next. 3.1 Piezoelectric Bender Driver 51 3.1.2 Implementation For this step, the complete circuit must be studied because a full characterization of each component is needed. Looking to figure 3.2, there are several resistors that were ignored in the previous section. This was derived of their low impact in the driver operation: •RHxis used with RLxto produce a voltage divider. This voltage divider is used to transform the output voltages of the capacitors in voltages that can be read by the microcontroller’s ADC that works in 0/5Vrange. The resistors should be as high as possible to limit the losses; •RFxare resistors used as current sense to improve control, if needed. They will be of 1Ω and can be replaced by a wire; •SW x are the transistors used as switches. The available choices are between BJT, MOSFET or IGBT and will be discussed below; •SW P is a simple on/off switch; •RGxxx are the gate resistors of the transistors. They must be calculated according to the transistor used and provide the needed current to switch it; •Since the Dx are diodes, only the current and voltage ratings are needed to choose them. Now that the other components functions are explained, the missing values need to be calculated. 3.1.2.1 Voltage Dividers The equation for a simple voltage divider is presented in 3.17 and in figure 3.11. The output voltage of the first stage is 25V. Setting this value to 4Vfor ADC measuring, this gives a ratio of 6.25. If R2 is setted to 1MΩ,R1 becomes 5.25MΩ. The output voltage of the second stage is 50Vbut it can go higher. Setting 100Vas maximum voltage value and making it 4Vfor ADC measuring, this gives a ratio of 25. If R2 is setted to 1MΩ,R1 becomes 24MΩ. Vo =R2 R2+R1∗Vi (3.17) 3.1.2.2 Transistor With the ample choice offered in the market, it is really important to chose the right transistors for the application. There are three main hypothesis: 58 Electronic Driver Figure 3.15: PCB layers. the equation in 3.9). The duty cycle is setted to 0 whenever the output voltage is higher than what is expected (gives time to the capacitor to discharge a bit). This type of control is a bit rudimentary and should be changed in future work (to a PID for example). This option was taken to provide a working controller as soon as possible and allow the actuator tests; –Read the current, RFeed1at the time of the writing, this measure was ignored. Future work; –Read the output voltage, ADC1the values read are used by the controller to set the duty cycle of the switch as explained in the previous item. •Second DC/DC stage - this stage is almost equal to the previous one. The only thing that changes is the threshold for the duty cycle. If more than 25Vare needed the duty cycle is adjusted to the correspondent value. If not, the duty cycle is setted to 0%; 3.1 Piezoelectric Bender Driver 59 Figure 3.16: Stripper Boost Converter PCB. •H-bridge - for the h-bridge, several pins need to be controlled. For each bridge, there are four essential pins, both ENxand both INx. Those pins control each half bridge and the control logic can be observed in table 3.5. According to the position commanded by the smartphone, the inputs change as desired (In1=HIGH,En1=HIGH,In2=LOW,En2= HIGH for +Vo,In1=LOW,En1=HIGH,In2=HIGH,En2=HIGH for −Vo and En1= LOW,En2=LOW for 0V). There are two more pins that need active operation, nRESET and nSLEEP. The first resets the internal logic with LOW input and must be setted to HIGH to allow normal operation. The second puts the device to sleep with LOW input and must be setted to HIGH too. Finally, there is a pin that goes to LOW if there is any problem with the device, nFAULT. This bridge can be voltage or PWM controlled. The controller firmware presented is very simple but performs rather well as will be presented next. This type of control was chosen because of its simple implementation and low development time (the biggest pro). Although, in the future, the controller should be changed to a more evolved and robust one (PID, for example). This could bring improvements in the output ripple and in 60 Electronic Driver Figure 3.17: Boost Converter. InxEnxOutx x 0 Z 0 1 L 1 1 H Table 3.5: H-bridge logic. Taken from the datasheet, property of Texas Instrument. the power consumption but needs good adjustment and that takes time (and was not viable in this project time-frame). 3.1.3 Experimental Results At the time of the writing, the PCB experimental results were not as expected. It wasn’t able to elevate the voltage over 20Vmeaning that something was drawing too much current. The most probable causes could be: •Bad programming of the firmware that lead to an incorrect functioning of the DRV8844; •The DRV 8844 draws more current than what is advertised; •The is an error in the PCB print/design; •Wrong model of one of the components (the first coil, most probably); 3.1 Piezoelectric Bender Driver 61 •The Arduíno is drawing some power from the driver (some current loop created); •Some obscure PCB design rule that was not followed. This was a serious drawback because the PCB was only ready two weeks before the deadline. This gave no time to perform the necessary debug of the board. Although, this was not a deal breaker because, while the PCB was not ready, the driver was implemented in a development board with some spare components that were lying in the laboratory. Although this was not ideal, it was working and drove the benders quite well. The circuit was not 100% faithful to the one presented but was really close. The differences were (compare with figure 3.14): •No SWPW R and RFEED1/RFEED2(meaning that no OpAmp too) were used; •C1 is 63V4.7µFand C2 is 450V2.2µF; •The diodes are two 1N4003 (200V1A); •L1 is 4mH and L2 is 68mH; •Every transistor was a BJT and a BD139 (NPN) or BD140 (PNP) with gate resistors of 11KΩ; •The H-bridge was made with individual components and follow the circuit show in figure 3.13 but with BJT transistors (the RPU are 10MΩresistors); •The OpAmp used was a OPA2350; To test the validity of the driver, a triangular wave was asked of the driver (see why in section 4) while using a bender and a 1KΩresistor. The driver responded with the wave shown in figure 3.18. The wave shows the triangles asked but the deadzone (the −5 to +5Vthat is converted in 0V) can be well observed. This is one of the limitations of the driver but shouldn’t be a big problem in the table implementations. It is even more noted because the bender doesn’t discharge as fast as desired. This can be corrected with a bigger resistor charge but that will ask more current from the driver. It is a matter of calibration but will stay like this for now. With this test, the driver is validated. 3.1.3.1 Performance Analysis As far as performance goes, two really important aspects can be tested: •Output Power - the driver was tested with only a resistor as a load and without the h-bridge. Starting with an 200KΩ(250µA) resistor, its value was successively lowered until the driver couldn’t output the 50V. With that, a value of 20KΩwas achieved. This represents an output current of about 2.5mA, half of what was expected. This represents an efficiency of 50% and was somewhat expected because of the use of a development board. It features several 62 Electronic Driver Figure 3.18: Wave response of the driver. parasitic RLC and the components weren’t the most indicated. This value can be seen as a success; •Ripple - as said in the implementation section, the accepted value is 0.5Vup or down. With the resistor specified above, a measure with an oscilloscope was made. It reported a maximum value of 50.4Vand a minimum of 49.6V. It is between the gap defined. This measure can be observed in figure 3.19. 3.1.3.2 Consumption Test Again, the used circuit was the one implemented in the development board, not the PCB one. The values here are estimated to be higher if the PCB was working flawlessly because all the components were picked with power consumption in mind (just the MOSFETs are a big difference because they are voltage controlled not current like the BJTs). As for the test, a very simple one was made after all the process of assembly (see section 4.6). The smartphone was charged up to 100% and a simple infinite loop of a full grid (10x10 steps, see figure 4.35) route was coded. Each step was made with 50Voutput voltage and a step interval of 5s. An Android application named GSam Battery Monitor was used to monitor the battery consumption. This app give numerous information but the most useful for this test is the battery percentage and voltage level. The app is shown in figure 3.20. 3.1 Piezoelectric Bender Driver 63 Figure 3.19: Output voltage of the driver. For this exercise, we assume that the discharge of the battery is linear. This can be made because, during the discharge from maximum value to more or less 3V, the curve is almost linear as can be seen in figure 3.21. The test was started at 22h39 and featured 4.269Vand 100%. After 1h30 the test was stopped and the the values were at 3.921Vand 76%. Doing a bit of extrapolation: m=4.269−3.921 24% =0.0145 (3.18) 4.269 =m∗100+b=>b=2.819 (3.19) This puts the lowest voltage at 2.819V. That’s very unreasonable because the minimum value never should go below 3V[10]. The best way to correct this curve is using only the voltage levels. With that: m=4.269−3 100 =0.01269 (3.20) 4.269 =m∗100+b=>b=3 (3.21) The plotted curves can be observed in figure 3.22. Using the voltage values and doing a simple 64 Electronic Driver Figure 3.20: GSAM Battery Monitor. proportion calculation: 4.269−3.921 =0.348V−>1.5h=>(4.269−3)∗1.5 0.348 =5.47h=5h28min (3.22) The value in equation 3.22 represents the approximate autonomy of this system, assuming non-stop working. This is well above the 1h refereed in subsection 1.2.1 even if this is without the image processing tasks and lightning. 3.1.4 Remarks After the driver presentation, some remarks can be made: 3.1 Piezoelectric Bender Driver 65 Figure 3.21: Li-Ion battery discharge plot [10]. (a) Battery consumption plot (V vs %). (b) Battery consumption plot (V vs h). Figure 3.22: PZT bender driver consumption plots. •The PCB didn’t work. The reason wasn’t found by the time of the writing but the expected reasons were enumerated and will be tested in future work; •In other hand, the circuit worked as expected in a breadboard implementation. The numbers presented weren’t as good as if implemented in the PCB but good enough to actuate the benders; •The control used works but a better one should be developed in the future. Since it is only software, it doesn’t condition the driver implementation. A PID controller is a good idea for it as shown in [39]; 66 Electronic Driver •The driver features some limitations. The deadzone is one of them and the bender discharge is the other. This brings the question if this is the best path for the implementation of a PZT driver... It is already known that this driver aimed to be as flexible as possible to allow some experimenting in the XY Table development but, when this implementation is well defined, a better, more focused driver should be developed; •The power consumption was a bit high derived of the backup plan for the PCB. It featured 5h28min (extrapolated value) of autonomy and this value is estimated to rise with a successful PCB implementation; •The driver construction costs 17.96efor the components plus 116.33eper two PCB boards. The full price is 76.125e. This is a prototype cost, in a large scale production, the cost can really go down. Using the PCB Pool price comparator, 100 PCBs cost 424.84eand that makes each one cost 4.25 e, for example. Using the prices given by Mouser, if 100 drivers are made, the cost is 14.51 eper board. This totals 18.76 e. 3.2 DC Motor Driver 3.2.1 Theoretical Study To drive a DC motor, only a h-bridge is needed per motor. The idea is very simple and explained in figure 3.23. If the 1 and 4 MOSFETs are closed, the motor spins to one side and the inverse happens if 2 and 3 are closed. Some resistors can be added if a fast current limiting method is needed. Figure 3.23: DC motor h-bridge. This is a very simple circuit and allows a fast motor actuation with a very easy control. The maximum current allowed is the the OTG limit that depends on the smartphone used. 3.2 DC Motor Driver 67 3.2.2 Implementation Like the previous driver, there are two solutions for the application, one custom made and the other using a commercial IC. With a quick web research, we can find the L293 family of circuits. These ICs are exactly what is needed because they feature two h-bridges, work at 5V with a maximum output current of 2Aand are driven directly by the Arduino pins. They are very similar to the DRV 8844 presented before. There are some variants of the same circuit, like the L293Dthat incorporates the fly-back diodes in the chip or the L293Ethat has current sense pins. It really comes to availability rather to functionality but, if all variants are available, the L293Dis the best option because it saves space derived to the included fly-back diodes. The used IC was the L293E(see table 3.6) and the circuit used can be observed in figure 3.24. Figure 3.24: L293Eh-bridge circuit. Some 0.1µFceramic capacitors were added in the motor pins to help stabilize the current. In Vss pin a 0.1µFceramic and a 100µFelectrolytic capacitors were added to filter current spikes and voltage drops. Since the Arduino Leonardo was already available, it was used for the implementation. This implementation leaves the current control to the load. This allows the motor to be directly connected to the IC or with a current limiting resistor. If the resistor is used, it should be of at least 50Ωand 0.5W, forcing the maximum current value to be 100mA, respecting the value referred in subsection 3.1.1.4. 74 Electronic Driver This may or may not surpass the DC motor driver advantages because it wins clearly in the price, easiness and autonomy time. At the time of the writing and with the tests performed, the DC motor driver is probably the best option. It can even be improved with more one chip and allow more two DC motors to be used (interesting, allows the addition of a Z axis motor). But this relates only to the driver choice and the best is a bit relative since these are two viable solutions that work well for their objectives. For a full analysis and conclusion, the next chapter is needed. Chapter 4 XY Table This chapter is focused in the development of the physical part that constitutes the XY Table. In it, the actuation principle is explained, followed by a report about the experience of working with the 3D printer and finally presenting the various topologies pursued during the project timeframe. Every topology is escorted by a full explanation of the principle theory and the physical structures of them are detailed. The results of the tests are presented too, making an analysis of the success/insuccess of the implementation. 4.1 Principle Theory The method idealized is based on the stick-slip phenomenon and was already lightly presented in subsection 2.2.4.2. There is little consensus in the literary work studied (a good explanation can be found in [41]) but, generally, it’s agreed that the behaviour results from the interaction of two surfaces that are influenced by thermal changes during different phases of the movement. The responsible forces are the static and kinetic friction. Normally, the static friction is higher than the kinetic one but, if a force applied is large enough to overcome it, there is a sudden jump in velocity of the movement [42]. A good example is to imagine an object (a cube for example) on top of a sheet of paper. If the sheet is moved slowly, the cube will move with it (stick) but, if there is a sudden change in the sheet velocity, the cube will stay behind (slip). If the start place is compared to the end place, we will see that the cube moved. To sum this idea, in figure 4.1 the principle can be observed applied to the project in hands. During the slow extension (represented by II), the platform moves with the actuator (stick) because the static friction is larger than the kinetic one. Then, the actuation voltage is reversed in a very small time (represented by III) and, in consequence, the actuator reverses its movement too but, since this change is so fast, there isn’t enough static friction and the slider stays in place. This traduces in a step. In the figure is also shown the control method of the actuator in terms of the voltage applied to the PZT bender. The electronic driver must be able to produce the voltage 75 76 XY Table triangles needed by the system with the correct timings. The tests were already presented in subsection 3.1.3 and they shown that the driver is valid and correct for the implementation. This stick-slip principle is very simple and observed in numerous ways in our day-to-day life but at the same time, too hard to be described by mathematical equations (derived of the general lack of knowledge of the friction behaviour and the lack of proper instruction in mechanics). This brief presentation should be enough to try to apply it but can’t be treated lightly. It is an important subject in mechanical engineering and a more knowledgeable discussion can be found in [41]. Figure 4.1: Same figure presented in 2.2.4.2, see 2.25 4.1.1 Implementation premisses To apply this principle, the main concerns are the actuator force, the point of contact, the material of contact and the movable body. Only a correct tuning of all of those concerns leads to the wanted behaviour in an efficient and reliable way. Analysing them: •Actuator Force and displacement - the PZT bender chosen in subsection 3.1.1.1 features a blocking force of 2N. This value is only achieved when the bender is in its original shape, dropping almost linearly with the displacement (see figure 2.18). This is the major point of reference of all the design. We must take in account that is almost impossible to transform all that static force into usable one. One more important reference is the fact that only half of the maximum displacement will be used (the 50Vused, discussed in previous chapter, represents half of the possible displacement), representing half of the blocking force, 1N. So, the upper boundary of the applied force is 2Nand the lower one is 1N, without any kind of amplification. As for the displacement, the logic is the same: with 100Vthe displacement is maximal and is 1mm. So, for 50V, the displacement is 500µmm; •Point and material of contact - probably the most important points in all the project. This will define the efficiency or even better, the success of the implementations. Analysing: 4.2 3D printer 77 –Point of contact - this point is really topology dependent. Although all will follow almost the same premisses. Its shape should be such that the moving structure is always in contact with it. This translates in a rounded shape to compensate the rounded movement of the bender (see 2.2.3.2). Another premiss is that its shape will be reflected according to an axis to allow movement forward and backward. This will be explored in each topology; –Material of contact - this a really difficult point. The material used needs to provide enough friction to the moving structure for it to stick but, during the retraction, the friction needs to be low enough that the structure stays in place or, at least, the backward displacement is lower that the forward one. For this point, a web search was performed and a good information source was found [43]. In it, we can observe that there are a number of materials that present high friction coefficients like Aluminium, Glass, Iron or Rubber. Of all, the easiest and cheapest one to find is the rubber. Since there are thousands of types of rubbers the most available ones were studied (see 4.2): ∗Common white rubber - this type is not hard enough, it bends too easily and can’t transfer the force; ∗Common green rubber - this one is really good for the application. Easy to cut, model and hard enough to apply force. This type was chosen; ∗Mixed rubber, red part - better than the white type in terms of bending but not enough; ∗Mixed rubber, blue part - as good as the green rubber but harder to cut; ∗Isolation rubber - not suitable for the application, extremely hard to make the forms wanted. •Movable body - it should be as light as possible and its point of contact with the actuator will be lined with the same material used in it. If this provides too much friction, it will be removed. It will be printed in the 3D printer so it will be made of PLA or ABS (see section 4.2). This will need to be fixated to some kind of structure so the friction with the point of contact needs be really low. Some mechanical aids (ball bearing for example) might be used depending on the success/insuccess of the topology. Everything presented here should be taken as an introductory and preliminary analysis to the problem. As will be shown in the rest of the chapter, some ideas and premisses changed and evolved during the development derived of each small step and topology iteration and are properly explained. 4.2 3D printer The 3D printer used is a Makerbot Replicator 2x. This printer is in an experimental phase and uses the principle of plastic extrusion where a type of it is heated and then pushed through an 78 XY Table Figure 4.2: Studied rubbers. extrusion nozzle head. It immediately hardens and form layers. This process is controlled by a microcontroller that turns the flow on and off and moves the head to the correct point. This specific model features a dual-extrusion mechanism that allows the simultaneous extrusion of different materials. Makerbot claims that it features 100µmof layer resolution, 11µmin XY and 2.5µin Z. These are impressive values and should be good for the project. The software used can be the Markerware (property of Markerbot) that works with any STL 3D model. There are some open source variants of it are more flexible (and bug free) like Replicator G. Figure 4.3: Makerbot Replicator 2x. 4.2 3D printer 79 4.2.1 Materials The two main materials used with the Replicator are the ABS and the PLA. As explained above, both are thermoplastics (soft and moldable when heated, solid when cooled). Both are valid options for 3D printing but some characteristics change and that’s the reason why some people prefer one over the other: •Storage: –ABS - If there is some humidity in the place where it is stored, it will tend to create bubbles and spurt during the print; –PLA - Same problems of ABS but has an even greater negative influence with alterations in extrusion temperature. •Smell: –ABS - Smells like hot plastic (may be a problem in closed environments); –PLA - Since PLA is made from sugar, it has a sweet scent that is better than hot plastic. •Accuracy: –ABS - Strong and somewhat flexible material. Is resistant to high temperatures and is often the preferred plastic for projects with mechanical uses in mind. Corners present a slight rounding; –PLA - More rigid than ABS making it more difficult to interconnect different pieces. This material has tendency to curl if the build plate is not hot enough. If actively cooled, much sharper details can be achieved. A more extensive discussed can be found in [44]. Analysing the presented pros and cons, the ABS characteristics are more attractive for the structure in mind because there will be a lot of interconnection pieces (no screws requirement). The somewhat flexibility of the material is the big advantage over the other material. The ABS used was Markerbot’s that featured a filament diameter of 1.75mm. 4.2.2 Calibration and Tests Before any printing can be done, the printer needs to be calibrated. This is achieved levelling the build plate, using the existing screws. This process is made with the help of a cardboard that should be able to move under the extruder with a bit of friction. The first few prints (a simple cube) were not successful (4.5). They were printed with the Markerware default settings using ABS. They had lot of flaws and its corners curled up. After some days of more testing, a new glass base was inserted into the printer (4.6). Around the web, there were reports of improvement with the parts and the curling. The quality of the new pieces improved indeed but they were nowhere near the promised resolution by Makerware. 80 XY Table Figure 4.4: Build plate spring screws. Figure 4.5: Failed cube print. There were errors in the scale of millimetres. The Replicator G software was tested too and its settings changed. A comparison between the failed cube and another printed with the glass base and Replicator G can be observed in figure 4.7. The best setting found was using the Replicator G default settings but with the built plate at 130oC. This presented reasonable results but, again, nowhere near of those expected (this can be testified by the previous users of the printer). This conditioned the implemented topologies as we will see next. 4.3 Triangular Tip topology 81 Figure 4.6: New glass base. Figure 4.7: Cube comparison. Notice the curled bases and the improved resolution of the red cube. 4.3 Triangular Tip topology 4.3.1 Model Development This solution was developed with flexibility in mind, trying to allow several uses for the motor. Its 3D model can be observed in figure 4.8. Everything is in scale with the bender that features its measures as detailed in the datasheet. Analysing it, some of the most important parts are the ones that belong to the clamping mechanism of the PZT bender and they are marked with 1 in figure 4.8. The complementary pieces clamp the bender (black figure) and fit in the main body of the motor. The front cover then keeps everything in place and features a hole to allow exterior observation of the mechanism. The tip is marked with the number 2. It is the most important part of this construction and features a slot to insert the actuator. This slot allows the use of the force to the both sides equitably. As observed, the tip has an hole where an axis will be inserted. This axis needs to be robust and the choice fallen into a paper clip part. It is easy to obtain and strong enough to hold in place. As 82 XY Table Figure 4.8: Google Sketchup 3D model of the triangular tip topology motor. for the dimensions, they were obtained by making an analysis over the mechanics of the simple lever machine created that can be observed in figure 4.9. Figure 4.9: Lever theory applied to the triangular tip topology. The force and displacement ratings were discussed previously and are 1Nand 500µmm. In the lever theory, Fout F1=L1 L2and that means that we can achieve force amplification only playing with the lengths. The downside of this method is that the displacement will lower by the same amount of the force increase. Since no amplification is wanted because we are producing movement in steps and the material will be really light (1.04 grams per cubic centimeter), L1and L2were projected to be equal and measure 5mm. The tip will work as explained in section 4.1 and will be coated with the rubber discussed before. The movement of the tip is considered horizontal because, since it will be coated with the 4.3 Triangular Tip topology 83 rubber, it will provide the necessary support to the axis. The supports marked with 3, are used to provide fixation to the motor. The slots in the bottom part are used to provide fixation to the movable axis. Finally, the hole in the side of the motor was inserted because of the bender wires. The axis supports were projected in a way that the axis will always be in contact with the tip. Here lays the biggest need in precision. The full (one axis) system can be observed in figure 4.10. To conclude, everything was developed with the smallest possible dimensions without compromising robustness. Figure 4.10: Google Sketchup 3D model of the triangular tip topology. 4.3.2 Physical Implementation After the 3D models ready and confirmed, it was time to print the pieces. As said above, the software used was the Replicator G with default settings (with some changes) that are: •Object infill = 10%; •Layer Height = 0.27mm; •Number of shells = 1; •Feedrate = 40mm/s; 90 XY Table 4.4.3 Experimental Results The first tip tested was the number 1. This system works the same way than the others but the applied wave is slightly different. The wave has the same form of the one shown in figure 4.1 but its limits are 0Vand +/−50Vdepending of the direction of the movement, being 0Vthe position of rest. The applied wave can be observed in figure 4.19 (again, controlled by the smartphone). Figure 4.19: Applied voltage to the actuator. This tip was unable to produce any kind of movement. The displacement amplification was too much and that severely limited the applied force. Even with numerous manual adjustments (moving the tip closer or farther) of the tip or changes in frequency (used 10Hz, 50Hz and 100Hz) no success was obtained. The second tip uses the same waveform of the first topology (see figure 4.14). This time, the platform moved but ultimately stayed in place. This means that only the stick principle was in operation. With some manual adjustments, some steps were achieved but they were too inconsistent (sometimes, a step occurred) to even consider this a success although, this was promising. 4.4.4 Remarks There are some ideas to retain from this experience: •The first tip was a fail. The idea was abandoned; •The second tip was able to move the platform. It presented promising results; •The force applied is more important than the displacement. This was obvious when the second solution was experimented; Since the time to the project end was rapidly approaching, this solution (with the second tip) was put in standby. It is indeed possible to develop an actuator with a stick-slip mechanism as seen in [42] but needs a lot more mechanical study to apply it. This might not be possible and compatible with the limitations of the project. With that in mind, two new paths were sketched: 4.5 DC motor table topology 91 •Develop a more simple approach with three benders. Not ideal because the design will become more expensive but good enough for a first prototype; •Develop a solution based in common motors. This idea was good in more than one way: it allows a comparison between solutions and is easy enough with a lot of examples in literature. These two paths are presented next. 4.5 DC motor table topology Derived from the remarks show in subsection 4.4.4, a new topology based in common motors was developed. To develop this system without spending too much time, we recurred to the mechanical research made in section 2.5 and selected the CD-rom system to be the base. This choice was made because it is really easy to get two (one per axis) broken systems from any computers store and this goes into the thesis objective of spending the least money possible. We can also find a great variety in terms of stepper or DC motors. A DC motor system was chosen because it is easier to control (only one H-bridge per motor vs two bridges per stepper motor), consumes less power and is cheaper. The downside is that it isn’t as precise as the stepper motor but, since the final system doesn’t need incredible precision, we can get away with it. This is not the final idea for the problem but rather a fast solution. Ideally, the whole system will be printed by the 3D printer and then we fit the DC motors in it. It will be just dependent of the DC motors and not of the CD-rom systems. The used system can be observed in figure 4.20. Figure 4.20: Example cd-rom system. This particular system uses a gear to translate the rotational movement of the motor in linear motion. It is not great but does the job well. Further when the motor stops, it has no need to continue to be energized because the mechanical helicoidal transmission holds the position fairly 92 XY Table very well. Features a sensor placed in the end (or beginning) of the axis that is nothing more that two pieces of metal that touch each other when the platform reaches them. Only one of the sides of the platform is hold by a metal axis, the other side is just lodged in a plastic support. The motor is a Mabuchi FF −030PK. This is a really small motor that features a stall current around 0.5Aand has a nominal voltage value of 5V. This motor starts spinning (without any load) at about 0.7Vand is capable of moving the system at about 1.2V. This means that the full 5Vof the driver won’t be needed and the motor can be controlled by PWM (see subsection 3.2.2.3). One interesting addition is the use of two mechanical actuated sensors. They were already in the design, they weren’t added. They signalize when the platform reaches them by creating a short circuit between two pieces of metal. This can be used by the Arduíno to signalize the origin (point (0,0)) of the grid. Two equal systems were used for each axis. This is ideal but not a requisite for the system. The control can be adjusted for each motor and system independently. To conclude, there is the need to talk about the grid implementation. For a successful analysis, the system needs one-hundred images and the idea of performing a grid type movement was already refereed in section 1.2 (the movement complies with the methodology proposed by WHO for malaria microscope analysis [13]). This movement will be performed as shown in figure 4.21 using the sensors for the (0,0). Figure 4.21: Grid movement implementation for the DC motor topology. The values represent a cell position. 4.5 DC motor table topology 93 4.5.1 Physical Implementation The assembly of the system was made with the most available components in the laboratory. This design is not optimized it was just made in a way that the assembly was as fast as possible because the time was short. Since both systems contain everything essential to work and just needed support, this was addressed. The assembled system can be observed in figure 4.22. Figure 4.22: DC motor XY Table with a microscope slide. An aluminium base was used to hold everything in place. This base has several 4mm holes and that was useful to hold the system in place. Some nylon M4 screws were used to place the X-axis system in place together with some nuts. As shown in figure 4.20, there was no obvious way to hold the other axis. For that, a support was developed that could fit in the platform without destroying it. That support can be observed in figure 4.23. It is a simple geometric form, adjusted to the platform in hands, leaving 2mm free counting from the higher point of the platform. This is not ideal because needs personalization for each system and a new solution must be achieved in the future but, for now, is enough. Since the resolution wasn’t a big problem with this support, the printed version was reasonable and more than enough. Two holes were made to hold it in the platform with the help of some screws and nuts. Then, on top of it, a platform made out of a cut cd-rom was fixated with a screw. It was cut with the shape of the system, leaving the hole in the middle directly under the moving platform. This could be useful for the illumination of the microscope slide. 94 XY Table Figure 4.23: Google Sketchup model of Y Axis support. Four holes were made in the cd platform to allow the hold of the second axis with some nuts and screws (nylon M4). Other support (like the one in figure 4.23) was assembled in the other axis to allow the assembly of the microscope slide holder. In the end, the microscope slide holder was assembled and the table was ready. 4.5.2 Experimental Results After everything assembled, some tests were performed. Some things needed testing: the validity of the table and the real resolution of it. The tests were: •Validity - test if a full run can be achieved in some specified constraints, with a relaxed step size but under 1 mm; •Resolution - test the real maximum resolution of each step for each axis with an accurate test and check if the result is under the needed step size; The smartphone was used to control the motors and conduce the testing with the test application developed (see chapter 5). 4.5.2.1 Validity For this validity test (and to the resolution one), a system for measurement must be used. In the laboratory, there were no machinery for this kind of application, so, there was the need for an ingenious and accurate approach with available materials. One of the most precise items that are present in almost all homes is the optical mouse. It features a light-emitting diode and a photo-sensor to detect movement relative to a surface. A normal mouse has around 1000DPI (or 39.3701 DPmm) that translates to dots (or pixels in case of a computer screen) per inch (millimeter). This is already high, meaning that it can detect movements of 1mm 39.3701 dots =25.4µmbut this is theoretically because several other factors need to 4.5 DC motor table topology 95 be taken into account (USB delay, movement detection algorithms, etc) turning the mouse in an accurate but not precise system. Although, this will be enough to have an idea of what is needed (around 500µmsteps) in a simple and cheap way. Every result should be taken with a grain of salt because the mouse lens is very susceptible to dust and imperfections so an error of 100µmis expected. This method is not new and a full analysis can be observed in literature [45]. A computer software is needed to process the information from de mouse. Instead of developing a software form scratch (that would take a lot of time), a freeware named Mousotron was used to count the pixels movement. This software is for Windows only and uses the Mouse API to give the movement details. Figure 4.24: Mousotron screenshot. The "X Coord" and "Y Coord" are important fields. To perform the analysis, the mouse used was a X7XL −750BK and it features 3600 DPI (141.7323 DPmm). The system shown in figure 4.25 was assembled to perform the tests. The assembly was not very robust so it was reinforced by some electrician tape. The cardboard was assembled as parallel as possible to the mouse. This is not a perfect testbench but it is enough to give some notion of the steps. For the validity, a run was made from position (0,0)to (2,9). The configurations used for the system were: •Voltage applied = 5V; •Period of actuation = 20ms; •PWM duty cycle = 100% (or 1023 in Arduíno PWM value) meaning that the motors were being voltage controlled; •PWM frequency = 10KHz (this value doesn’t matter since the duty cycle is 100%). 96 XY Table Figure 4.25: System assembled to measure the DC motor topology displacement. A black cardboard was used to enable the measure. (a) Position of the table. (b) Y axis stepsize. The average is 0.484 mm. Figure 4.26: DC motor topology validity test. The results can be observed in figure 4.26. As shown in the previous pictures, the measure system works very well. It induces some error as expected but does its job. About the system, it can be observed that, even with some relaxed configurations, the step size is about 500µm. That alone could be the final step size because it is enough for the 10x10 grid in a 20cm diameter sample. There was not enough data to characterize the X axis. It will be done in the resolution test. Probably, both axis will need different configurations because the X axis has more weight to move. In the figure can be observed the error from the mouse. The extra back-travel is physically impossible because the system started in maximum available position. The lack of repeatability can be observed but that can be error from the measure system. Although, the performance was 4.5 DC motor table topology 97 really good and shown that is possible to draw the grid in an open-loop configuration. 4.5.2.2 Resolution For the resolution test, it was just a case in reducing the PWM duty cycle and period of actuation until the motors stop moving. When that point was achieved, the configurations were slightly increased and the values were defined. The method of measurement was the same used in subsection 4.5.2.1. The greatest problem found was the inability of the measure system to read steps with the step time lower than 5ms accurately (better, with the same tolerance than the validity test). This was the wall achieved and the results can be found in figure 4.27. The step sizes of each axis are shown in figure 4.28. Figure 4.27: Position of the DC motor table. (a) Step size of X axis. The average is 0.273 mm.(b) Step size of Y axis. The average is 0.328 mm. Figure 4.28: DC motor topology resolution test step sizes. 98 XY Table These values took a lot of time to take. Several tries were needed and even more adjustments were made. It was really hard assembling the measure system in a way that the values were always reliable and without a lot of noise. The values shown represent a really good resolution. This time, the values seem more stable than in the validity test. That might be a result of a better assembly or a cleaner platform of movement. As expected, we can see a difference of resolution in both axis derived of the extra weight that the X axis must move. The lower number of comparison points can perform a role in the difference too. It must be said that lower step times are possible but the measuring system just can’t measure them. This means that even more resolution can be achieved but a new, more professional, measure system is needed. It cannot be said with 100% certainty that the system has a resolution lower than 300µmbut everything points to that. Even with only 500µmresolution, this system is able to respond to the proposed task. 4.5.3 Remarks Summing up the DC motor topology, some remarks can be made: •This system is very simple and does exactly what is needed; •The use of old CD-rom systems was a good idea but is not viable for the final system. A new model must be developed around the DC motors; •This system is capable of under 300µmsteps (needs further testing), more than enough for the project; •Overall, the system is very cheap and easy to implement. This might be the best path for the future of the project. 4.6 Three bender table topology Derived from the remarks show in subsection 4.4.4, a new topology based in three benders was developed. Since the main problem was the slip phase of the actuation principle, a third bender was inserted to remove the contact from the actuators and the moving platform during that phase. This is a patch of the intended topology, to prove that a PZT XY Table can be developed and to show a possible solution. 4.6.1 Model Development The model developed uses the friction forces to provide the intended movement. There are three benders, one for each axis and a complimentary one to do the function explained before. This complimentary bender needs a few electronic components to work. To the output of the PZT driver, the circuit shown in figure 4.29 was added. 4.6 Three bender table topology 99 Figure 4.29: Third bender circuit. This topology arrangement can be observed in figure 4.30. As show in the picture, this system is based in a simple cd-rom. This decision was taken because they are really common everywhere and are a cheap way to get some flat plastic. This cd can even be a printed platform, this is really flexible. The form of the platform can even be changed if desired. It is supported by four printed supports to elevate the system. The axis actuators use the same clamping system discussed in section 4.3 with a modified tip (see figure 4.31). The tip is a rounded piece of rubber that guarantees that it is always in contact with the moving platform and it keeps the 2:1 amplification system discussed in the lever topology. Those two cubic forms are just a way to limit the travel of the system. The distance is more than enough for the 20 cm travel needed. This arrangement is more a Xθtable. This is a possible solution because there is no need of a precise XY table, just 100 different positions and this solution produces that easily. The idea is that the actuator numbered with 3 is like a circumference center for the theta movement originated by the actuator numbered with 2. This movement follows a simple procedure: 1. The actuator numbered with 1 and 2 start at rest (0V); 2. Actuator 1 goes up (simply by applying the +V); 3. Actuator 2 goes to the opposite side of the movement (+/−V); 4. Actuator 1 goes down (0V); 5. Actuator 2 goes to the side of the desired movement using the wave show in the point II in figure 4.1 (maximum value is the contrary of the one presented in 3). 106 XY Table Figure 4.39: System assembled to measure the three bender topology displacement. Figure 4.40: Position of the three bender table. platform. There were a lot of problems with the cardboard arrangement too. A lot of tries were needed to get these acceptable values. As shown, the Y movement is around of what is expected. The platform goes from side to side but without much repeatability. This could be a characteristic of the design or a side effect of the mouse or even both combined (most probable). It features steps with an average of 225 µmand that is very good (even if we add 100 µmthe resolution, is enough). The X axis movement is a mess. We can see that the platform is moving forward (the point distribution is shifting up) but that could even be a measure error of the mouse since the step is so small. The X axis measures should be ignored, they are only here as a curiosity because the mouse can’t measure steps of 30 µmreliably. 4.7 Conclusion 107 (a) Step size of X axis. The average is 0.034 mm. (b) Step size of Y axis. The average is 0.225 mm. Figure 4.41: Three bender step sizes. It cannot be said with 100% certainty that the system has a Y axis resolution lower than 300µm but everything points to that. For the X axis, more work is needed until it works reliably. It is in the right track though and, with more time, a fully working system can be achieved and with great resolution. 4.6.4 Remarks Summing up the three bender topology, some remarks can be made: •The system just needs the driver and the benders. The rest is printed in the 3D printer; •The Y axis worked wonderfully. It featured steps of under 300 µmbut is too dependent of the complimentary bender adjustment; •The X axis still needs work; •The system is not fully functional but it is in good shape for the future work. The next steps should pursue a more successful implementation of the X axis and in building a more robust system (maybe join everything in single fitting piece). This implementation showed too that the idea is valid and possible; •During the development, stayed the feeling that the actuator was too big. Maybe a smaller bender with lower displacement but higher force is a good option for the future. 4.7 Conclusion After all the topologies presented and discussed, is now time to discuss what is the best design, the table with benders or with DC motors. A comparison can be made between the developed topologies: •Both topologies were just profs of concept, none have final designs; 108 XY Table •The DC motor topology was fully functional. The three bender option was almost fully functional; •The DC motor system will need some kind of mechanical component to translate the circular to a linear movement (right now is using gears). The bender topology just uses common available materials and it’s almost fully printed in the 3D printer. Because of this and without counting the actuators and drivers, the three bender topology is cheaper; •Right now, the three bender topology needs manual adjustments while the DC motor system works every time; •The DC motor topology can be well reduced in terms of size while the bender one is always stuck with the size of the actuators; •The bender system features smaller steps (according to the results for the Y axis); This was a hard fight and there is no clear winner. The bender system is a novel one and has the potential to be something really good in terms of resolution and repeatability but needs some work until a final design is achieved, while the DC motor topology is a bit more rudimentary but can make the work with a lot less effort needed. Since the final system needs to be replicable, the easy development takes a real weight in the path to take. The idea to take is that both systems are valid and represent solutions for the proposed problem. Refer to chapter 6for a more complete conclusion where everything is analysed and the best decisions for the project next steps are presented. Now there is only missing the analysis of the developed software. It is presented in next chapter. Chapter 5 Smartphone Controller Library This chapter is focused in the Android and Arduíno communications. Before digging deep in any of the platforms code, all the assumptions made before starting the development are presented and the technologies used are shown. All the necessary functions that need to be guaranteed are presented and the communication protocol is described as well. Then an UML analysis of the code developed for the Android is made and a high level explanation is presented for the most important functions and procedures. Every bit of code is well documented in source, this chapter is a complement to it. After everything about Android is crystal clear, the Arduíno code is dissected and presented. Here, no driver control tasks are presented (like voltage control), they are featured in chapter 3. Since there are two implementations, some functions and procedures are exclusive for each implementation. This is well explained below. 5.1 Technologies Used To develop the two parts of software needed for the project, different technologies were used because both platforms have their own needs and programming languages. This is presented below. 5.1.1 Android Technologies For the Android part, the language used was JAVA for Android. This is the main programming language for this ecosystem and brings the plus that, with little changes (only Android specific functions), the library code can be used for other platforms like Windows, Linux or MAC. The IDE used was Eclipse with ADT plugin running under Windows or Linux (depending of the computer used for the development). This setup is the most used and well tested by Android developers. Eclipse is a well mature IDE for a lot of languages but the plugin brings a lot of new functionalities to it like a drag-n-drop GUI editor, debug tools and custom XML editors. A screenshot of the IDE can be observed in figure 5.1. 109 110 Smartphone Controller Library Figure 5.1: Eclipse with ADT plugin. As referred before, the smartphone used to test the Android program was the Samsung Galaxy S4 Zoom. A picture of it can be seen in figure 5.2. Figure 5.2: Samsung Galaxy S4 Zoom. Foto from GSMArena.com. To perform the communication between both devices, the library USB Serial f or Android presented in 2.6 was used. This library already has the raw functions like open(), read(), write() and close() so the whole protocol was built over it. To save the work made and perform version control, a Git (distributed revision control system) repository was used. The project is private and stored in Bitbuckets. 5.1 Technologies Used 111 5.1.2 Arduíno Technologies For the Arduíno, the language used is a variant of C/C++ named Arduino Language that encapsulates most of the hard part of the microcontroller programming. Essentially, it is just a set of libraries written in C and C++. The IDE used was the Arduino IDE. This IDE does all the basic functions needed to program an Arduíno and features a ton of libraries and a serial monitor. A screenshot of the IDE can be observed in figure 5.3. Figure 5.3: Arduino IDE. As referred before, the board used was an Arduíno Leonardo. A picture of it can be seen in figure 5.4. 112 Smartphone Controller Library Figure 5.4: Arduino Leonardo. Foto from Arduino.cc. 5.2 Mandatory Functions The library must implement several functionalities to allow the correct control of the two implementations (three bender table and DC motor table). Some of them are pretty standard and are related to common communication tasks (open/close communication for example). The others are specific to each topology. The common tasks that must be implemented are: •open(serial parameters) - starts the communication between the Arduíno and the smartphone with the supplied parameters in terms of baudrate, parity, stopbits and databits; •close() - safely closes the communication; •isBusy() - asks the Arduíno if it is ready for a new request; •stop() - stops the driver and returns the actuator to its rest position; •restart() - restarts the driver logic. The open() and close() functions are already implemented by the USB Serial f or Android library. Just a protocol message is needed to inform the driver of the smartphone’s intention. The other functionalities are implementation based. Starting with the DC motor implementation: •move(axis, forward/backward) - makes the motor move, forward or backward, in the selected axis; 5.3 Communications Protocol 113 •changeSpeed(axis, speed) - sets the PWM value in the selected axis; •takeStep(axis, forward/backward) - performs a step, forward or backward, in the selected axis; •changeStepTime(axis, time) - changes the step time of the selected axis; And for the bender implementation: •changePosition(position) - changes the output voltage of the driver according to the desired position; •goLeft(axis) - applies the driver output voltage positively to the selected axis bender, adjusting the H-bridge (the bender goes left); •goRight(axis) - applies the driver output voltage negatively to the selected axis bender, adjusting the H-bridge (the bender goes right); •goCenter(axis) - applies 0Vto the selected axis bender, adjusting the H-bridge (the bender goes center); •tableUp() - applies the driver output voltage positively to the complementary driver (table goes up); •tableDown() - applies 0Vto the complementary driver (table goes down); To understand why these functions are essential see chapter 4. Before passing to the implementation, the communication protocol is explained below. 5.3 Communications Protocol Since this is a two device communication, the protocol was made as simple as possible, without adding any unnecessary overhead that could damage the reaction time of the system. First of all, the communication model must be defined. There are several interaction models in literature like Peer-to-Peer, Master-Slave, Client-Server or Producer-Consumer but most of them are too complex to the application. Using that idea of simplicity, a Master-Slave protocol was adopted: •There must be a master (the smartphone) and a slave (the Arduíno); •The communication is always started by the master; •A command is sent to the slave followed by a response from it. This model is more than enough to power the protocol. Moving now to the protocol, as said, the master always starts the communication. It is based in very simple packets sent by both of the devices. The packets sent by the master follow the model shown in figure 5.5. 114 Smartphone Controller Library Figure 5.5: Master packets model. As shown, this model is really simple and has everything needed to allow the communication between the two devices. The number of arguments is variable and each function named before need different ones to perform properly. This information and everything necessary to understand this protocol is presented in table 5.1. To every request, the Arduíno simply acknowledges if it was successful. For that, it sends just one byte of information containing the ID of the request sent by the master. There are other possible responses and they can be observed in table 5.2. Rule of thumb, before a request, the master needs to ask the driver if it is ready. If this question is not made, there is the risk that the request will fail with a BUSY response. Although, some commands don’t need to ask if the driver is ready. They are the OPEN, CLOSE and STOP for obvious reasons. The whole logic behind the busy messages are explained in section 5.5. To show an example transaction, figure 5.6 presents a simple sequence diagram for a STEP request. It features every communication required to successfully request a STEP form the system. In front of each identifier is the packet sent. Take note of the STOP request, the Arduíno answers with an invalid message identifier. This is expected because the STEP request is finite in time, so the motors are already stopped when the request gets to the Arduíno. But, for increased safety, that command should always be sent before CLOSE. 5.4 Android Library After the protocol explained, here is presented the library developed for the Android ecosystem. As referred in subsection 5.1.1, the USB Serial f or Android library is used as the backbone that powers this project. It needs a quick overview before presenting the library developed. 5.4.1 USB Serial for Android The library is updated regularly, supports all Android devices with USB host capabilities and all serial devices that use the drivers FT 232, CDC/ACM serial or CP2102. The Arduino Leonardo uses a CDC serial driver so its support is confirmed. This library is built over the class UsbManager offered by the Android API since version 3.1. This class allows the access to the USB devices connected to the smartphone. This class originated several other ones (Usbinterface,UsbEndpoint) that allow the USB communication. 5.4 Android Library 115 Request ID Number of Arguments Arguments Arguments Value Explanation OPEN 10 - -Signalizes that the system was turned on and is ready to perform. CLOSE 20 - -Signalizes that the system is shutting down. READY 30 - -Asks the driver if it is busy. STOP 40 - - Signalizes that the driver should stop. In case of the DC system, the motors stop. In case of the PZT benders, the DC converter stops and the H-bridge sets every actuator with 0V RESTART 30 0 - -Signalizes that the driver should restart its logic. DC motor requests MOVE 20 2 motor, direction motor - 0 if x axis or 1 if y axis; direction - 0 if forward or 1 if backward; Commands the driver to move the selected DC motor in the selected direction. The motor only stops moving when a STOP request is issued. SPEED 21 3motor, speed (2 bytes) motor - 0 if x axis or 1 if y axis; speed - PWM value, 0-1023 Changes the speed of the selected DC motor. STEP 22 2 motor, direction motor - 0 if x axis or 1 if y axis; direction - 0 if forward or 1 if backward; Commands the driver to take a step with the select motor in the selected direction. TIME 23 3motor, time (2 bytes) motor - 0 if x axis or 1 if y axis; time - time value in ms, 0-65535 Changes the time of the step of the selected motor. PZT bender requests GOLEFT/ GORIGHT/ GOCENTER 1motor motor - 0 if x axis or 1 if y axis; motor - 0 if x axis or 1 if y axis; Applies +V/−V/0Vto the PZT bender. GOPOSITION 91 voltage (position) voltage - 0 - 50 Changes the output voltage if the driver. Changing the voltage changes the position (1V=10µm) UP 10 0 - - Applies the driver output voltage positively to the complementary driver (table goes up); DOWN 11 0 - - Applies 0Vto the complementary driver (table goes down); Table 5.1: Every request detailed. 122 Smartphone Controller Library even if there isn’t any slot available. The argument driverToo signalizes if the driver should be destroyed (for a user instantiating only one motor, this parameter should be true). If the takeStepTaskInstance is operating, stops it (prevents memory leak and safely cancels the AsyncTask; more about this below) calling the stop() function. Can fail for a lot of motives, see the Javadoc; •public void stop() - sends a STOP message. Cancels takeStepTaskInstance if it is running. Waits for semaphore if there isn’t any slot available. Most of the implementation is in the Motor class because it is almost the same for each motor. See Javadoc for exceptions; •public void isBusy() - sends a READY message. Throws a DeviceBusyException if the device responds with BUSY. This function is used by almost all requests and should not be used directly because is not semaphore protected (might be changed to protected in the future); •public void goLeft()/goRight()/goCenter() - sends a GOLEFT/GORIGHT/GOCENTER request. If there aren’t any semaphore slots, throws a DeviceBusyException. Performs a driver and readiness check before sending the request and a response check after the request sent. This request doesn’t change the output voltage it just changes the H-bridge output. The goPosition() function should be used for that; •public void goPosition(int newPosition) - sends a GOPOSITION request. The argument newPosition should be an integer between −500 and +500 µm. If there aren’t any semaphore slots, throws a DeviceBusyException. Performs a driver and readiness check before sending the request. Since the position is directly related to the voltage outputted by the electronic driver by a ratio of 10x(100µmis equal to 10V), there is a minimum voltage after 0V(see 3.1.2.7) that is defined in the PiezoPosition class and is 5V(that is converted to 50µm). This function not only sets the voltage for the driver regarding the intended position but changes the H-bridge too to match it (calling goLeft()/goRight()/goCenter() if needed); •public int getCurrentPosition() - reads the position value from the PiezoPosition object and returns its value; •public void tableUp()/tableDown() - sends a UP/DOWN request. If there aren’t any semaphore slots, throws a DeviceBusyException. Performs a driver and readiness check before sending the request and a response check after the request sent; •public void takeStep(boolean forward, int numberOfSteps) - executes a step request. The argument f orward signalises the direction of the movement (true for forward and false for backward) and numberO f Steps should be a positive integer for a finite number of steps or 0 for infinite steps. This function gives the user the opportunity to walk several steps with one instruction. For this, a (AsyncTask is used, named takeStepTask were the functions above are called in the correct order to perform a step. Those functions include the 5.4 Android Library 123 goLeft()/goRight()/goCenter(), goPosition() and tableUp()/tableDown() and the order can be inferred from figure 4.32 (assume everything in rest position, 0Vin every bender): –For a y step forward (assuming that the voltage is at 50Vderived form a open() or goPosition() call): 1. tableUp(); 2. goLeft(); 3. tableDown(); 4. goPosition() - this function is called in a loop from goPosition(−MAXPOSIT ION ) until goPosition(MAXPOSIT ION), with STEPSIZE increments. This procedure gives full control over the step size because the boundaries can be chosen at will; 5. tableUp(); 6. goCenter(); 7. tableDown(); –For a x step forward (assuming that the voltage is at 50Vderived form a open() or goPosition() call): 1. goLeft() - remember, table doesn’t move because it is stuck in the y rubber tip; 2. tableUp(); 3. goCenter(), goRight() - since we can’t use the goPosition() here because the tableUp() command needs the full 50V, we do two big steps that are more than capable of moving the platform; 4. tableDown(); 5. goCenter(); Each instance of a PiezoelectricMotor controls two benders, the one controlling one of the axis and the other that lifts the table up or down. Since there is only one bender to lift up/down the table, 2 different instance of a PiezoelecticMotor calling this functions are controlling the same bender. Those functions are enough to control the motor and give flexibility to perform other tasks with the benders. 5.4.2.3 XYTable class This class encapsulates the motors in a way that the user is controlling the table and not them. Features two instances of one of the motors and it resumes to a set of simple functions that perform all the logic needed and call the correct functions from each motor. For the XY table, there is this concept of grid. This class tracks the table in this grid that is measured by the steps taken by the table. For the DcMotor table, there are two sensors signalizing the origin (point (0,0)). For the PiezoelectricMotor version, there aren’t any sensors so it is 124 Smartphone Controller Library assumed that the user sets it in the proper place (point (0,0)). The grids work in different ways for both implementations. These informations are not new can be observed in sections 4.5 and 4.6. The functions that can be used are: •public XYTable(Context mContext, boolean piezoelectric) - this is the constructor. The Context object is needed for the XY TableSerialDriver to acquire the UsbManager, necessary to communicate with any USB device. The piezoelectric is true if the table is actuated by the piezoelectric benders or false if actuated by DC motors. It initializes the motors and the driver too. In case of a PiezoelectricMotor table, assumes that the table is at point (0,0); •public void open() - this function initializes the driver with the first device it finds in the USB bus (more than enough for the application), uses the default serial communication values (115200bps, 8databits, 1stopbit and no parity) and sends a OPEN message. There is a version of this function that receives all communication parameters and the device wanted (see Javadoc); •public void close() - closes both motors calling their close() function with an false argument and then closes the driver. It just needs to call the function in one of the motors because they share the same electronic driver; •public void stop() - stops both motors calling their stop() function . It just needs to call the function in one of the motors because they share the same electronic driver; •public void isBusy() - calls the isBusy() function in one of the motors. Throws an exception, DeviceBusyException, if the device responds with BUSY. It just needs to call the function in one of the motors because they share the same electronic driver. This function is used by almost all requests and should not be used directly because is not semaphore protected; •public void moveX(boolean forward)/moveY(boolean forward) - makes the x/y motor move endlessly in the selected direction (if f orward is true, it goes forward; if not, it goes backward). In case of a DcMotor table, calls the motor move() function. In case of a PiezoelectricMotor, calls takeStep(forward, 0) function. Both motors can’t move at the same time, it will return a DeviceBusyException. Calling this function breaks the grid track; •public void takeXStep(boolean forward)/takeYStep(boolean forward) - makes the x/y motor take a step in the selected direction. It calls takeStep(forward, 1) function. Both motors can’t move at the same time, it will return a DeviceBusyException. Calling this function does not breaks the grid track; •public void resetPosition() - resets the motor position. In case of a DcMotor implementation, calls move(f alse)function for each motor (it automatically stops when it gets to the sensors, it is coded in the Arduíno) sequentially. For the PiezoelectricMotor implementation, it calls goTo(0,0) function that will be presented below. This resets the grid track broken by move() calls; 5.5 Arduíno Firmware 125 •public void nextStep() - according to the current position, this function calls the takeXStep() or takeYStep() in a way that the grid movements presented can be performed. When a full run is achieved, it calls resetPosition(); •public void goTo(int x, int y) - moves the platform to a user defined point. This the arguments xand ymust be valid values within the grid. Those values are defined in the filed MAXGRID POSIT ION . For the DcMotor implementation, the grid values are between 0 and MAXGRID POSIT ION and for the PiezoelectricMotor are between (−MAXGRID POSIT ION ) 2and (MAXGRID POSIT ION ) 2. To implement the movements, it relies on an AsyncTask that calls the necessary functions in order; •public int[] getPosition() - returns the current position grid values. With this three classes, the table and the motors can be fully controlled. There are other functions in the classes but they are used for debug or aren’t implemented yet. But, without a good electronic driver firmware, this library is pretty much useless. It is presented next. 5.5 Arduíno Firmware The Arduíno works like a common microprocessor, runs its program in a loop like it was using a while(1). The function that runs in this loop is simply called loop() and there goes all the code. But, before running this function, the Arduíno runs another one named setup() where the initializations should be made. It runs only one time, at boot. After this quick introduction, the implementation of the firmware for the table topologies need presentation. Since there are two implementations, the firmware changes a bit for each one. There was no advantage in implementing both in the same code (too ugly) so this was the path taken. As will be shown, most of the implementation follows the same ideas. The implementation for the bender topology is based in the breadboard driver, not the PCB driver. This was made because the PCB didn’t perform as expected and there was no time to debug it. 5.5.1 setup() As said above, this function should initialize every thing needed. It is divided in two function calls: •setupComms() - equal implementation for both topologies. Starts the serial communication at 115200 bps (can be changed at will, provided that the user changes it in the Android library) and waits that the serial port is open; •setupControl() - the implementation is almost the same for both topologies, the only thing that changes are the pins. In both of them, the PWM pins have its frequency adjusted to 126 Smartphone Controller Library 10 KHz thanks to the timer 1 (associated to pin 9) and timer 3 (associated with pin 5) libraries. The piezoelectric bender driver has the ADC frequency changed to 500KHz; The pins follow the circuits shown in figure 3.14 and 3.25. 5.5.2 loop() This is where all the code must be inserted. This subsection is split between both implementations because there are significant changes between them. 5.5.2.1 DC Motor The loop section is separated in several function calls and that can be observed in figure 5.9. Figure 5.9: Structure of the DC motor topology loop(). 1. readSerial() - reads the bytes (if exist) from the serial port to a byte array (inBu f f er) and increments a variable signalizing the number of bytes in the buffer. Tests if the message received is valid comparing the second byte of the message (see 5.5) and sets a boolean flag (newValidMessage and invalidMessage) to allow processing; 2. processComms() - processes the received message (signalized by the newValidMessage flag) analysing the first byte of it. If it is known and in correct order, sets two variables 5.5 Arduíno Firmware 127 (actualFunction[0]and actualFunction[1]) with the received function ID and fills an output byte buffer (outBu f f er) with this ID (see 5.3). This actualFunction array controls the H-bridges, setting the transitions of a FSM that controls them. If the message is not known or sent in an incorrect order, sets a boolean flag (invalidMessage) that fills the output buffer with an INVALID message. If the request is a SPEED request, it calls the function changeSpeed() that sets the PWMSPEED (contains the PWM speed values for each motor) array correct position with the new value. The request TIME works the same but with the changeTime() function and STEPTIME array; 3. processTask() - just calls the controlHBridges() function; 4. controlHBridges() - this function control the two motors H-bridges by implementing a FSM (one for each bridge). It can be checked in figure 5.10. The figure explains it pretty clearly, the transitions are just the values of the array actualFunction (updated by the processComms()). The only thing that is not clear is the fact that only one motor can be moving each time. The state names are just the possible values for the array bridgeState. After the transitions calculation for each bridge, the controlOut puts() is called and there the state is evaluated and one of the setForward()/setBackward()/setStopped() is called. In them, the correct pins are actuated, the PWM, using the PWMSPEED, is setted and, if the sensor is actuated, the next state set as STOPPED. See that the step logic is all performed in the Arduíno firmware contrary to the PZT bender topology. This was made to reduce the jitter lag in the DC motor start and stop (not relevant to the benders); 5. sendSerial() - if there is anything in the outBu f f er (signalized by outBu f f erPosition integer variable), it is sent; 6. turnLED() - turns the LED associated to the pin 13 (internal to the Arduíno) on if both axis sensors are actuated. 5.5.2.2 Piezoelectric Motor This follows the same structure of the last one and the functions can be observed in figure 5.11. 1. readSerial() - same as the DC motor implementation; 2. processComms() - same as the DC motor implementation but with PZT requests. If the request is a GOPOSIT ION request, it calls the function setPosition() that sets the output voltage to the new value, changing expectedVC1 and expectedVC2 variables (used in the controlHBridges()). If the request is a UP/DOWN, it calls the up()/down() function that controls the transistor of the complementary bender; 3. processTask() - calls the controlFirstDcDc() followed by controlSecondDcDc() and finishes with the call controlHBridges(); 128 Smartphone Controller Library Figure 5.10: DC motor topology FSM. (a) controlFirstDcDc()/controlSecondDcDc() - reads out putVC1/out putVC2 variable that represents the voltage that should be outputted and calculates the necessary duty cycle (using equation 3.9). Reads the real voltage at the capacitor using the ADC and, if it is higher than the wanted voltage, sets the PWM to 0% duty cycle. If it is lower, sets the duty cycle to the calculated value; (b) controlHBridges() - same as DC implementation but uses the setLe ft()/setRight()/ setCenter(). In WAITING state, it calls setVoltageValues() that update out putVC1/ out putVC2 with the received expectedVC1/expectedVC2. The FSM can be checked in figure 5.12; 4. sendSerial() - same as DC motor implementation. This overview gives all the necessary information to understand the Arduíno firmware developed. For more in-depth knowledge, see the well commented source code. 5.6 Test application To guarantee that everything was working as desired and to provide the ability to move the table, a test Android application was developed. This application is very simple and exemplifies how the users can build their own application and work correctly with the library. 5.6 Test application 129 Figure 5.11: Structure of the PZT motor topology loop(). Four different activities were created to power the app. The first one can be observed in figure 5.13 and represents the welcome screen of the application. As can be seen, it allows the choice of the device and, upon click, allows the choice of the axis wanted. At the time of the writing, there is no way to change the serial communication parameters, it uses the default ones. Choosing any of the options, the communication is established (or, if failed, the exception appears on the screen) and the correct screen appears. For the PZT option, the screen shown in figure 5.14 appears. As shown, the screen has all the actuation functions of the PiezoelectricMotor class. The position control button sets the position of the bender with the help of a slider dialogue. The take step button uses a Yes/No dialogue to allow the choice of a backward or forward step. The disconnect button stops the driver, closes the connection and returns to the main screen. The white space is actually a status console where all information will appear regarding the requests and eventual exceptions. There is an indicator too of the bender position. For the DC option, the screen shown in figure 5.15 appears. Works the same way of the PZT motor controller and uses a slider dialogue for the time and speed requests. There is an indication signalizing if the motor is moving or stopped. Finally, the XY Table screen can be checked in figure 5.16. 130 Smartphone Controller Library Figure 5.12: PZT motor topology FSM. Follows the same implementation of the previous activities. The indicator shows the grid position of the table. This is just an example of everything that can be made with the developed software. The final implementation will be very different because it will interconnect with the image processing software and not with an user. It must be said too that this library can be easily ported to other systems (Windows/Linux/Mac) because it is JAVA based (information already presented before). Using a pure JAVA library that replaces the USB Serial f or Android (JavaSimpleSerialConnector [46]), the MicroStage Serial works without almost any hassle. In the ambit of this project, a PC library was started but was left at a very raw stage because the time was not enough for everything. The PZT motor controller was almost all ported and only the functions U p()/Down() weren’t available. A screenshot of this JAVA application can be observed in 5.17. 5.6 Test application 131 Figure 5.13: App welcome screen. Figure 5.14: PZT motor controller screen.