Canada
Asked — Edited

I’M Trying To Connect An Ardui

I’m trying to connect an Arduino Nano with the EZ-B v4 to offload some of the work. UART1 and UART2 work fine!

Problem is with UART0 (information is send but corrupted)

Connection:

  • Arduino GND to EZ-B v4 GND

  • Arduino RX connected to UART0 TX (first pin), D5 or D18

Attached to the Arduino is a 2x16 character LCD (I2C connection) to display (the serial information (also visible true the Serial Monitor) using a simple protocol; 0 (0x30) = clear LCD, 1 (0x31) = start at line 1, 2 (0x32) = start at line 2. All other information is just displayed.

All is fine and Information is displayed correctly when attached to pin D5 or D18.

When connected to the TX pin of UART0 information is sporadically send but corrupted. Touching the wire (on the outside!) changes the behavior of the characters received (more characters but still corrupted)??!!


ARC Pro

Upgrade to ARC Pro

With Synthiam ARC Pro, you're not just programming a robot; you're shaping the future of automation, one innovative idea at a time.

#1  

This is the Script I used: :loop UARTInit(0, 0, 9600) #initialize UART0 UARTWrite(0, 0, 0x30) sleep(100) UARTWrite(0, 0, 0x31, "Hello UART-zero") UARTWrite(0, 0, 0x32, "Second Hello") sleep(100)

UARTInit(0, 1, 9600) #initialize UART1 UARTWrite(0, 1, 0x30) sleep(100) UARTWrite(0, 1, 0x31, "Hello UART-one") UARTWrite(0, 1, 0x32, "Second Hello") sleep(100)

UARTInit(0, 2, 9600) #initialize UART2 UARTWrite(0, 2, 0x30) sleep(100) UARTWrite(0, 2, 0x31, "Hello UART-two") UARTWrite(0, 2, 0x32, "Second Hello") sleep(100) Goto (loop)

PRO
Synthiam
#2  

Sounds like your wire has a loose connection or is broken. Try a new wire and secure it better on both ends.

Long as your arduino and ezb are set to 9600, there shouldn’t be a problem.

Also, post the arduino code.

#3  

It's not the wire. I added an extra wire via a breadboard to measure the voltage (I should use an oscilloscope but I don't have one) and noticed the changed behavior. I changed the wire nevertheless but problem is the same. Arduino Nano is on a breadboard EZ-Bv4 is connected with 3 wires originating from UART0 TX (first pin), D5 and D18 I use an extra wire to connect the Nano RX with one of the EZ-B wires

/* I2C LCD 16x2 Arduino Tutorial

  • More info http://www.ardumotive.com/i2clcd(en).html
  • Dev: Michalis Vasilakis Date: 19/11/2016 Ver. 1.0 */

//Libraries #include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd (0x27, 16, 2); // Set the LCD I2C address, if it's not working try 0x27. //LiquidCrystal_I2C lcd (0x27, 20, 4); // Set the LCD I2C address (20 chars 4 lines), if it's not working try 0x27.

void setup(){ Serial.begin (9600);

lcd.init(); // iInit the LCD for 16 chars 2 lines // lcd.init(); // iInit the LCD for 20 chars 4 lines lcd.backlight(); // Turn on the backligt (try lcd.noBaklight() to turn it off (mind CAPITALS!!!) // lcd.noBacklight(); lcd.setCursor(0,0); //First line lcd.print("EZ-B4 LCD Display"); lcd.setCursor(0,1); //Second line lcd.print("Ardumotive.com");

}

void loop(){ ReadInputFromPC (); }

void ReadInputFromPC () { if (Serial.available ()) { delay (100); while (Serial.available () > 0) { int temp = Serial.read();

  Serial.print ("Debug ");
  Serial.println (temp); 

  if (temp == 48) {
    lcd.clear ();
  }
  else {
    if (temp == 49) {
      lcd.setCursor (0,0);
    }
    else {
      if (temp == 50) {
        lcd.setCursor (0,1);
      }
      else{ 
        if (temp != 10) {
          lcd.write(temp);
        }
      }
    }
  }
}     

}
}

