• Build logs, Tutorials and Hacks

    Wednesday, May 19, 2010

    8-Channel Analog Data Aquisition System and Data Logger Using Matlab and RS-232

    Introduction





    The biggest problem with developing and testing real world systems and collecting data to software's like Matlab and Labview is that Data Acquisitions systems and cards are really expensive and hence hard to get. My goal has always been to develop systems and instruments for a student or hobbyist or a small scale researcher so that the first step is always possible. So this is a cheap system to get the wheels turning.




    This instrument consists of a microcontroller that is used to acquire data from an 8-Channel ADC(ADC0809). The controller is also connected to a two line LCD that is used to display the data that is acquired. The same data is sent via RS-232 to a PC where a script is running in MATLAB. The script can be replaced by a block diagram in simulink or a Control Block in LabView. This data can then be processed, analyzed and plotted as per requirement.




    As a bonus feature, the controller that I used was a Phillips variant of the 8051 that is In-System Programmable. This essentially means that to reprogram the controller, I don't need to take it out. All I have to do is change two jumper settings and that's it! I can used a ISP software like FlashMagic.




    I have also added an LED to demonstrated the bi-directional nature of the system and is discussed further in the improvements section.






    Final Specifications:




    * In-System Programmable Controller(P89C51RD2) @11.0592Mhz


    * 2-Line LCD


    * Firmware in C for further development


    * RS-232 interface.


    * 8 Channel ADC (ADC0809)


    * Can operate in stand-alone mode.


    * In-built Menu interface for control via Terminal Box.


    * Matlab Script for acquiring data from any channel


    * 8 digital outputs can be made available by removing LCD.(controlled via terminal or Matlab)




    Matlab Script File:


    Echo HEX for 8051 Derivative:





    Development and Research Methodology


    I can't exactly say how I got the specifications for this design came. Instead the design evolved in stages and I added features to the design over the development cycle.




    The start of any project is a humble one. The research for this project was inspired by the capabilities of a micro-controller and serial communication. The methodology is always to start with smaller and simpler goals in mind that can be accomplished with relative ease. Once it is established that the set goal(s) is achieved successfully, only then the design is modified further. This is the evolution of a design in a development cycle.



    Research for this project was completed in stages. I start developing all my project using simple building block modules that I made(shown in the Poorman's Robotics Kit). The stages and development is documented.



    Development


    I started with a simple objective in mind- serial communication and I ended the project with something a little better.



    Stage 1:



    • Establish two way Serial Communication between PC and AT89C51 micro-controller at 9200bps.

    • Send character via HyperTerminal and make micro-controller echo the same to verify.


    Stage 2:



    • Write Matlab Script to open serial com. and echo the character back to micro-controller.

    • The micro-controller will send a 'ready' text at reset and then echo any character sent to it.


    Stage 3:



    • Interface ADC0804 and add LCD

    • Program micro-controller to send value from ADC to PC in ASCII format.


    Stage 4:


    • Write Matlab Script to read values from serial port and make a table


    Stage 5:



    • Put all required peripherals on single PCB

      • MAX232

      • Micro-controller

      • ADC

      • LCD etc.



    • Upgrade Micro-controller to In-System Programmable P89C51RD2

    • Upgrade ADC to ADC0809

    • Add 555 based clock generator for ADC0809

    • Write Routine for interfacing ADC0809


    Stage 6:


    • Write menu interface in firmware for microcontroller for functionality control eg. channel select, LCD control and port control

    • Write interrupt scheme for receiving and sending data via RS-232


    Stage 7:



    • Write matlab Script for acquiring data from different channels of ADC and sending commands to control port pins.

    • Add interrupt button for stand alone operation of card w/o PC.




    A screen shot of the terminal Interface of the DAQ card. As soon as the controller is reset, it sends a menu interface and a prompt to the user's terminal via RS-232.


    The User selects an option and the controller responds accordingly.
    If the user enter's an option that is not available in the menu, the controller stops execution and sends a "Invalid Option" message to the user.

    I used the Terminal Supplied with the Flash Magic software. Hyper-terminal did not give expected results as I was using a USB to Serial Converter.


    The Matlab Interface show here is a text-only Interface. I plan to develop a graphical block for the same. The script shown here is a totally autonomous one. All the commands etc have already been entered into the script.
    The script executes and automatically gathers the required samples and closes the connection. 



    Further Work


    I am planing to add a lot more features to the system. It took me four days at my home lab to get this far.

    • Refine the controller code

    • Create GUI block for Matlab.

    • New Project- "DC motor Speed and position control using ..."

    • Add power down mode for DAQ

    • Add menu options like

      • Set Sampling Time.

      • Stand-Alone DataLogger

      • etc



    • Write a VB/ VC++ application

    No comments:

    Post a Comment