[comedi] PWM - usbduxsigma
Ozan Ă–gunc <[email protected]> Wed, 6 Jul 2022 06:54:18 -0700 (PDT)
| Newsgroups | gmane.linux.comedi |
|---|---|
| Message-ID | <[email protected]> |
------=_Part_8764_965262139.1657115658867
Content-Type: multipart/alternative;
boundary="----=_Part_8765_757363224.1657115658867"
------=_Part_8765_757363224.1657115658867
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
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=20
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 seen.
Gnd =3D pin 9 of the 15 pin connector
PWM =3D pin 1-8 ( all eight pins are checked)
2. The system log notes that the usb connection is successful:
usb 1-3: new high-speed USB device number 8 using xhci_hcd
usb 1-3: New USB device found, idVendor=3D13d8, idProduct=3D0020,
bcdDevice=3D 0.00
usb 1-3: New USB device strings: Mfr=3D0, Product=3D0, SerialNumber=3D=
0
comedi comedi0: ADC_zero =3D 800166
comedi comedi0: driver 'usbduxsigma' has successfully
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[])
{
int ret,i,help;
comedi_insn insn;
lsampl_t d[5];
comedi_t *device;
=20
int freq;
int duty;
=20
device =3D comedi_open("/dev/comedi0");
if(!device){
fprintf(stderr,"Could not open comedi\n");
exit(-1);
}
=20
insn.insn=3DINSN_CONFIG;
insn.data=3Dd;
insn.subdev=3D3;
insn.chanspec=3DCR_PACK(0,0,0);
=20
for(i=3D1; i<argc; ++i)
{
if(!strcmp(argv[i], "-on")) {
d[0] =3D INSN_CONFIG_ARM;
d[1] =3D 0;
//d[1] =3D 1; // G=C3=BCrsoy
insn.n=3D2;
ret=3Dcomedi_do_insn(device,&insn);
if(ret < 0){
fprintf(stderr,"Could sw on:%d\n",ret);
exit(-1);
}
}
=20
if(!strcmp(argv[i], "-off")) {
d[0] =3D INSN_CONFIG_DISARM;
d[1] =3D 0;
insn.n=3D1;
ret=3Dcomedi_do_insn(device,&insn);
if(ret < 0){
fprintf(stderr,"Could sw on:%d\n",ret);
exit(-1);
}
}
if(!strcmp(argv[i], "-duty")) duty =3D atoi(argv[i+1]);
if(!strcmp(argv[i], "-help")) help =3D 1;
}
if(help)
{
printf("----------------------------------------------\n");
printf("-on/-off \t Turn PWM on/off\n");
printf("-freq \t \t Adjust frequency\n");
printf("-duty \t \t Adjust duty cycle\n");
printf("----------------------------------------------\n");
exit(0);
}
printf("-duty =3D%d\n", duty );
=20
int channel=3D0;
// it's 0..511
comedi_data_write(device,
4,=20
channel,
0,
0,
duty);
comedi_data_write(device,
4,=20
channel+1,
0,
0,
400);
comedi_data_write(device,
4,=20
channel+2,
0,
0,
100);
comedi_data_write(device,
4,=20
channel+3,
0,
0,
200);
=20
return 0;
}
--=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/97da856b-025f-49df-b810-9e17c4c006b5n%40googlegroups.com.
------=_Part_8765_757363224.1657115658867
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div><div>I am currently having a problem and wanted to ask you.<br></div><=
div><br></div><div>I tried to setup and configure a pwm drive by using usbd=
uxsigma. I have</div><div>a current driver, but I do not get a signal from =
the usbduxsigma. Below </div><div>is my code. It compiles fine, but wi=
thout any output.</div><div><br></div><div>1. The example file pwm_0.c is s=
imply taken from the</div><div>"code-examples/pwm.c". It compiles alright. =
It also runs. However, when</div><div>I connect the oscilloscope to any of =
these outputs, no signal can be seen.</div><div><br></div><div>  =
; Gnd =3D pin 9 of the 15 pin connector</div><div><br></div><div> =
; PWM =3D pin 1-8 ( all eight pins are checked)</div><div=
><br></div><div>2. The system log notes that the usb connection is successf=
ul:</div><div><br></div><div> usb 1-3: new high-speed US=
B device number 8 using xhci_hcd</div><div> usb 1-3: New=
USB device found, idVendor=3D13d8, idProduct=3D0020,</div><div>bcdDevice=
=3D 0.00</div><div> usb 1-3: New USB device strings: Mfr=
=3D0, Product=3D0, SerialNumber=3D0</div><div> comedi co=
medi0: ADC_zero =3D 800166</div><div> comedi comedi0: dr=
iver 'usbduxsigma' has successfully</div><div>auto-configured 'usbduxsigma'=
.</div></div><div><br></div><div>I would be very happy if you could help.<b=
r></div><div><br></div><div><div>Thank you for your time and consideration.=
</div><div>Kind regards,</div><div>OZAN</div></div><div><br></div><div><br>=
</div><div>#include <stdio.h><br>#include <comedilib.h><br>#inc=
lude <fcntl.h><br>#include <unistd.h><br>#include <stdlib.h&=
gt;<br>#include <errno.h><br>#include <getopt.h><br>#include &l=
t;ctype.h><br>#include <string.h><br><br><br>int main(int argc, ch=
ar *argv[])<br>{<br> int ret,i,help;<br> comedi_insn insn;<br>&=
nbsp; lsampl_t d[5];<br> comedi_t *device;<br> <br> int f=
req;<br> int duty;<br> <br> device =3D comedi_open("/dev/=
comedi0");<br> if(!device){<br> fprintf(stderr,"Could no=
t open comedi\n");<br> exit(-1);<br> }<br> <br>&nb=
sp; insn.insn=3DINSN_CONFIG;<br> insn.data=3Dd;<br> insn.subdev=
=3D3;<br> insn.chanspec=3DCR_PACK(0,0,0);<br> <br> for(i=
=3D1; i<argc; ++i)<br> {<br> if(!strcmp=
(argv[i], "-on")) {<br> d[0] =3D INSN_CONFIG_ARM;<br> &n=
bsp; d[1] =3D 0;<br> //d[1] =3D 1; // G=C3=BCrsoy=
<br> insn.n=3D2;<br> ret=3Dcomedi_do_insn(device,=
&insn);<br> if(ret < 0){<br> fprint=
f(stderr,"Could sw on:%d\n",ret);<br> exit(-1);<br>&nbs=
p; }<br> }<br> =
<br> if(!strcmp(argv[i], "-off")) {<br>&=
nbsp; d[0] =3D INSN_CONFIG_DISARM;<br> d[1] =3D 0;<br>&=
nbsp; insn.n=3D1;<br>  =
; ret=3Dcomedi_do_insn(device,&insn);<br> &n=
bsp; if(ret < 0){<br> &n=
bsp; fprintf(stderr,"Could sw on:%d\n",ret);<br> =
exit(-1);<br>  =
; }<br> }<br><br> &nb=
sp; if(!strcmp(argv[i], "-duty")) duty =3D atoi(argv[i+1]);<br>  =
; if(!strcmp(argv[i], "-help")) help =3D 1;<br> }<br>&n=
bsp; if(help)<br> {<br> printf("----------=
------------------------------------\n");<br> printf("-=
on/-off \t Turn PWM on/off\n");<br> printf("-freq \t \t=
Adjust frequency\n");<br> printf("-duty \t \t Adjust d=
uty cycle\n");<br> printf("----------------------------=
------------------\n");<br> exit(0);<br> }=
<br> printf("-duty =3D%d\n", duty );<br> <br> int channel=
=3D0;<br> // it's 0..511<br> comedi_data_write(device,<br> =
; 4, <br> &nb=
sp; channel,<br> 0,<br>&nbs=
p; 0,<br> &nb=
sp; duty);<br> comedi_data_write(device,<br> &nbs=
p; 4, <br> ch=
annel+1,<br> 0,<br> &=
nbsp; 0,<br> =
400);<br> comedi_data_write(device,<br> &n=
bsp; 4, <br> channel+2,<br>=
0,<br> =
0,<br> 100);<br>&nb=
sp; comedi_data_write(device,<br> =
4, <br> channel+3,<br>  =
; 0,<br> &nbs=
p; 0,<br> 200);<br> <br>&nbs=
p; return 0;<br>}<br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;Comedi: Linux Control and Measurement Device Interface" group.<br=
/>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">comedi_=
[email protected]</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/d/msgid/comedi_list/97da856b-025f-49df-b810-9e17c4c006b5n%40googlegroups=
.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/ms=
gid/comedi_list/97da856b-025f-49df-b810-9e17c4c006b5n%40googlegroups.com</a=
>.<br />
------=_Part_8765_757363224.1657115658867--
------=_Part_8764_965262139.1657115658867--