PRO
Synthiam
#4   — Edited

The delay after reading on the Nano means you're skipping/missing bytes from the transmitter (EZ-B)

Quote:

[font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"]if (Serial.available ()) { [font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"]delay (100); <--- THIS IS BAD [font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"]while (Serial.available () > 0) { [font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"]int temp = Serial.read();

[/font][/font][/font][/font]

[font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"][font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"][font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"][font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"][font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"][font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"]

Also, you're writing to the LCD between character reads from the UART. That's going to cause a delay while the write occurs - which will also result in missing characters.  Also, you're DEBUG.WRITE() which is sending data out of a UART and that's gonna be slow as well which could result in the arduino not being able to keep up to the character transmissions[/font][/font][/font][/font][/font] [font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"][font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"][font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"][font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"][font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"] Instead, write your program to cache/buffer the serial read until a terminator character is sent. Following that, transmit the data in a batch to the lcd.[/font]

[font=OpenSans, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji]-OR-[/font]

[font=OpenSans, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji]check to see if there's DMA available on your arduino and read from a DMA buffer[/font]

[font=OpenSans, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji]-OR-[/font]

[font=OpenSans, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji]can the arduino have an interrupt execute when a new serial character arrives? If so, do that and add it to a buffer. Then have the main loop read from that buffer[/font][/font]

[font=OpenSans, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"][font=OpenSans, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica Neue, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol, Noto Color Emoji]Either way, that code is skipping/missing characters transmitted from the ez-b. The UART doesn't "wait until a character is received". That's not how serial works. Serial transmits whether the receiver is listening or not - there's no acknowledgement on serial. So by DELAY(100) and LCD.Write(), the Arduino is doing stuff while the EZ-B is transmitting data. This means the arduino is missing bytes because the arduino is busy doing something else instead of receiving data.[/font][/font][/font][/font][/font][/font]

PRO
Synthiam
#5  

Here - this is a little buffer i wrote for arduino this morning... use something like this.

#define _BUFFER_SIZE 512

byte        _INPUT_BUFFER[_BUFFER_SIZE];
unsigned int _WRITE_POSITION = 0;
unsigned int _READ_POSITION = 0;

bool IsAvail() {

  return _WRITE_POSITION != _READ_POSITION;
}

void serialEvent() {

  while (Serial.available()) {

    _WRITE_POSITION++;

    _INPUT_BUFFER[_WRITE_POSITION % _BUFFER_SIZE] = Serial.read();
  }
}

byte ReadByte() {

  while (_WRITE_POSITION == _READ_POSITION && Serial.available() == 0);

  serialEvent();

  _READ_POSITION++;

  return _INPUT_BUFFER[_READ_POSITION % _BUFFER_SIZE];
}

void loop() {

  if (IsAvail()) {

    byte temp = ReadByte();
    
    if (temp == 48) 
      lcd.clear ();
    else if (temp == 49) 
      lcd.setCursor (0,0);
    else if (temp == 50) 
      lcd.setCursor (0,1);
    else if (temp != 10) 
      lcd.write(temp);
  }
}
#6  

Thanks for your response! It's close to midnight in Amsterdam. I will give this a try tomorrow morning. Why is UART1 and UAERT2 working correctly with my code? The corrupted data is only with UART0

PRO
Synthiam
#7   — Edited

That's unusual if that's the case - i would imagine the wire in the UART0 connector is loose. The UART's are hardware on the EZ-B and using high precision timing.

Also, while writing that little bit of code for you, i ended up writing an arduino sketch that pretends to be an EZ-B v4 so ARC can connect to it via USB. The only thing it doesn't do audio or video or hardware UART

Get some rest and try again tomorrow :)

#8   — Edited

I replaced the wire (again), used your code but the problem is still there. problem is not that I'm missing characters but UART0 corrupts the characters.

I managed to get a small oscilloscope (BitScope Micro) to work and measured the signals. UART1 and UART2 signal are 3V, UART0 signal is less than 2V

#9  

Display of UART-0

User-inserted image

Display of UART-1

User-inserted image

Display of UART-2

User-inserted image

UART-0

User-inserted image

UART1

User-inserted image

UART-2

User-inserted image

PRO
Synthiam
#10   — Edited

Check your wiring to ensure there’s a proper connection. All Uarts are connected to the same chip. There’s no magic between the connector and the micro controller IC. The wires from the connector on the ezb run directly to the microcontroller and use the hardware uart on the IC.

Since uart 0 uses a female connector, I can only assume the wire that is shove into the connector is not making a proper connection. Also, ensure your grounds are connected correctly.

The uart 0, 1 and 2 are all on the same the same IC chip, which is the ezb’s st micro controller.

Also, the voltage scale is different between screenshots of uart 0 to 1 and 2

#11   — Edited

I checked what I did (not an expert yet with this micro scope). The 1.68V and 2.92V are not the scale but the offset from the zero line, depending on what type of reference is used (MIN, MAX, MEDIAN, MEAN). The scale for all readings is the same, 1 v/Div!

Made new readings with MAX as reference.

Used an oversized pin for the UART0 TX wire. Also connected the AURT0 GND with the Arduino GND with a similar wire. Problem is still the same :-(

I understand that, as you say the uart 0, 1 and 2 are all on the same the same IC chip, which is the ezb’s st micro controller but the way the signal is presented has to be different as TX UART1 and 2 are routed through digital pins 5 and 18

Could this be something with the pull-up for the TX pin of the uart0 or the fact that uart0 is 3.3v?

UART-0 User-inserted image

UART-1 User-inserted image

UART-2 User-inserted image

PRO
Synthiam
#12  

Hmmmm... are you really really really sure the gnd’s are joined between the arduino and ezb? Can you show a pic of your physical wiring so I can get an understanding of the setup?

#13  

The script keeps displaying the message to the 3 UART's

I can move the green wire between UART0, 1 and 2 to check the results for the different UART's.

The orange wire is for the BitScope Micro.

UART1 and 2 are fine. Only UART0 has the problem that characters are corrupted. (sometimes a few, sometimes all)

Could it possible that the signal for UART0 is just not low enough therefor getting correctly identified sometimes and sometime not?

User-inserted image :loop UARTInit(0, 0, 9600) UARTWrite(0, 0, 0x30) sleep(100) UARTWrite(0, 0, 0x31, "Hello UART-zero") UARTWrite(0, 0, 0x32, "Second Hello") sleep(100)

UARTInit(0, 1, 9600) UARTWrite(0, 1, 0x30) sleep(100) UARTWrite(0, 1, 0x31, "Hello UART-one") UARTWrite(0, 1, 0x32, "Second Hello") sleep(100) UARTInit(0, 2, 9600) UARTWrite(0, 2, 0x30) sleep(100) UARTWrite(0, 2, 0x31, "Hello UART-two") UARTWrite(0, 2, 0x32, "Second Hello") sleep(100) Goto (loop)

#14   — Edited

I got nothing. Looks like everything is attached properly to me.

Could there be an issue with the breadboard? I know you said you have changed the jumpers but maybe there is a bad connection? Have you tried different holes on the breadboard or even a different one? Perhaps you could hook up UART 0 directly and bypass the breadboard.

DJ mentioned before that UART 0 is a female connector. Maybe that connector inside the housing is damaged. You could solder a wire onto the back of the board at the solder joint just below this pin to check it. However I would not recommend this as it would void any help you will get from EZ Robot. Also if you are not good at soldering you could mess something else up. My motto is: No Guts, No Glory but your wallet has to support that. LOL.

PRO
Synthiam
#15   — Edited

You can’t short all three TX lines of each uart like that and get the same voltage during activity. That’s why you’re reading unusual voltages. Because the uart’s that aren’t writing are holding their voltage state - which is causing the active uart to over drive.

Also, take a ground from one of the digital pins, because perhaps it’s not grounding well in the female connector if it’s a bit loose.

Either way though, I can’t think of a reason why the uart #0 would not work for your application. I can’t even imagine a reason.

#16   — Edited
You can’t short all three TX lines of each uart like that

Unless I'm missing something or looking at the picture wrong I don't think his TX lines of each Uart are shorted on the breadboard. I know little about the Nano and how to wire it. Are you talking about the connections I see at A4 & A5?

I do like DJ's suggestion of running another ground from the black ground pins of the EZB's digital pins. Multiple grounds are always a good ideal in case one comes loose or broken. How about also attaching another ground wire to the other side of the Nano and running it directly to a EZB digital ground pin just to be sure. Bypass the breadboard with a sure ground connection.

PRO
Synthiam
#17  

Ooops I was tired and you’re correct Dave. I took a quick look and saw the three wires and didn’t pay attention before closing my eyes for a good night rest :)

Still, I can’t understand or imagine what could cause that for his setup.

#18   — Edited

Added an extra ground to the other side of the Nano (3 GND wires now), problem still exists.

The thing is, I can easily move the green wire between UART0, 1 and 2 and check how the transmission is going. AURT 1 and 2 always work fine so I would think Ground is fine.

The problem is only with UART0. Most of the time all characters are corrupted. With a bad connection of the TX wire you would expect that wiggling the wire would change the behavior. It does not.

It may or may not be related but almost every time I’m testing there is this message My battery is low. The only thing I’m doing right now is running this serial script. Nothing else connected.

I’m using a bench power supply at 7.4V. Increasing the voltage doesn’t help. Unplugging and re-initializing will most of the time fix it. Sometimes I need to restart a couple of times

User-inserted image

These are the Connection Control settings I use

User-inserted image

PRO
Synthiam
#19  

How come there’s a long list of countries in ubb code after each of your responses lol? We keep having to delete them

If the battery is low message, it’s  because you’re under powering the ezb - look into the battery monitor in the ezb data sheet. You’ve jumped a few steps ahead:) the min battery voltage is in the connection control, and can be hard coded in the web interface.

