1

USB works similar to the Master and Slave architecture. There is an Host which is manage the bus as like a Master. There can be various "devices" which is managed by host like slaves. I wonder that whether USB can be used in real-time motion control or not. For a real-time job, you need an deterministic interface. USB working principle is similar to the Master & Slave architecture. So this means that USB completely deterministic solution, right? At most how much cycle time can be reached by USB ? What is the drawback of USB for real-time motion control?


Say a system consist of one Host and 16-devices. Devices can be servo-drives and a few sensors (encoders, gyros etc.). For instance, I want to send motion commands to these servo-drives and receive back sensors feedback through the same USB interface. I probably would like to see sub miliseconds cycle-time such as 500 uS (2kHz), 250 uS (4kHz). USB interface can handle the these requirements? I concern about the delay of USB. Is it deterministic or non-deterministic?

Dave Tweed
  • 168,369
  • 17
  • 228
  • 393
doner_t
  • 105
  • 1
  • 6
  • what is the master? some other RTOS or windows? –  Sep 28 '19 at 11:05
  • Yeah, a PC OS will be much less "real-time" than USB... – bobflux Sep 28 '19 at 11:21
  • @JonRB, Probably Master or Host should be a Real-Time OS. Not windows. Any suggestion for this? – doner_t Sep 28 '19 at 11:29
  • @peufeu, Definetely correct. It should not be PC, but an embedded one. Right? How about USB usage in embedded environment? Is USB sufficiently robust for temperature, vibration and EMI/EMC effects? – doner_t Sep 28 '19 at 11:32
  • Please don't expand the scope of your question in the comments. Try and restrict to one particular issue. The other topics may make good separate questions. You'll need numbers. – Transistor Sep 28 '19 at 11:35
  • @Transistor, Sure. I will make a new question for other topics. – doner_t Sep 28 '19 at 11:36
  • Trying to use USB for this will be a costly mistake. – Chris Stratton Sep 28 '19 at 16:06
  • If you are intending to close a servo feedback loop with that kind of bandwidth USB will be disastrous. If you have a DSP or similar processor doing the heavy lifting USB could feed it commands, maybe. – Spehro Pefhany Oct 05 '19 at 19:34
  • @Spehro Pefhany, USB will not enough for the cycle time of 250 uS (4 kHz) ? That's correct. I will not prefer the USB for this work. – doner_t Oct 06 '19 at 20:14
  • The high-speed granularity can be as low as 125us less some tolerance, so it's not absolutely impossible but I think you will have many serious issues. For high performance motion control jitter and latency should both be low. Throughput is not a problem, of course. – Spehro Pefhany Oct 07 '19 at 00:15

2 Answers2

3

The concept of "real time" is a stretchable thing. If your controlled object is, say, a metallurgical oven, then, depending on the size of it the real control time may be from seconds to minutes or even hours. So you need to define more clearly what kind of sampling rate is sufficient to make a robust and stable control for your object. To determine which time-cycle do you need, you need careful analysis of dynamics and stability of your control loop.

Now, the question is good, but it needs to be re-formulated. It should be something like, what is the overall latency of USB system, the time from issuing an API call from some software control algorithm, to actual change in some GPIO pins on the side of USB-connected device. The chain of events is long, it goes through API, several layers of drivers, filling various TRBs structures in main memory, then the hardware gets involved, ringing the bell register initiating DMA access by xHCI controller and streaming data across several elasticity buffers into actual USB PHY, then waiting for protocol response. And then something similar happens inside the USB device itself before actually toggling some GPIO pin. I don't know the answer to this question. But it is quite clear that the desirable sub-ms loop latency is impossible.

Ale..chenski
  • 38,845
  • 3
  • 38
  • 103
0

I see your question is also tagged EtherCAT. Why not just use the EtherCAT protocol with an Ethernet adapter interface to your OS? You can easily achieve sub-millisecond communications

Jon
  • 1
  • Did you previously validate/test the EtherCAT protocol in your motion-control system? I think a third-party software-stack is needed for Master side. But USB-based products are easily found in the market. – doner_t Sep 29 '19 at 17:27
  • I don't follow your question. What do you mean by previously validate/test EtherCAT in my motion-control system? Typically a third-party software is needed to implement an EtherCAT master but their are also open source alternatives. If you use USB you will need some application to control the motor. – Jon Oct 01 '19 at 00:19
  • I meant that whether you test/validate the EtherCAT interface in cold and high temperature or did you see the performance of EtherCAT under vibration? – doner_t Oct 06 '19 at 20:10
  • EtherCAT is used in rugged industrial environments. I'm sure there are controllers and drives that have specifications for certain temperature and vibration ranges. – Jon Oct 07 '19 at 22:38