From 60e22a2431a71f0a3a9cfa40e6fabdf4317f1547 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 9 Dec 2010 12:27:14 -0500 Subject: [PATCH] Add Comedi and NI triggering post. --- posts/Comedi.mdwn | 2 +- posts/Comedi_and_NI_triggering.mdwn | 68 +++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+), 1 deletion(-) create mode 100644 posts/Comedi_and_NI_triggering.mdwn diff --git a/posts/Comedi.mdwn b/posts/Comedi.mdwn index c154bdd..50ff01f 100644 --- a/posts/Comedi.mdwn +++ b/posts/Comedi.mdwn @@ -28,7 +28,7 @@ and added them to my [[Gentoo overlay]]. [Ubuntu]: http://packages.ubuntu.com/natty/python-comedilib [Gentoo]: http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sci-libs/comedilib/?hideattic=0 -[[!tag tags/latex]] +[[!tag tags/linux]] [[!tag tags/programming]] [[!tag tags/tools]] [[!tag tags/hardware]] diff --git a/posts/Comedi_and_NI_triggering.mdwn b/posts/Comedi_and_NI_triggering.mdwn new file mode 100644 index 0000000..464bf8d --- /dev/null +++ b/posts/Comedi_and_NI_triggering.mdwn @@ -0,0 +1,68 @@ +Back in 2007 I [submitted a patch][submit] to [[Comedi]] to support +triggering analog output off the analog input start signal. The patch +was [accepted][], and is now old news, but I just ran across my notes +from developing it, and thought I'd publish them for posterity (and as +a reminder to myself in case I have to dig into the internals of +Comedi or NI drivers in the future). + +Patch notes +=========== + +To understand the patch, you should understand some portion of +National Instrument's Data Acquisition Systems Timing Controller (NI +DAQ-STC, see “Understanding NI DAQ-STC” below and the [manual][] for +more details). + +We are trying to set up the AO timing so it triggers off of the AI +start signal. In NI terminology, that means we want `AI_START1` to be +the source of `AO_START1`. The possible sources are listed in the +DAQ-STC manual in table 5-2, p6-7 (380), where we see that +`AO_START1`'s 19th input is `AI_START1`. To implement this, we need +to write to the card's `AO_Trigger_Select` register (Appendix B, +register 67, pB-21 (470)). + +Sounds fairly simple, we should just be able to set the appropriate +`start_arg`. However, looking into source of +`comedi/driver/ni_mio_common.c`, we see that no external triggering +information is written to the `AO_Trigger_Select_register`. Looking +back through the STC manual, we come across their AO trigger example +(3.6.1.4, p3-23 (185)) which shows how to set up AO triggering. +Comparing to `ni_mio_common.c`, we see that the AO triggering +configuration in `ni_ao_cmd()` looks just like the “software +triggered” case in NI's example. So it seems impossible to run +externally triggered AO. + +The patch edits `ni_mio_common.c` to make it more like NI's example +and `ni_mio_common.c`'s own AI code. + +Understanding NI DAQ-STC +======================== + +Consider the timing sequence shown in the Comedi manual. For output, +all the same timings apply, but data is flowing the other way. + +Here is a translation table between NI's terminology and Comedi's (NI +references from STC manual): + + + + + + +
Comedi AI NI AO Reference
seq_start AO_START1Fig 3-10, p3-12 (174)
scan_beginUPDATE Fig 3-2, p3-6 (168)
convert TMRDACWR Fig 3-2, p3-6 (168)
+ +There are references to an `AO_START` as distinct from `AO_START1`, +but it appears to be unsupported: + +* It does not show up in the manual's AO feature list (section 3.2, + p3-2 (164), compare to the AI feature list, section 2.2, p2-2 (31)) +* It shows up in some contexts as unsupported (e.g. section 3.6.5, + p3-36 (198)) + +[submit]: http://groups.google.com/group/comedi_list/browse_thread/thread/cc2141e7cf23e7ca/ +[accepted]: http://www.comedi.org/cgi-bin/viewvc.cgi/comedi/comedi/drivers/ni_mio_common.c?r1=1.343&r2=1.344 +[manual]: http://digital.ni.com/manuals.nsf/websearch/E929838D7D0EE50986256728007FEADF + +[[!tag tags/linux]] +[[!tag tags/programming]] +[[!tag tags/hardware]] -- 2.26.2