Serin T38400_32 14M2

rjandsam

Member
Hi,
I have just been playing with a 14m2 and have a quick question.
is there any reason the below code works fine in example A but not example B.
I have also ran the same tests on a 28x2 and all is good at both these baud rates, the serial data is coming from a PC.

A: serin [800,main], DATAIN,t19200_32,("ABC"),b0,b3,b6

B: serin [800,main], DATAIN,t38400_32,("ABC"),b0,b3,b6

Thanks

Rich
 

hippy

Technical Support
Staff member
They should work equally well but higher baud rates can have less time between data bytes sent which may mean a PICAXE doesn't have time to process one byte before the next turns up which can lead to corrupt data, qualifiers not being matched, SERIN commands timing out.

What is sending the data and how ?
 

rjandsam

Member
Hi Hippy,
The data is being transmitted for test purposes by a PC USB to 485 adaptor, I pulled the 14m2 slave out of my 485 network as I was trying to speed things up but after programming them all with the new baud rate it all stopped. everything works fine again after reverting back to t19200_32. when I had problems with the 14m2s at t38400_32 I popped a couple of 28x2 in the network and they worked fine as one would expect, hence the reason for bench testing through the computer now.

Rich
 

rossko57

Senior Member
Write some diagnostic code, that does not use qualifiers, and reflects the data actually seen to the terminal. Because of the speed disparity, you might want to collect a "complete" packet i.e. detect an idle period, before sending to terminal.

EDIT as the test data is PC generated, try it with two stop bits
 

rjandsam

Member
Hi Rossko57,
your advice was spot on, I did the tests with 2 stop bits and had to reduce the serin timeout from 800 down to 10, after doing this it works great. its just a shame that this isn't documented as I've been pulling my hair out over this. I found that if the qualifier is removed it works fine as is using only 1 stop bit and a timeout of 800 but adding the qualifier your way is the only way it will work and also reducing the timeout.

Thank you for the advice
Rich
 

rossko57

Senior Member
manual for SERIN says
"A maximum of 4800 baud is recommended for complicated serial transactions at 8MHz"
that would equate to 19200 at 32Mhz, just as you found.

manual also says
"Note that the microcontroller may not be able to keep up with processing complicated datagrams at higher speeds - in this case it is recommended that the transmitting device leaves a short delay (e.g. 2ms) between each byte."

Are there more hints that you think necessary? "Complicated" is open to interpretation.

Having to fiddle with the timeout is probably a consequence of how closely your packets are sent out, which is not known to us or under Picaxe control.
 
Top