Page 1 of 2
Z-UNO UART at 115200bps
Posted: 23 Dec 2016 16:42
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!
Re: Z-UNO UART at 115200bps
Posted: 23 Dec 2016 21:34
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
Re: Z-UNO UART at 115200bps
Posted: 26 Dec 2016 02:48
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"
Re: Z-UNO UART at 115200bps
Posted: 26 Dec 2016 03:07
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...
Re: Z-UNO UART at 115200bps
Posted: 26 Dec 2016 15:19
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?
Re: Z-UNO UART at 115200bps
Posted: 26 Dec 2016 16:09
by p0lyg0n1
Hi,
First of all:
1. Don't do this:
you have only 2KB of RAM.
2. Use correct speed 115200
Now you try this:
Re: Z-UNO UART at 115200bps
Posted: 26 Dec 2016 16:26
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...
Re: Z-UNO UART at 115200bps
Posted: 26 Dec 2016 17:15
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.
Re: Z-UNO UART at 115200bps
Posted: 26 Dec 2016 19:52
by hrob
Hmm... Definitely not working for me... So I will need to wait until you change that to DMA? Anything I could do?
Re: Z-UNO UART at 115200bps
Posted: 27 Dec 2016 22:25
by michap
Can you describe your Z-Wave device you want to create?
Maybe any other work around can be?
Michael