3

I have made a program which give instruction to a motor module. I have successfully send instruction to him, asking it to make a rotation back and forth, but I can't get back the feedback result.

I sent signal throught the GPIO14 (tx) and GPIO15 (rx) to get the result. So I'm writting data on port /dev/ttyAMA0, and reading result into it too.

On arduino, there is led for tx/rx signal, which make the debug more confortable. Here, since my motor work, I presume it get the signal. But i'm trying to read on /dev/ttyAMA0 again, and I don't get any result.

This is a half-duplex communication, so there is a control pin who decide which one can talk. The fact that I get nothing when I send data to the motor, then I don't know if it is an hardware problem, or if I need to ask feedback to the motor. In the doc they say when you give command to the motor, it return a feedback status packet. The fact is, I don't know when the data is transmitted.

So my question is, is there a rapid way to test on Raspi if tx pin send data and rx pin get data. Or if the only way is to place debug led on the circuit. And when you read into /dev/ttyAMA0, if you need to wait for the data, or it acts like a buffer?

Mr Bonjour
  • 163
  • 1
  • 8

1 Answers1

1

One of the easiest ways to debug the serial i/o is to perform a hardware loop back. If you happen to have a ttl 3.3v to rs 232 adapter (DB9 connector) such as this, simply shorting pins 2 (rx) and 3 (tx) using a short jumper wire should allow you to see whats being sent out using a terminal program such as minicom. For more details search for rs232 d connector loopback. If you have direct access to the Pi's pins, using a female-female jumper on tx/rx pins should do as well.

One another thing you might want to see if it is a permission problem. Assuming you are using raspbian, see this on how to give access to the default user pi.

I sincerely hope you have made sure the voltage levels are compatible. The PI's pins operate at 3.3v. If the motor controller works on 5V TTL/RS232 or RS485 an appropriate level shifter/isolation is essential. Otherwise you are very likely to have fried you PI or its pins.

Shreyas Murali
  • 2,446
  • 1
  • 16
  • 23