LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programatically generated boolean in loops

Billko, Yes i have noticed the highlight execution gives me inconsistent results as it waits for hardware responses and the code is slowed down so doesnt function correctly. But with other parts of the code was usefull a couple of times.

 

Nathand, Yes i use the Run Continuously button. The original part of the code was supplied with the hardware and i was trying to work with it. I didnt know pressing Run Continuously wasnt the norm. I am currently trying to strip down the original VI and try to use it in a loop.

 

If anyone fancies a laugh i included a recent VI which appears to do initially what i wanted for a test. But given my basic (only two weeks) knowladge of labview you will find it very funny looking at my "bodge together" basic code. The more i use it the more i learn. People hear are giving me good advice.

 

Just a bit of background to help anyone chukkle more: I created an encoder on a pan and tilt head with four quadrants (slits on an encoder wheel) The motor is a controlled stepper motor so i know its precise rate of turn. But for calibration i wanted to know which quarter it was facing: 0 Degrees (4 slits/digital pulses) 90 Degrees (3 slits/digital pulses) etc So the bellow VI does this for me. The next thing i want to do is take the information about direction and make an event structure (or something) that will then read the sensor inputs and act upon it.

 

Added a picture of the scanning head and a VI in Version 10. Hardware is what im good at, programming not so much!

 

Cheers Rich

Download All
0 Kudos
Message 21 of 31
(787 Views)

Does that version of the program work?

 

What's the difference between that version and the one you showed previously that doesn't work?

 

In that first version, you didn't have the output from the cluster wired to your loop.  I'd like to see what your program looks like when you connect the output from your .dll into the loop.

0 Kudos
Message 22 of 31
(777 Views)

Yes somehow when i go thought the "count pulses thought encoder" case select i made which then take the tick count and do a comparison and output a boolean into the wait timer all works well.

 

But it is impossible to wire my boolean from cluster directly to the timer. THIS I CANT understand. Hence i was talking about boolean action.

 

I have included a VI to demonstrate what i initially wanted, i cant understand! I left the code in for illustration only. Boolean i agree is boolean but why doesnt this work! This applied to about 15 other sample loops too so again the loop is not the problem...

 

Annoying or what im sure its amazingly simple.

 

 

0 Kudos
Message 23 of 31
(771 Views)

RobotLabviewTest wrote:

Nathand, Yes i use the Run Continuously button. The original part of the code was supplied with the hardware and i was trying to work with it. I didnt know pressing Run Continuously wasnt the norm. I am currently trying to strip down the original VI and try to use it in a loop.


I don't know what the sample code looked like, but I've found that LabVIEW code provided with hardware is rarely an example of good LabVIEW style.  Often it appears that the people who put together sample code in text-based languages were told "make a LabVIEW example too" and they do it exactly the way they would in a text-based language which is often completely wrong for LabVIEW (use of sequence structures for example).

 

You should restructure your code completely.  Right now your "delay" loops don't delay at all - they iterate three times (the i terminal is 0, 1, 2 and then 2>1 so they stop).  The sequence structure, as previously mentioned, is unecessary.  There's also no need to open the device over and over again, which is effectively what you're doing by using run continuously.  Move all the DLL calls out of the sequence structure.  Create a while loop around most of the code (start simple here), with the OpenDevice call outside it and the other DLL calls inside.  Chain the error out from one DLL call to the error in terminal of the next so that they'll execute in that order (execution highlighting will help show how this happens if it's not clear).  The while loop should also contain a Wait (ms) function (loops that don't wait run as fast as possible in LabVIEW, slowing the response of everything else) and a Stop button so you can stop the loop (just right-click the stop terminal of the While loop and create a control).  Use the "Run" button instead of the run continuously, and use the stop button you just created to stop the loop.

0 Kudos
Message 24 of 31
(770 Views)

Can you try explaining, with no reference to LabVIEW, what it is you're trying to do?  Something to the effect of "I have a sensor on channel x.  When that value is true, I want ... to happen."

0 Kudos
Message 25 of 31
(764 Views)

Thanks, i will take everything you have said and give it all another try from the start and i think you are exactly right. This hardware has extensive code in c++, VB etc Only after lots of complaints to the hardware vendow was a template labview program created.

 

I can actually make a program in VB and make it work. I beleive however labview will be must more suitable in the long term and once i understand it, it will be much more powerfull and easier to modify. Thank you very much for your helpful advice, i will take on board what you have said and hopfully have success in recreating a new code from scratch.

 

Cheers Rich

0 Kudos
Message 26 of 31
(762 Views)

I have a robot with 250watt motors, controllers, battery monitors, extensive sensors, computer, high DB gain wireless antenna with a powerful directional Tx/Rx.

 

I have made a clockwise, anti clockwise, up and down scanning head. I want to move the motor until it facing the left. Move one increment to the right then take a 1080p photo and measure the distance an continue until i have an amount of data point of the whole room.

 

So this robot can be driven into a room and be able to provide dimentional information about is surroundings. I have done something basic but never in labview.

 

I can provide more information if you need? The robot was initially designed to partol a warehouse area and alert security if there is any one present (pyro electric sensors) and audiably ask the person to leave and contact security. The robot is a pair and when one recharged itself the other would go and carry on the work.

0 Kudos
Message 27 of 31
(759 Views)

Set output to analog to 125 (turn left)  wait for pulses to indicate success to left. When left has been reached Set analog to 155 (turn right) wait for pulses to indicate success to right. Move head up Set analog 2 (125) for .5 second restart the scan. Each step polling a sensor. I will add some picture to explain as im sure this isnt clear.

0 Kudos
Message 28 of 31
(758 Views)

I suggest you look into defining a state machine to handle what you are doing. You should first do this on paper. Basically, create the requirements for what you are trying to build. From what you described a state machine architecture would be a perfect architecture.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 29 of 31
(751 Views)
A few robotics sites suggest a state machine. I currently dont know what one is or does. I will search for some examples and see if this is useful for what I am trying to do. This is the first time I have ever written on a forum for advice and everyone seems very helpfull, all these ideas I'm sure will get me closer to a solutions. Thanks again
0 Kudos
Message 30 of 31
(746 Views)