Re: [comedi] PWM - usbduxsigma
Bernd Porr <[email protected]> Wed, 6 Jul 2022 22:36:46 +0100
| Newsgroups | gmane.linux.comedi |
|---|---|
| Message-ID | <[email protected]> |
Oh yes. It should be subdevice 3. Can you try that?
/Bernd
bp1@bp1-Precision-WorkStation-T5400:~/nn$ comedi_board_info
overall info:
=C2=A0 version code: 0x00074c
=C2=A0 driver name: usbduxsigma
=C2=A0 board name: usbduxsigma
=C2=A0 number of subdevices: 4
subdevice 0:
=C2=A0 type: 1 (analog input)
=C2=A0 flags: 0x10119000
=C2=A0 number of channels: 16
=C2=A0 max data value: 16777215
=C2=A0 ranges:
=C2=A0=C2=A0=C2=A0 all chans: [-1.33333 V,1.33333 V]
=C2=A0 command:
=C2=A0=C2=A0=C2=A0 start: now|int
=C2=A0=C2=A0=C2=A0 scan_begin: timer
=C2=A0=C2=A0=C2=A0 convert: now
=C2=A0=C2=A0=C2=A0 scan_end: count
=C2=A0=C2=A0=C2=A0 stop: none|count
=C2=A0 command structure filled with probe_cmd_generic_timed for 1 channel=
s:
=C2=A0=C2=A0=C2=A0 start: now 0
=C2=A0=C2=A0=C2=A0 scan_begin: timer 250000
=C2=A0=C2=A0=C2=A0 convert: now 0
=C2=A0=C2=A0=C2=A0 scan_end: count 1
=C2=A0=C2=A0=C2=A0 stop: count 2
subdevice 1:
=C2=A0 type: 2 (analog output)
=C2=A0 flags: 0x00125000
=C2=A0 number of channels: 4
=C2=A0 max data value: 255
=C2=A0 ranges:
=C2=A0=C2=A0=C2=A0 all chans: [0 V,2.5 V]
=C2=A0 command:
=C2=A0=C2=A0=C2=A0 start: now|int
=C2=A0=C2=A0=C2=A0 scan_begin: timer
=C2=A0=C2=A0=C2=A0 convert: now
=C2=A0=C2=A0=C2=A0 scan_end: count
=C2=A0=C2=A0=C2=A0 stop: none|count
=C2=A0 command structure filled with probe_cmd_generic_timed for 1 channel=
s:
=C2=A0=C2=A0=C2=A0 start: now 0
=C2=A0=C2=A0=C2=A0 scan_begin: timer 1000000
=C2=A0=C2=A0=C2=A0 convert: now 0
=C2=A0=C2=A0=C2=A0 scan_end: count 1
=C2=A0=C2=A0=C2=A0 stop: count 2
subdevice 2:
=C2=A0 type: 5 (digital I/O)
=C2=A0 flags: 0x00030000
=C2=A0 number of channels: 24
=C2=A0 max data value: 1
=C2=A0 ranges:
=C2=A0=C2=A0=C2=A0 all chans: [0 V,5 V]
=C2=A0 command:
=C2=A0=C2=A0=C2=A0 not supported
subdevice 3:
=C2=A0 type: 12 (pwm)
=C2=A0 flags: 0x00020100
=C2=A0 number of channels: 8
=C2=A0 max data value: 512
=C2=A0 ranges:
=C2=A0=C2=A0=C2=A0 all chans: [0,1]
=C2=A0 command:
=C2=A0=C2=A0=C2=A0 not supported
bp1@bp1-Precision-WorkStation-T5400:~/nn$
On 06/07/2022 15:10, Ian Abbott wrote:
> On 06/07/2022 14:54, Ozan =C3=96gunc wrote:
>> I am currently having a problem and wanted to ask you.
>>
>> I tried to setup and configure a pwm drive by using usbduxsigma. I have
>> a current driver, but I do not get a signal from the usbduxsigma. Below
>> is my code. It compiles fine, but without any output.
>>
>> 1. The example file pwm_0.c is simply taken from the
>> "code-examples/pwm.c". It compiles alright. It also runs. However, when
>> I connect the oscilloscope to any of these outputs, no signal can be=20
>> seen.
>>
>> =C2=A0=C2=A0 =C2=A0=C2=A0Gnd =3D pin 9 of the 15 pin connector
>>
>> =C2=A0=C2=A0 =C2=A0=C2=A0PWM =3D pin 1-8=C2=A0 ( all eight pins are chec=
ked)
>>
>> 2. The system log notes that the usb connection is successful:
>>
>> =C2=A0=C2=A0 =C2=A0 =C2=A0usb 1-3: new high-speed USB device number 8 us=
ing xhci_hcd
>> =C2=A0=C2=A0 =C2=A0 =C2=A0usb 1-3: New USB device found, idVendor=3D13d8=
, idProduct=3D0020,
>> bcdDevice=3D 0.00
>> =C2=A0=C2=A0 =C2=A0 =C2=A0usb 1-3: New USB device strings: Mfr=3D0, Prod=
uct=3D0, SerialNumber=3D0
>> =C2=A0=C2=A0 =C2=A0 =C2=A0comedi comedi0: ADC_zero =3D 800166
>> =C2=A0=C2=A0 =C2=A0 =C2=A0comedi comedi0: driver 'usbduxsigma' has succe=
ssfully
>> auto-configured 'usbduxsigma'.
>>
>> I would be very happy if you could help.
>>
>> Thank you for your time and consideration.
>> Kind regards,
>> OZAN
>>
>>
>> #include <stdio.h>
>> #include <comedilib.h>
>> #include <fcntl.h>
>> #include <unistd.h>
>> #include <stdlib.h>
>> #include <errno.h>
>> #include <getopt.h>
>> #include <ctype.h>
>> #include <string.h>
>>
>>
>> int main(int argc, char *argv[])
>> {
>> =C2=A0=C2=A0 int ret,i,help;
>> =C2=A0=C2=A0 comedi_insn insn;
>> =C2=A0=C2=A0 lsampl_t d[5];
>> =C2=A0=C2=A0 comedi_t *device;
>>
>> =C2=A0=C2=A0 int freq;
>> =C2=A0=C2=A0 int duty;
>>
>> =C2=A0=C2=A0 device =3D comedi_open("/dev/comedi0");
>> =C2=A0=C2=A0 if(!device){
>> =C2=A0=C2=A0 =C2=A0 fprintf(stderr,"Could not open comedi\n");
>> =C2=A0=C2=A0 =C2=A0 exit(-1);
>> =C2=A0=C2=A0 }
>>
>> =C2=A0=C2=A0 insn.insn=3DINSN_CONFIG;
>> =C2=A0=C2=A0 insn.data=3Dd;
>> =C2=A0=C2=A0 insn.subdev=3D3;
>> =C2=A0=C2=A0 insn.chanspec=3DCR_PACK(0,0,0);
>>
>> =C2=A0=C2=A0 for(i=3D1; i<argc; ++i)
>> =C2=A0=C2=A0 =C2=A0 {
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 if(!strcmp(argv[i], "-on")) {
>> =C2=A0=C2=A0 =C2=A0 d[0] =3D INSN_CONFIG_ARM;
>> =C2=A0=C2=A0 =C2=A0 d[1] =3D 0;
>> =C2=A0=C2=A0 =C2=A0 //d[1] =3D 1; =C2=A0 =C2=A0// G=C3=BCrsoy
>> =C2=A0=C2=A0 =C2=A0 insn.n=3D2;
>> =C2=A0=C2=A0 =C2=A0 ret=3Dcomedi_do_insn(device,&insn);
>> =C2=A0=C2=A0 =C2=A0 if(ret < 0){
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 fprintf(stderr,"Could sw on:%d\n",ret);
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 exit(-1);
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 }
>>
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 if(!strcmp(argv[i], "-off")) {
>> =C2=A0=C2=A0 =C2=A0 d[0] =3D INSN_CONFIG_DISARM;
>> =C2=A0=C2=A0 =C2=A0 d[1] =3D 0;
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 insn.n=3D1;
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ret=3Dcomedi_do_insn(dev=
ice,&insn);
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if(ret < 0){
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 fprintf(stderr,"C=
ould sw on:%d\n",ret);
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 exit(-1);
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 }
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 }
>>
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 if(!strcmp(argv[i], "-duty")) duty =3D atoi(a=
rgv[i+1]);
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 if(!strcmp(argv[i], "-help")) help =3D 1;
>> =C2=A0=C2=A0 =C2=A0 }
>> =C2=A0=C2=A0 if(help)
>> =C2=A0=C2=A0 =C2=A0 {
>> printf("----------------------------------------------\n");
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 printf("-on/-off \t Turn PWM on/off\n");
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 printf("-freq \t \t Adjust frequency\n");
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 printf("-duty \t \t Adjust duty cycle\n");
>> printf("----------------------------------------------\n");
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 exit(0);
>> =C2=A0=C2=A0 =C2=A0 }
>> =C2=A0=C2=A0 printf("-duty =3D%d\n", duty );
>>
>> =C2=A0=C2=A0 int channel=3D0;
>> =C2=A0=C2=A0 // it's 0..511
>> =C2=A0=C2=A0 comedi_data_write(device,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 4,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 channel,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 duty);
>> =C2=A0=C2=A0 comedi_data_write(device,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 4,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 channel+1,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 400);
>> =C2=A0=C2=A0 comedi_data_write(device,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 4,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 channel+2,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 100);
>> =C2=A0=C2=A0 comedi_data_write(device,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 4,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 channel+3,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 0,
>> =C2=A0=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 200);
>
> I'm not that familiar with the device[*], but those=20
> comedi_data_write() calls are writing to a non-existent subdevice 4.=C2=
=A0=20
> It should be subdevice 3.
>
> [*] Bernd Porr sent me one about a decade ago, but unfortunately it=20
> got destroyed in an office fire!
>
--=20
www: http://www.berndporr.me.uk
http://www.tinnitustailor.tech
http://www.attys.tech
Mobile: +44 (0)7840 340069
Work: +44 (0)141 330 5237
University of Glasgow
School of Engineering
Rankine Building, Oakfield Avenue,
Glasgow, G12 8LT
--=20
You received this message because you are subscribed to the Google Groups "=
Comedi: Linux Control and Measurement Device Interface" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/=
comedi_list/f7cf32b7-bdb8-f51d-5c04-d6cc4d6087e0%40berndporr.me.uk.