Top Banner
EIGHT- CHANNEL DATA ACQUISITION & LOGGING SYSTEM DEVESH SAMAIYA In environments like factories, power plants and transformers in electricity substations, controlling temperature to a safe value is important. Supervisory and control systems are used to monitor the temperature and other physical parameters on a centralised machine whereby one can monitor and control the remote devices. The AVR microcontroller-based system described here does the same job of acquiring the analogue data and sending it to a remote terminal for monitoring. Fig.1: Block diagram of eight-channel data acquisition and logging system Fig.2: Author’s prototype
18

8-Channel Data Acquisition Ing and Logging System

Aug 29, 2014

Download

Documents

Deepali Kamat
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 8-Channel Data Acquisition Ing and Logging System

EIGHT- CHANNEL DATA                                  

ACQUISITION & LOGGING SYSTEM 

DEVESH SAMAIYA

In environments like factories, power plants and transformers in electricity substations, controlling temperature to a safe value is important. Supervisory and control systems are used to monitor the temperature and other physical parameters on a centralised machine whereby one can monitor and control the remote devices. The AVR microcontroller-based system described here does the same job of acquiring the analogue data and sending it to a remote terminal for monitoring. 

Fig.1: Block diagram of eight-channel data acquisition and logging system

Fig.2: Author’s prototype

Fig.1 shows the block diagram of the eight-channel data acquisition and logging system using AVR microcontroller and Fig.2 shows the author’s prototype. The key features of this system are:

1. The software is user-friendly and written in VB 6.0.

Page 2: 8-Channel Data Acquisition Ing and Logging System

2. Data is acquired through serial port of the PC and displayed on the screen of the PC monitor.

3. Precise analogue signal conversion using AVR analogue-to-digital converter with 10 bitre solution

4. All data acquired by the system is logged into a database for future reference with date and time of sampling.

5. The internal analogue-to-digital conversion (ADC) channels of the AVR are used to acquire real-time data in the form of analogue signal. The data is sent to the PC via UART channel.

Circuit descriptionFig.3 shows the circuit of the eight-channel data acquisition and logging system using AVR. At the heart of the circuit is ATMega32 AVR microcontroller from Atmel.

Fig.3: Circuit for eight-channel data acquisition and logging

Page 3: 8-Channel Data Acquisition Ing and Logging System

The ATMega32 microcontroller has 32 kB of flash program memory, 2 kB of SRAM, internal analogue-to-digital converter (ADC) with 10-bit resolution, internal EEPROM and full-duplex UART channel. This data logger uses ADC channels of the AVR to acquire real-time data in the form of analogue signal and sends this data to the PC via UART channel.

Vcc (pin 10) and AVcc (pin 30) of the AVR are connected to +5V for operation. By default, this AVR works with the internal RC oscillator at 1MHz. Here, fuse bits of the AVR are set to operate an external oscillator. We have used an external stable crystal oscillator to run at a frequency of 16 MHz.

The AVR has internal power-on reset facility. Resistor R2 (10-kilo-ohm), capacitor C5 (10μF) and switch S1 make up the external reset circuitry. Switch S1 allows you to reset  the system at run time.

Analogue reference voltage pin VREF (pin 32) is connected to the variable terminal of the 10-kilo-ohm preset. Using this preset, you can adjust the ADC reference voltage. 

We have used all the eight channels of the 10-bit ADC for acquiring the analogue voltage proportional to the environmental temperature of temperature sensors.

The in-built UART channel of ATMega32 is used to send the current data to the host PC. UART works on 9600 bauds per second. The length of RS-232 serial cable is tested for operation up to 10 metres but it should work upto 15 metres.

Data acquisition and logging

Page 4: 8-Channel Data Acquisition Ing and Logging System

Temperature sensor. Temperature sensor LM335 from National Semiconductors has been used in this project. Its pin details are shown in Fig.4. 

Fig.4: Pin details of LM335

LM335 has a breakdown voltage directly proportional to absolute temperature at 10 mV/°K with less than 1-ohm dynamic impedance. The device operates over a current range of 400 μA to 5 mA with virtually no change in performance. LM335 can be used in any kind of temperature sensing application over the temperature range of –55°C to 150°C. Low impedance and linear output make it easier to interface with the readout and control circuitry. It is not internally calibrated for degree Celsius (°C), so you need some external circuitry in the form of a 10-kilo-ohm preset and a 1-kilo-ohm pull-up resistor as shown in Fig.5.

