Serial strange behaviour

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
vebryn
Posts: 8
Joined: 16 Dec 2017 02:38

Serial strange behaviour

Post by vebryn » 11 Jan 2018 01:29

Hello,

I suspect an issue using baudrate less than 9600. Let me explain some cases :

Case 1, 2 and 3: Z-Uno connected to PC using Serial

Code: Select all

int ByteReceived;

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

void loop(){
  if (Serial.available() > 0){
    ByteReceived = Serial.read();     
    Serial.print(char(ByteReceived));
  }
}
Case 1: both Z-Uno and PC serial baudrate set to 9600
When I send Hello World, I get back Hello World. :arrow: OK

Case 2: Z-Uno serial set to 1200 and PC serial set to 1200
When I send Hello World, I get back Hello World. :arrow: OK

Case 3: Z-Uno serial set to 1200 and PC serial set to 9600
When I send Hello World, I get back Hello World. What ? I must not be able to read my message with a wrong baudrate.

Case 4, 5 and 6: Z-Uno connected to Sparkfun FDTI Basic (https://www.sparkfun.com/products/9873) using Serial0

Code: Select all

int ByteReceived;

void setup(){
  Serial0.begin(9600); 
}

void loop(){
  if (Serial0.available() > 0){
    ByteReceived = Serial0.read();     
    Serial0.print(char(ByteReceived));
  }
}
Case 4: both Z-Uno and Sparkfun FDTI serial set to 9600
When I send Hello World, I get back Hello World. :arrow: OK

Case 5: Serial connected to Sparkfun FDTI Basic https://www.sparkfun.com/products/9873, Z-Uno serial set to 1200 and Sparkfun FDTI serial set to 9600
When I send Hello World, I get back �����������. :arrow: OK

Case 6: Serial connected to Sparkfun FDTI Basic https://www.sparkfun.com/products/9873, Z-Uno serial set to 1200 and Sparkfun FDTI serial set to 1200
When I send Hello World, I get back �����������. What ? I must be able to read my message with a proper baudrate.

Case 3 and 6 are abnormal situations. Z-Uno seems not working well using a baudrate of 1200. I test a few other speed; 2400, 4800 and 19200. Both 2400 and 4800 are not working. 19200 is working fine. Is it related to oscillator frequency ? Too fast to cadence a speed below 9600 ?

Best regards.

vebryn
Posts: 8
Joined: 16 Dec 2017 02:38

Re: Serial strange behaviour

Post by vebryn » 11 Jan 2018 02:12

argh! I just saw on Reference page that 9600 is the minimum speed accepted.
Sets the data rate in bits per second (baud) for serial data transmission. For USB baudrate is fixed on 115200 bps, on UART it is possible to select baudrate. Valid values are: 9600, 14400, 19200, 38400, 57600, 115200, 230400 bps
Any hope to support speed below 9600 :?: Arduino supports speed from 300 to 115200.
Is SoftwareSerial from Arduino compatible with Z-Uno :?:

User avatar
PoltoS
Posts: 3894
Joined: 26 Jan 2011 19:36

Re: Serial strange behaviour

Post by PoltoS » 11 Jan 2018 23:47

Z-Uno uses h/w UART from the Z-Wave chip. You can do s/w UART, but Arduino SoftwareSerial uses a lot of ASM instructions, hence not portable at all. You will have to adopt it for Z-Uno. For lower rates where speed is not that fast this should not be hard.

vebryn
Posts: 8
Joined: 16 Dec 2017 02:38

Re: Serial strange behaviour

Post by vebryn » 15 Jan 2018 23:50

AltSoftSerial library seems nice : https://github.com/PaulStoffregen/AltSoftSerial.

However, it is based on an frequency timer (FTM) or an interrupt register (ICR).

What is the easy way to adapt this library ? Is FTM close to GPT ? Is there any ICR available on Z-UNO ?

Best regards.

User avatar
PoltoS
Posts: 3894
Joined: 26 Jan 2011 19:36

Re: Serial strange behaviour

Post by PoltoS » 22 Jan 2018 01:42

GPT is exactly what you need. Just make sure not to use this SoftSerial in higher bause rate (anyway useless, since Z-Way can handle it using h/w Serial).

Post Reply