[prev in list] [next in list] [prev in thread] [next in thread]
List: comedi
Subject: Re: [NI PCI-6071E] AI Start Trig
From: Martyn Welch <welchm () comp ! lancs ! ac ! uk>
Date: 2005-07-29 9:00:02
Message-ID: 200507291000.05609.welchm () comp ! lancs ! ac ! uk
[Download RAW message or body]
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
- ------ Original message ------
On Tuesday 26 Jul 2005 20:13, David Schleef wrote:
> On Tue, Jul 26, 2005 at 05:40:09PM +0100, Martyn Welch wrote:
> > From the documentation I have I believe this to be the "PFI 0/AI START
> > TRIG" signal. This line doesn't seem to be outputting anything, I guess it
> > is setup as input by default.
>
> Correct.
>
Is that "correct" as in "it's set up as input by default" or "the AI START
TRIG line is triggered when a command-type capture is started" or both?
> > How can I set the line up as output?
>
> The PFI lines are available as subdevice 7. You simply need to
> configure the correct line for output.
>
I think I have done this, though it doesn't seem to be working...
I've attached an example I have written.
Thanks for your help,
Martyn
- --
Martyn Welch (welchm@comp.lancs.ac.uk)
PGP Key : http://ubicomp.lancs.ac.uk/~martyn/pgpkey/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
iD8DBQFC6fAVQPzYXciChNcRAv0YAJ9S4tSDX7nypYeigro3y/T7bVxfUwCgiZuF
VOjURASvf+niQlrBdTWTzJI=
=jWYW
-----END PGP SIGNATURE-----
["main.c" (text/x-csrc)]
/* Created by Anjuta version 1.2.2 */
/* This file will not be overwritten */
#include <stdio.h>
#include <comedilib.h>
#include <string.h>
#include <unistd.h>
//Sub-Devices to use
#define AI 0
#define AO 1
#define DIO 2
#define PFI 7
//Define number of conversions to make
#define N_SCAN 10
//Define number of channels to scan
#define N_CHAN 2
//Function to create capture command list
int setup_input(comedi_t *, comedi_cmd *, char, char);
int main(){
comedi_t *it; // Global for DAQ card pointer
unsigned int i; // Loop Var
comedi_cmd cmd; // Command List
unsigned int chanlist[N_CHAN]; // Channel List
unsigned int buf_len = N_SCAN * N_CHAN;
char buf[buf_len];
int ret;
long scan_num = 0;
//Open DAQ Card
it = comedi_open("/dev/comedi0");
if(it == NULL){
comedi_perror("comedi_open");
return(1);
}
//Setup PFI Channels
for(i=0;i<10;i++){
if(comedi_dio_config(it, 7, i, COMEDI_OUTPUT) != 1){
comedi_perror("comedi_dio_config(PFI)");
return(1);
}
}
// Set up channel list
for(i=0;i<N_CHAN;i++){
chanlist[i]=CR_PACK(i,0,AREF_GROUND);
}
// Clear cmd memory
memset(&cmd,0,sizeof(cmd));
// This comedilib function will get us a generic timed
// command for a particular board. If it returns -1,
// that's bad.
if(comedi_get_cmd_generic_timed(it,AI,&cmd,800) < 0){
comedi_perror("comedi_get_cmd_generic_timed");
return 1;
}
// Modify parts of the command
cmd.chanlist = chanlist;
cmd.chanlist_len = N_CHAN;
cmd.scan_end_arg = N_CHAN;
cmd.scan_begin_arg = 4000;
cmd.stop_arg = N_SCAN;
// comedi_command_test() tests a command to see if the
// trigger sources and arguments are valid for the subdevice.
//Print Error and user check if command needed changing...
if(comedi_command_test(it,&cmd) != 0){
fprintf(stderr,"Command Needed Changing\n");
return(1);
}
//Run Command
if(comedi_command(it,&cmd) < 0){
comedi_perror("comedi_command");
return(1);
}
while(1){
ret = read(comedi_fileno(it),buf,buf_len);
if(ret<0){
// some error occurred
perror("read");
break;
}else if(ret==0){
// reached stop condition
break;
}else{
static int col = 0;
for(i=0;i<ret/2;i++){
printf("sensor:%d\ttime:%luns\tvalue:%lu\n", col, (unsigned long)((scan_num * \
4000) + (col *800)), (unsigned long)(((sampl_t *)buf)[i]));
col++;
if(col==N_CHAN){
col=0;
scan_num++;
}else{
}
}
}
}
return(0);
}
_______________________________________________
comedi mailing list
comedi@comedi.org
https://cvs.comedi.org/cgi-bin/mailman/listinfo/comedi
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic