0

I want to communicate with this Rhino DC servo motor with RPi4 B. I enable uart3 in RPi4 by modifying the /boot/config.txt file. In this file, I add dtoverlay=uart3 in the last. When I used ls /dev/ttyAMA* , I got /dev/ttyAMA0 /dev/ttyAMA1 , So I think uart3 is enable in RPi4.

For uart3, TXD is at GPIO04 and RXD is at GPIO05. So, I connected RXD of RPi with TX of motor and vice-versa. In this servo motor, to rotate we have to give commands like G200, G300,, etc. To get the current position, we have to send P. This link explains it in detail.

I used the below code to communicate with motor and RPi4:

import time
import serial

ser = serial.Serial(
        port='/dev/ttyAMA1', 
        baudrate = 9600,
        parity=serial.PARITY_NONE,
        stopbits=serial.STOPBITS_ONE,
        bytesize=serial.EIGHTBITS,
        timeout=2
)

#ser.write(str.encode(str('G600')+'\n'))
ser.write('G600'.encode('utf-8'))
val = ser.read('P')
print(val)
ser.close()

But there was no rotation of the motor (no error was there too). and I got value b' ' using print(val)

I want to know, how to run this servo motor with RPi4?

2
  • Use abyz.me.uk/rpi/pigpio/piscope.html to check for activity on GPIO4/5. Check that the activity is as expected. read('P') is wrong. You need to write the command and then read the result.
    – joan
    Jun 8, 2021 at 7:44
  • Yes Sir, that what I'm asking. How to write the commands as my commands are like G200 etc. Jun 8, 2021 at 8:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.