06-26-2020 11:59 AM
Hello! I am very new to LabVIEW and not much of a coding expert in general but I am trying to write a program that allows me to control the motion of a stepper motor. The motor moves along the y and the x axis and I have four Booleans (configured like on a keyboard) that indicate which direction the motor should go in. I was hoping to use an event structure within a while loop in my program, with different event cases for each direction. My dilemma is that I'm not actually sure what to put in the event case to indicate what direction the motor should be going in. Any advice would be great!
Thank you
06-26-2020 12:14 PM - edited 06-26-2020 12:15 PM
@Mk.2020 wrote:
My dilemma is that I'm not actually sure what to put in the event case to indicate what direction the motor should be going in.
The direction will uniquely depend on which boolean is pressed. As a first step, try to create a simple simulation e.g. moving a point on a fixed axis xygraph. Once that works, implement the hardware interface. What kind of stepper drivers do you have? What is your LabVIEW version?
What have you done so far? Do you have the front panel with the four buttons? Did you decide on a mechanical action for the buttons? Did you add a stop button too? Should it go in one direction while the button is held down? What should happen once it reaches the edge?
06-26-2020 12:45 PM
I am actually doing a research project where I am interfacing the moving parts of a Laue Diffractometer with the computer. So i am writing a program to control the direction of the motor so it can be done remotely instead of in the lab with a joystick. the motor is a 6 axis DC stepper motor by Multiwire. This link has all the parts that I'm working with for reference.
http://multiwire.com/products/accessories/
To answer your other questions:
Yes, i have the four buttons, they are all set to latch until release. I want the motor to move while the buttons are held down and then stop when the button is released. The steps should all be a specific size and speed (that I have come up with already).
06-26-2020 01:09 PM
It is difficult to tell what is giving you problems. Did you do all the basic tutorials?
Here's a quick draft that might give you some ideas. There are many ways to do that.
06-27-2020 10:11 AM
The action you are describing for your Button, "True while being held down, False when released" is "Switch until released", diagrammed on the Front Panel as a Push-button. "Latch until Released" is very different, and is meant for things like the "Stop" or "OK" (subtly diagrammed on the Boolean Palette as rectangular buttons) -- their value does not change when you push it (it is "Latched"), but changes when ("until") you release it. But Wait, there's More -- when you subsequently read the value of the button in LabVIEW, the button's value resets to the Default setting (typically False). It is "almost" like a Push Button, but serves a very different purpose (think about it, ask a colleague, read a book, and try to understand why you would want such an "interesting" action for a Boolean Button).
Bob Schor
06-27-2020 10:56 AM
@Mk.2020 wrote:
To answer your other questions:
Yes, i have the four buttons, they are all set to latch until release. I want the motor to move while the buttons are held down and then stop when the button is released. The steps should all be a specific size and speed (that I have come up with already).
Yes, as Bob said, make sure you get the terminology right. Also note that if you use "value changed" events for such buttons, you get exactly two events. One event on pressing and another event on release, (and nothing in-between!) This means you you need to do the actual stepping in the timeout case or some consumer loop. Polling buttons is cheap and makes things easier, as you can see in my earlier example.
07-10-2020 02:20 PM - edited 07-10-2020 02:21 PM
Hi again, Thank you all for your responses they were extremely helpful for me. Since i posted this I have moved on to making a 3D simulation where I am able to move my cube around each axis and translate the box left/right and up/down. My problem now, which might be kind of silly, is that my axes are in a position that I would like to change but don't know how. Currently the z axes is pointing towards the viewer and the y axis is point upwards and the x axis is pointing right. I would like to change them so that the z axis is pointing upwards. Like this:
Is there a way I can reorient my axes to look like this? Thanks!
I have attached a copy of my code.