UNDERSTANDING COMMANDS FOR EDITING YOUR OWN C
CODES
This section will describe the basics for understanding how commands are
sent to the devices through the controller. It will also include a
description on how to customize the available C Codes as well as creating
ones from scartch.
Command Format
The two most general forms for commands are:
OUTPUT xxx; Block of data
ENTER xxx
where OUTPUT is used to talk to the device , (ie sending a command or a
query to it while the instrument is in "listen" mode), ENTER to address
the device to talk (the controller is in "listen" mode in this case),
xxx to refer to the device bus address, and "Block of data" represents the
instructions to be sent .
This syntax for this data differs from one instrument to another, but is
easy to acquire.
Example I illustrates how a digital multimeter with address 01 could be
used to measure a resistance across it.
Example II illustrates how a DC power supply with bus address 01 could be
set, remotely, to 5 Volts (for example) then use the digital multimeter to
measure this voltage and display it on the screen of the
computer.(Appropriate cable connections are assumed to be made).
EXAMPLE I:
OUTPUT 01; MEASure:RESistance?
/* An interrogation mark is added
because the command is a query */
ENTER 01
/* Address the multimeter to talk */
EXAMPLE II:
OUTPUT 02; Vset 5
/*Sets the voltage to 5 Volts*/
OUTPUT 01; MEASure:VOLtage:DC?
ENTER 01
/* Note that the previous two examples could be tested by running the
"kbc" program available with the SCSI driver, and the values of the used
resistor and the Voltage of the power supply will be displayed on the
terminal screen */
Using commands in C
IEEEIO.C that comes with the driver contains several useful functions and
declarations that could be used if "kbc" is not to be used and codes are
to be developped in C.
The two functions that are most commonly used are:
IEEEWT and IEEERD
where "wt" stands for write and "rd" stands for read.
The general syntax of ieeewt command is:
ieeewt("OUTPUT xxx; Block of data\n")
For example, if EXAMPLE I presented above is to be written in C, it would
be modified to:
ieeewt("OUTPUT 01; MEASure:RESistance?\n");
ieeewt("ENTER 01\n");
ieeerd(response);
/* Where response is a float declared in main
*/
printf ("%f\n", response);
Editing your own code:
All codes have the same basic overheads (such as initializing the SCSI,
resetting it at the end, inlcuding the header files...).
They differ only in the main part where commands are chosen according to
specific purposes.
HEADER FILES
Almost all codes need to have the following "header include" at their
beginning:
#include signal.h
#include stdio.h
#include stdlib.h
#include string.h
#include "ieeeio.h"
INITIALIZATION
Then checking if the controller is on and establishing communication with
it is next. An error message is displayed if no communication was
established.
/* Establish communications with Personal488 */
if (ieeeinit()==-1)
{
printf("Cannot initialize IEEE system.\n");
exit(1);
}
The following step is to check for some routines such as the driver
revision number (HELLO command) and the status of the controller
(STATUS command). This step is optional but it is always good to include
it because it helps in debugging.
Some more routine checks could be made, 195DEMO.C includes the usage of
such checks.
/* Read the Driver488 revision number */
ieeewt("HELLO\n");
ieeerd(response);
printf("%s\n",response);
/* Display the Personal488 system status */
ieeewt("STATUS\n");
ieeerd(response);
printf("%s\n",response);
Then, the main program follows with the usage of ieeewt and ieeerd
functions.
RESET
Once this is done, the last step is to reset the SCSI interface with the
command RESET
ieeewt("RESET\n");
The the file is saved and needs to be compiled.
COMPILING
The SCSI driver was installed on "jormungandr" in "/opt/IOTsiti" path.
First, rlogin to jormungandr and copy all the files into your own home
directory. The files are also available in my home directory in the
following path: ~safi/iotech. These files are made readable for
everybody.
****First CSHRC needs to be sourced.****
If CSHRC file was not sourced, the following error appears:
make: *** No rule to make target `$@.c', needed by `195demo'.
Stop.
Next, the MAKEFILE that comes with the driver needs to be edited by adding
the name of the new file (EXCLUDING the extension) on the first line
beside EXAMPLE =
If the new file name was plot.c, then the present MAKEFILE would be
edited as follows:
EXAMPLES = 195demo kbc HP3588 HP3588_ini TEK820 plot
/* The file name "plot" was added */
After this is done, save the changes made to MAKEFILE and at the unix
prompt, enter the command "make examples" which causes the code to be
compiled. The "make examples" also creates an object and executable files
having the same names as the original file ("plot" in this case) .
Now the file is ready to be run by typing, at the unix prompt, the name of
the file (with no extension, corresponding to the executable version that
was previously created by "making" examples ).