Start by unzipping the LabA.zip file into your csci/255 directory.
Next go to the command line and type the single command make. If you get an error message, talk to the instructor.
Get one of the nine LabJack U3's from the instructor and customize it just like the sample brought by the instructor.
This could take a while.
If you have done this sort of thing before, you may be wondering why there are no limiting resisters on the LED's: It's because there is a 550 Ω resister inside the U3 on the digital output path.
There is one downloaded file, Makefile, that controls the C-compilation process. This is your "IDE". By the way, you can use NetBeans to control C compilation, but you'll be on your own there.
# This is a sample Makefile to build a U3 application # Define this for your local environment INCDIR=/opt/csci/include LIBDIR=/opt/csci/lib CFLAGS=-Wall -g -I$(INCDIR) CC=gcc $(CFLAGS) LDFLAGS=-L $(LIBDIR) LIBS=-lm -lu3 all: u3LabA u3LabA: u3LabA.c $(CC) -o u3LabA u3LabA.c $(LDFLAGS) $(LIBS) clean: rm -f *~ *.o u3LabA
The C program is stored in u3LabA.c.
#include "u3.h" #include <unistd.h> int main(int argc, char **argv) { HANDLE hDevice; int localID; long retV ; long lngState; retV = LJUSB_GetDevCount(U3_PRODUCT_ID) ; if (retV == 0) { fputs("No available LabJack devices.\n", stderr) ; exit(1) ; } else { printf("# of available LabJack devices: %ld.\n", retV) ; } //Open first found U3 over USB localID = -1; if( (hDevice = openUSBConnection(localID)) == NULL) { fputs("Unable to open LabJack device.\n", stderr) ; exit(1); } //Read state of FIO6 and FIO7 printf("\nReading state of FIO6 and FIO7\n"); if((retV = eDI(hDevice, 1, 6, &lngState)) != 0) { fputs("Unable to read FIO6\n", stderr) ; exit(1) ; } printf("FIO6: %ld\n", lngState); if((retV = eDI(hDevice, 1, 7, &lngState)) != 0) { fputs("Unable to read FIO7\n", stderr) ; exit(1) ; } printf("FIO7: %ld\n", lngState); while (1) { sleep(2) ; printf("\nSetting FIO1 to output-low\n"); if((retV = eDO(hDevice, 1, 1, 0)) != 0) { fputs("Unable to set pin 3\n", stderr) ; exit(1) ; } printf("\nSetting FIO3 to output-low\n"); if((retV = eDO(hDevice, 1, 3, 0)) != 0) { fputs("Unable to set pin 3\n", stderr) ; exit(1) ; } sleep(2) ; printf("\nSetting FIO1 to output-high\n"); if((retV = eDO(hDevice, 1, 1, 1)) != 0) { fputs("Unable to set pin 3\n", stderr) ; exit(1) ; } printf("\nSetting FIO3 to output-high\n"); if((retV = eDO(hDevice, 1, 3, 1)) != 0) { fputs("Unable to set pin 3\n", stderr) ; exit(1) ; } } closeUSBConnection(hDevice); return 0; }
Depending on the time, try to (1) make both LED's flash on and off at the same time or (2) "test" the value of FIO4 in the loop and don't flash if FIO4 is zero.