07-25-2010 09:09 PM
Hi, I'm asking here has anyone had any experience working with the AI MOTOR-701?
I'm new to programming and I'm currenty working on converting a C program header for control of the motor mentioned above into LabVIEW and I've ran into some problem. See, the motor, according to the C program, receive hexadecimal code for control.
I've translated part of the the C program ( only the Rotate and SendOperaCommand function, the SendOperCommand is a subVI within the VI. According to my supervisor the rest aren't neccesary to be converted ) into a LabVIEW vi. with the same command, sending out the same hexadecimal codes however the motor isn't responding. The original C program and the LabVIEW version I've converted are attached to this post.
Can someone look at the program and let me know whether I've made a mistake converting the program or maybe the rest of the program are neccesary to be converted or maybe it's something I don't know about?
Solved! Go to Solution.
07-25-2010 11:34 PM - edited 07-25-2010 11:36 PM
You should be using VISA functions rather than the obsolete serial port functions that you have in there.
Also, there are a lot of Rube Goldberg constructs in working with the bytes. Coercion dots due to incorrect datatype. Your subVI is not present, but is just seems to be taking the two bytes, adding the header and checksum. But without it, I can't tell if it is doing what it is supposed to, because all of your code prior to that is converting to hexadecimal strings, rather than working with the bytes directly. Also, the boolean functions work directly on numeric values. No need to convert to boolean arrays and back.
The attached snippet should be doing the same thing your C code is doing (I have no means of testing it), but with much less code.
07-26-2010 03:23 AM
Thanks for replying my post 🙂 I'm quite new to programming and LabVIEW and I didn't know that boolean functions work on numerical values.
I forgot to mention that I'm using a touch panel to control the Motor thus I usually convert the VIs into builds and transfer them to the touch panel to work. Somehow the VISA you suggested dosen't seem to work with the touch panel. It didn't transmit anything when I tested the output pin with an oscilloscope. It just showed 5 volts.Also my supervisor just confirmed to me that the VISA isn't the problem.
My previous solutions has signals but the motor didn't run. As did the solution you offered when transmitting using the original serial port function.
The subVI is attached to this reply if you'd like to help out again. In the mean time I'll keep trying different combinations.:)
07-26-2010 12:30 PM - edited 07-26-2010 12:31 PM
Your use of strings is incorrect. There is a big difference when you enter (for example), an ASCII 'FF' and a single byte in hex of FF. Right click on your concantanated string and select Hex Display. See how you are not sending the correctly formatted datat. Just avoid using strings at all and use the correct numeric representation. Here is an example that uses U8 controls and the Numerc Array to String - just like the above example.
07-26-2010 08:36 PM
thanks for replying my post:)
the issue of the hex display was solved...it's displaying the correct codes in hex display. However my string constants dosen't have the small cross beside it...I assigned the representation to be unsigned byte and display to be hexadecimal. Is that configuration suitable for a motor that takes in hex codes for control?
07-26-2010 10:22 PM
The small x is a radix. You can show it by right clicking on the constant and selecting the Visible > Radix property. It is there to make it obvious that the constant is in hex. You'd get a "d" for decimal, "b" for binary, and an "o" if it was octal.
07-27-2010 05:00 AM
Thank you all very much for helping out guys. The motor works now. Though I corrected the program like you guys suggested turns out BOTH the motors I was testing of had problems in them.