LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Started with Modbus over RS485 (LabView)

Hi Michael,

 


@Michael_Smith wrote:
Dear,
  • myRIO
  • RS485
  • USB to Serial Connector
  • Because I've to rotate a something which is time critical and requires accuracy aswell

In general the FPGA has no connection to USB or LAN port of your myRIO.

 

Please define "time critical" and why you don't want to handle this in the RT (=Realtime) part of your myRIO! Here you can access the RS485 port (more) easily…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 11 of 24
(231 Views)

@Michael_Smith wrote:

Dear,

  • myRIO
  • RS485
  • USB to Serial Connector
  • Because I've to rotate a something which is time critical and requires accuracy aswell

You talk over RS-485, a serial port electrical interface, typically talking at maybe 38.4 kBaud, but almost certainly never more than 115.2 kBaud. Sending a Modbus command and receiving its answer will typically be in the milli-second range, so FPGA really won't add much of an advantage. But implementing Modbus on FPGA is going to cost you A LOT of development effort. For one you wouldn't be able to use your USB to RS-485at all from the FPGA. There is no way to get that handled from your FPGA code, as FPGA has no access to serial ports, except if you would use a NI-9871 C series module. Still, implementing the Modbus protocol on FPGA is even then a major development effort that will be hard to justify, even if you are a student, whose hours "cost" nothing. It would cost even more effort if you use a generic digital IO C series module and have to handle the bit level protocol too yourself.

Rolf Kalbermatter
My Blog
Message 12 of 24
(215 Views)

@GerdW wrote:

Hi Michael,


In general the FPGA has no connection to USB or LAN port of your myRIO.

 

Please define "time critical" and why you don't want to handle this in the RT (=Realtime) part of your myRIO! Here you can access the RS485 port (more) easily…


Hello Gerd, 

 

By time critical I mean, I've to point my flashlight mounted on servo motor instantaneously to certain degrees. Changes won't be abrupt but achieving a accurate postion is the key.  

 

Btw I've these parameters. 

Michael_Smith_0-1742375297521.pngMichael_Smith_1-1742375618305.png

 

Michael_Smith_2-1742375637495.png

 

0 Kudos
Message 13 of 24
(194 Views)

Hello Rolfk,

 

I've these parameters and provisions to work with. I understand it's difficult to implement on FPGA but I'm confused when I will access it from RT then how do I start with?

 

Michael_Smith_1-1742375789046.png

 


@rolfk wrote:

@Michael_Smith wrote:

Dear,

  • myRIO
  • RS485
  • USB to Serial Connector
  • Because I've to rotate a something which is time critical and requires accuracy aswell

You talk over RS-485, a serial port electrical interface, typically talking at maybe 38.4 kBaud, but almost certainly never more than 115.2 kBaud. Sending a Modbus command and receiving its answer will typically be in the milli-second range, so FPGA really won't add much of an advantage. But implementing Modbus on FPGA is going to cost you A LOT of development effort. For one you wouldn't be able to use your USB to RS-485at all from the FPGA. There is no way to get that handled from your FPGA code, as FPGA has no access to serial ports, except if you would use a NI-9871 C series module. Still, implementing the Modbus protocol on FPGA is even then a major development effort that will be hard to justify, even if you are a student, whose hours "cost" nothing. It would cost even more effort if you use a generic digital IO C series module and have to handle the bit level protocol too yourself.


 

0 Kudos
Message 14 of 24
(193 Views)

Hi Michael,

 


@Michael_Smith wrote:
By time critical I mean, I've to point my flashlight mounted on servo motor instantaneously to certain degrees. Changes won't be abrupt but achieving a accurate postion is the key.  

The ServoDrive will handle the positioning (accuracy and timing), so you don't need any of this inside a FPGA!

 


@Michael_Smith wrote:

when I will access it from RT then how do I start with


You need to follow your ServoDrive manual with all needed settings to initialize the drive and set/command the required movements…

(Use the Modbus library on your RT target, it will do the communication stuff.)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 15 of 24
(187 Views)

@GerdW wrote:

 


@Michael_Smith wrote:

when I will access it from RT then how do I start with


You need to follow your ServoDrive manual with all needed settings to initialize the drive and set/command the required movements…

(Use the Modbus library on your RT target, it will do the communication stuff.)


