Ref:C0641
Development of an open-source, low-cost and adaptable 3D accelerometer for monitoring animal motion Tim Van De Guchta,b,*, Tim Blanckaert, Jean-Pierre Goemaereb,c, Carine Naessensc, Simon Coola, Koen C. Mertensa, Annelies Van Nuffela, Jürgen Vangeytea a
Technology and Food Science Unit - Agricultural engineering, Institute for Agricultural and Fisheries Research (ILVO), Burg. van Gansberghelaan 115 bus 1, 9820 Merelbeke, Belgium b
Catholic University Leuven, TELEMIC research group Kasteelpark Arenberg 10, bus 2444, 3001 Leuven-Heverlee, Belgium c
Catholic University College Ghent, DraMCo research group, Gebroeders Desmetstraat 1, 9000 Ghent, Belgium *
[email protected]
Abstract Lameness is, after mastitis and reduced fertility, the third most important health problem in dairy cows. Lameness causes a significant decrease in milk production, a reduced fertility, a higher culling rate and severely deteriorates animal welfare. To help farmers in detecting lame cows, ILVO has developed the GAITWISE system which consists of a six-meter long pressure sensitive mat to detect the positions of the legs with respect to time as well as the relative pressure exerted by the legs when cows walk over it. In order to determine whether a cow is lame, measured variables (e.g. stride length, abduction, asymmetry in relative force) are compared with the previous values of the same cow by a cow specific model. To validate the measurements from the GAITWISE, an open-source, low-cost and adaptable prototype 3D accelerometer is developed. The goal is to detect the motion of the cow’s legs using accelerometers and gyroscopes in x, y and z-direction in a way that data can be obtained online in order to reconstruct the motion of a cow’s legs. For the first prototype the single-board microcontroller Arduino Nano with an Atmega 328, an open source platform, serves as the processing unit, while MPU-6050 (InvenSense, CA, USA) is used to get the raw tri-axis acceleration and angular velocity data. The MPU-6050 is designed for low power, low cost and high performance requirements of wearable sensors. The unit has a digital output and communicates with the Arduino platform through I2C. An ultra-low power module (NRF24L01+, Nordic Semiconductor, Trondheim, Norway) is used to create a network that allows to receive the data online using the 2.4 GHz ISM band. The newly developed sensor is user programmable, allowing one to choose between different ranges and resolutions for the measurement of the acceleration (±2g, ±4g, ±8g or ±16g) and the angular velocity (±250°/s, ±500°/s, ±1000°/s or ± 2000°/s). An Arduino Nano with a high power NRF24L01+ module and a rechargeable battery is placed on the neckband of the animal as an extra node in the network to amplify the signal. The receiver module contains also an Arduino Nano and a high power NRF24L01+ module and is connected to a computer to collect and process all the received data. The price for the sensor on the legs (one per leg) will be approximately € 20.5, the neckband transmitter and the receiver around € 26 and € 17 respectively, which adds up to a total of € 125. First tests showed that the prototype is able to measure accelerations with an error below 2.5 % and gyroscope values with an error below 0.3 %. A preliminary test with a walking cow showed that the sensor was able to record the acceleration and angular velocity of the cow’s legs. Moreover, the designed sensor is open source and low-cost. The main drawback of our first prototype is that after 24hrs the battery needs recharging. To be used in future tests with walking cows a smaller version of the sensor that is attached to the legs, will Proceedings International Conference of Agricultural Engineering, Zurich, 06-10.07.2014 – www.eurageng.eu
1/8
be designed. Therefore the Pro Mini version of the Arduino microcontroller will be used with a NRF24L01+ low power transceiver and a rechargeable battery. Keywords: radio frequency identification, pigs, feeding, validation, range measurement
1
Introduction
In agricultural research, 3D-accelerometers are interesting sensors that can be implemented in a wide range of different research topics (behavioral monitoring of pigs, cows, mechanical damage of vegetables, measuring the stability of agricultural machinery) (Pastell et al., 2009; Arazuri et al., 2010; Cornou et al., 2011; Praeger et al., 2013). However, off-the shelf sensors for e.g. cow stepping behavior do not provide the raw data of the sensor but only variables of activity or variables of general behaviors like lying, standing, walking, etc. In order to use accelerometers in the different research topics, the existing accelerometers do not provide us with the information that we want or expect. Taking into account that platforms like Arduino allow us to build low cost open source sensors that are easily adaptable to other applications, it is worthwhile to build a custom sensor. Hence, a self-made accelerometer was developed, built and tested for its usability to monitor the movements of a cows’ leg in a pilot study. Using this leg movement information and translating it into gait variables could result in a well described gait of the cows. Monitoring cow gait is a prerequisite if one wants to detect a lame cow in the herd based on alterations in their normal gait. Detection of lameness in large dairy herds is becoming increasingly important because farmers do not have enough time to detect lame cows. Besides the fact that lameness has detrimental effects on the welfare (Whay et al. 1997), it also affects farms’ income due to decreased production of lame cows (Bruijnis et al., 2010). Several approaches to automatically monitor cow gait features using sensor technology and detect lame cows based on changes in these gait variables have already been published (Pastell et al., 2009, Ito et al., 2010; Pluk et al. 2010, Poursaberi et al., 2010, Van Hertem et al., 2013, Viazzi et al., 2014). At ILVO, a pressure sensitive device measures the spatialtemporal and force related variables of cows when they walk over the GAITWISE system (Maertens et al. 2011, Van Nuffel et al., 2013). Combining data of this GAITWISE system and accelerometers attached to the legs of the cows, might create added value for the detection of lame cows as well as a validation system for GAITWISE. Therefore the goal of this paper was to develop a low cost accelerometer that can be used in several fields of agricultural research. Based on our interest in comparing the GAITWISE system with accelerometers in future research on lameness detection in cows, this low cost accelerometer was tested for measuring cow leg movement in a small preliminary test.
2
Materials and methods
2.1 2.1.1
Sensor design Accelerometer
After performing a review of the available sensors (Blanckaert, 2014) and taking into account that a sound cow produces between 2 and 6 g in the hind legs (Pastell et al.,2009), a motion processing unit (MPU) was selected: the MPU-6050 (Invensense, San Jose, California 95110, USA). This MPU combines a Micro Electrical Mechanical System (MEMS) 3-axis accelerometer with a 3-axis gyroscope on a single chip and has an onboard Digital Motion Processor™(Sarathkumar, B. & Sawal, R., 2014). It uses a standard I2C bus at 400 kHz or SPI at 1 MHz for data transmission. The 16-bits analog to digital conversion hardware for each channel make it possible to capture the x, y, and z channel at the same time with a high accuracy. Moreover this system on a chip is designed for the low power, low cost, and high performance requirements of smartphones, tablets and wearable sensors (Fisher et al.). The gyroscope and accelerometer operating current is 3.8 mA at all rates for the gyroscope and at 1 kHz for the accelerometers. The full chip idle mode supply current is 5 µA.
Proceedings International Conference of Agricultural Engineering, Zurich, 06-10.07.2014 – www.eurageng.eu
2/8
2.1.2
Wireless communication
Bluetooth and ZigBee were considered for the wireless communication, but a single chip radio transceiver was chosen (nRF24L01+ (Nordic Semiconductor, Trondheim, Norway)) based on the price, the data rate and the power use. The Nordic nRF24L01+ is a highly integrated, ultralow power (ULP) 2 Mbps RF transceiver IC for the 2.4 GHz ISM (Industrial, Scientific and Medical) band. The transceiver consists of a fully integrated frequency synthesizer, a crystal oscillator, a demodulator, modulator and Enhanced ShockburstTM protocol engine. The output power and frequency channels are easily programmable through an SPI interface. The built-in power down and standby modes keep the energy consumption low. The transceiver is very well suited for the implementation of advanced and robust wireless connectivity with low cost 3rd-party microcontrollers. 2.1.3
Microcontroller
Arduino is an open-source hardware board designed around the 8-bit AVR microcontroller from Atmel. For the first prototype the single-board microcontroller Arduino Nano with an Atmega328p microcontroller is used. It has 14 Digital I/O Pins and 8 Analog Input Pins. Two pins are used to receive (RX) and transmit (TX) TTL serial data. Four pins support SPI communication. The Arduino Nano has USB communication onboard allowing an easy programming of the microcontroller. Later, the Arduino Pro Mini will be used which has no chip (Future Technology Devices International, Glasgow, Scotland) for USB communication but it is smaller and uses less power. Power is provided by a 3.7 V 2000 mAh Li-ion battery. 2.1.4
Software
The Arduino board is programmed in C++ based language and the IDE to program the Arduino board together with the necessary libraries for communication over SPI and I²C and are available on the Arduino project website. The libraries for the nRF24L01+ transceiver and the MPU-6050 are also freely available.
2.2
Validation
First the newly developed sensor was validated. The accelerometer was mounted onto a rotating disc powered by a motor with a variable frequency drive (Figure 1). Rotational speed of the disk (ωdisk [rpm]) was gradually increased. The rotational speed of the disk was determined with a digital photo-tachometer (DT-2236, Lutron Electronic Enterprise, Taipei, Taiwan) with an accuracy of ±0.05 % (Digital Tachometer, 2014). The output values of the sensor are acceleration (𝛼 sensor [g]) and rotational speed (ωsensor [°/s]). Theoretic acceleration values (𝛼 theoretic) were calculated as:
𝛼𝑡ℎ𝑒𝑜𝑟𝑒𝑡𝑖𝑐
2𝜋 2 (𝜔𝑑𝑖𝑠𝑘 × 60 ) × 𝑟 = 9.81
with 𝛼𝑡ℎ𝑒𝑜𝑟𝑒𝑡𝑖𝑐 = acceleration calculated [g] r = disk radius [m] ωdisk = rotational speed of the disk [rpm] 𝜔𝑠𝑒𝑛𝑠𝑜𝑟 = 𝜔𝑑𝑖𝑠𝑘 × 6 with ωsensor = rotational speed measured by the sensor [°/s] Proceedings International Conference of Agricultural Engineering, Zurich, 06-10.07.2014 – www.eurageng.eu
3/8
Two MPU-6050 sensors were tested with this setup. For the accelerometers and for the gyroscopes the range was set to 0-8 g and 0-2000 °/s, respectively. The relative deviations 𝛿 accel and 𝛿 gyro are calculated as: 𝛿𝑎𝑐𝑐𝑒𝑙 =
𝛼𝑡ℎ𝑒𝑜𝑟𝑒𝑡𝑖𝑐 − 𝛼𝑠𝑒𝑛𝑠𝑜𝑟 𝛼𝑠𝑒𝑛𝑠𝑜𝑟
× 100 [%]
𝛿𝑔𝑦𝑟𝑜 =
𝜔𝑡ℎ𝑒𝑜𝑟𝑒𝑡𝑖𝑐 − 𝜔𝑠𝑒𝑛𝑠𝑜𝑟 𝜔𝑠𝑒𝑛𝑠𝑜𝑟
× 100 [%]
Figure 1: Test setup with sensors mounted on the disk
2.3
Cow set-up and preliminary testing
A sensor was attached to each leg of the cow. These 4 sensors transmit their data to an extra transceiver with amplifier that was attached to the neckband of the cow. This transceiver receives the data and sends it with an amplified signal to a portable computer in a stable nearby. Measurement frequency was set at 20 Hz. Since raw measurements are measured with a 16 bit configuration, data needs simple conversion before the actual values are known. Conversion consists of dividing the raw values by the value that belongs to each respective measurement range.
3 3.1
Results & Discussion Sensor validation
Figure 2 shows the relative acceleration and gyroscope deviation from a test with two sensors. A negative sign means an overestimation of the real value, a positive sign means an underestimation. From these results can be concluded that the accelerometers underestimate the real value less than 2.5 %, and the gyroscope overestimates the real value less than 0.30 % in the 8 g range.
Figure 2: Percentage deviation of the acceleration and gyroscope values in the 8g range
Proceedings International Conference of Agricultural Engineering, Zurich, 06-10.07.2014 – www.eurageng.eu
4/8
The small difference between the sensors can be explained by a possible slightly different position on the disk, which has a different radius as a result. Also, the radius was measured manually with a measuring accuracy of about ± 2 mm. The deviation from the calculated value can hence be explained by these influencing factors and by the measuring accuracy of the tachometer.
3.2
Preliminary prototype test
A preliminary test on a walking cow was performed to check whether the newly developed sensor was able to perform measurements in practice. Figure 3 and Figure 4 show the measurement values of the accelerometer and gyroscope on the right hind leg of the cow, in three dimensions. These results are comparable with similar more elaborated tests like e.g. the study of de Mol et al. (2009).
Figure 3: Gyroscope values of the right hind leg of a walking cow at 20 Hz
In this measurement it was not taken into account how the sensor position varied in relation to the ground surface. To use these acceleration and gyroscope data for lameness research, the position of the x, y and z axes of the sensor should be fixed on the leg. The position of the sensor compared to the ground surface can be determined using the 3D acceleration components. These need to be corrected for the orientation of the sensor which can be derived using the angular velocity values and an initial starting orientation. At rest, the vector of gravitational acceleration can be determined and from this, the position of the sensor in relation to the ground level can be determined. This enables an online correction of the orientation of the sensor since errors on the orientation based on angular velocity measurements accumulate in time.
Proceedings International Conference of Agricultural Engineering, Zurich, 06-10.07.2014 – www.eurageng.eu
5/8
Figure 4: Accelerometer values of the right hind leg of a walking cow at 20 Hz
The current prototype has an estimated battery life of about a day when constantly measuring. For monitoring the cow’s gait online for short periods this is acceptable. Of course, in practice, a constant monitoring of the cow’s gait is necessary. A first improvement can be achieved by replacing the Arduino Nano by the Arduino Pro Mini that uses less power and is also smaller. LEDs on the different components could be removed to reduce power consumption. In this stage the sensor is measuring constantly. The code can be optimized in a way that data is only transmitted if values are higher than a threshold. If not, the transceiver stays in power down mode. An option is to use more or more powerful batteries that have a longer battery life. Another possibility is to introduce a memory component that can temporarily save the measured data and send it to the computer on specified time moments.
3.3
Prototype price
Table 1 shows the estimated costs of the prototype with four measurement units, a neck transceiver and a receiver on a computer. The total cost sums up to about 125 euro. Future adaptations might reduce the cost by using cheaper Arduino boards, but extra batteries or components will increase the price. Table 1: Component costs of he prototype
Leg unit MPU-6050 Arduino Nano (Pro mini uC (future)) nRF24L01+ transmitter module Battery (3.7V Li-ion, 18650 or 14500) Boost converter (3.7 V to 5 V) 3.3 V regulator for transmitter Total
Price € 3.5 € 7 (€ 4) €1 € 4/5 per unit €2 €2 € 20.5 (€ 17.5)
Proceedings International Conference of Agricultural Engineering, Zurich, 06-10.07.2014 – www.eurageng.eu
6/8
4
Neck unit/transceiver
Price
Arduino Nano (Pro mini uC (future)) nRF24L01+ transmitter module + antenna Battery (3.7V Li-ion, 18650 or 14500) Boost converter (3.7 V to 5 V) 3.3 V regulator for transmitter Total
€ 7 (€ 4) € 10 € 4/5 per unit €2 €2 € 26 (€ 23)
Receiver Arduino Nano nRF24L01+ transmitter module + antenna Total
Price €7 € 10 € 17
Complete set
€ 125
Conclusions
With the described components and software we were able to build a low cost, adaptable 3D sensor that is capable of measuring 3D accelerations and 3D angular velocity. The project was intended as an open-source development hence the components set up and software code are freely available for other interested users. In this first phase a prototype with four sensors was tested to monitor a cow’s gait online. The system provides raw acceleration and angular velocity data at a frequency of 20Hz. The sensor was validated against a theoretical calculation and yielded acceptable results. The first preliminary test showed that the sensor recorded accelerations and angular velocity of the cow’s legs that are comparable with other studies. Besides acceleration, the prototype is able to measure angular velocity, which doesn’t seem to be the case in most other accelerometer systems used in lameness research. To estimate the potential of the sensor to provide usable data for cow gait monitoring further development and data processing are yet to be done. Adaptations to improve the efficiency and performance of the system are necessary.
5
Acknowledgements
This sensor development was a student project and was done by Tim Blanckaert for his master thesis. Special thanks are due to the animal keepers of the ILVO experimental farm.
6
References
Arazuri, S.; Arana, I.; Jaren, C. (2010). Evaluation of mechanical tomato harvesting using wireless sensors. Sensors, 10, 11126–11143. Arduino : an open-source http://www.arduino.cc/
electronics
prototyping
platform
,
[online],
Available:
Bergmann, N. W., Wallace, M. and Calia, E. (2010). Low Cost Prototyping System for Sensor Networks,” 6th International Conference on Intelligent Sensors, Sensor Networks and Information Processing, Brisbane, 7-10 december 2010, pp. 19-24. Blanckaert, T. (2014). Development of an open-source low-cost en adaptable prototype 3D – accelerometer system for monitoring the movement of animals. Associatie Kuleuven. Master Thesis, 49 p.
Proceedings International Conference of Agricultural Engineering, Zurich, 06-10.07.2014 – www.eurageng.eu
7/8
Brown-Brandl, T.M., & Eigenberg, R.A. (2011). Development of A Livestock Feeding Behavior Monitoring System. Transactions of the Asabe 54, 1913-1920. Bruijnis, M.R.N., Hogeveen, H., Stassen, E.N., (2010). Assessing economic consequences of foot disorders in dairy cattle using a dynamic stochastic simulation model. Journal of Dairy Science 93, 2419-2432. Cornou C., Christensen S., Kristensen A.R., (2011). Modelling and monitoring sows’ activity types in farrowing house using acceleration data. COMPAG, 76(2): 316-324. de Mol, R. M., Lammers, R. J. H., Pompe, J. C. A. M., Ipema, A. H., & Hogewerf, P. H. (2009). Recording and analysis of locomotion in dairy cows with 3D accelerometers. In Precision Livestock Farming '09, 4th European conference on precision livestock farming (pp. 333-341). Wageningen Academic Publishers. Digital tachometer. Lutron DT-2236. (2014). Accessed on May http://www.instrumentcatalog.com.au/brands/k-l/lutron/lutron-dt-2236
13th
2014
via
Fisher, D. and Gould, P. (2012) Open-Source Hardware Is a Low-Cost Alternative for Scientific Instrumentation and Research. Modern Instrumentation, Vol. 1 No. 2, pp. 8-20. doi: 10.4236/mi.2012.12002. Ito, K., von Keyserlingk, M.A.G., LeBlanc, S.J., Weary, D.M. (2010). Lying behavior as an indicator of lameness in dairy cows. Journal of Dairy Science 93, 3553-3560. Praeger, U., Surdilovic, J., Truppel, I., Herold, B., Geyer, M. (2013). Comparison of electronic fruits for impact detection on a laboratory scale, Sensors, 13, pp. 7140–7155 Pastell, M., Tiusanen, J., Hakojarvi, M., Hanninen, L. (2009). A wireless accelerometer system with wavelet analysis for assessing lameness in cattle. Biosystems Engineering 104, 545-551. Pluk, A., Bahr, C., Leroy, T., Poursaberi, A., Song, X., Vranken, E., Maertens, W., Van Nuffel, A., Berckmans, D. (2010). Evaluation of Step Overlap As An Automatic Measure in Dairy Cow Locomotion. Transactions of the ASABE 53, 1305-1312. Poursaberi, A., Bahr, C., Pluk, A., Van Nuffel, A., Berckmans, D. (2010). Real-time automatic lameness detection based on back posture extraction in dairy cattle: Shape analysis of cow with image processing techniques. Computers and Electronics in Agriculture, 74, 110-119. Sarathkumar, B. & Sawal, R. (2014). Towards A Hi-Fi Wireless Sensor Network for Rehabilitation Supervision. International Journal Of Engineering Sciences & Research Technology, 3(4) pp 7063-706 Van Hertem, T., Maltz, E., Antler, A., Romanini, C.E.B., Viazzi, S., Bahr, C., Schlageter-Tello, A., Lokhorst, C., Berckmans, D., Halachmi, I. (2013). Lameness detection based on multivariate continuous sensing of milk yield, rumination, and neck activity. Journal of Dairy Science, 96, 4286-4298. Viazzi, S., Bahr, C., Van Hertem, T., Schlageter-Tello, A., Romanini, C.E.B., Halachmi, I., Lokhorst, C., Berckmans, D. (2014). Comparison of a three-dimensional and two-dimensional camera system for automated measurements of back posture in dairy cows. Computers and Electronics in Agriculture, 100, 139-147. Whay, H.R., Waterman, A.E., Webster, A.J.F. (1997). Associations between locomotion, claw lesions and nociceptive threshold in dairy heifers during the peri-partum period. Veterinary Journal, 154, 155-161.
Proceedings International Conference of Agricultural Engineering, Zurich, 06-10.07.2014 – www.eurageng.eu
8/8