LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sensor Reading And time delay

Highlighted

Hello everyone, I am Using an ultrasonic sensor to make a limitation on a pneumatic Double Acting Cylinder.

Example: When i am closing the cylinder .. I want it to not Completely get Closed but Stop before the end when the ultrasonic reads 5 cm.

The Cylinder takes about 3 Seconds to get fully closed .. So i need the reading from the sensor  to be repeated and renewed every millisecond to stop  the closing when reads 5 cm.

I have done a VI
but i have problem
I can't put a delay in the system to make the cylinder takes its time to close because it makes the sensor reads every "delay time" Second.

I hope anyone can help me with this problem

 

0 Kudos
Message 1 of 4
(584 Views)

When you set the cylinder digital output to True, does it take 3 seconds to close after that point?

 

You will be able to read the sensor much faster if you take the digital write functions outside the loop, you do not need to update them every loop right? Just put a while loop around the "read" function and stop the loop when the distance passes your threshold. However, reading it every 1 ms may not be possible. After all, the Wait (ms) function only has a resolution of 1ms. If you are ok with some jitter you can just try to read it as fast as possible, but you may need a more real-time system if your requirements are precise.



CLA // LabVIEW 2016 // BALUG // Unofficial Forum Rules and Guidelines
0 Kudos
Message 2 of 4
(576 Views)

In this case, I would update the Arduino sketch to handle the stopping of the cylinder.  You can just send a command to it to start the closing process and you can get updates, but the Arduino handles all the DIO on its own.  You will get much more consistent results.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 3 of 4
(565 Views)

I agree with crossrulz, if you can do it on the hardware, do it on the hardware. Especially if there is any kind of safety involved. But looking back at the picture you posted I don't see how that code ever reads the sensor more than once. It looks to me like it just takes a reading and if it's closer than 5 cm set a signal to 0. Seems like there should be a while loop in there.

0 Kudos
Message 4 of 4
(539 Views)