Z-UNO UART at 115200bps

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
hrob
Posts: 5
Joined: 23 Dec 2016 16:15

Z-UNO UART at 115200bps

Post by hrob »

Hi,

I recently got a Z-Uno and am trying to "z-wave-enable" my "old" Botvac D85. During my tests with my z-uno board I found that for some reason the serial communication with speeds above 9600bps using either Serial0 or Serial1 is malfunctioning.

While sending works fine, receiving massively drops characters... This leads to unusable results for 115200bps. I retested with a USB-UART board and found that the issue starts for speeds above 9600bps (see below for 19200)

Code: Select all

?

USB ost DC Comuniction Clas v1.0

 BAU <valu>          -1900|3400|5700|15200]
                       [23400|6080]
  I         0- Sting - endsstrig onceCR rceivd
                     2 - acket- sens a pcket trin
  CHO ONOFF            SetLoca Ech ON orOFF
   OF
  HLP o ?            - diplayhelp
and with 115200 and communicating to my botvac ("GetVersion"-command)

Code: Select all

telmrS25a6f
naVs,,o,tBi00,AaQSEPV
r m,21412f
euor0,irhe,EU_WKV
fr11Uodrr0
IaSte,
cP6,aSoy1LSOO,WlTeWEOO,
Gei
peMoiri,
sD2.800
typ,M0L
wT,LER,oleei20
rMrp,UMOR
rSe2,CsR1
onre,PERI
Da,704
 U8x0,DeaP1A04,LSte.15000
a,OLS
gsT,MSOO,MBrelurP2,a61
iaVs,,oltci00,QaQSEPV
r m,S1512f
duPr0,iBhp,ER_RKE
fa1,UBdra0,Ia tr,
cP,,WSsy1ASSO,Wlde,EOO,
Is there anything I can do?

Thanks in advance!
michap
Posts: 442
Joined: 26 Mar 2013 10:35
Contact:

Re: Z-UNO UART at 115200bps

Post by michap »

Hi,

I never had such an issue - working in most cases with Serial0 at 115200

Sounds like wrong parameters - have you checked flow control?

Michael
hrob
Posts: 5
Joined: 23 Dec 2016 16:15

Re: Z-UNO UART at 115200bps

Post by hrob »

Hi,
thanks for that info. I found it really strange that this should not (in general) work...

First, Serial0 or Serial1 make no difference.

About Parameters... Both devices should return data as 8/N/1, yet, I do not know how to change that anyway...
What is strange, though: I can transmit (on the receiver side properly interpreted) commands to the receiving uC (in all cases). This let me to believe that something within z-uno is eating up CPU-cycles (a lot) and thus makes it difficult to catch all data-bytes...

Just for clarification, only thing I am doing right now is passing through data:

Code: Select all

void loop() {
  if (Serial.available() > 0) {
    char in = Serial.read();
    Serial1.write(in);
  }

  if (Serial1.available() > 0) {
    char in = Serial1.read();
    Serial.write(in);
  }
}
I really do not know how to solve this issue...

Thx again and "Frohe Weihnachten"
User avatar
PoltoS
Posts: 7579
Joined: 26 Jan 2011 19:36

Re: Z-UNO UART at 115200bps

Post by PoltoS »

Have you tried to disable one side and just catch all data from your Botvac into a string and only then print it to USB?

Just to check if Z-Uno work ok with only one UART working. May be they interfere and makes it loose bytes...
hrob
Posts: 5
Joined: 23 Dec 2016 16:15

Re: Z-UNO UART at 115200bps

Post by hrob »

Hi,

so now I also tried that... Sadly the same result...
Here the code:

Code: Select all

char serialBuffer[100000];
int readcounter = 0;
int command = 0;

#define BTN_PIN     18
#define LED_PIN     13

void setup() {
  // put your setup code here, to run once:

  Serial.begin();
  Serial1.begin(115000);
  pinMode(BTN_PIN, INPUT_PULLUP);  // set button pin as Input
  pinMode(LED_PIN, OUTPUT);        // set LED pin as output
}

