Measuring Mechanical Vibrations Using An Arduino As A .

3y ago
18 Views
2 Downloads
3.82 MB
25 Pages
Last View : 1m ago
Last Download : 3m ago
Upload by : Jamie Paz
Transcription

FREIA Report 2015/04June 9, 2015Department of Physics and AstronomyUppsala UniversityMeasuring mechanical vibrationsusing an Arduino as a slave I/O to anEPICS control systemAdam Hjort & Måns HolmbergUppsala University, Uppsala,SwedenDepartment ofPhysics and AstronomyUppsala UniversityBox 516SE-75120 UppsalaSwedenPapers in the FREIA Report Series are published on internet in PDF format.Download from http://uu.diva-portal.org

Physics Project with a Research Connection 5 hp, 1FA605 June 2015Measuring mechanical vibrations using an Arduinoas a slave I/O to an EPICS control systemAdam Hjort & Måns HolmbergSupervisor: Volker Ziemann & Konrad GajewskiDepartment of Physics and AstronomyUppsala UniversitetAbstractIn this study we have assembled hardware and software to be used for measuring of mechanical vibrationsin the FREIA-laboratory at Uppsala University. We have utilized an Arduino microcontroller as a slaveI/O and equipped it with dual accelerometers to be used for vibration measurements and a serial adapterwhich was used to connect the hardware to an EPICS IOC for analysis. Data from the two accelerometershave then been cross correlated in order to find a transfer function. Our results where in good agreementwith theory.1IntroductionIt is of utmost importance when designingphysical experiments that one takes into account the mechanical vibrations that may occur and affect the results. There are severalways to measure mechanical vibrations and inthis study we look closer on how to measurethem using an MEMS-based accelerometer [3].By using two accelerometers we can see howvibrations transfers from one point to anotherand thereby gain some information into thecharacteristics of the medium the vibrationspropagated through. To provide the accelerometers with power and collect the waveforms,an Arduino microcontroller is being used. TheArduino functions as a slave IO and can be connected to either MATLAB or an EPICS controlsystem. During hardware testing a speaker wasused to generate desired sine waves, seen in figure 6. Since this speaker propagates the sounddirectly into the material it is being placed on,it proved excellent as a frequency test devicefor the accelerometers. As an real world experiment, we measured the transfer function for avacuum pump at the FREIA-laboratory.2HardwareFigure 1: The Arduino Uno rev. 32.1ArduinoArduino is an open source microcontroller thathas become very popular amongst students,hobbyists as well as with professionals. It hasa very active community and the low cost ofpurchase makes it an excellent tool to quicklytest and deploy ideas. We have chosen to workwith the reference model Arduino Uno rev. 3that can be seen in figure 1. It measures 68.6x 53.4 mm and weights 25 g. It is based onthe ATmega328 8-bit microcontroller. It has a1

