LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading from a USB serial port

Hello everyone

 

First of all I have to say that I know almost nothing about LabView, so I would like to apologise for my ignorance.

I have to read data from an electric motor drive; these data are sent to a computer via serial port (protocol rs-422).

This is all I was able to do:Immagine.jpg

With this VI I'm reading nothing.

What I think is the problem is that I have to ask the drive to send data, but I don't know how to do that.

 

With the drive came a software that should have done all this; too bad it's garbage and almost useless.

 

PS: even NI I/O Trace is not seeing anything.

0 Kudos
Message 1 of 6
(7,222 Views)

What model is the motor drive?  Do you have the manual?

 

Some general issues with your code:

1. The Configure Serial Port should be before the loop and the VISA Close should be after the loop.  You are constantly opening and closing the port.  So if any data happens to come in while you have the port closed, you will miss that data.

2. For 99% of systems out there, the Bytes At Port is the wrong choice for deciding how many bytes to read.  You can get parts of messages quite easily due to its nature.  But without knowing the protocol (the format of the data), I cannot give any real advice of an alternative.

3. You should stop your loop on an error.  And make sure you have displaying that error.  Those often will tell you when there is an issue with your set up.


GCentral
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
Message 2 of 6
(7,203 Views)
  1. 99.9% of the cases the "Bytes at port" option is a no go
  2. What your device uses is not USB, but serial protocol. It is another thing that you might have a USB-to-serial adapter to connect the motor drive to your PC. Could you tell us the model (both the USB adapter and the motor drive)? Does it support RS-422 protocol?
  3. Did you do the cabling (pinout) properly, according to the manual (between the motor drive and the USB adapter)?
  4. Read the manual of the motor drive. It should tell you how to do the communication, for example you might need to send a character set for what the drive responds. Also check the serial parameters you need to use, termination characters, etc!
  5. If you have a While loop, you should initialize your VISA comm BEFORE the While loop. Your VI tries to initialize the comm at EVERY iterations. Same for the VISA Close: do it AFTER the While loop. Inside the While loop you should only have Visa Read and Write functions (according to the manual).
Message 3 of 6
(7,199 Views)

Thank you all for your responses.

 

I don't know the name of the USB adapter but it works fine; I'm currently able to do everything with the motor, and with its own software I can see the data I need (speed and position from the encoder integrated in the motor).

The problem is that the trace function in this software samples data with a predefined time step (which is unknown) and can't be changed; I have to choose the time step because I need to couple the position information with a force information coming from another instrument.

 

The drive is EcoTech4 from Selema; I have the manual but it's written in italian and above that there aren't information about the communication protocol.

I only know this:

RS-422

baud rate: 19200

data bits: 8

parity: even

stop bits: 2

 

I can't attach the exe of the sw I was talking about.

 

 

 

0 Kudos
Message 4 of 6
(7,189 Views)

Based on what I could find in the manual, it looks like this device uses a Modbus protocol.  Modbus is a register based protocol, so you need to know which registers hold the data you need.  Call up the manufacturer and ask for details.  There are a few libraries out there for doing ModBus with LabVIEW.


GCentral
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
Message 5 of 6
(7,179 Views)

Here is a manual in English primarily for Service Installation, but it does get into some of the programming and operation later in the manual.

http://www.selema-srl.it/demoselema/wp-content/uploads/2016/01/ECO-TECH-EVO-Man-Install_EN.pdf

Help the Community (and future reviewers) by marking posts as follows:
If it helped - KUDOS
If it answers the issue - SOLUTION
Message 6 of 6
(7,166 Views)