LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

The conversion of rectangle dimensions

My program consists of a picture box containing repeating vertical black rectangles to form an alternating black and white rectangular pattern. The user can change the width of the black rectangles (which also changes the width of the seperating white rectangles). I have used input values ranging from 20 to 100. Does anyone know what units accompany these values? Perhaps pixels??
The program is attached, the part of the program dealing with the drawing of the rectangles is on the first frame (frame 0) of the program.
 
Thank you!!
0 Kudos
Message 1 of 6
(3,055 Views)

The units are picture control coordinates which by default are equal to pixels. This can be changed by changing the Zoom property of the picture indicator.

A quick look shows some other problems in your code. For example:

  • Why are you using strings to do the input? Why not use numeric controls?
  • Stacked sequence structure are often a sign that you would want to rethink the structure of your program.
  • There is no way to stop this in mid execution.
  • There is no error handling for the DAQ.

To learn more about LabVIEW, I suggest you try searching this site and google for LabVIEW tutorials. Here, here, here and here are a few you can start with and here are some tutorial videos. You can also contact your local NI office and join one of their courses.
In addition, I suggest you read the LabVIEW style guide and the LabVIEW user manual (Help>>Search the LabVIEW Bookshelf).


___________________
Try to take over the world!
0 Kudos
Message 2 of 6
(3,049 Views)
In addition to tst's comments you may want to pre-calculate how many bars will fit into your picture control. The Draw Rect.vi has I16 inputs which mean a maximum range of -32767 to 32768 for the coordinates. (Notice the coercion dot at the input?) With the values you have mentioned the coordinates will overflow more than once, possibly producing unexpected results. For the simple mathematics you are using the math primitives make diagrams much easier to read than the Formula Express VIs. In the next to last frame you are using -1^i>0 to toggle the motion. A shift register carrying a boolean and a Not function is a much cleaner way. Use of a Case structure would mean you only need to do the calculation you will be using rahter than all the calculations and a selector for the final value. In this application it really does not make much difference, but the alternative technique would be much better if you were doing lengthy or time concsuming calculations in each loop. Look at the example I posted to one of your earlier questions for some code.

Lynn
0 Kudos
Message 3 of 6
(3,037 Views)
The units of the picture control are pixels. But the zoom property modifies this. If zoom is .5, then it specifies half pixels.


If you want to convert pixels to real dimensions (inch, cm, etc.) look into TWIPS. It won't be easy though. See http://forums.ni.com/ni/board/message?board.id=170&message.id=48244&requireLogin=False for some discussion about it.


Regards,


Wiebe.



"chip007" <x@no.email> wrote in message news:1152709807985-390224@exchange.ni.com...
My program consists of a picture box containing repeating vertical black rectangles to form an alternating black and white rectangular pattern. The user can change the width of the black rectangles (which also changes the width of the seperating white rectangles). I have used input values ranging from 20 to 100. Does anyone know what units accompany these values? Perhaps pixels??
The program is attached, the part of the program dealing with the drawing of the rectangles is on the first frame (frame 0) of the program.
&nbsp;
Thank you!!



final vert rect.vi:
http://forums.ni.com/attachments/ni/170/194900/1/final vert rect.vi
0 Kudos
Message 4 of 6
(3,034 Views)

How exactly do I change the zoom property? (Right click on the icon, etc...)

Thanks!

 

0 Kudos
Message 5 of 6
(3,032 Views)
It's a control property.
Right click on the terminal in the block diagram, Create->Property, then click on the property name and choose Zoom Factor.
Right click on the property and choose Change to Write.
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 6 of 6
(3,027 Views)