Physics Project with a Research Connection 5 hp, 1FA605 June 2015clock frequency of 16 MHz and a 32 KB flashmemory. It operates at 5 V and can be powered over USB or an external power supply. Onthe board there are 6 analog pins and a totalof 14 digital I/O Pins and 6 of these providePWM output. There are also pins for powermanagement [7].The analog pins which are the ones we mostlywork with in this project has a resolution of10 bits meaning they can handle 1024 differentvalues. This is usually done by having eachvalue correspond to a voltage between groundand 5 V, however this can be changed by usingthe AREF pin (analog reference pin).For communication with the Arduino UARTTTL (5V) serial communication is used. Thedigital pins 0 (RX) and 1 (TX) can also be usedto send and receive serial data. In the IDE thereis a built-in serial monitor that can be used tosend and receive information. When connectedover USB to a computer the Arduino showsup as a virtual COM-port and any softwarecapable of serial communication can be used.2.2AccelerometerTo measure frequencies we use an accelerometer similar to the ones you find in smartphones.The accelerometer measures as the name hintsthe acceleration that it being is subjected to.The model we have used is mounted on abreakout board from SparkFun and use theADXL335 3-axis accelerometer from AnalogDevices [1]. It measures 3 g in three orthogonal axis labeled the X, Y and Z direction. It canread in the range of 0.5 Hz to 1600 Hz for theX and Y axis while the Z axis has a range of 0.5Hz to 550 Hz. However the SparkFun modelcomes mounted with 0.1 µF capacitors that actsas a low-pass filter and limits the lower bandwidth of each axis to 50Hz.2Figure 2: The accelerometer breakout board with theADXL335To operate the accelerometer it needs between1.8 V to 3.6 V so we can’t use the 5 V outputon the Arduino and have to use the 3 V. Thisalso means that simply plugging one of theaxis into one of the Arduinos analog inputpins will lead to complications since it expectsa maximum value to be 5 V. To solve this weconnect the supply voltage to the AREF pinon the Arduino as well as to the accelerometerand in the software tell the Arduino to use thisvoltage as a reference instead of the default 5 V.The ADXL335 is a so called MEMS (MicroElectro Mechanical System) accelerometer. Thesensor in the ADXL335 is a polysilicon surfacemicromachined sensor that is built on a siliconwafer. In the sensor there is a proof masscalled a seismic mass that is tethered to deflectable plates. When subjected to accelerationthe plates are deflected by the mass and thisdeflection is measured by a differential capacitor. The differential capacitor is madeof independently fixed plates and the platesthat are connected to the seismic mass. Thefixed plates are driven by 180 out of phasesquare waves and when the plates are deflectedthe differential capacitor gets unbalanced andgives an output signal of a square wave whoseamplitude is proportional to the acceleration.

Physics Project with a Research Connection 5 hp, 1FA605 June 2015By using demodulation techniques that aresensitive to the phase-magnitude and directionof the acceleration can be determined. Thesignal is then amplified and taken through a 32kW resistor and now one signal for each axis isavailable. Each signal is then taken through a0.1 µF capacitor that as was mentioned earlieracts as a low-pass filter. The ADXL335 usesone structure for the X, Y and Z axis whichgives the axis high orthogonality that in turnleads to little cross-axis sensitivity [9] [2].2.3Serial adapterTo be able to integrate the Arduino into theEPICS environment used at FREIA it needs tobe connected to a serial device server using aD-sub 9 connector. The serial device server inturn gives the device an IP adress and makesit accessible over the network. The Arduinosdigital pin 0 and 1 are by default used asRX (receive) and TX (transmit) but this doesnot mean that one can simply attach D-sub 9connector and get a working connection. Thereason for this is that the Arduino communicates with the UART (Universal asynchronousreceiver/transmitter) protocol that sends datawith TTL (Transistor–transistor logic) voltagelevels that are in the interval of 0 V to 5 Vwhile the serial device server uses RS-232 thatuses -15 V to -3 V for 0 and 3 V to 15 V for1. communication. The data sent from UARTcan however be converted to work with RS232devices by feeding the signal through an integrated circuit named MAX232. The MAX232is a dual driver/receiver and works by changing the outgoing voltage to be in the RS232compatible interval of approximatively 7.5V and the incoming voltage is reduced to bebetween 0 V to 5 V [4].For a complete view of all hardware usedand how to connect it please see figure 11 inAppendix 7.1.33.1SoftwareArduinoThe Arduino microcontroller is programed using the Arduino language, which is based onC/C , and comes with a user-friendly integrated development environment (IDE) [8].The user only needs to define two functions,to make an executable program: a setup() andloop() function. The setup() function is only executed once, and is used to initialize variables,pin modes etc. The loop() function is essentially a infinite loop that is called repeatedlyuntil the device is turned off, this is where yourcode is implemented. These types of programsare called cyclic executive programs.Figure 3: The Arduino IDE.While one can create a wide variety ofprograms using only these two functions, theloop() function is not ideal for precision highspeed applications. This is because it runscontinuously, without the use of a timer [8]. Instead, we will be using interrupts, to allow forpredictable timing, which is essential to highspeed data collection. The interrupts are implemented using the library MsTimer2 [15]. The3

