NI Home > Community > NI Discussion Forums
Reply
Member
Harry1984
Posts: 7
0 Kudos

> Faster readout of data through COM Port (Modbus)

[English]

Hy!

I read out a controller of a BergerLahr axles via RS232 (with an "RS232 to RS485" adapter) and I
use the "Modbus" protocol to do this task.

Everything works fine, but the readout rate is too slow... I am only able to achieve a rate
of approx. 10-15Hz to get the data.

Is there a possibility to boost the readout value ... (the more the better)?

- in the attachment there is the screenshot of the VI (auslese01.JPG)
- the VI itself (auslese.vi)
- and the modbusprotocol für LabView (you need it to open the VI)
(http://sine.ni.com/devzone/cda/epd/p/id/4756)


Thank you for your help & time
Greetings from Austria
Harry



--------------------------------------------
[German]


Hallo Ihr!


Ich lese über die RS232 Schnittstelle - über einen "RS232 to RS485" Adapter - einen Controller
einer BergerLahr Linearachse über das Modbus Protokoll aus.

Das ganze funktioniert eigentlich sehr gut, jedoch geschieht das Auslesen mit nur 10-15Hz...
daher bekomm ich viel zu wenig Messwerte herein.

Gibt es eine Möglichkeit die Datenerfassung zu beschleunigen?

Hab im Forum schon ähnliche Fragen gefunden, jedoch bringen die mich leider nicht weiter.
Man kann da an den Schleifen selbst, etc. Verbesserungen vornehmen...

- Anbei ist ein Screenshot des VIs (auslese01.JPG)
- Das VI selbst (auslese.vi)
- Und das Modbusprotokoll für LabView ist hier zu finden -> benötigt man zum Öffnen des
VIs(http://sine.ni.com/devzone/cda/epd/p/id/4756)


Vielen Dank für Eure Hilfe & Zeit
LG
Harry
Active Participant
shoneill
Posts: 1,545
0 Kudos

Re: > Faster readout of data through COM Port (Modbus)

Hi Harry,

firstly a couple of things....

You don't need to branch off the array for saving.  You can wire directly to the shift-register on the right-hand side of the loop and save this, it will save the same data and doesn't create copies.

Secondly, you're expanding the array in each iteration which can be expensive in terms of memory usage.  Do you know how many times the loop will execute before you run the program?  If so, pre-allocate the array of the right size and use "Replace array subset" instead of "insert into array".

Thirdly, you're indexing an array element that you're not actually using.

Having said this, I think the instrument may well not be capable of more than 10-15 commands per second.  This actually seems quasi-reasonable for a 38400 BAUD connection.  Remember each BYTE transferred pro command requires around 10 bits, so one BYTE is transferred in 10*1/38400 (0.26 milliseconds).  Assuming a command length of 50 BYTES, this gives a theoretical minimum of 13 millisceonds per command which gives around 75Hz.  Bear in mind this is a THEORETICAL limit and will most likely be lower in reality.  Also, you need to factor in the size of your SENT packets which will further reduce the available bandwidth.  Factor in the response time of the instrument (anywhere from 1ms to 100ms) and you have a typical serial communication really.

You might be able to speed things up a little (Have a look in the modbus VI), but I reckon any improvements will be less than an order of magnitude.

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Member
Harry1984
Posts: 7
0 Kudos

Re: > Faster readout of data through COM Port (Modbus)

Hey!

In connection with LabView Support we managed it to "boost" the thing... now it is possible that I am able to get data each 10ms (more than 15x faster)... so my measurement is a lot faster than before. (A "Wait" command was adjusted in the modbuslib, so that an important part of the VI runs every 1ms instead of 10ms)

Thank you for your help!
Harry
Active Participant
shoneill
Posts: 1,545
0 Kudos

Re: > Faster readout of data through COM Port (Modbus)

[ Edited ]
Harry,

Firstly, I'm happy you got it working faster, but two questions remain:

1) How long is your command (how many bytes sent / read per command)?  My original 75Hz theoretical limit was based on a command length of 500 Bytes.....

2) How did you manage to "boost" it?

Shane.


Message Edited by shoneill on 01-22-2007 01:41 PM

Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Member
Harry1984
Posts: 7
0 Kudos

Re: > Faster readout of data through COM Port (Modbus)

[ Edited ]
Hey!

How can I find out the lenght of my command? I only use the (finished) "MB Serial Master Query.vi" to interact with my controller.. nothing else.

In the "MB Serial Receive.vi" there is a "wait" function with a 10ms constant. Delete it or "shrink" it to 1ms and you will go faster.

Greetings from Austria
Harry

Message Edited by Harry1984 on 01-22-2007 06:47 AM

Active Participant
shoneill
Posts: 1,545
0 Kudos

Re: > Faster readout of data through COM Port (Modbus)

Harry,

You must have some serial protocol for the instrument, no?  The commands should be listed there.  My original guess of 500 Bytes was based on your observed speed.

Are you saying your whole problem was a 10ms wait function at the wrong place?

That'll do it alright.

Greetings from Switzerland

Shane.
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
Member
Harry1984
Posts: 7
0 Kudos

Re: > Faster readout of data through COM Port (Modbus)

Hehe... yes... indeed. This tiny function was brake in my VI. It is bulit in (from NI) to make "older" modbus systems work with the VI... so not to create timeout errors and so on. The higher the value of the "wait" function the "safer" the system works. That's life ;-)

I will check with a serialport scannertool the commands...

Greetings
Harry
Member
Harry1984
Posts: 7
0 Kudos

Re: > Faster readout of data through COM Port (Modbus)

Here is an exaple of a command/request

Request: 22.01.2007 14:11:04.97264
01 10 1B 02 00 02 04 00 00 00 00 CC 86

Answer: 22.01.2007 14:11:04.98264 (+0.0100 seconds)

01 10 1B 02 00 02 E6 EC


MFG
Harry

Active Participant
shoneill
Posts: 1,545
0 Kudos

Re: > Faster readout of data through COM Port (Modbus)

NI is to blame?  Oh man, those kind of problems can really make your day, eh?

OK, 21 Bytes is a bit less than the 500 I had guessed.  Then it's clear that your 10Hz was way too slow.....

Happy wiring!

Shane
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)