Fig.5: Circuit for calibration ofLM335 to 2.982V at 25°C

Calibration. Calibration is done carefully to map voltage values exactly into temperature in degree Celsius. Calibration procedure is simple. Voltage values are measured for different temperatures and a constant multiplying factor is obtained. This constant is multiplied with the current ADC value every time.

When calibrated at 25°C, typically, LM335 has an error of less than 1° over a range of 100°C. Most of all, it has a linear output. The voltage across the output terminal of LM335 is 2.982V at 25°C.

This microcontroller works with TTL digital logic, while the RS-232 standard specifies different voltage levels of the digital logic. So you need a signal-level converter for communication between the microcontroller and the PC over RS-232 port.

Page 5: 8-Channel Data Acquisition Ing and Logging System

Signal-level conversion. MAX232 is used as the signal-level converter. For voltage-level conversion, four electrolytic capacitors (10μF, 16V) are used  with MAX232.

There are eight input lines (IN0 through IN7) through which analogue inputs are fed into the circuit. The analogue input is converted into digital level by the AVR and transmitted to the PC through the 9-pin, D-type serial comport connector. Here, we have used only three pins of the connector (Rx, Tx and Gnd) for communication with the PC.

PC GUI software

The graphic user interface (GUI) displays on the dashboard the stored data with date and time of logging. This can be useful to analyse the trend of change in temperature. The software dashboard has eight blocks for displaying data of eight different analogue channels.

The GUI software is written in Visual Basic and has MSComm ActiveX controls for communication with the serial port of the PC. It is programmed to scan real time incoming data from the external hardware. The entire working logic is asynchronous; it doesn’t matter which channel has what data. The software can capture the data from a particular channel and put it into an appropriate location in the database. A special protocol is used to synchronise the software with the hardware in order to make the program identify the data and channel number currently active on the serial port. The microcontroller first sends the channel number followed by the current captured data on the channel.

The software is calibrated such that it shows the temperature directly in degree Celsius by multiplying a calibration constant with the incoming analogue voltage.

The software is configured to work with fixed values such as ‘com1’ for the serial port and ‘9600’ for the baud rate by default. But you can easily configure it to work with different serial ports (like com2, com3 or com4) and baud rates.

The software can save data of the different input channels into a ‘daq. mdb’ database with time and date of each channel input data. Start/stop buttons are provided to start or stop the logging activity any time by the user. The GUI program output is shown in Fig.6.

Page 6: 8-Channel Data Acquisition Ing and Logging System

Fig.6: GUI program output on the dashboard

Construction

A single-side, solder-side PCB layout of the circuit for eight-channel data acquisition and logging is shown in Fig.7 and its component layout in Fig.8. A 9V PP3 battery is used to power the circuit. 9V is converted into 5V using a 7805 regulator. The glowing of LED1 indicates the presence of 5V supply in the circuit. The circuit acquires analogue data from the eight channels through IN0 through IN7 inputs. The analogue temperature data at IN0 channel is acquired from LM335 temperature sensor (IC4). Temperature calibration for IC4 is done using a 10- kilo-ohm preset (VR2). The remaining inputs can be fed from external temperature sources.

Page 7: 8-Channel Data Acquisition Ing and Logging System

Fig.7: A single-side, actual-size PCB layout for eight-channel data acquisition and logging system

Fig.8: Component layout for the PCB

Assemble the temperature sensor along with preset separately on a small general-purpose PCB for each channel. Extend two wires from each of the general-purpose PCBs to the respective input points (IN1 through IN7) in the main PCB. Two-pin SIL male and female pair connector may be used for connecting the PCB to the general-purpose PCB for each channel input. As shown in Fig.5, a 10-kilo-ohm preset is used for calibration of each temperature sensor.

Calibrate each temperature sensor (LM335) before connecting the circuit to the PC. After calibration is done, install the sensors at appropriate locations or on the device whose temperature is to be monitored. Now, run the datalogger 8chnl.exe GUI software and click ‘start’ button to start the data acquisition and logging process. If data display on the dashboard is not proper, press reset switch S1 momentarily, or switch off the power supply and then switch it on. Using preset VR1, adjust ADC reference voltage such that it is exactly 5V across pin 32 of IC3. Microcontroller firmware