And most importantly, you can simply use the NI Modbus library mentioned by ZYong in the 3rd post in this thread. It can have its tricky aspects to use, but believe me trying to implement your own Modbus library in LabVIEW through VISA and even more so in FPGA, is going to be hyper-exponentially more tricky.

Rolf Kalbermatter
My Blog
Message 16 of 24
(186 Views)

@rolfk wrote:

@GerdW wrote:

 


@Michael_Smith wrote:

when I will access it from RT then how do I start with


You need to follow your ServoDrive manual with all needed settings to initialize the drive and set/command the required movements…

(Use the Modbus library on your RT target, it will do the communication stuff.)


And most importantly, you can simply use the NI Modbus library mentioned by ZYong in the 3rd post in this thread. It can have its tricky aspects to use, but believe me trying to implement your own Modbus library in LabVIEW through VISA and even more so in FPGA, is going to be hyper-exponentially more tricky.


And what about the hardware aspect. I still connect it via USB to Serial?

0 Kudos
Message 17 of 24
(183 Views)

@Michael_Smith wrote:

@rolfk wrote:

@GerdW wrote:

 


@Michael_Smith wrote:

when I will access it from RT then how do I start with


You need to follow your ServoDrive manual with all needed settings to initialize the drive and set/command the required movements…

(Use the Modbus library on your RT target, it will do the communication stuff.)


And most importantly, you can simply use the NI Modbus library mentioned by ZYong in the 3rd post in this thread. It can have its tricky aspects to use, but believe me trying to implement your own Modbus library in LabVIEW through VISA and even more so in FPGA, is going to be hyper-exponentially more tricky.


And what about the hardware aspect. I still connect it via USB to Serial?


Yes! Unless you want to buy a NI-9871 module (and have a free slot in the cRIO chassis) or have a cRIO chassis with an actual RS-485/422 port already build in (such as the cRIO-9066 for instance).

 

Since you use the myRIO, another option might be to interface to one of the build in UARTs on the MXP-A or MXP-B connectors. But you would have to do some TTL to RS-485 translation, for instance with something like this: https://www.otronic.nl/nl/max485-ttl-to-rs485-converter-module.html

 

Or you can implement your own circuit using a MAX485 or similar chip on the according MXP breadboard that your myRIO should have come with. 

Rolf Kalbermatter
My Blog
Message 18 of 24
(174 Views)

@rolfk wrote:

@Michael_Smith wrote:

@rolfk wrote:

@GerdW wrote:

 


@Michael_Smith wrote:

when I will access it from RT then how do I start with


You need to follow your ServoDrive manual with all needed settings to initialize the drive and set/command the required movements…

(Use the Modbus library on your RT target, it will do the communication stuff.)


And most importantly, you can simply use the NI Modbus library mentioned by ZYong in the 3rd post in this thread. It can have its tricky aspects to use, but believe me trying to implement your own Modbus library in LabVIEW through VISA and even more so in FPGA, is going to be hyper-exponentially more tricky.


And what about the hardware aspect. I still connect it via USB to Serial?


Yes! Unless you want to buy a NI-9871 module (and have a free slot in the cRIO chassis) or have a cRIO chassis with an actual RS-485/422 port already build in (such as the cRIO-9066 for instance).

 

Since you use the myRIO, another option might be to interface to one of the build in UARTs on the MXP-A or MXP-B connectors. But you would have to do some TTL to RS-485 translation, for instance with something like this: https://www.otronic.nl/nl/max485-ttl-to-rs485-converter-module.html

 

Or you can implement your own circuit using a MAX485 or similar chip on the according MXP breadboard that your myRIO should have come with. 


I mean what software programming scheme I should follow, If I implement this Hardware Hierarchy? 


Michael_Smith_0-1742461709427.png

 

0 Kudos
Message 19 of 24
(117 Views)

@Michael_Smith wrote:


I mean what software programming scheme I should follow, If I implement this Hardware Hierarchy? 

Michael_Smith_0-1742461709427.png


You really keep changing the specifications on a whim!

 

First you talk about controlling the Modbus directly from the FPGA on the myRIO because you are concerned about latency.

Suddenly you want to connect the Modbus to the PC instead. That is quite a fundamental change in specifications. And poses the additional question what you want to use the myRIO for.

Rolf Kalbermatter
My Blog
Message 20 of 24
(107 Views)