Embedded utvikling og design av bølgeestimator
Abstract
Programvare og algoritmer for estimering av bølgedata og sanntids-bølgehøyde ble implementert på en STM32 ARM-Cortex-M mikrokontroller. Bølgesensoren er laget tilbruk på flytende målebøyer, til estimering av bølger og til beregning av posisjon ogorientering i sanntid. Ved bruk av DMA (Direkte minnetilgang) og multitasking medFreeRTOS kan bølgesensoren sende sanntidsdata med lav forsinkelse til datalogger overseriell port, samtidig som bølgestatistikk beregnes i bakgrunnen.Bølgedata som beregnes er bølgespektrum, signifikant bølgehøyde hm0, gjennomsnittligbølgeperiode tm01, tidsserien av bølgehøyden, og første- og andre fourierkoeffisienter forretningsspektrum. Bølgesensoren mottar akselerometer, gyroskop og magnetometerdatafra en SBG Ellipse 2 Micro IMU, som er koblet til UART på mikrokontroller.STMicroelectronics eget gratis utviklingsverktøy STM32CubeIDE ble brukt til utviklingog debugging av software, samt til å generere kode for konfigurasjon og initialisering avmikrokontrolleren. STs lavnivå-drivere (Low-layer drivers) ble brukt for konfigurasjon ogstyring av UART og andre periferienheter på mikrokontrolleren.Bølgesensoren bruker en AHRS til estimering av bøyens orientering i sanntid ved brukav sensor-data fra akselerometer, gyroskop og magnetometer. Med bøyens orienteringfinner man den vertikale akselerasjonen som dobbelt-integreres for å finne bølgehøyde.AHRS som velges til oppgaven er et Eksplisitt Komplementær Filter, kjent fra Mahonyet al. (2008) [18] og bruker en implementasjon fra Hua et al. (2014) [12]. AHRSen testespå rådata fra en Fugro SEAWATCH bøye, til estimering av orientering (rull, stamp oggir-vinkler) og bølgedata/statistikk. AHRSen viser seg å være godt egnet til oppgaven.De viktigste delene av kildekoden er med i vedlegget på slutten av rapporten. Observer for sanntidsestimering av bølgehøyde ble implementert. Observeren er implementertpå tilstandsrom-form og bruker et kalman-filter til beregning av kalman-forsterkning ogkovariansmatrisen i hvert tidssteg. Implementasjonen gir gode muligheter for å også estimere posisjon og hastighet horisontalt i sanntid. Valg av observer for sanntids estimeringav posisjon og hastighet i sanntid, og akselerometerbias blir diskutert i rapporten. Software and algorithms for estimation of wavedata and real-time waveheight was implemented on a STM32 ARM-Cortex-M microcontroller. The wavesensor is made to beused on a floating weather buoy, for estimation of waves and for estimation of positionand attitude in real-time. By using DMA (Direct Memory Access) and multitaskingwith FreeRTOS, the wavesensor can send real-time data, with low delay to the datalogger, connected with RS-232, and at the same time computes wavestatistics in thebackground.The wavedata computed includes the omnidirectional wavespectrum, significant waveheight hm0, average waveperiod tm01, the timeseries of waveheight, and first- and secondorder Fourier-coefficients for the directional wavespectrum. The wavesensor receivesaccelerometer-, attitude rate sensor- and magnetometer-data from a SBG Ellipse 2 MicroIMU, connected to the microcontroller with serial interface.STMicroelectronics’ free of charge integrated development environment STM32CubeIDEwas used for development and for debugging the software, and to generate code forconfiguration and initialization of the microcontroller. The LL-drivers (Low-layer) fromST was used for programming the peripherals of the microcontroller.With sensordata from the accelerometer, attitude rate sensor and magnetometer, thewavesensor uses an AHRS for estimation of the buoy’s attitude in real-time. The buoy’sattitude is used for computation of the vertical acceleration, which is integrated twiceto find the waveheight.The AHRS-observer chosen in this thesis is the Explicit Complementary Filter [18], usingthe implementation from Hua et al. (2014) [12]. The observer was tested on IMU-sensordata from a Fugro SEAWATCH buoy, for estimation of attitude and wavedata. TheAHRS proves to be well suited for the task.The most important parts of the source-code is provided in the appendix of the report.An observer for real-time estimation of waveheight was implemented. The implementation uses the state-space form of the observer, and computes the kalman-gain andcovariance-matrix in each timestep. The implementation makes it easy to extend theobserver to estimate horizontal position and velocity in addition to the vertical. Choiceof observer for real-time estimation of position and velocity in all three dimensions, andestimation of accelerometer-bias is discussed in the report.