Physics Project with a Research Connection 5 hp, 1FA605 June 2015library MsTimer2 combines both ease of useand good time resolution (1 ms). The eventsthat triggers the interrupts are internal timeroverflows. Each time a timer overflow, a chosenfunction is called and executed, in our case thiswill be a function that reads an analog pin (ortwo simultaneously). The maximum frequencyof the interrupts is 1 kHz and is determinedby the time resolution of MsTimer2, and hencelimits the speed at which we can sample data.Listing 1: Reading analog waveform// Reads 512 values of analog pin 0 every// 1 ms using MsTimer2#include MsTimer2.h const int buffer 512; // Buffer sizeint analogDataArray[buffer];int count 0;int analogPin 0;int period 1; // Periodvoid getWaveform() {analogDataArray[count] analogRead(analogPin);count ;if (count buffer){MsTimer2::stop();count 0;}}void setup() {analogReference(EXTERNAL);MsTimer2::set(period, getWaveform);MsTimer2::start();}void loop() {}To read the voltage from an analog pin onboardthe Arduino, we use the function analogRead().The analog to digital converter (ADC) willturn the voltage into an digital signal, rangingfrom 0-1023, where the reference voltage (value1023) is set by the function analogReference().Because the ADXL335 accelerometer operatesusing 3.3 V, the function analogReference() will4be set to EXTERNAL, which indicates that anreference voltage will be applied to the AREFpin. The time used to read an analog inputusing analogRead() is about 100 µs, thereforeit does not limit the frequency of which we cansample [8].In order to establish serial communicationbetween the Arduino slave and EPICS, weneed call the begin() method of the class Serial.The argument of begin() is the baud rate of thecommunication, which will be set to 115200Bd. Data will be sent and received as humanreadable ASCII text, with the methods print()and read(). Listing 2 illustrates the simple codeneeded to establish serial communication.Listing 2: Exemple showing serial communicationvoid setup() {Serial.begin(115200);}void loop() {Serial.println("Hello World");}To program a useful Arduino slave IO thatwill be able to respond and perform tasks upondifferent commands sent by the EPICS control system, we will use a switch statement.First we have to read the command sent byEPICS. This can by done by scanning the incoming characters until the terminator character is reached, which we have set to newline,shown in Listing 3.Listing 3: Switch statement, reading serial inputString input;void setup() {Serial.begin(115200);}void loop() {while (Serial.available() 0){char lastRecived Serial.read();input lastRecived;if (lastRecived ’\n’){

Physics Project with a Research Connection 5 hp, 1FA605 June 2015switch (input[0]) {case eak;}input ""; // Clear recieved buffer.dled the serial communication. Below is thefunction readWaveform() that reads a waveform from an analog channel on the Arduino.function waveform .readWaveform(serialObj, analogPin)output [’W’, num2str(analogPin), ’?’];fprintf(serialObj, output);input strsplit(fscanf(serialObj,.’%c’), ’ ’);}}}We use a buffer of 512 elements (limited by thememory of the Arduino) to temporarily storethe waveforms on the Arduino, before the datais sent to EPICS or MATLAB [7]. This methodwas not limited by the time delay introducedby constantly sending a command and receiving one data point at a time, which was ourfirst approach.if m dendAppart from acquiring analog values, we alsoimplemented digital I/O. The represetive commands are detailed in the appendix 7.2.3.2MATLABMATLAB is a numerical computing environment that is built around an easy scripting language, which makes MATLAB perfect for quicktesting and data analysis. First, we initializedthe serial communication between MATLABand the Arduino slave, with the native function serial(). Using this function, we createda serial object and set the parameters DataBits 8, StopBits 1, BaudRate 115200.serialObj serial(comPort);set(serialObj, ’DataBits’, 8);set(serialObj, ’StopBits’, 1);set(serialObj, ’BaudRate’, 115200);Then we implemented our protocol, see Appendix 7.2, into different functions that han-Figure 4: Waveform of a 60 Hz signal.With only this simple code we are now ableto perform tests and evaluate the performanceof the ADXL335 accelerometer. Figure 4 showsthe raw waveform obtained by the accelerometer placed near the Adin tone generator playinga 60 Hz sine wave. The sine wave was generated using onlinetonegenerator.com [14]. Thecollected waveform is then transformed fromthe time domain into the frequency domain,using fast fourier transform (FFT) [10], whichis shown in figure 5. The 60 Hz signal is clearlydistinguished from the background noise.5

