LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stuck trying to communicate with a stepper+controller via Serial port

Hi! I have been trying to communicate with a stepper attached to a controller using the serial port. I am able to see the COM port in the NI Max but I can't seem to get anything done with the motor.

 

I am using a non-NI RS-232 to USB: Ugreen which has a Prolific PL2303GT chipset but it seems to working fine and is detected both by Windows and NI_MAX

 

Maybe, I am writing the commands wrongly. The controller accepts ASCII commands in the order: Command, argument, carriage return. So, if I know a command F to move stepper forward 64000 microsteps then F64000\r should work, isn't it? I tried using the Example program for Continuous Write and Read and also in the VISA Test panel, but still no movement.

Somehow it doesn't work for me. Most of the other settings in the VISA test panel seem default. Any help would be appreciated! Any things that I need to lookout for maybe? Peace!

0 Kudos
Message 1 of 7
(1,696 Views)

Need more information.  Can you share the code you are currently trying?  And what controller are you trying to talk to?  I'm specifically looking for the command protocol and verifying you are setting up correctly.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 2 of 7
(1,689 Views)

Hi! Yes I can attach my vi.

 

The controller I am using is an old controller for stepper motors. I don't really have a manual for it, but there is a manual for the microcontroller present inside it. It also lists out all the various commands that it can understand.

 

I also tried sending commands to the stepper via the Basic continuous read and write vi, but still nothing happened. I am afraid I am making some error in the way of inputting the commands. I also tried writing commands in the VI test panel window but the same result.

 

 

Download All
0 Kudos
Message 3 of 7
(1,653 Views)

The documentation clearly states that the command structure is Command,Argument,Carriage Return.  You were doing Argument,Command.  What I would do is use Format Into String to build up the command.  This easily allows for formatting the argument and adding the Carriage Return.

 

Also, make sure you are wiring your reference and error wire through every case in the Event Structure.  You are dropping your reference if you don't.



There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
0 Kudos
Message 4 of 7
(1,639 Views)

Hi! Thanks for the correction. I also realized it, later on.

 

There are still a few things I'd like your help on:-

  1. I think maybe the error could be in inputting the commands. Could you please give some feedback if my way of interpreting the commands is correct?
    For example as per the format (Command, argument, carriage return) to move forward 10000 steps (due to microstepping).

    The command should be: F10000\r  ?

    Is that a correct understanding?

  2. The program still doesn't make the stepper move. Is there a way to know if at all my PC is able to recognize the controller and the Stepper. I can see the COM port in the MAX devices list but couldn't see anything happening when I tried testing it with VISA Test Panel. Are there some standard commands for VISA that I could use to know if the stepper if at all is connected and recognized by the PC?

  3. In the modified vi, my Emergency switch doesn't seem to work. I wanted to stop the loop when I press the Boolean button in the front panel. Is there some mistake in that? My LabVIEW experience has grown day-by-day but sometimes I still run into troubles.

 

I am attaching the Microcontroller manual once again for your reference. It would be very helpful if you could take a look and confirm if I am right or am making some errors.

I have been stuck with this for more than a week and its a crucial part of my project.

Thanks again!

Download All
0 Kudos
Message 5 of 7
(1,624 Views)

@SS23 wrote:

 

I am using a non-NI RS-232 to USB: Ugreen which has a Prolific PL2303GT chipset but it seems to working fine and is detected both by Windows and NI_MAX

 


Hmmm... Prolific chipset serial adaptors are known to be flakey at best, and were victims of massive counterfeiting up until a few year ago. This has caused Prolific to release drivers that can detect a counterfeit chipset and just not work if it thinks if found one. There is no indication that it found a counterfeit, it just does not work. This has caused me to avoid Prolific at all costs.

 

But that being said. Have you tried communicating with your stepper using a standard serial terminal program like TeraTerm?

 

I generally try this first before I start coding LabVIEW to get a good handle on the command structure and serial port settings.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 7
(1,609 Views)

The manual you attached has some specific information about the Baud Rate on page 4 (and by specific, I mean unusual, I guess...).

Depending on the BR1 and BR0 pins that you have, and also the specific device, it might be your baud rate is too high (LabVIEW defaults to 9600, which is only valid for 1/8 of the configurations listed).

However, it sounds like this is only maybe the manual in question, so perhaps there are other components compensating for this in the collection of unknown hardware you have?

 

I'd suggest trying some different Baud Rates (you can set this at the VISA Configure Serial Port call) from that table, or if you can find the BR1 and BR0 pins, establishing what this manual thinks the rate should be.

 

If that doesn't work, could you perhaps upload a photograph of what you're talking about and the wiring (ideally with any labels visible). If not, it's fine, but we might see something that hints at a problem (or not, but worth a shot if baud rate doesn't work out).


GCentral
0 Kudos
Message 7 of 7
(1,588 Views)