Incorrect work Advantech PCI-1713

36 views
Skip to first unread message

Dmytro Fil

unread,
Dec 20, 2019, 3:00:12 AM12/20/19
to Comedi: Linux Control and Measurement Device Interface
Hello!
I have analogue input card Advantech PCI-1713. I read analog data using function comedi_data_read(). 
The data from channels 0-15 is correctly read, but the signals of channels 16-31 duplicate the values of channels 0-15. For example when I send a signal from the calibrator to channel 0, then I see the same signals on channel 0 and 15. When I send a signal from calibrator to channel 15, then I don't see any changes. Same story with another pair of signals.

How to read all data from my card?

OS: Ubuntu 18.04.3 LTS
Kernel: 5.0.0-37-generic
Comedi version 0.7.76
Card info:
overall info:
  version code: 0x00074c
  driver name: adv_pci1710
  board name: pci1713
  number of subdevices: 1
subdevice 0:
  type: 1 (analog input)
  flags: 0x00519000
          SDF_CMD_READ:can do asynchronous input commands
          SDF_READABLE:subdevice can be read
          SDF_GROUND:can do aref=ground
          SDF_DIFF:aref=diff
  number of channels: 32
  max data value: 4095

My source code is below (it's changed example tut2.c from demo folder):
#include <stdio.h>  /* for printf() */
#include <comedilib.h>

int subdev = 0;     /* change this to your input subdevice */
int range = 0;      /* more on this later */
int aref = AREF_GROUND; /* more on this later */

int main(int argc,char *argv[])
{
   comedi_t *it;
   lsampl_t data[32];
   int retval;
    it = comedi_open("/dev/comedi0");
   if(it == NULL) {
       comedi_perror("comedi_open");
       return 1;
   }
while (1) {
// read data
    for (int chan = 0; chan < 32; chan++){
       retval = comedi_data_read(it, subdev, chan, range, aref, &data[chan]);    
       printf("%d|", data[chan]);
       if(retval < 0){
           comedi_perror("comedi_data_read");
           return 1;
       }
    }
    printf("\n");
}
   return 0;
}


Dmytro Fil

unread,
Dec 20, 2019, 3:10:49 AM12/20/19
to Comedi: Linux Control and Measurement Device Interface
Additional information:
If I use drivers and example from Advantech my card work correctly.

пятница, 20 декабря 2019 г., 10:00:12 UTC+2 пользователь Dmytro Fil написал:

Ian Abbott

unread,
Dec 27, 2019, 12:15:12 PM12/27/19
to comed...@googlegroups.com, Dmytro Fil
On 20/12/2019 08:00, Dmytro Fil wrote:
> Hello!
> I have analogue input card Advantech PCI-1713. I read analog data using
> function /comedi_data_read()./
> The data from channels 0-15 is correctly read, but the signals of
> channels 16-31 duplicate the values of channels 0-15. For example when I
> send a signal from the calibrator to channel 0, then I see the same
> signals on channel 0 and 15. When I send a signal from calibrator to
> channel 15, then I don't see any changes. Same story with another pair
> of signals.
>
> How to read all data from my card?
>
> OS: Ubuntu 18.04.3 LTS
> Kernel: 5.0.0-37-generic
> Comedi version 0.7.76
> Card info:
>
> /overall info:
>   version code: 0x00074c
>   driver name: adv_pci1710
>   board name: pci1713
>   number of subdevices: 1
> subdevice 0:
>   type: 1 (analog input)
>   flags: 0x00519000
>           SDF_CMD_READ:can do asynchronous input commands
>           SDF_READABLE:subdevice can be read
>           SDF_GROUND:can do aref=ground
>           SDF_DIFF:aref=diff
>   number of channels: 32
>   max data value: 4095/

Hi,

I've tracked this down to a small bug in the driver introduced in kernel
version 4.5. The channel number is being AND'ed with a bit-mask of 0xf,
causing channels 16-31 to be treated as aliases of channels 0-15.

I've sent a patch to the Linux "staging" development list (and Cc'ed a
copy to you), and marked it for inclusion in older "stable" kernels.
Hopefully, the Ubuntu kernel team will apply the patch to their stable
kernels eventually, but this may take a few weeks.

--
-=( Ian Abbott <abb...@mev.co.uk> || Web: www.mev.co.uk )=-
-=( MEV Ltd. is a company registered in England & Wales. )=-
-=( Registered number: 02862268. Registered address: )=-
-=( 15 West Park Road, Bramhall, STOCKPORT, SK7 3JZ, UK. )=-

Dmytro Fil

unread,
Jan 14, 2020, 4:32:30 AM1/14/20
to Comedi: Linux Control and Measurement Device Interface
I have good news about this problem.
Today I have received a letter that "Patch "staging: comedi: adv_pci1710: fix AI channels 16-31 for PCI-1713" has been added to the 4.9(4.14, 4.19, 5.4)-stable tree"
But last stable revision kernel 5.4.11 didn't have these changes.
I found that revision 5.5.0-rc6 have our fix. I tested it. Advantech PCI-1713 was working correctly!


пятница, 27 декабря 2019 г., 19:15:12 UTC+2 пользователь Ian Abbott написал:
Reply all
Reply to author
Forward
0 new messages