DSBOX-NX2 Serial Communication Interfaces Tutorial

Updated: 2 days ago

On this blog post, we will test the serial communication interfaces(RS232, RS422, RS485) of DSBOX-NX2.



First, let's look over the IO connector. On the connector, there are 4 serial communication pins and 1 digital ground. When using serial communication interface always double check which ground pin you are using. You must use digital ground for serial communication applications.


On DSBOX-NX2, there is a system service that binds login prompt to the serial port which we want to use. Before beginning, you should disable this service to get stable communication. To do this comment all lines inside "/etc/systemd/nvgetty.sh" file. Then reboot your system.

  • sudo gedit /etc/systemd/nvgetty.sh

  • sync



RS232 Application Example


To test RS232 functionality, we used USB-Serial adapter. Connect that adapter to the USB port of the host pc and install it's driver software if necessary. To the other side of the adapter connect your DSBOX-NX2 RS232 pins with cross connection(Rx to Tx, Tx to Rx). You can find the hardware pins below. For ground connection use GND_DIGITAL pin.


After proper connection, You should do pin muxing on DSBOX-NX2 to use Serial Port as RS232. To do this open new terminal on DSBOX-NX2 then you can use the commands below.

  • sudo echo 424 > /sys/class/gpio/export

  • sudo echo 436 > /sys/class/gpio/export

  • sudo echo out > /sys/class/gpio/gpio424/direction

  • sudo echo out > /sys/class/gpio/gpio436/direction

  • sudo echo 0 > /sys/class/gpio/gpio424/value

  • sudo echo 0 > /sys/class/gpio/gpio436/value



With these commands we changed communication mode as full-duplex and RS232; you can find gpio pin jobs below.



Lastly, open new terminal and install gtkterm program for ease of use(make sure ethernet cable is connected). Then run gtkterm program with arguments. On host side you can use teraterm or putty for windows; gtkterm for Ubuntu OS. If you are using gtkterm on Ubuntu run gtkterm without any argument and set port parameters later. You can find DSBOX-NX2 commands below.

  • sudo apt install gtkterm

  • sudo gtkterm -p /dev/ttyTHS0 -s 115200


If you have done everything correctly you could see your keyboard presses on the other machine's serial terminal.



RS422 Application Example


To test RS422 functionality, we used USB-Serial adapter. Connect that adapter to the USB port of the host pc and install it's driver software if necessary. To the other side of the adapter connect your DSBOX-NX2 RS422 pins with cross connection(Rx to Tx, Tx to Rx but positive to positive, negative to negative). You can find the hardware pins below. For ground connection use GND_DIGITAL pin.


After proper connection, You should do pin muxing on DSBOX-NX2 to use Serial Port as RS422. To do this open new terminal on DSBOX-NX2 then you can use the commands below.

  • sudo echo 424 > /sys/class/gpio/export

  • sudo echo 436 > /sys/class/gpio/export

  • sudo echo out > /sys/class/gpio/gpio424/direction

  • sudo echo out > /sys/class/gpio/gpio436/direction

  • sudo echo 0 > /sys/class/gpio/gpio424/value

  • sudo echo 1 > /sys/class/gpio/gpio436/value



With these commands we changed communication mode as full-duplex and RS485; you can find gpio pin jobs below.


Lastly, open new terminal and install gtkterm program for ease of use(make sure ethernet cable is connected). Then run gtkterm program with arguments. On host side you can use teraterm or putty for windows; gtkterm for Ubuntu OS. If you are using gtkterm on Ubuntu run gtkterm without any argument and set port parameters later. You can find DSBOX-NX2 commands below.

  • sudo apt install gtkterm

  • sudo gtkterm -p /dev/ttyTHS0 -s 115200



If you have done everything correctly you could see your keyboard presses on the other machine's serial terminal.


RS485 Application Example


To test RS485 functionality, we used USB-Serial adapter. Connect that adapter to the USB port of the host pc and install it's driver software if necessary. To the other side of the adapter connect your DSBOX-NX2 RS485 pins. You can find the hardware pins below. For ground connection use GND_DIGITAL pin.


After proper connection, You should do pin muxing and make selection of data direction on DSBOX-NX2 to use Serial Port as RS485. To do this open new terminal on DSBOX-NX2 then you can use the commands below.

  • sudo echo 267 > /sys/class/gpio/export

  • sudo echo 424 > /sys/class/gpio/export

  • sudo echo 436 > /sys/class/gpio/export

  • sudo echo out > /sys/class/gpio/gpio267/direction

  • sudo echo out > /sys/class/gpio/gpio424/direction

  • sudo echo out > /sys/class/gpio/gpio436/direction

  • sudo echo 1 > /sys/class/gpio/gpio424/value

  • sudo echo 1 > /sys/class/gpio/gpio436/value

To Write Data:

  • sudo echo 1 > /sys/class/gpio/gpio267/value

To Read Data:

  • sudo echo 0 > /sys/class/gpio/gpio267/value




With these commands we changed communication mode as half-duplex and RS485; you can find gpio pin jobs below.


Lastly, open new terminal and install gtkterm program for ease of use(make sure ethernet cable is connected). Then run gtkterm program with arguments. On host side you can use teraterm or putty for windows; gtkterm for Ubuntu OS. If you are using gtkterm on Ubuntu run gtkterm without any argument and set port parameters later. You can find DSBOX-NX2 commands below.

  • sudo apt install gtkterm

  • sudo gtkterm -p /dev/ttyTHS0 -s 115200 -w RS485



If you have done everything correctly you could see your keyboard presses on the other machine's serial terminal according to your data direction. You can change data direction with changing value of gpio267.


Thanks for reading.

27 views
Check out our latest tutorials and blog posts

Email us for any questions

info@forecr.io

For large quantity inquiries

sales@forecr.io

©2020 by forecr