Jump to content

Read counter on signal change of digital input - DAQmx


Wim

Recommended Posts

Hi LAVA,

I need some help.

I have a motor that moves a tray.

During the movement of the tray, 2 switches will change value.

I want to read out the counter value / motor position when the signal of the switches changes. (rising and falling edges)

At this moment the only thing I can think off is a loop vi that reads the value of the swicthes and motorposition and evaluate the swicth states... But i'd rather have the position reading triggered by the digital lines.

I'm running LV2010SP1, DAQmx 9.4

Hardware:

cDAQ chassis: 9178

NI 9401 module => encoder signals are connected to this one.

NI 9403 module=> 2 digital inputs(so the switches) are connected here.

Thanks in advance for your help.

Best regards,

Wim

Link to comment

Have a look at DAQmx Trigger, you probably want to use the Reference Digital Edge mode. You may need to have trigger lines on the same card as the counter task, but even if you're using quadrature encoders you should have a couple lines left over on the 9401.

Link to comment

Can't say I know the hardware, but I just finished an application that had to do much the same, only I was doing an SPI read rather than an counter read after a digital edge is received.

All I can say is I had zero luck with any form of digital edge detection in DAQmx (the mode where you set up an event structure to get signaled upon a digital edge transition). Everything seemed to work as no errors would ever be generated, but nothing would ever cause my blocked code to wake up. The example VI didn't work either. I'd watch the pulses go by on my scope, meanwhile the DAQmx driver was on a coffee break or something. I know the mode works though, as I have used them in the past, all I can say is there seems to be something going on where some hardware just silently refuses to work in this mode. This was on an X-series USB device for what it's worth.

I could poll the line and things would work...

Ultimately I ended up configuring the digital line as a clock source for a timed event structure and I do the read when the loop wakes up. No idea why the digital edge can be detected as a clock source but not a digital edge. Maybe it's just not...edgy enough? One of those mysteries of the NI universe I guess.

/shrug

Link to comment

All,

thanks for the help.

My customer does not allow any hardware changes at this point because it is a shared system and a polling implementation gave good results so far... so i just keep the polling method for now.

Cheers,

Wim

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.