- From: SA <n0td1scl0s3d_at_ntlworld.com>
- Date: Mon, 15 Aug 2005 15:10:57 +0100
Dear List,
On my pci-das4020/12 card I have a puzzling problem, the board has a 8255 on
it for DIOs. I can successfully write to all channels (0-23, ports a,b,c),
however, I cannot read from ports B and C (channels 8-23).
The channels in ports B+C all return 1 regardless of input, does anyone have
any suggestions? because I am quite stuck now.
Thanks,
SA
Also several of the errors in the dio library don't set the error number
correctly (for instance "wrong subdevice" sets the error as "success").
I presume that when you set the direction for one channel in a port then all
the other channels in that port also have their direction set- is this
correct?
--------------------------- code used to test digital input --------------
for(i=0;i<10000;i++){
usleep(100000);
for(channel=0;channel<20;){
printf("A(");
for(i=0;i<8;i++,channel++){
ret=comedi_dio_read(device,subdevice,channel,&data);
printf("%d",(int)data);
if(ret==-1){
comedi_perror("The error is");
printf("%d\n",comedi_errno());
}
}
printf(") : B(");
for(i=0;i<8;i++,channel++){
ret=comedi_dio_read(device,subdevice,channel,&data);
printf("%d",(int)data);
if(ret==-1){
comedi_perror("The error is");
printf("%d\n",comedi_errno());
}
}
printf(") : C(");
for(i=0;i<4;i++,channel++){
ret=comedi_dio_read(device,subdevice,channel,&data);
printf("%d",(int)data);
if(ret==-1){
comedi_perror("The error is");
printf("%d\n",comedi_errno());
}
}
}
printf(") %d channels read\n",channel);
}
---------------- output from code ------------------------------
A(00000000) : B(11111111) : C(1111) 20 channels read
A(00000000) : B(11111111) : C(1111) 20 channels read
A(00100000) : B(11111111) : C(1111) 20 channels read <- A2 toggled
A(00100000) : B(11111111) : C(1111) 20 channels read
A(00000000) : B(11111111) : C(1111) 20 channels read
A(00000000) : B(11111111) : C(1111) 20 channels read
A(00000000) : B(11111111) : C(1111) 20 channels read
A(00000000) : B(11111111) : C(1111) 20 channels read
A(00000000) : B(11111111) : C(1111) 20 channels read <- B2 toggled
A(00000000) : B(11111111) : C(1111) 20 channels read
A(00000000) : B(11111111) : C(1111) 20 channels read
---------------code used to driver DOs --------------------------
for(i=0;i<10000;i++){
usleep(2000000);
if(out==1)out=0;
else out=1;
for(channel=0;channel<24;channel++){
ret=comedi_dio_write(device,subdevice,channel,out);
if(ret==-1){
comedi_perror("The error is");
printf("%d\n",comedi_errno());
}
}
printf("%d\n",out);
}
--- this code works, all DIOs switch from 0v to 5v every 2 seconds---
Received on 2005-08-15Z13:10:57