void loop() {

  if (command == 0) {
    // Only ask for button if not a command was already sent...
    
    byte buttonState = digitalRead(BTN_PIN);
    
    if (buttonState == LOW) {
      //ButtonPressed

      command = 1;
      digitalWrite(LED_PIN, HIGH); // turn the LED on
      delay(1000);
      Serial1.println("GetVersion");
    }
    else {
      digitalWrite(LED_PIN, LOW);  // turn the LED off
    }
  }
 
  if (Serial1.available() > 0) {
    char in = Serial1.read();
    serialBuffer[readcounter] = in;

    if (serialBuffer[readcounter] == '\x1A')
    {
      // Transmission ends with a CTRL-Z

      Serial.print("Transmission received with ");
      Serial.print(readcounter);
      Serial.println(" bytes:");
      Serial.println("==================");

      for (int i=0;i<readcounter;i++) {
        Serial.write(serialBuffer[i]);
      }
      Serial.println();
      Serial.println("==================");
      readcounter=0;
      command = 0;    // Ready for new Button
      digitalWrite(LED_PIN, LOW);  // turn the LED off
    }
    else {
      readcounter++;
    }
  }
}
The results:
Transmission received with 128 bytes:
==================
romnMoirdusD,00BypNHCLor1L_Gol r20
uor1UORI
he0,aiv,oee,PN_ICPeAEPDSiNrP,a2f
dhw0,euT,DBOE_Vow,1Braw,
oda,3
mr
aSoeWEOG
eoe,_D,
==================
Transmission received with 0 bytes:
==================

==================
Transmission received with 130 bytes:
==================
Ge
onM,nBd
a00,0tr,N_E
oy1W_
oari,,
hty1HO_IBhd2
aR,
osy,OS_,CteSTREeab,2562,
rPr5
dsy,DUVER
oe,
Bda,0Ioow1,cP5
lny,LE_I
ey,H_OG

==================
Transmission received with 129 bytes:
==================
Viootjn,luaI0.0
ry,ME,or1LRRoore,0
ror,R_TI
se2,hs,,oeT,PEOGDa,_EPV
luO2,461SePr0,drp2_UVER1fa2
ara,Ua tr,aP6
lnr1ANRG
eo1H__G

==================
I am really running out of ideas here... Is there a way to change the Serial Parameters?
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: Z-UNO UART at 115200bps

Post by p0lyg0n1 »

Hi,
First of all:
1. Don't do this:

Code: Select all

char serialBuffer[100000];
you have only 2KB of RAM.

2. Use correct speed 115200
Now you try this:

Code: Select all

Serial1.begin(115000);
hrob
Posts: 5
Joined: 23 Dec 2016 16:15

Re: Z-UNO UART at 115200bps

Post by hrob »

Hi,

sorry. That was just a copy/paste issue... I read somewhere that serial transmissions only accept about 2.5% speed difference between HW-clocks, so i tried to shift my timing a little (anticipating the errors are due to losses on bit-level)... Correct speed does not change anything, though...

About RAM: right. reduced that but this did not cause the trouble, either...
User avatar
PoltoS
Posts: 7579
Joined: 26 Jan 2011 19:36

Re: Z-UNO UART at 115200bps

Post by PoltoS »

Z-Uno current implementation do read byte per byte when control is out of loop() or on Serial.*. Data is buffered. If you read slower than it is obtained via Serial, some bytes might be dropped. We will certainly change this to DMA version in future if this will make problems. But so far for small data it was always ok.
hrob
Posts: 5
Joined: 23 Dec 2016 16:15

Re: Z-UNO UART at 115200bps

Post by hrob »

Hmm... Definitely not working for me... So I will need to wait until you change that to DMA? Anything I could do?
michap
Posts: 442
Joined: 26 Mar 2013 10:35
Contact:

Re: Z-UNO UART at 115200bps

Post by michap »

Can you describe your Z-Wave device you want to create?
Maybe any other work around can be?

Michael
Post Reply