Serial Communication on Beaglebone Black

I have been trying to communicate with a CNC machine through RS 232 to the Beaglebone Black.
Following are the Serial Port settings at the Machine
Baudrate=9600
Databits=8
Stopbits=1
Parity=None
CR only

When i tried connecting it to my desktop(windows 10-using python) directly(done without using BBB) and i set the same parameters i got the response from the machine like i had expected.

Although, when done using the BBB (debian), also using python, i just received the string command i sent to the machine. Following is the python code.

import Adafruit_BBIO.UART as UART

import serial, string

UART.setup(“UART1”)
with serial.Serial(port="/dev/ttyO0",baudrate=9600,timeout=2) as ser: #i also tried mentioning databits and stopbits and other parameters but they still did not work
ser.write(b"Q100\r")
c=ser.readline().decode(“utf-8”,“ignore”)
print©
ser.close()

This works all fine in windows(gives the serial no. as the output) but simply gives back Q100 as output (same as input).

I was wondering if it could be due to the different OS on my laptop and BBB. Should i try installing windows ce on the BBB and work with that?

Thank you

Ask for a refund from ncsu.edu you have been cheated

You need to activate the serial port first.
http://beaglebone.cameon.net/home/serial-ports-uart

Yes i have already tried activating the serial ports as shown in the link before. Still it did not seem to work.

What kernel and image?

newer ones use config-pin to activate the UARTS and seem to have problems with some of the overlays.

On: BeagleBoard.org Debian Image 2015-11-12 with kernel: 4.1.18-ti-r49 #1 SMP PREEMPT Fri Feb 26 00:12:54 UTC 2016 armv7l GNU/Linux

It boots “cape-universal” and I enable UART1 wtih:
sudo config-pin P9.24 uart
sudo config-pin P9.26 uart

Before going too far, jumper RX to TX and test it with minicom, the default echo on will double type any keys you press in the console, and with echo off you get no response without the jumper and get the character with it installed.

BeagleBoard.org BeagleBone Debian Image 2014-04-23
Linux beaglebone 3.8.13-bone47 #1 SMP Fri Apr 11 01:36:09 UTC 2014 armv7l GNU/Linux

I am fairly new to beaglebone, could you tel me how to configure the cape-universal overlay.

I did try to configure it using “config-pin overlay cape-universal” but it said

Loading cape-universal overlay
bash: line 0: echo: write error: File exists
Error loading device tree overlay file: cape-universal

What do i do

I did try to configure it using “config-pin overlay cape-universal” but it said

Loading cape-universal overlay
bash: line 0: echo: write error: File exists
Error loading device tree overlay file: cape-universal

What do i do

I’m not big on Python, but it looks like you are using some of the Adafruit libraries, they are broken for some kernels, I’m not the guy to tell you if your current kernel is one of them.

To isolate the problem, do:
apt-get install minicom and jumper RX to TX.

I think by default in Debian images you need to run minicom as root.

sudo minicom -D /dev/ttyS1

OTOH your python script may also need to run as root with the default device permissions.

If minicom works (after you’ve jumpered TX to RX) you know the overlay is loading correctly, and the problem is either the Python library or the permissions your scripts runs with.

If minicom doesn’t work the overlay is not loading correctly. There has been a fair number of threads about what uart overlays to use with various kernels try some searching.

Hope this helps.

Okay. I shall look it up.
By the way, i did confirm the working of the UART pins(UART1 RX to UART4 TX and vice versa).
I had two terminal tabs open and when i typed into one and entered(UART1 settings) it showed up on the other terminal with UART4 settings. I inferred that the Adafruit libraries work just fine for the BBB (correct me if i am mistaken)

It is just that while interacting with a CNC machine(with a HAAS OS) it is not communicating rather just showing up what is being sent.

You may need CTS or DTR active for the other end to accept data and respond. Are you sure the CNC machine doesn’t need a “hardware handshaking” protocol?

If you have uart1 talking to uart4 on the Beaglebone, that says the problem is the physical connection and/or the protocol to the CNC machine. Is the CNC machine wired to be DTE or DCE?

At this point I think you need help from the CNC machine’s documentation, or from someone familiar with that particular machine.

The cnc is dte as far as I know.
And I am assuming since it worked without hardware handshaking on my pc, it shouldn require the same for the bbb either.
That said, I have tried both the settings. With and without hardware handshaking.
The only thing I can think of is for some reason perhaps, the default serial port settings must be different on the bbb (with debian) than my pc (where I previously successfully had communicated-windows)

You do realize that on your PC the RS232 signal levels from the COM ports are +/- 12V while without extra hardware the Beaglebone levels are 0-3.3V? You may have fried the RX input on the Beaglebone if you’ve connected it directly to a +/- 12V RS232 TX output.

Assuming you’ve got the logic levels right, If you used a “standard” serial cable on your PC to the CNC machine it probably activated the CTS or DTR automatically, you may need to run one more wire from the Beaglebone, or tie it active on the CNC interface side.

if he connected it to the cnc with no 3.3v adapter it also could have
fried the bbb.

The RX and TX at the beaglebone are working just fine. The TX output from the RS-232 is 5V. Also i tried with and without connecting the red wire(5V) from the RS 232. The necessary connections are GND (black wire) , RX and TX(green and white wires) of the PL2303 USB to Serial adapter.
I also tried using a BeagleBone Black RS-232 Serial Micro-cape (see http://www.logicsupply.com/cbb-ttl-232/).

Note: RX and TX are working just fine for all the UART ports.(i confirm after every try)

CTS and DTR were not activated at the PC interface, i had looked up the serial port settings on which it was working. Anyway i did try with and without both and individually as wel.

Do you guys think i should also try a FTDI USB to Serial Adapter for BBB? It might eliminate the voltage issue altogether.

the output from the bbb is 3.3v not 5v. if you use anything other than
some kind of level translator you risk harming your BBB

it talks about that in the BBB srm.

I anyway could not find any previous work on serially connecting to a machine with BBB. I might have to shift to intel NUC. Do you think using FTDI USB to serial adapter is worth taking the risk? Is there anything different you suggest i could do perhaps?

The RX and TX at the beaglebone are working just fine. The TX output from
the RS-232 is 5V. Also i tried with and without connecting the red
wire(5V) from the RS 232. The necessary connections are GND (black wire) ,
RX and TX(green and white wires) of the PL2303 USB to Serial adapter.
I also tried using a BeagleBone Black RS-232 Serial Micro-cape (see
Shared Product 404 | OnLogic).

Note: RX and TX are working just fine for all the UART ports.(i confirm
after every try)

Even though you check after each try, putting a signal over 3.3 volts
on the BBB pins (or 1.8 volts on the analog pins) is just asking for
trouble.

Good engineering says not to put too much voltage on processor pins.

5 volts on a 3.3 volt maximum pin is too much. You may or may not
have overstressed the pins, which may or may not fail sooner or later.

If you are in college, and you have not been told this, then you need
to speak to your professors. Data sheet maximum ratings are not
suggestions.

You need the ground and the RXD and TXD lines. The maximum voltage on
the RXD and TXD lines should be 3.3 volts, on the average adaptor,
there's a jumper for that. There's also a jumper to select a 5 volt
swing. You do not need either the 3.3 volt power line or the 5 volt
power line.

Harvey