Physics Project with a Research Connection 5 hp, 1FA605 June 2015Figure 5: Frequency domain of the waveform infigure 4. Note the logarithmic scale.To test for the frequency response of theADXL355, we generated a linear chirp from100 Hz to 250 Hz with the Adin tone generatorand collected the data over a period of 15 min[11]. The response is illustrated in figure 7. Alllines with a positive slope is harmonics or thefundamental. The other lines with negativeslope are Nyquist reflections.Figure 6: The Adin KKBT speaker which has beenused as a tone generator during the experiments.6Figure 7: The frequency response of a 100 Hz to250 Hz chirp waveform. The colormap representsthe relative amplitude.3.3EPICSEPICS (Experimental Physics and IndustrialControl System) is an open source softwareenvironment for development and management of control systems used globally in smalland large scale projects [6]. EPICS is availablefor Windows and Linux and in this projectwe used Scientific Linux 6 as operating system. The EPICS version used is the standaloneversion CODAC Core System v4.1.0 that isdistributed by the ITER Organization. EPICSutilizes Client/Server and Publish/Subscribetechniques to handle communications. Inan EPICS environment a server is called Input/Output Controller and is abbreviated IOC.To an IOC multiple sensors and modules canbe attached for measuring and controlling thesystem. Through the Channel Access (CA)network protocol other computers can interactwith the IOCs and read data and send commands to them. EPICS is very scalable and asystem can consist of a single IOC for smallprojects to thousands of IOCs for more massiveprojects [6].On an IOC a protocol file is stored that tellshow the communication with an attached device should be handle. This is done by definingcommands in the file that tells EPICS what datato send and what to expect in return. There

Physics Project with a Research Connection 5 hp, 1FA605 June 2015is also a database file, where the records aredefined. A record tells what commands willbe available through the CA network. Thereare many different ways records and protocolscan look like and we will show an exampleof how these can be structured to work witheach other. The example shows how we measure a single analog reading from an Arduinothat has been loaded with our serial protocol.When requesting a single analog read from pin0 the user should send A0? to the Arduino.If the value on the pin at the moment is 496the output will be A0 496. We will not coverhow to install EPICS and create an applicationsince there is plenty of guides already availableonline on that topic [5].There are two files that needs to be configured before we can start making our record. Inthe file userPreDriverConf.cmd we configurehow to connect to the Arduino which we havenamed to be 003")We connect using an IP-adress but other methods are also possible. All the settings for thebaud rate, stop bits and so on are handledby the serial switch so this is not somethingthat needs to be set in this case but for othermethods this can be configured here. In thefile dbToLoad.cmd we specify what database toload when the IOC starts and what name thatshould be assigned to the variables PREFIX andARD PORT:dbLoadRecords("strdev.db","PREFIX STRDEV,ARD PORT ARD0")In the database file strdev.db we have a recordthat looks like this:record(ai, " (PREFIX):A0") {field(DTYP, "stream")field(INP, "@accel.proto get analog(0) (ARD PORT)")field(SCAN, ".5 second")}In the first row we state that we want to createa record by writing record, in the parentheses that follows afterward we set what typeof record we will be using. In our example it says ai meaning it’s an analog inputrecord. After that we see " (PREFIX):A0"and this is the name of the record that willbe used on the CA network. This is themost conventional way of naming records "NameOfDevice:Sensor". Next we see threerows of fields, a field is where the settingsfor the record is made. The first row says DTYP(which means device type field) and this setswhat kind of device the record is going to beused with. In our example "stream" meansthat we will be using StreamDevice which isa device support module for EPICS that facilitates the use of devices that communicatesusing strings [16] [12]. The middle row saysINP which stands for input link, as was saidearlier this is an analog input record so this iswhere we specify where the input will comefrom. The line "@accel.proto get analog(0) (ARD PORT)") specifies what protocol files touse, which in this case is @accel.proto andget analog what commands to run in the protocol. The (0) is a variable that can be sendalong to the protocol. This means we can usethe same the command in the protocol file fordifferent inputs. The last field says (SCAN, ".5second") and tells how and when a record processes which in this case is set to fetch a newvalue every 0.5 second. The command beingcalled by the record in the protocol file is lookslike this:get analog {out "A\ 1?";in "A\ 1 %d";}The first row says get analog and is the nameof the command that the records use to call it.Next we see out "A\ 1?" and specifies whatcommand will be sent to the Arduino. The \ 1will be replaced with the variable that was sentalong from the record which means that thecommand that is sent in this case will be A0?.The last row in "A 1 %d" tells EPICS what to7

