Prop to Prop problem
rixter
Posts: 95
Hello,
I am very new to the Propeller, so newbie issues may be obvious here. I am trying to get a simple communication between two Propellers (a Propeller Demo Board and a PE Kit). I am using the FullDuplex Serial object to send a series of bytes from one Prop to the other and display using the Parallax Serial Terminal object. I've succeeded in most respects, but I'm having a frustrating time figuring out some extraneous (and or dropped) characters at the receiving Prop. My suspicion was improper buffering or timing. I've tried all kinds of insertion of delays on the sending and receiving sides to remedy the issue, but those attempts make the situation worse. The Transtest.spin and Rectest2.spin listings are attached. What I get on the Parallax Serial Terminal display are a sequence of Hello! lines and random lello! or Hello1 as shown below. Any hints or clues as to what I am missing are greatly appreciated.
Rick
Hello!
Hello!
Hello!
Hello!
Hello!
Hello!
Hello1
Hello!
Hello1
Lello1
Hello!
Hello!
I am very new to the Propeller, so newbie issues may be obvious here. I am trying to get a simple communication between two Propellers (a Propeller Demo Board and a PE Kit). I am using the FullDuplex Serial object to send a series of bytes from one Prop to the other and display using the Parallax Serial Terminal object. I've succeeded in most respects, but I'm having a frustrating time figuring out some extraneous (and or dropped) characters at the receiving Prop. My suspicion was improper buffering or timing. I've tried all kinds of insertion of delays on the sending and receiving sides to remedy the issue, but those attempts make the situation worse. The Transtest.spin and Rectest2.spin listings are attached. What I get on the Parallax Serial Terminal display are a sequence of Hello! lines and random lello! or Hello1 as shown below. Any hints or clues as to what I am missing are greatly appreciated.
Rick
Hello!
Hello!
Hello!
Hello!
Hello!
Hello!
Hello1
Hello!
Hello1
Lello1
Hello!
Hello!
Comments
Another thing, use .rxtime(1) mode, and program your .tx to only send every .75ms or so.
This prevents the rx loop from catching data in the middle of a tx loop.
The rx loop needs time to return to getting more data, so does the tx loop. The rx loop needs more time to return, this info and more is in in the fullduplexserial file
Wait a minimum amount of time before every tx, to let the rx loop process and copy the data into ram.
I found that using transmit "keys" also helps align serial transmission.
Basically, you begin your data with a known "key" that you use to not only align transmissions, but this also acts as a kind of crc, if the first byte of data isn't the "key" then you know that your misaligned, and need to wiat for the first key byte.
rixter: Your problem sounds like the buffer is overflowing. When characters are not taken out of the receive buffer quick enough, a block of 16 will get lost as the buffer wraps around and begins to overwrtite the previous block. I suspect your spin code timing (I presume you are doing this in spin) is too slow. Just to prove this, lower your transmission rate to half that of the rate of the serial to the PST terminal. If you have a TV or VGA connected, it will be even easier to prove this is the problem.
In the OBEX is a FullDuplexSerial_RR004? of mine which allows you to have a much bigger buffer (up to 256 in powers of 2). Try this with a big buffer size and likewise you will see a different dropping of characters.
Rixter, the circuit is very important along with the software. Some considerations are pull up, pull down, duplex, stop bits, parity, power, and the choice of resistor values. Also you need protection resistors on the pins. You could make a circuit hand sketch and photo it and post the photo. I posted a hand sketch of some useful interfaces for prop to prop communication here for a type of simple serial. See post #112.
In transtest you send in full speed, in rec test you receive and the do debug transmissions to the terminal. This of course slows down the receiver loop ending up in a full buffer as cluso99 said. If you want to debug this you should propably use a different protocol. The sender waits for a ready to receive from the receiver before it sends new data, if possible. If not you could also start another COG for the debugging.
Rick
Thank you all for the suggestions and help.
Rick
The main thing I can't understand is why a dropping of the baud rate, while keeping all other code settings the same, can cause problems. So I can run fine at any speed from 38600 to 115200, but dropping to 19200 or lower causes problems. I had figured lower would also work better, albeit slower. Apparently when you slow the baud down enough, you have to fiddle with timing somewhere to compensate. Someone suggested rxtime(1) mode in Full DuplexSerial Object, but I had less success with that than using rx.
Rick
The reason it works sometimes is because of capacitance and static charge, but that will be very unreliable. Even if it works at certain baud, eventually that will fail or get disrupted by sun spots, power grid spikes, your neighbor turning on their microwave, etc...
The amount of RF, EMI, heck, even the movement of your neighbor walking across their carpet, generating static electricity will reak havok on your communications when you have no common ground.
(electrons always need a way back to the source)
High voltage is one exception, but even then the electrons are jumping off into the air, or into other objects, albeit with very little current, limiting the baud rates that can be used with this type of high voltage no ground method of data communication (your basically talking about radio then)
I appreciate the advice. It will be well taken in this project. While I ended up getting reliable communications in my final experiment in that phase of my project, I realize I need to implement sound principles in the future to assure success in conditions less than what may have been just an ideal sampling.
Thanks again for the contribution.
Rick