The main.c source code for ATMega32 (given at the end of this article) is written in ‘C.’ It is compiled using avr-gcc cross-compiler to generate hex code. Avrdude is used to burn hex code into the ATMega32 microcontroller. 

WinAVR is a free software development tool for AVR series microcontrollers hosted on the Windows platform. It has avr-gcc, avr-libc, avr-binutils and avr-dude within one package. Linux users have to install these components separately. For details of AVR programming hardware and software, visit www.electroons.com 

EFY note. The source code and other relevant files of this article are included in the link below:

http://www.efymag.com/admin/issuepdf/DAQ.zip

Page 8: 8-Channel Data Acquisition Ing and Logging System

CELLPHONE-BASED DEVICE CONTROL WITH  VOICE ACKNOWLEDGEMENTAZARUDEEN ANIFA

Here is a circuit that lets you operate your home appliances like lights and water pump from your office or any other remote place. So if you forgot to switch off the lights or other appliances while going out, it helps you to turn off the appliance with your cellphone. Your cellphone works as the remote control for your home appliances. You can control the desired appliance by pressing the corresponding key. The system also gives you voice acknowledgement of the appliance status.

Circuit descriptionFig.1 shows the circuit for cellphone based device control with voice acknowledgement. It comprises microcontroller AT89C51, DTMF decoder MT8870, voice recording/playback device APR9600 and a few discrete components.

Page 9: 8-Channel Data Acquisition Ing and Logging System

Fig.1: Circuit for cellphone-based device control with voice acknowledgement

Page 10: 8-Channel Data Acquisition Ing and Logging System
Page 11: 8-Channel Data Acquisition Ing and Logging System
Page 12: 8-Channel Data Acquisition Ing and Logging System

Microcontroller AT89C51 is at the heart of the circuit. It is a low-power, high-performance, 8-bit microcontroller with 4 kB of flash programmable and erasable read-only memory (PEROM) used as on-chip program memory, 128 bytes of RAM used as internal data memory, 32 individually programmable input/output (I/O) lines divided into four 8-bit ports, two 16-bit programmable timers/counters, a five-vector two-level interrupt architecture, on-chip oscillator and clock circuitry. A 11.0592MHz crystal (XTAL1) is  used to provide basic clock frequency for the

microcontroller. Capacitor C3 and resistor R3 form the power-on reset circuit, while push-to-on switch S20 is used for manual reset.

Port pins P1.0 through P1.7 of the microcontroller are configured to get the input from push-to-on switches S1 through S8. Pins of Port P1 are pulled high via resistor network RNW1. Port pins P2.0 through P2.4 are configured to receive the decoded DTMF signal from DTMF receiver MT8870. The functions of the corresponding switches (S1 through S8) and cellphone keys are shown in Table I.

The DTMF decoder is used for decoding the mobile signal. It gets DTMF tone from the mobile headset’s speaker pins and decodes it into 4-bit digital signal. The

DTMF decoder is operated with a 3.579MHz crystal (XTAL2 )  In DTMF receiver MT8870 (IC3), capacitor C12 is used to filter the noise and resistors R6 and R7 help to amplify the input signal using the internal amplifier. Pin 16 of IC3 connected to resistor R5 provides the early steering output. It goes high immediately when the digital algorithm detects a valid tone pair (signal condition). Any momentary loss of signal condition causes ESt to return to low state.

Pin 17 of IC3 connected to capacitor C11 is bidirectional, acting as steering input/guard time output (St/GT). A  steering logic VTSt detected at St causes the device to register the detected tone pair. The guard time output resets the external steering time constant, and its state is a function of ESt and the voltage at St. Port P3 pins P3.6 and P3.7 of IC1 are configured to select the control source for the devices. These are connected to DIP switches S17 and S18 and pulled high via resistors R2 and R1, respectively. Here, we are using two control sources, switches and mobile’s key. DIP switches S17 and S18 select the control sources as shown in Table II.

Page 13: 8-Channel Data Acquisition Ing and Logging System

