LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Looping coordinates for microscope

Hi!

I am trying to build a microscope using the CNC shield with A4988 drivers. I would like to program the microscope to move between coordinates for time lapse experiments. At this point I can control the stepper motors with arrow keys and store the X and Y positions in an array (.vi attached), but I am struggling to use that array containing the coordinates to make a loop and move the motor between the points of interest. Please, could you help me with this?

 

Thank you so much in advance! 

0 Kudos
Message 1 of 4
(775 Views)

As a very first step you should go over the learning resource listed at the top if the forum. There are some seriously bad habits here.

 

  • Don't hide the label of terminals (stop). None of the local variables are needed. This is not text programming. (place the terminal in the lower loop and place a TRUE diagram constant in the stop event.)
  • Moving an LED around to show position is probably not the most intuitive. You can use a picture indicator or xy graph, for example. Why don't you read from the terminal instead of local variables?
  • "Position array" belongs in a shift register, not bounced via local variables.
  • You can build an array of two elements x, y using build array. (Initializing an array with the x elements and inserting the Y element later is pure rube Goldberg.
  • Your lower loops spins millions of times per second, as fast as the computer allows. Place a reasonable wait!
  • Not sure why you have three states in the lower loop.
  • Are you sure you have the correct mechanical action setting for "save position"?
  • You only need five cases. Four useful one and an empty default case. In fact, correctly done the four cases can be combined into one.
  • Why is the diagram and front panel so big, showing mostly whitespace?

I cannot run your VI because I don't have your instrument. Can you explain how it is to be used and what you expect.

Message 2 of 4
(743 Views)

See if this can give you some ideas. You should probably do the playback differently, i.e. not to "hog" the event structure, but this should get you started.

Message 3 of 4
(734 Views)

Hey, thank you so much for all the comments! I am a beginner doing labview things and it is so valuable for me to have this kind of feedback.

As you suggested to me, I will check the learning resource listed at the top of the forum.

 

About the instrument, it is supposed that the stepper motor linked to the CNC shield will move pressing arrow keys and display coordinates in the screen, when I see something interesting in the microscope I would save the coordinates. Then when I have collected some coordinates I will run loop experiments moving the stepper motor automatically to reach the different saved positions taking pictures during a certain period of time (e.g. 1 hour).

Using the microscope.vi file, I can move the stepper motor pressing arrow keys.

But I can not make the stepper motor move automatically into a loop using the saved coordinates. I mean, if the current position is X1 = 200 and Y1 = 120 and the saved position in the array is X2 = 300 and Y2 = 400, so during the loop I am expecting the stepper motor will move automatically from X1 = 200 to X2 = 300, when X position is reached, do the same with Y1 to Y2, then when X = 300 and Y = 400 do a pause, take a picture and then go to the next saved position and do the same (e.g. X3 = 270 and Y3 = 300) for a certain period of time (e.g. 1 hour). Do you have some advice to do it?

 

I used the LED and the circle as a reference just to show how it is supposed that the microscope is moving through the sample, but you are right, I will consider a visual support more intuitive.

 

Thank you so much for the Microscope_MODCA.vi file, I think I have some ideas to work with!

0 Kudos
Message 4 of 4
(676 Views)