Physics Project with a Research Connection 5 hp, 1FA605 June 2015expect back from the Arduino. The A 1 will ofcourse once again translate into A0 and the %dmeans that there will come a signed decimalafterwards representing the value of the analogpin.Once the protocol and database are preparedthere are several ways to interact with and readdata from the IOC. The most common way isto create a GUI that displays the informationbut the easiest way to see that the applicationworks is to use caget in the terminal. The following code shows how to start the applicationcalled accel and read data from the recordthat we created in the example above:[User@localhost ] ./target/main/scripts/accel-ioc startStarting IOC accel[ OK ][User@localhost ] caget STRDEV:A0STRDEV:A04968

Physics Project with a Research Connection 5 hp, 1FA605 June 20154ResultsWe have shown that our system, hardwareand software, is wor

leads to little cross-axis sensitivity [9] [2]. 2.3 Serial adapter To be able to integrate the Arduino into the EPICS environment used at FREIA it needs to be connected to a serial device server using a D-sub 9 connector. The serial device server in turn gives the device an IP adress and makes it accessible over the network. The Arduinos

Related Documents:

AA242B: MECHANICAL VIBRATIONS 1/50 AA242B: MECHANICAL VIBRATIONS Undamped Vibrations of n-DOF Systems These slides are based on the recommended textbook: M. G eradin and D. Rixen, \Mechanical Vibrations: Theory and Applications to Structural Dynamics," Second Edition, Wiley, John & Sons, Incorporated, ISBN-13:9780471975465 1/50

AA242B: MECHANICAL VIBRATIONS 1/41 AA242B: MECHANICAL VIBRATIONS Direct Time-Integration Methods These slides are based on the recommended textbook: M. G eradin and D. Rixen, \Mechanical Vibrations: Theory and Applications to Structural Dynamics," Second Edition, Wiley, John & Sons, Incorporated, ISBN-13:9780471975465 1/41

Mechanical vibrations. (Allyn and Bacon series in Mechanical engineering and applied mechanics) Includes index. 1. Vibrations. I. Morse, Ivan E., joint author. Hinkle, Theodore, joint author. Title. 1978 620.3 77-20933 ISBN ISBN (International)

Vibration is a continuous cyclic motion of a structure or a component. Generally, engineers try to avoid vibrations, because vibrations have a number of unpleasant effects: . It is thought that the vibrations were a form of self-excited vibration known as flutter, or ‘galloping’’ A similar form of vibration is known to occur .

Introduction to Vibrations Free Response Part 1: Spring-mass systems Vibration is a sub-discipline of dynamics that deals with repetitive motions. Some familiar examples are the vibrations of automobiles, guitar strings, cell phones and pendulums. Vibrations can be unwanted or wanted. For example,

Mechanical Vibrations Lecture #1 Derivation of equations of motion (Newton-Euler Laws) Derivation of Equation of Motion Define the vibrations of interest -Degrees of freedom (translational, rotat

The approach has been applied to evaluate the mechanical vibrations of the motors in associate with the geometry of the rotor slots. Also, the effects of nonsinusoidal supply voltages on the current harmonics have . comparison studies of the rotor slot shapes affecting the motor lateral vibrations in associate with three IEEE standard slots .

Experimental evidence has shown that a human body can be injured by vibrations. It was reported that about 12 million workers in the USA were affected by vibrations . [2] According to that, researchers have been working hard to reduce this dangerous phe-nomenon, and therefore they have written a lot of studies on how to avoid the effects of