Pin 2.5 of Port P2 is configured to show the rest status. That is, if none of the control sources is selected by DIP switches S17 and S18, LED1 glows. Resistor R14 limits the current through LED1. Voice acknowledgement is provided by the APR9600 (IC2). It is a single-chip voice recording and playback device that can record and play multiple messages at random or in sequential mode for 60 seconds. The user can select sample rates with corresponding  quality recording lengths. Microphone amplifier, automatic gain control (AGC) circuits, internal antialiasing filter, internal output amplifier and message management are some of the features of the APR9600. Here the APR9600 is configured in random-access mode, which supports two, four and eight messages of fixed durations. The length of each message is the total recording length available divided by the total number of memory segments/tracks enabled. Audio processor APR9600 can store up to eight voice messages. Port P0 pins and P2.7 are configured to communicate with IC2. Port P0 pins trigger selection of the message. Port pin P2.7 is the input signal to identify whether the voice message is playing or not.

Fig.2: Pin configuration of mobile headset

Pins P3.0 through P3.5 of Port P3 control the devices with the help of relays RL1 through RL6 via relay driver IC4.

A speaker is connected to IC2 for audio output. The speaker output drives the mic input of the mobile for audio acknowledgement. An electret microphone MIC1 is connected to IC2 to record the voice in IC2. LED2 flashes to show the busy status of IC2 during recording and playback. The audio messages to be recorded in APR9600, by using trigger switches S9 through S16, are shown in Table III. SPST switch S19 is closed for recording and switch S19 is opened for playback. 

Page 14: 8-Channel Data Acquisition Ing and Logging System

Fig.3 shows the power supply circuit. The 230V AC mains is stepped down by transformer X1 to deliver the secondary output of 9V, 500 mA. The transformer output is rectified by a full-wave bridge rectifier comprising diodes D1 through D4, filtered by capacitor C16 and then regulated by IC 7806 (IC5). Capacitor C15 bypasses the ripples present in the regulated 6V power supply. LED3 acts as a power-on indicator and resistor R16 limits the current through LED3. 

Fig.3: Power supply circuit

An actual-size, single-side PCB for cellphone-based device control with voice acknowledgement is  shown in Fig.4 and its component layout in fig.5.

Page 15: 8-Channel Data Acquisition Ing and Logging System

Fig.4: A single-side, actual-size PCB layout for cellphone-based device control 

with voice acknowledgement

Fig.5: Component layout for the PCB

Recording and playback 

Page 16: 8-Channel Data Acquisition Ing and Logging System

To record the voice in IC2, follow Table III. Close SPST switch S19 to make pin 27 of IC2 low. Thereafter, press and hold switches S9 through S16 to record corresponding voice messages. LED2 flashes to indicate audio recording.

For playback of any device status, open SPST switch S19 and press the corresponding switch (S9 through S16). The recorded audio can be heard from the speaker connected to pins 14 and 15 of IC2. Fig.2 shows the pin configuration of mobile headset.

Software

The program (Device_Control.BAS) for the microcontroller is written using BASCOM microcontroller programming software. In the program, first, initialise the port (P0-P3) for corresponding controls. Thereafter, declare the variables for the program. After declaration, assign some initial value to variables. Here, microcontroller ports are initialised to make all the devices ‘off’ initially.

After that, the main function checks through ‘Do’ loop which control source has been enabled by using DIP switch pins. If you select switch S17, it searches the input from the mobile only. If you select switch S18, it searches the input from the switches (S1 through S8) only. If you enable both switch S17 and switch S18, it searches the inputs from switches and mobile. Else, the rest-status LED1 glows. Refer to Table II to select the control source. The mobile signal is decoded into the DTMF signal by IC3. The DTMF output for each mobile key (used in this project) pressed is shown in Table IV.

After getting the input from the switches or mobile, the program goes to the device_action subroutine and executes the corresponding action (refer Table I). The device_action subroutine changes the status of the device and calls the voice_alert subroutine. The voice_alert subroutine checks the device status and device name from the source input and controls the corresponding pins of IC2. First, it selects the voice signal for the device name. After playing that, it selects on/off status of corresponding device as mentioned in Table III. If you press ‘*’ key followed by the device number on your mobile handset, it will not change the status of that device and inform the current device status. If you press device number

Page 17: 8-Channel Data Acquisition Ing and Logging System

followed by ‘*’ key on your mobile handset, it will change the status of that device and inform the changed device status. ‘#’ key controls the voice_control subroutine and acts like a mute key.

EFY note. The source code of this project is available on the link given below. http://www.efymag.com/admin/issuepdf/DeviceControlWithVoiceAcknowledgement.zip