#20   — Edited

I don't know how this list is added. [url=https://synthiam.com/Community]

I was able to delete the extra lines

#21   — Edited

As stated, I added an extra ground to the other side of the Nano (3 GND wires now), problem still exists.

The thing is, I can easily move the green wire between UART0, 1 and 2 and check how the transmission is going. UART1 and 2 always work fine so I would think Ground is fine.

The problem is only with UART0. Most of the time all characters are corrupted. With a bad connection of the TX wire you would expect that wiggling the wire would change the behavior. It does not.

#22  

I just found out that when I unhook the mini scope (BitScope DSO connected to orange wire) no characters are received at all. Plugging the orange wire back in, UAET0 start immediately producing (mostly corrupted) characters again. It is as if the signal is pulled down a bit more so it can be recognized as a signal but not far enough to be recognized correctly

As always UAR1 and 2 are working fine with or without the oscilloscope being attached

PRO
Synthiam
#23   — Edited

Those are indeed symptoms of a bad ground - which I can't understand given your picture looks fine.

Oh, reviewing your picture... I noticed the Bitscope isn't connected correctly as it's missing the ground. So if it "works" with the Bitscope connected, i'm guessing it's a grounding issue still. I know it's not what you want to hear but it's the only thing i can think of with similar results that you're experiencing.

