Hello everyone this is my first post to the forum. I want to control 2 stepper motors using RS-232 as a way of directly communicating with step drivers from my desktop. I am new to communication standards such as RS-232, 422, 485. I have two questions. One, is RS-232 like an I2C network where Devices such as sensors, servo drivers(PCA9685) are given an address and then you can program what happens to that device via its address? If not how does RS-232 work in a use case such as robotics where you have to control step motors? Thank you for any and or all help. My goal is to be able to control 2 nema17 or 23 motors and write python code to control them. I want to use a solution other than usb/arduino for the connection that gets made between motor controllers and the computer.
-
$\begingroup$ RS232 is a lowest-common-denominator format. Bad for a "product", good for hooking up to a PC quickly for research, using something like an IMS Mdrive integrated motor-driver-comm (ps -- 15 years out of date, there are cheaper things now with same function), If you want RS232 on windows PC with no driver nonsense, I settled on the TrendNet TU-S9 adapter (prolific driver) $\endgroup$– Pete WCommented Jan 27, 2021 at 11:43
-
$\begingroup$ Also, I would suggest asking this question in the neighboring EE forum. $\endgroup$– Pete WCommented Jan 27, 2021 at 11:49
-
$\begingroup$ Look to purchase a stepper motor driver with an RS-232 interface. You are more likely to to find one with a USB interface. $\endgroup$– Eric SCommented Jan 27, 2021 at 12:38
3 Answers
RS232 is way more simple - it's strictly 1 to 1 communication, no addresses, no negotiation, no error correction (just very rudimentary optional verification - parity bit, usually unused). There are optional (also usually unused) control lines or special byte values to pause/unpause transmission, not even any indication there's anything connected (no distinction between lack of rs232 cable and remote device not having any data).
So you'll communicate with only one device over a single RS232 port; any verification, keep-alives, checksums or error correction will need to occur within your own protocol. Protocol and port configuration negotiation (speed, block length, parity, stop bits, software/hardware control) is performed over sneakernet ("manually enter the same configuration on one device, then walk up to the other and manually enter the same configuration on it too").
So you'll need some sort of driver that can drive two stepper motors (if you want 2 drivers, you need 2 RS232 ports in the desktop), set up the ports right on both ends (which usually means set up the port on the PC to what the manual of the driver says as its config is fixed), then implement whatever control protocol it uses, on top of the RS232 transmission provided by the system.
Try researching USB to UART solutions as an alternate. RS232 ports on desktop computers are thing of the past, thus you are limiting your design. USB port are pretty common with computers thus a USB -> UART might be simpler modern solution with added features.
Note this is still a 1 - 1 communication, but with additional USB port on the desktop, the design can be scaled easily.
Note: One of the differences between UART and RS232 is the voltage levels. UART is 3.3V or 5.0V, RS232 is +/- 15V
References:
Like other have said RS232 is a serial communication protocol similar in a sense to i2C (there are some differences though).
While you may find nema 17 motors that have integrated support for RS232 or I2C, most nema motors don't have that capability. You need to put between them some sort of low level peripheral and a stepper motor driver.
So ideally the a simple way to control the 2 stepper motor is the following:
You'd need a Raspberry which runs python. You would connect 3 digital outputs for PULSE, DIRECTION and ENABLE to each of the stepper motor controllers (preferably something like this). Then each controller is connect to its own motor. That would be a pretty robust system.
OR ALTERATIVELY if you really must use RS232 another setup you could use is the following:
Where basically, you replace raspberry with a PC and an Arduino. Most of the other elements remain the same.
DISCLAIMER: This are just two of an almost infinite possibility of configurations.
IMHO, using a boxed stepper motor controller/driver will help you get started very quickly with the minimum cost, and maximum reliability.