RS232 Industruino only sending over Serial1 (or any other?) not receiving

Hi,

Help is appreciated with a problem that can be summarised as "I can only send over serial but not received anything".


The RS232 setting :

  • an IND.I/0 D21G (serial number AR0003587)
    • via Serial1 by using (D10/D5 & ISO2 GND) and a TTL-to-USB cable connected to my workstation
    • powered via USB by same workstation.
    • using Serial1 in the program for communication
  • no other connections are made on the Industruino.
  • a basic program uploaded (see infra) that
    • echo's over serial what is read over that same serial connection
    • in addition for each 10 bytes received and each 500.000th iteration, it will send a message through serial + print it on the LCD screen.
  • to observe what is send over that serial port I use on a linux workstation in a terminal window

    cat /dev/ttyACM0

  •  to sent something, I launch in another terminal window

    echo "Hello" > /dev/ttyACM0

Observations :

  • all messages from Industruino to the workstation are seen on screen
  • no messages sent to the Arduino are echoed,
    • is confirmed by the 'bytes received counter' which  is not increased
    • I assume they never arrive? but why? Did rechecked I did not by accident misplaced D10 RX.

Alternatives tried :

  • I used a regular Arduino Mega to verify if there was not error somehow made in the setup
    • this functions as expected the "Hello" text is echoed in the terminal, like the other messages too
  • Instead of Serial1, I tried to communicate via SerialUSB
    • it receives nothing what I sent
    • but the behaviour is not the same. When I start to monitor it with 'cat /dev/ttyACM0' on the LCD and what is echoed shows it is receive a lot
    • what is echoed of what seems to be received are 'related fragments' of what is sent.
    • Is this maybe related to the cause of my problem?

Any help is welcome as I am out of ideas how to proceed?

Kind regards
Mario

------ the program itself --------------

#include "Arduino.h"
#include <stdlib.h>
#include <limits.h>

#define ARDUINO_BAUD_RATE 9600
#define SERIALOBJ Serial1
#define INDUSTRUINO

#ifdef INDUSTRUINO
    #include <Arduino.h>
    #include <Indio.h>
    #include <Wire.h>
    #include <U8g2lib.h>

    static U8G2_UC1701_MINI12864_F_2ND_4W_HW_SPI u8g2(U8G2_R2, /* cs=*/ 19, /* dc=*/ 22);

    #define LCD_PIXELS_WIDTH 128
    #define LCD_PIXELS_HEIGHT 64
    #define CHARACTER_WIDTH 4
    #define CHARACTER_HEIGHT 6
    U8G2LOG lcdlog;
    #define U8LOG_WIDTH LCD_PIXELS_WIDTH/CHARACTER_WIDTH
    #define U8LOG_HEIGHT LCD_PIXELS_HEIGHT/CHARACTER_HEIGHT
    uint8_t u8log_buffer[U8LOG_WIDTH*U8LOG_HEIGHT];
    const int backlightPin = 26; // PWM output pin that the LED backlight is attached to
    int backlightIntensity = 4;        // LCD backlight intesity
#endif

unsigned long int counter = 0;
unsigned long int nm_rvcd = 0;

void setup() {
    #ifdef INDUSTRUINO
        pinMode(backlightPin, OUTPUT); //set backlight pin to output
        analogWrite(backlightPin, (map(backlightIntensity, 5, 1, 255, 0))); //convert backlight intesity from a value of 0-5 to a value of 0-255 for PWM.

        u8g2.begin();
        // set the font for the terminal window
        // small
        u8g2.setFont(u8g2_font_tom_thumb_4x6_mf);
        // large
      //  u8g2.setFont(u8g2_font_amstrad_cpc_extended_8f);
        lcdlog.begin(u8g2, U8LOG_WIDTH, U8LOG_HEIGHT, u8log_buffer);    // connect to u8g2, assign buffer
        lcdlog.setLineHeightOffset(0);    // set extra space between lines in pixel, this can be negative
        lcdlog.setRedrawMode(0);        // 0: Update screen with newline, 1: Update screen for every char
    #endif
    SERIALOBJ.begin(ARDUINO_BAUD_RATE);
}

