My control loop is working well using the idioms for AO on
demand output from aoex2.cpp and AI continuous acquisition from
aiex1.cpp. However the interrupt follows the LXRT extension to RTAI
example for processor generated periodic interrupts using
start_rt_timer(period_);
rt_make_hard_real_time();
nrn_fake_step(); // get as much as possible into the cache
// saves up to 10 us on the first step
rt_task_make_periodic(rtrun_task_, rt_get_time() + period_, period_);
rt_task_wait_period();
while (t < tstop_) {
t1 = rt_get_cpu_time_ns();
nrn_fixed_step(); // start ai scan, compute, ai read, ao write
nrn_rtstep_time_ = (double)(rt_get_cpu_time_ns() - t1);
ovrn += rt_task_wait_period();
if (stoprun) { break; }
}
rt_make_soft_real_time();
stop_rt_timer();
Now I'd like to have the 6229 generate the interrupt and I wonder if
anyone can give advice on how to carry out the transformation. There
was some mention about using the FIFO condition interrupt or the scan
clock interrupt and there are some intriguing lines in
http://forums.ni.com/ni/board/message?board.id=90&message.id=287&query.id=4559#M287
but I have to admit to being somewhat at a loss as to how this connects
to the rtai api. The only thing I've found that is remotely analogous is
http://www.captain.at/programming/rtai/parportintlxrt-magma2.php
that gives an example using things like rt_request_irq_task,
rt_startup_irq, rt_enable_irq, rt_irq_wait, rt_ack_irq,... Is that the
avenue I should explore?
I should mention that my experiments with AO on demand and AI hardware
time acquisition from aiex2.cpp also worked nicely and I expect to use
that idiom after I get this interrupt driven. However I was unable to
get the AO hardware timed generation from aiex4.cpp to work hardly at
all. Sometimes it hung in aoArm at
while (board->Joint_Status_2.readAO_TMRDACWRs_In_Progress_St ())
{
// Wait
}
and could only get it going again by running the aoex4 example itself,
More often no output I was writing appeared at the BNC connector, and
when I did see output it was delayed by a dozen or so steps. Obviously
I do not know how to manage the fifo. The serious conceptual error,
though, was using kCDO_Update_Source_SelectAI_Convert to toggle P0.0
and then connecting that to AI CONV CLK and using
kAO_START1_SelectAI_START_1 for the trigger and
kAO_UPDATE_Source_SelectPFI2 for the aoUpdate. The problem is that the
rising edge is every two steps so my output is half the rate I want.
Sorry for the long message and my glaring naivety. I suspect that a few
minutes from someone with experience will save days of my flailing
around.
Thanks!
Michael