Is there a different GND pin on the arduino that you can use? Maybe that GND isn't connected correctly or something?

Also, i doubt that USB power on the arduino can power the display correctly AND the arduino. You should consider giving it adequate supply rather than USB. I suspect if you checked the +5 that's powering the display you'll find the voltage to be quite low when it's displaying data

What happens if you take GND off somewhere else on the EZ-B? Like a digital port GND pin or an ADC gnd pin?

Lastly, you "could" try putting a 4.7k resistor pulling the EZ-B's TX line to GND (down). Maybe there's a lot of capacitance in the arduino?

As you know, this is the simplest circuit you could come across. It's ridiculously simplified and shouldn't be this complicated so something is affecting the results - and all signs point to a ground, but i can't understand how if you're confident the grounds are solid

United Kingdom
#24  

This might be a silly question and you may have already tried it, but have you tried another Nano. I’ve have some obscured faults with a couple of Nano’s, which i’ve put down to Static damage due to the way they were packed on delivery. Anyway just a thought!

#25  

Hi Cem, I startend this atempt with an Arduino Uno. Same problem. The thing is that UART1 and 2 both work fine. Just the UART0 is giving this problem

#26   — Edited

Hi DJ, Thanks for your response. I started this exercise with a wire to the digital GND.  My current setup is 2 GND wires, one to digital GND and one to the GND of the UART0. Also an extra wire to the 2nd GND on the Nano. Problem is the same :-(  What puzzles me is that UART1 and 2 are working fine, so I’m confident the grounds are solid (with UART1 and 2 at least)

#27   — Edited

Did some more step by step testing.

  • Added GND to the Bitscope, trigger at minimum  - Cleared op the signal a bit but no incoming characters at all on UART0 (Value UART0 is 2.14V, value UART1 and 2 is 1.6V)
  • Moved power of the LCD to separate power - no incoming characters are recognized at all on UART0
  • Removed the Bitscope
  • Added a 4.7K resistor between TX and GND - Improvement, a lot of characters are coming in but all scrambled
  • Added the Bitscope, trigger at minimum - a lot of characters are coming in but are still all scrambled (Value UART0 is 2.07V, value UART1 and 2 is 1.5V)
  • Removed GND from the Bitscope, trigger at minimum - slight improvement,  a lot of characters are coming in scrambled but some (5-10%) are OK (Value UART0 is 2.01V, value UART1 and 2 is 1.5V)

It seems that the Signal LOW for UAERT0 is not low enough. The lower it gets the better the results

PRO
Synthiam
#28   — Edited

Add the resistor between TX and +3.3v instead of GND... try that

The fact the results change with the bitscope connected still leans toward a broken ground somewhere. The bitscope should be floating and not affect the reading. that's the point of a meter or a oscilloscope for measurement is that it cannot affect the results. The fact that it is affecting the results leans toward a bad ground

#29   — Edited

Hi JD,

Moving the resistor between TX and +3.3v instead of GND didn't help. Less incoming characters and all incoming characters are corrupted. Removed GND from Digital pin. Connected now is GND from UART0, D5 and D18. As UART1 and 2 are still working fine, ground is fine for UART1 and 2 even using GND from UART0 Any grounding issue with UART0 therefore would be internal to the EZ-Bv4 isn't it?

#30  

Maybe ez robot should try and replicate this scenario at there facility. Get it resolved quicker?

PRO
Synthiam
#31  

We replicate it daily. Many of our robots have arduino, ssc-32 or uart<->usb devices connected. Also, the lidar dev units all connect to uart0. This works for us on a daily basis, which is why i'm at a loss to of why it wouldn't work for tonlaar. All signs point toward a bad ground is the only suggestion i have, even if it sounds like a broken record.

Connecting devices to UART 0 is common practice for us on a daily basis

#32  

Long shot, but where are you located?  Maybe one of us is close enough to let let you test with another EZ-B and rule out anything wrong specific to yours?

#33  

Ya, I agree with Thetechguru. Try another EZB. There may be something wrong internally with the one you're using.

Have you tried wiring directly and eliminating the breadboard?

#34  

The thing is the whole setup including the the 2 ground wires I use are working for UART1 and UART2 so Serial communication is working but not for the UART0