void loop() {
   if (SERIALOBJ.available()) {
     nm_rvcd++;
     // pure echo
     SERIALOBJ.write(SERIALOBJ.read());
   }
   if (((nm_rvcd % 10)==0) && (nm_rvcd>0)) {
       SERIALOBJ.print("Total received : ");
       SERIALOBJ.println(nm_rvcd, DEC);
       #ifdef INDUSTRUINO
           lcdlog.print("Total received : ");
           lcdlog.print(nm_rvcd);
           lcdlog.print("\n");
       #endif
   }
   counter++;
   if ((counter % 500000)==0) {
       SERIALOBJ.print("Counter : ");
       SERIALOBJ.println(counter, DEC);
       #ifdef INDUSTRUINO
           lcdlog.print("Counter : ");
           lcdlog.print(counter);
           lcdlog.print("\n");
       #endif
   }
}

----- SerialUSB apparently receiving rubrish that resembles what it has sent -------
[mario@workstation]$ cat /dev/ttyACM0
Counter : 6500000

Counter Total received : 1040

: 6500000
Total received : 1050


Couner T1Total received : 1060

0465000010Total received : 1070

5Cone T104Total received : 1080

6500010T

Total received : 1090

 

one T104Total received : 1100

To00010T

Total received : 1110

 

Mario Vackier
Mario Vackier
14
| 0 0 0
Asked on 12/9/21, 9:29 PM
0
vote
1330 Views

Hi Tom,

The helpline functioned very well. You've put me back on rails. Thanks a lot.

Solution for me : just connecting the INDIO to an external power source. I was not aware this was mandatory in case the analog & digital zone was not used (of course just for testing some basic things ;-)

Here some more notes related to the other items on the checklist :

  • TTL-USB does accept 3.3V. My lack of in dept knowledge made no distinction between the UART and RS232. A topic I can delve in deeper later if needed. Thanks to point that out.
  • regarding the monitoring of the serial port I did not mentioned I do set the baudrate upfront with the following command
    • stty 9600 -F /dev/ttyACM0 raw -echo
    • so thats functioning fine
  • in my case the microUSB connection from arduino maps to /dev/ttyACM0, the serial1 which I connect via ttl-to-USB maps to /dev/ttyUSB0. See
    • mario@arenin]$ ls -l /dev/serial/by-id/usb-ES_Gear_Ltd._Industruino_D21G-if00
    • lrwxrwx--- 1 mario mario 13 Dec 10 09:13 /dev/serial/by-id/usb-ES_Gear_Ltd._Industruino_D21G-if00 -> ../../ttyACM0

Kind regards

Mario

Mario Vackier
Mario Vackier
14
| 0 0 0
Answered on 12/10/21, 8:29 AM
0
vote

Hi, i will list a few things for you to check:

  • to use the INDIO, you need to provide external power, i.e. 12-24V on the V+/V-  terminals. power from USB only gives unpredictable results.
  • you are using the Serial UART on D10/D5, this is not RS232. it has a TTL signal of 3.3V so your TTL-USB converter should also allow 3.3V voltage levels.
  • to monitor a Serial port on Linux, it is better to use the 'screen' command so you can specify the baud rate, e.g. screen /dev/ttyACM0 9600 - however, it's much easier to use the Arduino IDE's Serial Monitor: select the port, open the window, and select the baud rate at the bottom. you see what it receives, and you can write in the top bar.
  • i'm a bit confused with your statements, in my experience /dev/ttyACM0 is what you get when you connect the microUSB cable to the Industruino, for programming, and you can read/write to this with 'SerialUSB'. a TTL-USB cable will usually show up as /dev/ttyUSB0. you can also connect to this port in the Arduino IDE's Serial Monitor.

Let us know if any of this fixes your issue.

Tom
Tom
5675
| 1 1 3
Answered on 12/9/21, 11:49 PM
0
vote

Your answer

Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!

Ask a Question

Keep Informed

About This Forum

This community is for professionals and enthusiasts of our products and services.

Read Guidelines

Question tools

67 follower(s)

Stats

Asked: 12/9/21, 9:29 PM
Seen: 1330 times
Last updated: 12/10/21, 8:30 AM