LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Communication (COM-port) via Sb Rio9636

Solved!
Go to solution

Hi all,

 

I have been working on a project which needs the actuation of a stepper motor. This was done by using the analog outputs on the Sb Rio9636 in the FPGA module of LabVIEW. Recently, I have been given a new (faster) stepper motor, which unfortunately works with serial commands (ASCII). I have no idea about how I can use any of the COM-ports on the RIO to communicate with my stepper motor as I have no experience with serial communication in LabVIEW whatsoever.. 

Any help or examples about serial communication would be greatly appreciated. 

Thanks in advance,

Oliver

0 Kudos
Message 1 of 8
(3,903 Views)

Serial communication in LabVIEW requires VISA drivers and functions. Make sure that VISA drivers are installed on the Sb RIO.

There are enough examples about VISA in LabVIEW (and plenty of posts in this forum), just take a look at them.

Writing data with VISA is quite trivial; while reading, pay a special attention to the termination character specified in the motor protocol specification. It's very likely that a term character is defined, e.g. 0x0A = LF (Line Feed) or 0x0D = CR (Carriage Return).

You should configure VISA (VISA Configure Serial Port.vi) in such a way to stop reading when receiving the termination character. With the same vi, select a proper timeout to wait for the motor answer. Calling the VISA Read.vi, input a byte count (number of characters to read) greater than the maximum expected answer length.

I'm assuming here that the motor features its own proprietary protocol. On the other hand, if the protocol is serial Modbus, there are dedicated sets of vi's, built on top of VISA, to configure, read and write.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 2 of 8
(3,879 Views)

Thank you for your response!

I've found some useful information about VISA drivers on the web! 

In attachment you can see a screenshot of the program I have written so far ("writeonrio"). I expect to write a command (eg. "+") to the COM1-port on my sb RIO 9636. The motorized microdrive (steppermotor) I'm using should interpret this command and subsequently take one step forward (see ASCII commands in attachment). 

However, this is not what happens.. Do you have any idea why my stepper motor doesn't respond to this input? 

Thanks in advance,

Oliver

Download All
0 Kudos
Message 3 of 8
(3,854 Views)

Thank you for your response!

I've found some useful information about VISA drivers on the web! 

In attachment you can see a screenshot of the program I have written so far ("writeonrio"). I expect to write a command (eg. "+") to the COM1-port on my sb RIO 9636. The motorized microdrive (steppermotor) I'm using should interpret this command and subsequently take one step forward (see ASCII commands in attachment). 

However, this is not what happens.. Do you have any idea why my stepper motor doesn't respond to this input? 

Thanks in advance,

Oliver

0 Kudos
Message 4 of 8
(3,839 Views)

Well, the command documentation is only a summary. Are you sure that commands don't need to be terminated by a given character?

Second, the doc says 19200 baud, why are you setting 9600?

Third, what the motor is expected to answer? Is the answer terminated by LF (dec 10)  as you enabled? You don't let the motor the time to respond, you are reading immediately. Don't use Bytes at Port, input a large number (say 100) and set a lower timeout (say 1000 ms instead of 10000).

The only character read seems to be only an echo of the output: this is expected behaviour on some RS485 ports but it's quite odd on a RS232.

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 5 of 8
(3,845 Views)

Thanks again! I changed the baud-rate to 19200 and replaced the Bytes at Port with an integer constant. 

I have no real experience with serial communication between the board and the motor. The motor I previously used required analog inputs, so this all very new to me.. 

I expect the "+"-command to be read at the serial port (COM1) of the sb9636. In this port a cable is connecting the board with the motor (see picture), so I figure the motor should then "read" the command and execute it (take a step) but nothing happens. Is this not a correct assumption according to you? 

 

0 Kudos
Message 6 of 8
(3,840 Views)
Solution
Accepted by Oliver.Cautereels

It's correct, more or less. However, if nothing happens, the motor did not catch the command properly.

As I said before, usually ASCII commands are terminated with a carriage return, a line feed or a combination of the two charactesr.

If you don't have a detailed documentation of the protocol (strongly recommended to find it), you may try to concatenate to your command, as a termination, either a CR or a LF or both (CR then LF). Those constants can be found on the String palette.

 

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
0 Kudos
Message 7 of 8
(3,832 Views)

Thank you very much!! I added the carriage return command in labVIEW and now everything works fine. Thank you for your help! 

0 Kudos
Message 8 of 8
(3,823 Views)