* [Xenomai] Troubleshooting Analogy DIO
@ 2014-05-23 21:43 Manu S Madhav
2014-05-23 22:31 ` Gilles Chanteperdrix
2014-05-24 18:59 ` Paul Janzen
0 siblings, 2 replies; 11+ messages in thread
From: Manu S Madhav @ 2014-05-23 21:43 UTC (permalink / raw)
To: xenomai
Hello all,
I am running Ubuntu Precise (12.04) with kernel version 3.4.6 and
xenomai-2.6.2.1. I have a NI PCIe 6259 which I am trying to configure for
Digital I/O. Currently, the code itself is non-RT, I am trying first to
figure out how to do I/O as well as obtain counter / quadrature information
from my DAQ card.
Using Analogy, and with a bit of reading, I was able to get analog input
and output up and running without too much trouble, but digital I/O is
completely evading me. I am just trying to turn on all digital outputs to 1
using synchronous instruction to the DIO subdevice (#2, in my case). Size
of the subdevice is 4 (32 bits).
None of the following attempts worked. From the mailing list archives, I
found a suggestion to compile xenomai libs with --fno-omit-frame-pointer,
and that also didn't help. Any suggestions would be appreciated.
*First try (Using command-line insn_bits)*
********************
insn_bits -v -d analogy0 -s 2 0xffffffff 0xffffffff
insn_bits: device analogy0 opened (fd=0)
insn_bits: basic descriptor retrieved
subdevices count = 14
read subdevice index = 0
write subdevice index = 0
insn_bits: complex descriptor retrieved
insn_bits: selected subdevice index = 2
insn_bits: mask = 0xffffffff
insn_bits: value = 0xffffffff
insn_bits: result = 0x0
********************
*Second try (Using a4l_sync_dio)*
********************
// dsc = is a4l_desc_t , previously configured
int subd_DIO = 2;
uint32_t mask = 0xffffffff;
uint32_t buf = 0xffffffff;
a4l_sync_dio(&dsc, idx_subd_DIO, &mask, &buf);
********************
Again, even when I am getting a return of 0 (success), I am not measuring a
digital 1 at the physical pins.
*Third try (Using a4l_send_insn)*:
********************
// dsc = is a4l_desc_t , previously configured
int subd_DIO = 2;
unsigned char values[16];
a4l_insn_t insn;
insn.type = A4L_INSN_BITS;
insn.idx_subd = idx_subd_DIO;
insn.data = values;
values[0] = 0xff;
values[1] = 0xff;
insn.data_size = 2 * sizeof(uint32_t);
a4l_snd_insn(&dsc, &insn);
********************
Manu S Madhav
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [Xenomai] Troubleshooting Analogy DIO 2014-05-23 21:43 [Xenomai] Troubleshooting Analogy DIO Manu S Madhav @ 2014-05-23 22:31 ` Gilles Chanteperdrix 2014-05-24 18:59 ` Paul Janzen 1 sibling, 0 replies; 11+ messages in thread From: Gilles Chanteperdrix @ 2014-05-23 22:31 UTC (permalink / raw) To: Manu S Madhav, xenomai On 05/23/2014 11:43 PM, Manu S Madhav wrote: > Hello all, > > I am running Ubuntu Precise (12.04) with kernel version 3.4.6 and > xenomai-2.6.2.1. I have a NI PCIe 6259 which I am trying to configure for > Digital I/O. Currently, the code itself is non-RT, I am trying first to > figure out how to do I/O as well as obtain counter / quadrature information > from my DAQ card. > > Using Analogy, and with a bit of reading, I was able to get analog input > and output up and running without too much trouble, but digital I/O is > completely evading me. I am just trying to turn on all digital outputs to 1 > using synchronous instruction to the DIO subdevice (#2, in my case). Size > of the subdevice is 4 (32 bits). > > None of the following attempts worked. From the mailing list archives, I > found a suggestion to compile xenomai libs with --fno-omit-frame-pointer, > and that also didn't help. Any suggestions would be appreciated. I will let others answer this mail, but: - the bug with omit-frame-pointer was fixed, I believe, in xenomai 2.6.0, or 2.6.1 - 2.6.2.1 is not the latest version, so, please try 2.6.3 before reporting an issue that may have been fixed since then. -- Gilles. ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai] Troubleshooting Analogy DIO 2014-05-23 21:43 [Xenomai] Troubleshooting Analogy DIO Manu S Madhav 2014-05-23 22:31 ` Gilles Chanteperdrix @ 2014-05-24 18:59 ` Paul Janzen 2014-05-24 20:22 ` Manu S Madhav 1 sibling, 1 reply; 11+ messages in thread From: Paul Janzen @ 2014-05-24 18:59 UTC (permalink / raw) To: Manu S Madhav; +Cc: xenomai Manu S Madhav <manusmad@gmail.com> writes: > Using Analogy, and with a bit of reading, I was able to get analog input > and output up and running without too much trouble, but digital I/O is > completely evading me. I am just trying to turn on all digital outputs to 1 > using synchronous instruction to the DIO subdevice (#2, in my case). Size > of the subdevice is 4 (32 bits). Before writing to the DIO device, you have to configure each line that you want to be a digital output as an output, otherwise it stays a digital input: for (i=0; i<num_channels; i++) { err = a4l_config_subd(dsc, subd_DIO, A4L_INSN_CONFIG_DIO_OUTPUT, i); if (err < 0) [...] } -- Paul ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai] Troubleshooting Analogy DIO 2014-05-24 18:59 ` Paul Janzen @ 2014-05-24 20:22 ` Manu S Madhav 2014-05-25 1:46 ` Paul Janzen 0 siblings, 1 reply; 11+ messages in thread From: Manu S Madhav @ 2014-05-24 20:22 UTC (permalink / raw) To: Paul Janzen; +Cc: xenomai Thank you, Paul, I was under the impression that a4l_config_subd was used for asynchronous instructions only. DIO is up and running now - thank you! One more question: Is anyone aware of an analogy implementation for using the DAQ counter for quadrature encoding? E.g. by using the A4L_INSN_CONFIG_GPCT_QUADRATURE_ENCODER instruction. I saw a couple of threads where someone successfully armed the counter, but was unable to read information from it. I am going to try and implement it this weekend, just wondering if there is already a working solution. Gilles: I will upgrade to the newest version of Xenomai. Thank you for your suggestion. --- Manu Madhav On Sat, May 24, 2014 at 2:59 PM, Paul Janzen <pcj@xenomai.sez.to> wrote: > Manu S Madhav <manusmad@gmail.com> writes: > > > Using Analogy, and with a bit of reading, I was able to get analog input > > and output up and running without too much trouble, but digital I/O is > > completely evading me. I am just trying to turn on all digital outputs > to 1 > > using synchronous instruction to the DIO subdevice (#2, in my case). Size > > of the subdevice is 4 (32 bits). > > Before writing to the DIO device, you have to configure each line that > you want to be a digital output as an output, otherwise it stays a > digital input: > > for (i=0; i<num_channels; i++) { > err = a4l_config_subd(dsc, subd_DIO, A4L_INSN_CONFIG_DIO_OUTPUT, i); > if (err < 0) [...] > } > > -- Paul > > > > > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai] Troubleshooting Analogy DIO 2014-05-24 20:22 ` Manu S Madhav @ 2014-05-25 1:46 ` Paul Janzen 2014-05-27 12:56 ` Rosali Pyun 0 siblings, 1 reply; 11+ messages in thread From: Paul Janzen @ 2014-05-25 1:46 UTC (permalink / raw) To: Manu S Madhav; +Cc: xenomai Manu S Madhav <manusmad@gmail.com> writes: > One more question: Is anyone aware of an analogy implementation for > using the DAQ counter for quadrature encoding? E.g. by using the > A4L_INSN_CONFIG_GPCT_QUADRATURE_ENCODER instruction. I know it works in Comedi, but have not tried it in Analogy. You may have to snarf some bit definitions from comedi. Try INSN_CONFIG, with two data { A4L_INSN_CONFIG_SET_COUNTER_MODE, NI_GPCT_COUNTING_MODE_QUADRATURE_X4_BITS | NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS } and then again to arm the counter: { A4L_INSN_CONFIG_ARM, NI_GPCT_ARM_IMMEDIATE } Then you should be able to get the counter value back with a4l_sync_read. A4L_INSN_CONFIG_GPCT_QUADRATURE_ENCODER appears to be a half-baked sensoray only thing. -- Paul ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai] Troubleshooting Analogy DIO 2014-05-25 1:46 ` Paul Janzen @ 2014-05-27 12:56 ` Rosali Pyun 2014-05-27 14:42 ` Manu S Madhav 0 siblings, 1 reply; 11+ messages in thread From: Rosali Pyun @ 2014-05-27 12:56 UTC (permalink / raw) To: Paul Janzen, Manu S Madhav; +Cc: xenomai@xenomai.org > To: manusmad@gmail.com > From: pcj@xenomai.sez.to > Date: Sat, 24 May 2014 18:46:22 -0700 > CC: xenomai@xenomai.org > Subject: Re: [Xenomai] Troubleshooting Analogy DIO > > Manu S Madhav <manusmad@gmail.com> writes: > > > One more question: Is anyone aware of an analogy implementation for > > using the DAQ counter for quadrature encoding? E.g. by using the > > A4L_INSN_CONFIG_GPCT_QUADRATURE_ENCODER instruction. > > I know it works in Comedi, but have not tried it in Analogy. You may > have to snarf some bit definitions from comedi. > > Try INSN_CONFIG, with two data > { A4L_INSN_CONFIG_SET_COUNTER_MODE, > NI_GPCT_COUNTING_MODE_QUADRATURE_X4_BITS | > NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS > } > > and then again to arm the counter: > { A4L_INSN_CONFIG_ARM, NI_GPCT_ARM_IMMEDIATE } > > Then you should be able to get the counter value back with > a4l_sync_read. > > A4L_INSN_CONFIG_GPCT_QUADRATURE_ENCODER appears to be a half-baked > sensoray only thing. > > -- Paul > I was not able to use the counter for quadrature encoder with NI m-series DAQ card.I ended up using "quadrature clock converter" chip along with the encoder and implemented simple counting functionality. INSN_CONFIG with {A4L_INSN_CONFIG_SET_COUNTER_MODE, NI_GPCT_COUNTING_MODE_NORMAL_BITS | NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS} Let me know if you have any luck with quadrature encoder mode. -Rosali ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai] Troubleshooting Analogy DIO 2014-05-27 12:56 ` Rosali Pyun @ 2014-05-27 14:42 ` Manu S Madhav 2014-05-27 15:03 ` Paul Janzen 0 siblings, 1 reply; 11+ messages in thread From: Manu S Madhav @ 2014-05-27 14:42 UTC (permalink / raw) To: Rosali Pyun; +Cc: xenomai@xenomai.org Hey Rosali, Paul, Thanks for the information. I have been trying to do this, using your instructions as well as gpct_encoder.c from comedi, and also code from people who have implemented it in Analogy (on 660x DAQs). The attempts have been a complete bust so far. I am able to disarm and arm the counter, and this I know because when I read from counter 0 (using a4l_sync_read), the value is decremented if the counter is armed, when a +5V input is applied to PFI0. However, the value keeps decreasing as long as the input is connected, even though there is no edge. This does not happen when the counter is disarmed, and also the initial value is 0 when the counter is disarmed and then armed. This is the only behavior I am able to produce from the counter. I have tried using both QUADRATURE_X4_BITS and NORMAL_BITS, as well as a combination of other things. I don't seem to be able to set the mode of the counter properly. Curiously, regardless of whether the chan_desc in the instructions say 0 or 1, it is counter 0 which seems to be affected. I cannot do anything with counter 1, reading it always gives me a value of 0. Rosali, do you have some sample code I can test? Even with NORMAL_BITS, I would think the counter should decrement (or increment) only a single time a +5V input is connected. Manu S Madhav Postdoctoral Associate The Knierim Lab, Zanvyl Krieger Mind/Brain Institute, LIMBS Lab, Mechanical Engineering Department Johns Hopkins University Baltimore, MD, USA 21218 On Tue, May 27, 2014 at 8:56 AM, Rosali Pyun <whimt@hotmail.com> wrote: > > > > To: manusmad@gmail.com > > From: pcj@xenomai.sez.to > > Date: Sat, 24 May 2014 18:46:22 -0700 > > CC: xenomai@xenomai.org > > Subject: Re: [Xenomai] Troubleshooting Analogy DIO > > > > > Manu S Madhav <manusmad@gmail.com> writes: > > > > > One more question: Is anyone aware of an analogy implementation for > > > using the DAQ counter for quadrature encoding? E.g. by using the > > > A4L_INSN_CONFIG_GPCT_QUADRATURE_ENCODER instruction. > > > > I know it works in Comedi, but have not tried it in Analogy. You may > > have to snarf some bit definitions from comedi. > > > > Try INSN_CONFIG, with two data > > { A4L_INSN_CONFIG_SET_COUNTER_MODE, > > NI_GPCT_COUNTING_MODE_QUADRATURE_X4_BITS | > > NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS > > } > > > > and then again to arm the counter: > > { A4L_INSN_CONFIG_ARM, NI_GPCT_ARM_IMMEDIATE } > > > > Then you should be able to get the counter value back with > > a4l_sync_read. > > > > A4L_INSN_CONFIG_GPCT_QUADRATURE_ENCODER appears to be a half-baked > > sensoray only thing. > > > > -- Paul > > > > > I was not able to use the counter for quadrature encoder with NI m-series > DAQ card. > I ended up using "quadrature clock converter" chip along with the encoder > and implemented simple counting functionality. > > INSN_CONFIG with > {A4L_INSN_CONFIG_SET_COUNTER_MODE, > NI_GPCT_COUNTING_MODE_NORMAL_BITS | > NI_GPCT_COUNTING_DIRECTION_HW_UP_DOWN_BITS > } > > Let me know if you have any luck with quadrature encoder mode. > > -Rosali > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai] Troubleshooting Analogy DIO 2014-05-27 14:42 ` Manu S Madhav @ 2014-05-27 15:03 ` Paul Janzen 2014-05-27 15:54 ` Rosali Pyun 0 siblings, 1 reply; 11+ messages in thread From: Paul Janzen @ 2014-05-27 15:03 UTC (permalink / raw) To: Manu S Madhav; +Cc: xenomai@xenomai.org Manu S Madhav <manusmad@gmail.com> writes: > counter is armed, when a +5V input is applied to PFI0. However, the value > keeps decreasing as long as the input is connected, even though there is no > edge. This does not happen when the counter is disarmed, and also the > initial value is 0 when the counter is disarmed and then armed. You are counting ticks of the internal clock (20 MHz in the original 6602), gated with PFI0. You need to CONFIG_SET_CLK_SRC to count an external "clock" (edges). > Curiously, regardless of whether the chan_desc in the instructions say 0 or > 1, it is counter 0 which seems to be affected. I cannot do anything with > counter 1, reading it always gives me a value of 0. Counter 1 is one *subdev* up from counter 0, it is not the second channel of subdev 2. -- Paul ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai] Troubleshooting Analogy DIO 2014-05-27 15:03 ` Paul Janzen @ 2014-05-27 15:54 ` Rosali Pyun 2014-05-28 13:31 ` Manu S Madhav 0 siblings, 1 reply; 11+ messages in thread From: Rosali Pyun @ 2014-05-27 15:54 UTC (permalink / raw) To: Manu S Madhav; +Cc: xenomai@xenomai.org > To: manusmad@gmail.com > From: pcj@xenomai.sez.to > Date: Tue, 27 May 2014 08:03:36 -0700 > CC: xenomai@xenomai.org > Subject: Re: [Xenomai] Troubleshooting Analogy DIO > > Manu S Madhav <manusmad@gmail.com> writes: > > > counter is armed, when a +5V input is applied to PFI0. However, the value > > keeps decreasing as long as the input is connected, even though there is no > > edge. This does not happen when the counter is disarmed, and also the > > initial value is 0 when the counter is disarmed and then armed. > > You are counting ticks of the internal clock (20 MHz in the original > 6602), gated with PFI0. You need to CONFIG_SET_CLK_SRC to count an > external "clock" (edges). > > > Curiously, regardless of whether the chan_desc in the instructions say 0 or > > 1, it is counter 0 which seems to be affected. I cannot do anything with > > counter 1, reading it always gives me a value of 0. > > Counter 1 is one *subdev* up from counter 0, it is not the second > channel of subdev 2. > > -- Paul I am attaching a sample code, which is based on comedi example. As Paul said, for NI card, counter 0 is subdevice 11 and counter 1 is subdevice 12. I am not using GATE functionality at the moment.I also found out that P0.6 and P0.7 are UP/DOWN channel for counter 0 and counter 1. (at least for NI PCI 6629 card) I hope this helps. -Rosali -------------- next part -------------- A non-text attachment was scrubbed... Name: counter.cpp Type: text/x-c Size: 5432 bytes Desc: not available URL: <http://www.xenomai.org/pipermail/xenomai/attachments/20140527/e73d559f/attachment.bin> ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai] Troubleshooting Analogy DIO 2014-05-27 15:54 ` Rosali Pyun @ 2014-05-28 13:31 ` Manu S Madhav 2014-05-30 11:30 ` Rosali Pyun 0 siblings, 1 reply; 11+ messages in thread From: Manu S Madhav @ 2014-05-28 13:31 UTC (permalink / raw) To: Rosali Pyun; +Cc: xenomai@xenomai.org Thanks again for your suggestions and code samples. I hadn't realized the two counters were two separate subdevices. Turns out I was using lsampl_t instead of unsigned int for the instruction data structure, and that messed up the clock source instruction. Normal counting works for now, and I can even get by using that, since my encoder is high resolution (5000 counts / rev). However, quadrature (and particularly the index bit) would be really useful. So I set the counter mode to QUADRATURE_X4_BITS | HW_UP_DOWN_BITS, disabled both gates, and used A4L_INSN_CONFIG_SET_OTHER_SRC to set a,b sources using, for e.g.: int a = 8; unsigned int data[3]; a4l_insn_t insn; insn.type = A4L_INSN_CONFIG; insn.idx_subd = idx_subd_CNT; insn.chan_desc = 0; insn.data_size = sizeof(data[0])*3; data[0] = A4L_INSN_CONFIG_SET_OTHER_SRC; data[1] = NI_GPCT_SOURCE_ENCODER_A; data[2] = NI_GPCT_PFI_OTHER_SELECT(a); insn.data = data; a4l_snd_insn(&dsc, &insn) Now the counter gives one value for clockwise rotation (e.g. 0) and another for counterclockwise (e.g. 1). So clearly it is using both a and b inputs to determine direction of rotation. And this happens regardless of whether clock source is set or not. Getting closer - any thoughts? Manu S Madhav Postdoctoral Associate The Knierim Lab, Zanvyl Krieger Mind/Brain Institute, LIMBS Lab, Mechanical Engineering Department Johns Hopkins University Baltimore, MD, USA 21218 On Tue, May 27, 2014 at 11:54 AM, Rosali Pyun <whimt@hotmail.com> wrote: > > > > To: manusmad@gmail.com > > From: pcj@xenomai.sez.to > > Date: Tue, 27 May 2014 08:03:36 -0700 > > > CC: xenomai@xenomai.org > > Subject: Re: [Xenomai] Troubleshooting Analogy DIO > > > > Manu S Madhav <manusmad@gmail.com> writes: > > > > > counter is armed, when a +5V input is applied to PFI0. However, the > value > > > keeps decreasing as long as the input is connected, even though there > is no > > > edge. This does not happen when the counter is disarmed, and also the > > > initial value is 0 when the counter is disarmed and then armed. > > > > You are counting ticks of the internal clock (20 MHz in the original > > 6602), gated with PFI0. You need to CONFIG_SET_CLK_SRC to count an > > external "clock" (edges). > > > > > Curiously, regardless of whether the chan_desc in the instructions say > 0 or > > > 1, it is counter 0 which seems to be affected. I cannot do anything > with > > > counter 1, reading it always gives me a value of 0. > > > > Counter 1 is one *subdev* up from counter 0, it is not the second > > channel of subdev 2. > > > > -- Paul > > I am attaching a sample code, which is based on comedi example. > > As Paul said, for NI card, counter 0 is subdevice 11 and counter 1 is > subdevice 12. > > I am not using GATE functionality at the moment. > I also found out that P0.6 and P0.7 are UP/DOWN channel for counter 0 and > counter 1. (at least for NI PCI 6629 card) > > I hope this helps. > > -Rosali > ^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [Xenomai] Troubleshooting Analogy DIO 2014-05-28 13:31 ` Manu S Madhav @ 2014-05-30 11:30 ` Rosali Pyun 0 siblings, 0 replies; 11+ messages in thread From: Rosali Pyun @ 2014-05-30 11:30 UTC (permalink / raw) To: Manu S Madhav; +Cc: xenomai@xenomai.org > Now the counter gives one value for clockwise rotation (e.g. 0) and another for counterclockwise (e.g. 1). So clearly it is using both a and b inputs to determine direction of > rotation. And this happens regardless of whether clock source is set or not. > Getting closer - any thoughts? I also had same experience with my DAQ card.I couldn't make any progress, so I decided to use the clock converter chip. -Rosali ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2014-05-30 11:30 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-05-23 21:43 [Xenomai] Troubleshooting Analogy DIO Manu S Madhav 2014-05-23 22:31 ` Gilles Chanteperdrix 2014-05-24 18:59 ` Paul Janzen 2014-05-24 20:22 ` Manu S Madhav 2014-05-25 1:46 ` Paul Janzen 2014-05-27 12:56 ` Rosali Pyun 2014-05-27 14:42 ` Manu S Madhav 2014-05-27 15:03 ` Paul Janzen 2014-05-27 15:54 ` Rosali Pyun 2014-05-28 13:31 ` Manu S Madhav 2014-05-30 11:30 ` Rosali Pyun
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.