This section explains the steps needed in order to install Melon. These should be already-known instructions, as Melon follows the standard configure, make and make install procedure. Experienced users may skip this chapter.
Installing from a source distribution is recommended. First get a tarball such as melon.tar.gz and unpack it:
jeremy@artemis:~$wget http://ib.cnea.gov.ar/~thelerg/melon/melon.tar.gzjeremy@artemis:~$tar xzf melon.tar.gz
Now run the configure script
jeremy@artemis:~$cd melonjeremy@artemis:~/melon$./configure
The script should detect whether libcomedi library is installed in the system and automatically enable Comedi input/output support in Melon. If everything went fine (as should be), it is time to compile
jeremy@artemis:~/melon$ make
The binary executable is located in the directory src. To make it system-wide available (and install the manual page also) run as root
jeremy@artemis:~/melon$suartemis:/home/jeremy/melon#make install
and you are done. The binary executable should be located in /usr/local/bin/melon.
If for some reason you do not want to build the sources, you still may try a shot on using pre-compiled binaries. Go to http://ib.cnea.gov.ar/~thelerg/melon and get a tarball that suits your needs. Suppose its is named melon-bin.tar.gz. Then unpack it and copy (as root) the binary to /usr/local/bin or any other directory that is PATH-accessible.
jeremy@artemis:~$tar xzf melon-bin.tar.gzjeremy@artemis:~#cp melon-bin/melon /usr/local/bin
You may want to check if the pre-compiled dynamic executable has found all the needed libraries in your system
jeremy@artemis:~$cd /usr/local/binjeremy@artemis:/usr/local/bin$file melon melon: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.4.1, dynamically linked (uses shared libs), for GNU/Linux 2.4.1, not strippedjeremy@artemis:/usr/local/bin$ldd melon linux-gate.so.1 => (0xffffe000) libcomedi.so.0 => /usr/local/lib/libcomedi.so.0 (0xb7ee2000) libm.so.6 => /lib/tls/i686/cmov/libm.so.6 (0xb7ebd000) libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7d8b000) /lib/ld-linux.so.2 (0xb7f0c000)
Melon may use Comedi API in order to use acquisition hardware. If Comedi-LIB is installed, Melon's configure scripts will automatically enable Comedi support. Even though Comedi is needed if you want to control or acquire information from a real plant, it is not necessary if you plan to use Melon only to control numerical software simulations.
As quoted from Comedi documentation,
Comedi is a free software project that develops drivers, tools, and libraries for various forms of data acquisition: reading and writing of analog signals; reading and writing of digital inputs/outputs; pulse and frequency counting; pulse generation; reading encoders; etc. The project's source code is distributed in two packages,
comediandcomedilib, and provides several Linux kernel modules and a user space library:
Comedi is a collection of drivers for a variety of common data acquisition plug-in boards (which are called “devices” in Comedi terminology). The drivers are implemented as the combination of (i) one single core Linux kernel module (called “
comedi”) providing common functionality, and (ii) individual low-level driver modules for each device.Comedilib is a separately distributed package containing a user-space library that provides a developer-friendly interface to the Comedi devices. Included in the Comedilib package are documentation, configuration and calibration utilities, and demonstration programs.
Kcomedilib is a Linux kernel module (distributed with the
comedipackage) that provides the same interface as comedilib in kernel space, and suitable for real-time tasks. It is effectively a “kernel library” for using Comedi from real-time tasks.Comedi works with standard Linux kernels, but also with its real-time extensions RTAI and RTLinux/GPL.
Melon takes advantage of the unified API that Comedi provides, such that controlling real physical plants is simplified in the sense that detailed information about the acquisition and control hardware is handled by Comedi in a very convenient way. However, installation and configuration of a working Comedi environment may present some challenge for the regular user, as it involves dealing with kernel modules and headers.
Getting Comedi to work is not as straight-forward as configuring, making and make install. The first step is to get both Comedi and Comedi-LIB from http://www.comedi.org. As stated above, Comedi provides kernel modules, and as such it works in kernel space. In order to compile Comedi, you will need either the full sources or at least the headers of the running kernel (it is not necessary to re-compile the kernel though), including the actual configuration file. On the other hand, Comedi-LIB works in user space, so its installation follows the familiar configure, make and make install sequence. Naturally, detailed information about the installation is available in the packages documentation.
Once Comedi-LIB is installed, the configuration script of Melon will enable Comedi support. Nevertheless, if the kernel modules are not installed, no device will be usable. You must tell Comedi which hardware is available, where to find it and how it is configured (single-end or differential, unipolar or bipolar, available output ranges, etc). First, you have to load the appropriate kernel module for your device. For example, for MicroAxial ADQ12B card, the module is named adq12b (see devices.txt in Comedi distribution for a list of supported hardware)
artemis:/home/jeremy# modprobe adq12b
This command should have loaded one or more extra comedi-related kernel modules
artemis:/home/jeremy# lsmod | grep adq12b
adq12b 4000 0
comedi 29528 1 adq12b
Now, you have to link a specific device file to the hardware you are planning to use and tell Comedi about the card internal jumped configuration. This is done with the command comedi_config
artemis:/home/jeremy# comedi_config /dev/comedi0 adq12b 0x300,0,0
The file /dev/comedi0 is the special device file that will be linked to the acquisition hardware, which should be handled by the already loaded adq12b kernel module. The last three numbers are the base address of the ISA card, and the bipolar-unipolar and differential-single jumped settings. Each card accepts different types of options as the last argument to comedi_config. Please read the drivers.txt in the Comedi distribution for information related to your specific hardware.
The device should be now configured and ready to use. To see what kind of supported functions your card has, use the program board_info located in the example directory of Comedi-LIB
artemis:/home/jeremy/tmp/comedilib-0.8.1/demo# ./board_info
overall info:
version code: 0x00074a
driver name: adq12b
board name: adq12b
number of subdevices: 3
subdevice 0:
type: 1 (analog input)
flags: 0x00110000
number of channels: 16
max data value: 4095
ranges:
all chans: [-5,5] [-2,2] [-1,1] [-0.5,0.5]
command:
not supported
subdevice 1:
type: 3 (digital input)
flags: 0x00010000
number of channels: 5
max data value: 1
ranges:
all chans: [0,5]
command:
not supported
subdevice 2:
type: 4 (digital output)
flags: 0x00020000
number of channels: 8
max data value: 1
ranges:
all chans: [0,5]
command:
not supported
From the information above we conclude that subdevice 0 (analog input) provides 16 input channels with 4 different fullscales, but this device does not support analog output. Thus, an hypothetic control action must be implemented with another device. However, Comedi developers are working in a PWM-type of output, that appropriately filtered may work as an analog control signal.