How to make the PST faster than 115,200 bps?
turbosupra
Posts: 1,088
I've tried going beyond 115200 and not had success, has anyone done this besides viewport which I believe is around a gbps.
Does something in the actual object need to be modified as well? I'd like to go up to 250000 or 460800, I need to compare a bunch of data all at once to chase down an issue I'm having.
Does something in the actual object need to be modified as well? I'd like to go up to 250000 or 460800, I need to compare a bunch of data all at once to chase down an issue I'm having.
Comments
For the computer side, try using a different terminal program.
Is it still too slow, maybe I'll have to try and write a PASM com program?
In any case, FullDuplexSerialPlus and FullDuplexSerial4Port both use only two pins per serial coms: one TX pin and one RX pin. With the four port, you need a pair for each port. I don't know if ViewPort uses 4 pins, but I doubt it: the FTDI chip has only RX and TX.
I wrote an rxblock routine that is able to handle 2 mega-bits/second. It uses bytemove to move data from the FDS receive buffer to a data buffer. I plan on integrating this into my YMODEM code at some point. A similar technique could be used for transmit to speed that up also.
EDIT: This routine handles a buffer size of 128. Other sizes can be handled by changing the values of 128 and 127 to the buffer size and the mask. The buffer size must be a power of 2. The return value indicates the number of bytes read, which is between 0 and num.
I just timed a program at two different bauds.
At 57600 baud the loop to display the PlayStation 2 controller information (after removing any waitcnt statements) took 47.8 million clock cycles. At 115200 baud the same loop only took 2.99 million clock cycles.
I think 57600 is still below the maximum useful baud rate for the Prop (using Spin).
Edit: I think 115200 is approaching the limit for Spin. I changed the baud to 230400 and the loop time changed to 2.89 million cycles. Not much better than the time at 115200. The loop time didn't change when I increased the baud to 250,000.
Actually, much of the screen isn't printed each loop.
I counted 285 characters displayed each loop.
Some while ago I made some improvements to the Full Duplex Serial driver to speed it up a bit. The following thread speaks about it.
http://forums.parallax.com/showthread.php?126569-Fast-Full-Duplex-Serial-to-921600
Somewhere in this forum I have also posted a 5 Megabit/sec assembly based full duplex driver, taking data from/to a hub buffer of any desired size. Would take some digging to find it I suppose. Be happy to do that if it is of interest to you.
Cheers,
Peter (pjv)
I'd be VERY interested in a 2Mbps full duplex driver. Most of the stuff I make hangs off a FTDI USB adaptor, and I have times when it'd be far easier to blast out an ascii .csv data file over the serial port at 2Mbps than switch to a packed binary format that needs decoding software on the PC. (though it sounds like I'd need to make some ASM formatting code [and a faster terminal program] to truly use this speed.)
You can search for your own posts if you click on you name in the top left of a post. Also you can see everything you've ever attached to a forum post in the dialog to attach a new file.
Lawson
Thanks for the tip on how to quickly examine all posts I have made. It was a great help to track down the 5Megabit/sec routines I was referring to. The link is here.
http://forums.parallax.com/showthread.php?120125-5Mbit-sec-ASCII-streaming-from-to-Hub-RAM
Holler if you have any questions.
Cheers,
Peter (pjv)
Looking at your code, I'm only a PASM novice and a little overwhelmed trying to follow the logic, do you think you could give an example of how to use it?
Just an aside since a fast scan of this thread revolves around hacking the serial object without mentioning some other limitstions.
You should take a look at the RS-232 standards regarding handshake and the fact that you must derate the speed as the line distance increases. Since your project seems to be instrumenting and controlling an engine, in another thread, depending on how you lay out your comms may affect the speeds you can communicate to your data collection system (laptop?) You may need to implement hardware rts/cts or software (xon/xoff) so that you don't overflow and get giberish.
Although it costs more it may be worth going CAN for the speed, increased distance and noise immunity inherent in CAN. NXP or TI may be a good source of sample devices. I may be mis-crediting, but it seems Jonnymac has threads regarding CAN as well. All of the OEM medical imaging systems I work with use CAN for high-speed non-real time data.
FF
I'd like to do that, but what are you looking for me to test with? Just a loop that does a cnt print screen? Am I missing something? They seem pretty close?
I'm getting the same results against PST, FDS and FastFDS?
I remember you writing that and that has been lingering in the back of my head ever since you did. The way this object was presented, it seemed as if this driver had a way around that.
Would my com loop have to run completely in PASM to get faster than 125k bps?
jm_txserial won 2 of the tests (seems to be faster with small values or numbers followed by carriage returns)
FastFullDuplexSerial won 2 of the tests (seems to be faster with long strings)
Now, how to correlate this to bps?
Test bits sent :
"string " + (previous cnt - current cnt) + carriage return
Fast Full Duplex Serial (by PJV) - 126176 clk cycles between loops
Full Duplex Serial - 126176 clk cycles between loops
Parallax Serial Terminal - 126176 clk cycles between loops
jm_txserial - 115872 clk cycles between loops
Test bits sent :
"string adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd " + "string adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd " + (previous cnt - current cnt) + carriage return
Fast Full Duplex Serial (by PJV) 832784 - clk cycles between loops
Full Duplex Serial - 1175120 clk cycles between loops
Parallax Serial Terminal - 1173520 clk cycles between loops
jm_txserial - 1165520 clk cycles between loops
Test bits sent :
"Value 1: " + "1" + "Value 2: " + "2" + "Value 3: " + "3" + "Value 4: " + "4" + "Value 5: " + "5" + "Value 6: " + "6" + "Value 7: " + "7" + (previous cnt - current cnt) + carriage return
Fast Full Duplex Serial (by PJV) - 751504 clk cycles between loops
Full Duplex Serial - 751504 clk cycles between loops
Parallax Serial Terminal - 751504 clk cycles between loops
jm_txserial - 697088 clk cycles between loops
Test bits sent :
adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfa
sfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfa
sdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdf
asfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasf
asdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfad
fasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfa
dfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadf
adfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfad
fadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfas
dfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfas
dfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfa
dfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfa
sdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfa
dsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfa
dsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfa
sdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd
adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfa
sfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfa
sdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdf
asfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasf
asdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfad
fasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfa
dfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadf
adfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfad
fadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfas
dfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfas
dfasdfadfadfadfadfadfasfasdfasfasdfasfd adfasdfadsfadsfasdfadfasdfasdfadfadfadfadfadfasfasdfasfasdfasfd+ (previous cnt - current cnt) + carriage return
Fast Full Duplex Serial (by PJV) - 17520096 clk cycles between loops
Full Duplex Serial - 26043840 clk cycles between loops
Parallax Serial Terminal - 25679456 clk cycles between loops
jm_txserial - 25830368 clk cycles between loops
I think I understand what you meant earlier about spin being the limitation. I tried your MIT license in a spin loop (modified your code with the section posted below) and the best I could get from cnt measurement to cnt measurement was 2530592 clk cycles 0.0316324 seconds, which is about 53110 bps, backing up what you said earlier. I believe you said nothing could be done about this if spin were used.
Could something be written where when a program is loaded, a bunch of spin long addresses are passed to a pasm com cog that could loop and write their values to the terminal? And therefore effectively circumvent the spin loop bottleneck?
I took your code and ran it on one of my QuickStart boards while my scope was attached to capture the data streams.
The scope is set to decode the streams into ascii (or hex) characters, and I have 5 screen shots for you.
The first (000) is your standard FullDuplex driver at 115200. Notice the 100-ish usec space between characters, and 300 odd usec between packets.
The second (001) is the FastFullDuplex driver at 921600, using the same 200 usec horizontal resolution. The charactes appear as merely horizontal "ticks", with a varying 100 to 200 usec of time between them. There is insufficient resolution for the ascii decoder to display the text. As pointed out earlier in the thread by Dave and others, this idle time between characters is the time consumed by Spin to process and render the data.
The third screen (002) is the same data, but zoomed (the bracketed section from the upper non-zoomed part) to 40 usec per division. The individual characters are now clearly visible.
The fourth (003) is again the same data, but the bracketed section is moved over a couple of characters.
The last shot (004) is again the same data, but zoomed to 20 usec, and displaying the characters as hex instead of ascii. Also I forgot to turn the capture details off, so the scope menu and parameters are visible.
As you can see, the Fast Duplex (transmitter at least) works at the specified speed; it is Spin that throttles things so markedly. If you need truly fast communications, Spin cannot be part of your rendering loop. You will need to capture the data into a file in hub, then dump it out via an assembler routine.
If assembler is not part of your repertoire, then 115200 is about the fastest that Spin can manage.
Hope this helps.
Cheers,
Peter (pjv)
I tested your program and saw as you stated, am I correct about the reason when it looped inside of a spin loop it would only update at 53000bps?
In scanning this thread I was left wondering what you are trying to accomplish. The first post says, "I'd like to go up to 250000 or 460800, I need to compare a bunch of data all at once to chase down an issue I'm having." It appears from what follows that you only need to transmit data, not receive. What means, "compare a bunch of data"?
A "bunch of data" is technical jargon for longs from different pasm cogs
In a perfect world, I'd have something that was 460800 or 921600, that could send and receive data, the receive would be 2% of the bandwidth (occasional key stroke updates) and the send 98% of the duplex bandwidth. Maybe a PASM object that could be preloaded with an array of longs to read and send? And it could loop and update the values as fast as my heart desired? I would even attempt to write this on my own (if possible) if I were a little better with PASM and had a push in the right direction.