Beruflich Dokumente
Kultur Dokumente
Daniel K. Fisher
ABSTRACT
The field of electronics continues to change and evolve rapidly. Electronics are increasingly being
used to collect and process all types of data, transfer information, make decisions, and provide
automation and control functions. Modern microcontrollers and semiconductor components offer
many advantages and ease of use in designing custom measurement and control systems. An array
of microcontrollers, sensors, and accessory components are presented and their features,
capabilities, and costs are discussed. Several measurement and datalogging circuits were designed
for use in irrigation-related research activities. The design, implementation, and performance of
these systems are described.
302
MODERN ELECTRONICS FOR AGRICULTURE
The field of electronics continues to change and The number and capabilities of semiconductor
evolve rapidly. Electronic components and sensors and auxiliary components that interface
assemblies can be found in a wide variety of easily with microcontrollers have also increased.
industrial and commercial products, and with a Many components, such as sensors, clocks,
wide variety of functions and capabilities. memory chips, and display units are designed to
Modern household appliances, toys, and connect directly to microcontrollers, operate
automobiles often contain microprocessors, over compatible voltage ranges, and
sensors, displays, and data storage and transfer communicate easily with one another. These
systems. components usually require minimal external
circuitry, have low power requirements, and are
Electronics are increasingly being used to controlled in software.
collect and process all types of data, transfer
information, make decisions, and provide These modern electronic components can be
automation and control functions. Electronic put to use in agriculture as in the many other
components are increasing in their capabilities, applications in which they already serve. The
while becoming easier to use, smaller in size, availability, compatibility, and ease of use
and cheaper to buy. Many more specialized combine to offer many advantages to using
components and sensors are available which microcontrollers and semiconductor components
interface easily and simplify circuit design. to create measurement and control systems.
The microcontroller is an important element in The objective of this paper is to present and
modern electronics, and has brought about a discuss some of the current, powerful,
change in the way electronic circuits are inexpensive, and easy-to-use electronic
designed. A microcontroller is a device that components available to and of potential use in
interfaces with external components, can input agricultural research. The function, operation,
and output information to and from these and costs of some of these components will be
external components, and can be programmed discussed, and a number of examples of their
by the user. It is similar to the central use will be presented.
processing unit (CPU) of a personal computer in
that it is very flexible and can be programmed to
do a wide variety of things.
MATERIALS
In the past, significant electronics expertise and
experience were required to design a circuit. Microcontrollers
Now, with a microcontroller, a circuit can be
designed much more simply because many of The number of manufacturers, number and
the desired functions can be accomplished in variety of products, and capabilities of the
the microcontroller’s software. Examples of products continue to grow each year. Cravotta
functions easily accomplished with a (2004) lists 45 manufacturers of microcontroller
microcontroller include; timing (doing something products, and gives an overview of the target
at regular intervals, or measuring elapsed time applications, users, and capabilities of each
between events); calibration (converting a raw manufacturer’s product lines. Rather than
measurement to a quantity in the desired units); discussing the many microcontroller options,
accurate signal measurement (measuring a capabilities, and differences, however,
voltage level or frequency from a sensor); data experiences with two microcontrollers from one
output (transferring measured data or manufacturer will be presented.
information to another device, computer, or
display).
303
The PIC microcontrollers from Microchip for these and other programming environments
(Microchip Technology Inc. 1, Chandler, Arizona can be found on the Internet.
USA, www.microchip.com) were chosen due to
their widespread use and availability, ease of Among the simplest programming environments
programming, low cost, and advanced features. are PicBasic and PicBasic Pro
PIC microcontrollers are among the most (MicroEngineering Labs, Inc., Colorado Springs,
popular in use today, and are used in many Colorado USA). These versions of the BASIC
diverse applications. Much information is programming language include many functions
available, especially on the Internet, in the form which greatly simplify the programming of the
of application notes, project descriptions and microcontrollers. Functions are included for
documentation, circuit diagrams and using the PICs’ analog-to-digital converters,
schematics, program code, and user forums. communicating with other digital chips via
common protocols (such as I2C and SPI),
PIC microcontrollers are available in a range of outputting information to serial ports and LCD
sizes and features. Sizes range from 8 pins to displays, measuring frequencies and
84 pins. Available features include digital and pulsewidths, outputting analog signals, and
analog input and output, analog-to-digital (A-D) enabling interrupts and power-saving features.
converters, serial ports, USB capability, varying Once a program has been written, the PicBasic
processor speeds, built-in oscillators, timers, compiler converts the BASIC program to the
and varying amounts of program memory. proper format for downloading to a PIC. While
the PicBasic programming environments are not
The work presented in this paper was free (PicBasic costs about US$100, PicBasic
accomplished using two different PIC Pro about US$240), they are much easier to
microcontrollers, the 16F819 and the 16F877. learn and use than assembly language.
The 16F819 was chosen for its size and
features: it has 16 input/output pins, five 10-bit A hardware interface is required to download the
analog-to-digital converters, a built-in oscillator, compiled program to the microcontroller. One
an adjustable processor speed, serial-port such interface, the EPIC programmer
capability, and a large program memory area. (MicroEngineering Labs, Inc.), connects to a
The 16F877 has similar capabilities, but with computer’s parallel port, includes software for
additional input/output pins. editing and downloading a program, is
compatible with most PIC microcontrollers, and
costs about US$60. Other programmers are
available for purchase, and many plans and
Programming schematics can be found on the Internet for
building simple programmers.
An additional reason for selecting the PIC
microcontrollers was for their ease in
programming. A number of programming
environments are available for PIC Sensors
microcontrollers, including assembly language,
C compliers, and BASIC compilers. Many different sensors are available for
Programming environments are available free of measuring a variety of variables. These
charge, including an assembly-language inexpensive, semiconductor sensors operate in
programming environment provided by low voltage ranges and interface easily with
Microchip, while others can be purchased. microcontrollers. Examples of sensors available
Many code examples and complete programs for measuring parameters of interest in
agriculture are discussed in Fisher et al. (2003)
and presented herein.
1
The mention of trade or manufacturer names is
for information only and does not imply an
Temperature
endorsement, recommendation or exclusion by
USDA-Agricultural Research Service. Analog temperature sensors are available which
output a voltage that is linearly proportional to
304
temperature. The LM35 (National transmitter, which sends a pulse, and measures
Semiconductor), for example, requires an the length of time for the pulse to return. The
excitation voltage of 5 Vdc, and is calibrated to microcontroller then calculates the distance
output a voltage with a 10 mV / oC scale factor. based on the time interval. The SRF04 can
The output voltage is read with an analog-to- measure distances within a range of 3 cm to 3
digital converter, and the voltage is converted to m, and costs about $35.
a temperature reading in the microcontroller’s
software. The LM35 temperature sensor costs Other variables
about $2.
Additional semiconductor sensors are available
Infrared thermometer for measuring many other variables, and
interface easily with microcontrollers. There are
In some applications, a non-contact or remote sensors for measuring acceleration, humidity,
temperature measurement is required. The proximity, illumination, location (GPS
MX90601 (Melexis) infrared thermometer coordinates), and rotation, for example. Many
module was designed for automotive and of the sensors return an analog voltage in the
consumer appliance applications, and provides range of 0 to 5 Vdc, a digital signal, or a
remote and ambient temperature measurements frequency, and require an excitation voltage of 5
in analog voltage and digital signal form. The Vdc. Other sensors, such as soil-moisture
module requires an excitation voltage of 5 Vdc, sensors, strain-gage loadcells, and conductivity
and the analog output voltage can be read with sensors, which are often connected to traditional
the microcontroller’s A-D converter. The voltage dataloggers, may also be suitable for use with
is then converted to temperature in the inexpensive microcontrollers.
microcontroller’s software using the
manufacturer’s calibration equation. The
MX90601 infrared thermometer module costs
about $53. Auxiliary Components
305
Storage memory EXAMPLE APPLICATIONS
Most microcontrollers do not normally provide Collecting agricultural field data can be labor-
memory for long-term data storage. External intensive, time-consuming, and costly. By
memory chips, such as Maxim’s 24LCxxx series, automating sensor measurements, data can be
are available which can store from 1 kbyte to collected much more frequently and reliably with
512 kbytes of data. The non-volatile memory is much less effort. A few examples of data-
accessed via the microcontroller’s software, and collection equipment constructed using
data can be written and read randomly. The microcontrollers and semiconductor components
chips cost about $2 each. are presented in the following sections.
Analog-to-digital converters
306
the water potential of the sensor/soil. A Table 1. Parts list and cost of main components
calibration equation was developed to convert on moisture-sensor circuit board
frequency to water potential. A series of known
resistances was connected to the circuit, and Description Cost (US$)
the corresponding frequency from the circuit Part number, Manufacturer
board was recorded. The known resistances Microcontroller
were then connected to the moisture-sensor PIC 16F819, Microchip Technologies 3
meter, and the corresponding water potential Clock
values were recorded. Correlating these data DS1302, Dallas Semiconductor 3
yielded a calibration equation which provided a Memory
water potential value based on output signal 24LC512, Microchip Technologies 3
frequency. Multiplexer
74HC4051, Phillips Semiconductors 1
The main components of the circuit consist of a RF transmitter
microcontroller, AC-excitation circuit, TX-434, Laipac 5
multiplexer, real-time clock, memory chip, and Circuit board 1
batteries. The circuit was etched onto a copper- Batteries 2
clad circuit board. Components were then Miscellaneous (resistors, capacitors,
soldered onto the board. Two temperature pins, timer, voltage regulator) 2
sensors were added to the circuit, one to total $20
measure the temperature of the circuit board,
and a second to measure soil temperature. The
component-side of the completed circuit board
is shown in Figure 1. A list of the main The microcontroller was programmed to make
components and their costs is shown in Table 1. and store measurements at 2-hour intervals.
The microcontroller continuously monitored the
microcontroller memory real-time clock, which had a backup battery to
maintain the correct time. At the beginning of
temperature sensor clock battery
each measurement interval, the microcontroller
voltage regulator clock activated the AC-excitation circuit and
multiplexer chip. The multiplexer selected one
sensor at a time, the AC-excitation circuit
powered the sensor, and the microcontroller
measured the frequency. The microcontroller
program applied the calibration routine to
convert the frequency to water potential. The
program then looped and continued the sensor-
measurement process by instructing the
multiplexer to select the next sensor, make a
measurement, and continue until all sensors had
been read. The date, time, and sensor
measurements were stored in the memory chip,
and the microcontroller then put itself into a low-
voltage sleep mode to conserve battery power
until the next measurement interval.
moisture sensor RF transmitter The circuit board was also designed to transmit
connections timer the data out of the field automatically via an on-
board RF transmitter. An RF receiver circuit
soil temperature multiplexer located on one edge of the field would receive
sensor connection the data from all circuit boards within that field,
making it quicker and easier to access the data
Figure 1. Component side of moisture-sensor
without having to download the data manually
circuit board.
from each individual circuit board. The receiver
307
circuit design was not completed by the time the the field were made during this time period to
circuit boards needed to be deployed, however, collect data. Long-term trends are apparent, but
and this feature was not enabled. conditions immediately after a rainfall or
irrigation event are not detected.
Circuit boards were deployed in the 2004
growing season to monitor moisture sensors Measurements collected automatically during
installed in corn, soybean, and cotton fields. the 2004 growing season are shown in Figure 3.
Measurements were made at 3 depths at each The field was visited normally once per week, to
sensor location in the field. The three visually inspect crop conditions, collect other
measurements were also averaged. data, and download moisture-sensor data.
Much less time and labor were required to
Sensor readings for two one-month periods are collect moisture data, and a much more
shown in Figures 2 and 3. In Figure 2, complete picture of the moisture conditions was
measurements collected manually during the obtained by automating the measurements.
2003 growing season are shown. Nine visits to
Field 3c, Site 2 (cotton): July 2003 Automated Evaporation Pan and
0 4.0
Atmometer Measurements
-20 3.6
-40 3.2
Recent efforts to automate evaporation pan and
Soil Water Potential (kPa)
308
determined by measuring the hydrostatic Table 2. Parts list and cost of main components
pressure and calculating the depth based on the for evaporation pan/atmometer circuit
pressure vs depth relationship for water.
Description Cost (US$)
The main components of the circuit board Part number, Manufacturer
consist of a microcontroller, connectors for the Microcontroller
two pressure sensors, real-time clock, memory PIC 16F819, Microchip Technologies 3
chip, and batteries. The circuit was built on a Clock
prototype board, shown in Figure 4. The DS1302, Dallas Semiconductor 3
maincomponents of the circuit and their costs Memory
are shown in Table 2. 24LC512, Microchip Technologies 3
Pressure sensors
The microcontroller was programmed to make MPX5010D, Motorola 20 ea
and store measurements at 2-hour intervals. Circuit board 1
The microcontroller continuously monitored the Batteries 2
real-time clock, and when time came to make Miscellaneous (resistors, capacitors,
measurements, provided an excitation voltage to connector pins, voltage regulator) 2
the pressure sensors. The pressure sensors total $54
were factory calibrated to provide a voltage
signal linearly related to pressure. The
microcontroller measured the signal voltages date, time, and water depth data were then
with its built-in analog-to-digital converters. The stored in the memory chip, and the
microcontroller program contained a calibration microcontroller put itself into a low-voltage sleep
routine to convert the voltage signals to mode to conserve battery power until the next
pressures and then to the depths of water. The measurement interval.
309
Atmometer, Evaporation Pan: 21- 30 September 2004 the retention curve is described by Klute (1986),
12 and involves determining the water content of a
soil sample over a range of known water
10 potentials.
Depth of water (in)
8
The equipment used to develop a water
6
retention curve normally consists of a pressure
chamber and porous ceramic plate, a source of
4 compressed air, and an air-pressure regulating
Atmometer, automated
manual
system. The compressed-air source, usually an
2 Evap pan, automated electric air compressor, supplies pressurized air
manual to the pressure chamber. The pressure-
0 regulating system maintains the pressure in the
21 22 23 24 25 26 27 28 29 30
pressure chamber at the desired level.
310
storage-tank pressure decreases below a set
level, the microcontroller turns on the air
compressor. The compressor remains on until
the pressure inside the storage tank is
recharged. The microcontroller program loops
continuously, monitoring the pressure sensors
and adjusting the pressures at 1-second
intervals.
311
activated to detect the reflected signal. The Table 4. Parts list and cost of main components
distance of the object from the sensor can be on ultrasonic rangefinder circuit board
calculated based on the time it takes for the
pulse to be reflected and return to the sensor Description Cost (US$)
and the speed of sound in air. Part number, Manufacturer
Microcontroller
The rangefinder was installed above the PIC 16F819, Microchip Technologies 3
evaporation pan described previously, and used Clock
to measure the depth of water in the pan. Depth DS1302, Dallas Semiconductor 3
measurements were then compared to those Memory
made manually and with the pressure-sensor 24LC512, Microchip Technologies 3
circuit described above. Ultrasonic rangefinder
SRF04, Devontech 35
The main components of the circuit board Circuit board 1
consist of a microcontroller, real-time clock, Batteries 2
memory chip, transistor, connector for the Miscellaneous (resistors, capacitors,
ultrasonic rangefinder, and batteries. The circuit connector pins, transistor) 2
was built on a prototype board, shown in Figure total $49
8. The main components of the circuit and their
costs are shown in Table 4.
triggered the sensor, which transmitted an
The microcontroller was programmed to make acoustic pulse, and initiated a timer. When the
and store measurements at 2-hour intervals. sensor’s receiver detected the reflected pulse,
When time came to make measurements, the the timer stopped. The microcontroller program
microcontroller first energized the transistor, contained a routine to convert the time of travel
which acted as a switch to turn on power to the of the pulse to a distance, and then to a depth of
ultrasonic rangefinder. The microcontroller water. The date, time, and water depth data
were then stored in the memory chip, and the
microcontroller put itself into a low-voltage sleep
memory clock battery mode to conserve battery power.
clock ultrasonic
sensor A series of water depth measurements made
transistor manually, with the rangefinder, and with the
connection
pressure-sensor circuit is shown in Figure 9. In
general, the rangefinder showed more variation
6.5
6.0
Depth of water (in)
5.5
5.0
4.5
sonic rangefinder
4.0 pressure sensor
manual
3.5
microcontroller 21 22 23 24 25 26 27 28 29 30
312
in depth than did the pressure sensor. This may Cravotta, R. 2004. Field Guide: 31st
have been due in part to the mounting of the Microprocessor Directory. EDN, 5 August 2004,
rangefinder: the rangefinder was attached to the pp39-58.
chicken-wire screen covering the evaporation
pan which may have flexed throughout the day. Dukes, M.D., S. Irmak, J.M. Jacobs. 2004. An
On a few occasions, unrealistic depths were Automatic System for Recording Evaporation
recorded. The cause of these significant from ET Gages. Paper Number: 042191, 2004
random errors is unknown and must be ASAE/CSAE Annual International Meeting,
investigated. Ottawa, Ontario, Canada, 1-4 August 2004.
The capabilities, prevalence, and ease of use of Fisher, D.K., S.J. Thomson, L.A. Smith, and B.L.
modern electronic components are increasing Brazil. 2003. Automated Data Collection Using
rapidly. Electronics are increasingly being used Simple and Inexpensive Microcontrollers and
to collect and process all types of data, transfer Semiconductor Sensors. Paper Number
information, and provide automation and control 033146, Presented at the 2003 ASAE Annual
functions. Many more specialized components International Meeting, Riviera Hotel and
and sensors are available which interface easily Convention Center, Las Vegas, Nevada, USA,
and simplify circuit design. 27-30 July 2003.
These modern electronic components can be Klute, A. 1986. Water retention: laboratory
put to use in agriculture as in the many other methods. p. 635-662. In: A. Klute (ed.)
applications in which they already serve. A Methods of Soil Analysis: Part 1. Physical and
number of useful, inexpensive, and easy-to-use Mineralogical Methods. ASA Monograph
electronic components were described. Several Number 9. ASA, Madison, WI.
examples of circuits used in irrigation research
were presented and discussed.
ACKNOWLEDGEMENTS
The author wishes to thank Barry Collins,
Electronics Technician, USDA Agricultural
Research Service, Application and Production
Technology Research Unit, for his electronics
expertise and assistance in designing and
constructing the circuits and circuit boards.
REFERENCES
Bruton, J.M., G. Hoogenboom, and R.W.
McClendon. 2000. A comparison of
automatically and manually collected pan
evaporation data. Transactions of the ASAE,
vol. 43(5):1097-1101.
313