ADC100 and Linux

 
Post new topic   Reply to topic    Pico Technology Forum Index -> Getting Started
Author Message
Martin
Guest





PostPosted: Wed Nov 17, 2004 4:57 pm    Post subject: ADC100 and Linux Reply with quote

Have recently bought ADC100. Using Mandrake 10.1, installed software as per instructions, ran ./a100test, selected port 0, but just get o/p consisting of series of of 0's (chA) and 1's (chB) when using choice C (continuous reading), with voltage of around 1volt applied to BNC channel A. System is dual boot and all works fine under Win98. lsmod shows up parport module ok. Any suggestions?
Back to top
Martin
Guest





PostPosted: Fri Nov 19, 2004 12:05 pm    Post subject: more details Reply with quote

Hope someone can help. Applying a dc voltage to chA in steps of 0.05V and reading the ADC100 with the program listed below gives strange results. At 0.5V applied, the ADC output value printed by the progarm is 2047 and this value does not alter until the applied voltage reaches 0.7V, at which point the ADC output value printed becomes 1790. Any help much appreciated.

#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>
#include <asm/ioctl.h>

#include "../kernel/pico_lnx.h"

#define MAX_SAMPLES 10000
int file;

int main (int argc, char ** argv)
{
char line [80];
char dev_name [20];
char ch;
int port;
int value;

printf ("Pico ADC100 example for Linux V1.0\n");

/* file = adc100_open (0); */
sprintf (dev_name, "%s%d", DEVICE_FILE_NAME, 0);
printf("%s \n", dev_name );

file = open (dev_name, 0);
if (file == 0)
{
printf ("Unable to open port\n");
exit (99);
}

value = 100;
ioctl (file, IOCTL_PICO_GET_VERSION, &value);
printf("Version %d\n", value);
value = 100;
ioctl (file, IOCTL_PICO_GET_HW_VERSION, &value);
printf("Hardware Version %d\n", value);


value = 100;
ioctl (file, IOCTL_PICO_SET_PRODUCT, &value);

value=0;
ioctl (file, IOCTL_PICO_SET_SCALE, &value);

/*value = (ADC100_CHANNEL_A << 16) + ADC100_RANGE_20V;*/
value=6;
printf("%d\n", value);
ioctl (file, IOCTL_PICO_SET_RANGE, &value);
ioctl (file, IOCTL_PICO_SET_RANGE, &value);

value=READ_MODE_DOUBLE;
ioctl (file, IOCTL_PICO_SET_READ_MODE, &value);

int j;
for (j=0; j<1; j++) {
value=0;
ioctl (file, IOCTL_PICO_GET_VALUE, &value);
}
printf(" %d \n", value);


return(0);
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Pico Technology Forum Index -> Getting Started
All times are GMT
Page 1 of 1

 


Pico Technology topic RSS feed 
Powered by phpBB © 2001, 2005 phpBB Group