LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with motor control

Hello, I am a first time LabVIEW user and barely started this week. I been having issue creating this code for a motor. The motor must spin clockwise and counterclockwise. The issue I been having is the question presented, " if the user were to change the voltage, (from counterclockwise to clockwise or vise versa) would the motor crash as the sudden change of voltage would be too fast for the motor?" My task has been to make a program that will cause the motor to go clockwise and countrclockwise, ( my teammate suggest we should decrease the voltage by 0.5 to change into the different speed?) and to also time how fast the motor can generate one rotation around the field we are placing it in.

Attached to the bottom is a code given to us, the first code is not the best as we do not need half of the code for the motor. And the second code is what I have been working on.

Download All
0 Kudos
Message 1 of 14
(256 Views)

A hint for getting much more help is to back save your VI for older LabVIEW versions since very few of us have 2024 installed.

 

File > Save for Previous Version...  Choose 18.0.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 2 of 14
(235 Views)

One more thing.  It's always a good idea to tell us what hardware you are using.  

 

If it's a DAQ card or other external hardware, tell us the model and how it's wired up.  A simple diagram always helps. 😉

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 3 of 14
(234 Views)

Hello NIquist, thank you so much for your feed back and from my understanding I am using a DAQ by national Instruments, that I found in the lab I am currently at. I will send photos, and I hope it will help. Please let me know if it doesn't I can also try to figure it out further with the person who may have purchased it.

USB-6346

Item details
Supported Power Input: -
Maximum Number of Single-Ended Analog Input Channels: 0
Analog Input Resolution: 16 bits
Maximum Sample Rate: 500 kS/s/ch
Number of Analog Output Channels: 2
Maximum Update Rate: 900 kS/s
Bus Connector: USB 2.0
Number of Counters/Timers: 4
Number of Bidirectional Digital Channels: 24
Analog Input FIFO Buffer Size: 4095 samples
Maximum Number of Differential Analog Input Channels: 8
Simultaneous Sampling: Yes
Analog Input Absolute Accuracy: 3225 μV
Analog Input Isolation: -
Enclosed: Yes

 

and its connected to a Electro-Craft Max-100 115V PWM SERVO DRIVE P/N 9078-0121 B

IMG_2585.jpg

IMG_2586(1).jpg

0 Kudos
Message 4 of 14
(224 Views)

I am so sorry, the LabVIEW software I am currently using is provided in the lab I am currently working at. But I will take this into consideration as well, and may as a friend if I can use their older LabVIEW software to reprogram 🙂

0 Kudos
Message 5 of 14
(219 Views)

You don't have to "use other software" to save your LabVIEW 2024 code in a "previous version".  Here's how to do this:

  1. Open your version of LabVIEW (which I assume is LabVIEW 2024).
  2. Now open your VI (LabVIEW code) so that you can see its Front Panel and Block Diagram.
  3. Go to the "File" menu (near the upper right corner) and choose "Save for Previous Version".  It will offer you a choice of Versions -- I believe 2018 was suggested.

LabVIEW has a "version" problem.  In a text language, like C++, Python, or Matlab, the code is in a "speaking" language (often English, French, or Chinese).  LabVIEW, however, is "written in Pictures", and the "Pictures" contain the code in mysterious ways.  LabVIEW 2024 "knows" how LabVIEW 2018 "encoded this picture" (because it can "see how it was done 6 years ago"), but LabVIEW 2018 cannot read LabVIEW 2024 code because it (unfortunately) cannot (yet) "predict how NI will encode it six years later".

 

Bob Schor

0 Kudos
Message 6 of 14
(177 Views)

Thank you so much for the input! I will attached the new file below, I been working on it and made some improvements but I am a bit uncertain of it still :,)

I also ran into the issue of an error that mentions:

 

Jane_42_1-1718206613600.png

 

0 Kudos
Message 7 of 14
(141 Views)

@Jane_42 wrote:

Thank you so much for the input! I will attached the new file below, I been working on it and made some improvements but I am a bit uncertain of it still :,)

I also ran into the issue of an error that mentions:

 

Jane_42_1-1718206613600.png

 


This message is saying that you are trying to do something with a serial port but you didn't give it a usable serial port reference.  It could be that you only have COM1 and COM2 on your PC and you are telling it to initialize COM3, or it could be that you're passing it a blank reference or some other unusable string that isn't a COM or ASRL reference at all.

Message 8 of 14
(125 Views)

Kyle97330 is correct.  I can run your code fine with my USB DAQ, but I don't have an Arduino connected or your hardware, so I only see the motor speed voltage change.

 

If I change my COM port from COM1 (which I have), to COM2 (which I don't have), I get the exact same error you posted.

 

Are you using a USB to Serial converter perhaps?  Maybe you need to install drivers?

 

You can check your COM ports with NI-MAX under Devices and Interfaces.  Make sure it's working before you run your VI...

NIquist_0-1718221114802.png

 

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 9 of 14
(113 Views)

A little hint.  When you want to select options like CW, CCW, STOP, etc. that should only run one at a time, use an ENUM control with a case structure.  This code does the same thing as all your buttons and local variables 😝 and you can't choose two commands at once.  You can also use the radio button control if you prefer buttons. 

NIquist_0-1718221787554.png

NIquist_1-1718221873710.png

 

 

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
0 Kudos
Message 10 of 14
(110 Views)