Recommended Posts

A digital input read is not working the way I was expecting.

I'm using a LabJack U3-LV. Pin CIO4 (channel # 19) is configured as a digital input. In DAQFactory, I have this channel configured as a digital input and named. In the channel tabs, under 'Table' and 'Graph' it is behaving correclty. The value is 1 when the line is pulled high and the value is 0 when the line is pulled low.

However, whenever I try to get the state of this line in a sequence or even in the command window, it is always 0.

The way I am trying to check the state of this digital line is as follows:

if(NEStop_Pressed == 0)

beginseq(LoopAlarm)//If the E-stop button was pressed, begin the loop alarm sequence

endif

(Crital operation on an EStop press occure at a hardware level and DAQFactory actually looses control of my system. I just want it to loop an alarm sound when/if the EStop is pressed.)

Link to comment
Share on other sites

I can't say for sure without seeing your .ctl document, but you definitely want a [0] after the channel name:

if (NEStop_Pressed[0] == 0)

Make sure you don't have a global variable or other resource named NEStop_Pressed.

Glad to hear you have a hardware e-stop and aren't using DAQFactory (or any other software) to handle your safety systems!

Link to comment
Share on other sites

  • 8 years later...

Hello.  I am having a similar problem.  What I am attempting to do is to use a contact closure and confirm that a device has actuated.  I have wired it so that the DI is the current source, through the contact to the ground.  This tests out correctly (switches the I/O) using the LJ test function so I believe that my channels are configured properly.  However, DF does not seem to be reading the signal.

The other (but related) problem I am having is that the LED device works differently than I think it should.  Again, my intent is that the LED goes on when the contact closes.  Please advise where I am going wrong.  The email I sent to support (no response yet) is attached.

 

Lab5 - RVET Simulation.ctl

VACT1194 F2021 SG7-RVET Elementary.pdf

Link to comment
Share on other sites

I'm sorry but we never received the email, so I am glad you followed up here.  The issue with the LED component is that you are using a single = sign.  This is "assignment" and used to assign a value to variable/channel.  For comparison, you need two equal signs: 

CR1[0] == 1  

(FYI: This matches up with most other programming languages in that assignment and comparison are two different operators.  The double = matches up with many of the more common ones, such as Javascript and C.)

You also want [0] so it only compares the most recent value.  CR1[] is the same as just CR1, which gives the entire history of CR1.

As to the LJ side, there are a number of possibilities, including lack of pull-up/down resistor, wrong input, wrong LabJack, and improper input configuration.  I'm going to assume that the resistor is not the issue since you say it works in the LabJack software.  I doubt you have the wrong input.  You should be in FIO6 and 7.  You are using D# 0 which means first found, and I suggest instead specifying the exact LabJack ID.  This ensures that you are connecting to the LabJack you think you are if you ever plug in multiple LabJacks.  Which leaves input configuration.  For this I recommend contacting LabJack.  DAQFactory largely wraps LabJack's UD driver.  It does a few things automatically, such as ensure the input type is correct based on the I/O type, but it does little else so as to give you access to all the flexibility the LabJack has to offer.  It is possible, though I am not sure what, that the LabJack software is sending a configuration command that DAQFactory is not.  Again, LabJack would likely have the answer.

BTW: you can start by testing the input with a jumper.  Disconnect your circuit, then wire a jumper into your input.  Attach it to ground and the channel in DAQFactory should read 0.  Attach it to Vref and it should show 1.  If it does, then you have eliminated the "wrong input" and "wrong LabJack" options.

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
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.