From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timed while loop with LINX

Solved!
Go to solution

Is there anyway to make a digital read only output true if the signal is true for a certain amount a time, while still looping? I am trying to make it so a sensor reads non-stop and once it reads true for a certain amount of time it will output true. The issue is that the sensor will read true for a very short time randomly throughout the entire code, but if the sensor reads for too long I need the entire code to stop.

 

Thanks, 

 

Guy who started using labVIEW 3 weeks ago and is sucked in

0 Kudos
Message 1 of 12
(1,163 Views)

A chattering Digital Input is a hardware problem and should not be obscured by a software workaround. 

 

Tell us more about the system.


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 12
(1,144 Views)

Basically it is a sorting system that drops an item into a bin, but if it doesn't fall all the way into the bin and gets stuck, the sensor is there to notice it. The sensor is triggered even when the item passes by but I want it to stop the entire code if the sensor is triggered for longer than a second. I am using this in parallel with the main code, I thought of using a timed sequence but the issue is I don't want it to wait everytime the while loop loops, I would rather it read true for a certain amount of time then output true if possible.

 

Thanks for the help, if more details are needed I can upload the code as well, it is just not finished yet.

 

 

0 Kudos
Message 3 of 12
(1,141 Views)
Solution
Accepted by MaccoTaco

I'll try to advise you now and if you need help implementing it you will need to post some code .

 

Your DIN is doing two things.

  • Incrementing the count of items dropped when it changes value from FALSE to TRUE 
  • Incrementing the number of items in the bin when it changes from TRUE to FALSE

So, if the next reading after any TRUE transition is still TRUE you need to increment a 2nd counter by the time between readings.  If the 2nd counter becomes larger than a specific time you need to pause the program and report something like "Error! An Object is stuck in the drop shoot!  Safely Clear the Obstruction."

 

If the Reading ever becomes FALSE  reset the 2nd counter.

 

Then redesign the shoot or lube with suitable materials.   You DO have a hardware problem!


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 12
(1,130 Views)

My question is basically the subject, I am creating a sorting machine and it will do almost all of the first iteration of the while loop, but for some reason my digital write square wave statements are not fully working. The first loop they all but 1 work perfectly, but then the second loop they do not work at all, none of them do for some reason. Just wondering if this is common or if there is a fix for it. If possible I would also like to know if there is anyway for me to fix the one digital write square wave statement that will not work on the first iteration. I have all the pins correct and the time set as well as the frequency but it will not write. Is it possible that a regular digital write statement might be messing with it?

 

Thanks,

MaccoTaco

0 Kudos
Message 5 of 12
(1,075 Views)

Hi Macco,

 

I merged your threads because of the very related questions…

 

Until now you failed in attaching some/all of your code.

How should we answer questions on problems with your code when you refuse to attach that code?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 12
(1,066 Views)

Sorry about that I thought I attached the code. I am having the error in the main while loop, "Move back to middle" will not work at all, "Reset Motors" and "Release probes and record data" work but not after the first iteration.

 

Thanks for all the help I really appreciate it

 

0 Kudos
Message 7 of 12
(1,061 Views)

Hi Macco,

 

please attach your VI again after converting to an older version of LabVIEW. Not all of us are already using LV2021…

(File->Save for previous)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 8 of 12
(1,058 Views)

Sorry again, hopefully this is the correct version. Still kind of new to this.

0 Kudos
Message 9 of 12
(1,049 Views)

Hi Macco,

 


@MaccoTaco wrote:

Sorry again, hopefully this is the correct version.


Nope, still LV2021. You just changed the filename…

 

File->Save for previous. Select "LV2020" or "LV2019", then save the file. Attach this newly saved file…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 10 of 12
(1,031 Views)