Using Arduino UNO to control a stepper motor via RS485

Hi, I am trying to use Arduino UNO to control a stepper motor via RS485, but I am not sure about the wiring between the UNO and the MAX485 ttl to RS485 conversion board. Wiring the TX and RX pins of the UNO to the DI and RO pins of the MAX485 board is sure, but there seems a number of ways of connecting the DE and RE pins of the MAX485 board to the UNO pins. I am not sure which to choose. Since the pulse and the direction need to be defined, it seems another two pins, e.g., 2 and 3, of the UNO should be connected with the MAX485 board. Thus, I have the following wiring. However, the RE pin of the MAX485 is the Receiver Enable pin for receiving data. So, the below wiring seems incorrect.

Anyone has relevant experience? Thanks a lot.

You can use any of the digital output pins to drive the DE and RE pins. DE is driver enable, means you are ready to transmit, RE is receiver enable, means you are ready to receive data. It's just a way to signal the RS485 module what you are going to do next.

Thanks for the instant reply. For controlling a stepper, two pins need to be used to transmit pul and dir signals if the UNO can be directly wired to the driver. In the case of RS485 communication, are those two pins still needed? I think the answer is yes, because MAX485 module just plays a role of signal conversion. However, according to the functions of the DE and RE pins, it seems they cannot be wired to the pins for dir and pul. What do you think? Thanks.

The wiring of your RS485 module looks ok, however, they are normally used with a software serial port on an UNO so it doesn't interfere with the hardware UART connected to the on-board serial->USB interface.

I've used AltSoftSerial on an UNO several times with success. It uses pin 9 (for TxD) and pin 8 (for RxD) on an UNO.

I'm guessing pul = pulse?

Can you provide a link to your "Motor driver with RS485 interface"?

Thank you. Yeah, pul and dir mean pulse and direction. I thought only pins 0 and 1 are for RX and TX, good to know there are other possibilities, interesting.

The motor driver I am using is AZD-CD from the Orientalmotor. Although it has a built-in controller, it is not feasible to use it with the provided software MEXE02 to control a stepper for S-curve or sinusoidal motion. So, I am working on using Arduino UNO to control the driver and motor via RS485.

The following link is the function manual of the driver I am using. It has a description of the method of control via RS485 communication in Section 5. The driver has two RJ45 ports for RS485 communication.

Attached figure shows the main interfaces of the driver and their corresponding operation methods. This may help get a clearer understanding.

1 Like

Ok, so according to that manual, the unit uses Modbus over the RS-485 link. There are Arduino Modbus libraries around that you can use to talk to this device.

So MEXE02 is a PC application that talks to the motor controller - in this case an AZD-CD device - but for some reason you can't use it in this case? Does that mean you can't use Modbus either?

Yeah, I got the Modbus library loaded and referred to the code posted here. The author wired RE and DE of the MAX485 to 2 and 3 of the UNO. Although RE and DE are set as output pins, their values do not vary in the loop function. In my case, using the same wiring but defining 2 and 3 as dirction and pulse outpus, their values need to change in the loop function. So, I don't know whether it is correct.

I cannot use MEXE02 for coding sinusoidal motions, it is not practical. I can use the Modbus protocal or the RS485 communication via the RJ45 port on the driver.

At first glance, RE & DE don't appear to vary in the loop function - but they do - it's just not very clear. RE & DE get changed when the Modbus library calls the preTransmission() and postTransmission() functions that were declared at the top of the sketch. The Modbus library calls these functions as part of the message handling.

Thank you. RE and DE may vary in the loop function. It seems that wiring them to the pulse and direction pins is still not suitable, because DE and RE are always active-high and active-low, respectively, and RE is for receiving data only thus transmitting either direction or pulse signal is not feasible. So, I think the wiring is still incorrect but have no clue of the correct one. Also, the wiring may differ between unipolar and bipolar steppers. Got completely stuck.

Hold on a sec. I think we may have 2 halves of 2 different methods of control here. I'm not an expert in motor controllers by any means, so this may be complete garbage :laughing:

You talk about pulse and direction pins. I know those terms from driving stepper motors years ago. Are you saying that your controller (sorry I don't understand much of these modern motor controllers) has connections to accept a discrete signal for step (aka pulse) and a direction?

If that's the case, then do you know the voltage levels the controller expects for high & low?

No worries. :joy:

I have got stuck here quite a while. I am now looking for other options. :slightly_smiling_face:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.