Max frame rate?
Moderators: jsmcortina, muythaibxr
-
- Super MS/Extra'er
- Posts: 1072
- Joined: Fri Sep 16, 2011 5:29 am
- Location: Brisbane, Australia
- Contact:
Max frame rate?
G'day folks, just looking at the max frame rate of MS2 vs the 115,200 bps serial connection speed and where the delay is at...
So, looking at straight serial, there is a max transfer rate of 14,400 bytes/sec (at 115,200 bps).
With the payload at around 175 bytes, that would indicate a maximum frames of ~82 frames per second.
Now I'd assume the serial port needs to be sent an 'A' from the PC and then the MS2 needs to see this command (via an interupt) and then respond with writing out txtbuf to the serial port... so this has some lag in response.
What I'm puzzled about is why does the frame rate reach nothing like 80 frames/second? It seems hard to reach even 20 which is 4x less than the serial port bandwidth... so why have the port at 115,200 bps ???
Would it not be more reliable to have a serial connection at 57,600 and if not, why not?
G
So, looking at straight serial, there is a max transfer rate of 14,400 bytes/sec (at 115,200 bps).
With the payload at around 175 bytes, that would indicate a maximum frames of ~82 frames per second.
Now I'd assume the serial port needs to be sent an 'A' from the PC and then the MS2 needs to see this command (via an interupt) and then respond with writing out txtbuf to the serial port... so this has some lag in response.
What I'm puzzled about is why does the frame rate reach nothing like 80 frames/second? It seems hard to reach even 20 which is 4x less than the serial port bandwidth... so why have the port at 115,200 bps ???
Would it not be more reliable to have a serial connection at 57,600 and if not, why not?
G
Mazda MX5 + MS3 Pro
Re: Max frame rate?
Maybe because you don't want to calll realtime() 80 times per second?
The man behind MS Labs
2005 Audi A3 2.0L TFSI DSG AWD - Extreme MS3
2002 Mazda Miata 1.8 6sp - Enhanced MS3 1.4.0, sequential injection, sequential ignition, big turbo, lots of boost
2005 Audi A3 2.0L TFSI DSG AWD - Extreme MS3
2002 Mazda Miata 1.8 6sp - Enhanced MS3 1.4.0, sequential injection, sequential ignition, big turbo, lots of boost
-
- Site Admin
- Posts: 39617
- Joined: Mon May 03, 2004 1:34 am
- Location: Birmingham, UK
- Contact:
Re: Max frame rate?
See scope shot:
James
The "high" baud rate is useful for fetching and sending configuration data.James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk
My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
-
- Super MS/Extra'er
- Posts: 12732
- Joined: Sat Jul 16, 2005 8:07 am
- Location: Moorseville, NC
- Contact:
Re: Max frame rate?
What firmware are you using?What I'm puzzled about is why does the frame rate reach nothing like 80 frames/second? It seems hard to reach even 20 which is 4x less than the serial port bandwidth... so why have the port at 115,200 bps ???
What USB to serial chip?
What version TunerStudio?
With the current beta TunerStudio, MS2E 3.3b and an FTDI chip USB to serial on Windows 7
I am getting ~52 reads per second. So that isn't a surprising loss.
With the FTDI chip, check the Advanced settings, make sure you set latency to 1, by default it is 16. That has a pretty good performance effect.
Phil Tobin
EFI Analytics, helping to simplify EFI
Next Generation tuning software.
Supporting all MegaSquirt versions and firmwares.
http://www.TunerStudio.com
http://www.efiAnalytics.com/MegaLogViewer/
Support the firmware running your engine:
http://www.msextra.com/doc/donations.html
EFI Analytics, helping to simplify EFI
Next Generation tuning software.
Supporting all MegaSquirt versions and firmwares.
http://www.TunerStudio.com
http://www.efiAnalytics.com/MegaLogViewer/
Support the firmware running your engine:
http://www.msextra.com/doc/donations.html
-
- Experienced MS/Extra'er
- Posts: 193
- Joined: Wed Nov 11, 2009 11:35 am
- Location: Berlin, Germany
Re: Max frame rate?
Hi,
the 3.1.1 Firmware with a payload of 169 bytes was able to supply around 67 frames/second which comes quite near to your 80 frames/s. This was achieved with an AVR logging to an SD-Card.
I have never seen more than >25 frames on a PC but it is nice to hear, that 52 are possible.
Best Regards, Mario
the 3.1.1 Firmware with a payload of 169 bytes was able to supply around 67 frames/second which comes quite near to your 80 frames/s. This was achieved with an AVR logging to an SD-Card.
I have never seen more than >25 frames on a PC but it is nice to hear, that 52 are possible.
Best Regards, Mario
Peugeot 106 Sergio_Tacchini, 1124cm³, MS2/Extra pre3.3alpah15, E85
Citroen AX, 954cm³, MS2/Extra pre3.3alpha15, E85
Peugeot 106 Rallye, 1298cm³ ... waiting for ITBs and full sequential injection
Citroen AX, 954cm³, MS2/Extra pre3.3alpha15, E85
Peugeot 106 Rallye, 1298cm³ ... waiting for ITBs and full sequential injection
-
- Super MS/Extra'er
- Posts: 1072
- Joined: Fri Sep 16, 2011 5:29 am
- Location: Brisbane, Australia
- Contact:
Re: Max frame rate?
I wonder then if all those calls to "realtime()" are really effective and not just chewing up CPU time in the mainloop when perhaps a single realtime() at the end of the loop would achieve the same results and actually allow the main loop to run a little quicker?
My thinking is that the serial functions aren't actually occurring (for a MS2 using ~60 frame/second) any quicker than the total time it takes to step through the entire main loop - I mean it is only able to grab data from the outpc variables every 16 milliseconds and yet the main loop seems to execute in sub milliseconds... so it is unclear why all the realtime calls???
G
My thinking is that the serial functions aren't actually occurring (for a MS2 using ~60 frame/second) any quicker than the total time it takes to step through the entire main loop - I mean it is only able to grab data from the outpc variables every 16 milliseconds and yet the main loop seems to execute in sub milliseconds... so it is unclear why all the realtime calls???
G
Mazda MX5 + MS3 Pro
-
- Super MS/Extra'er
- Posts: 1072
- Joined: Fri Sep 16, 2011 5:29 am
- Location: Brisbane, Australia
- Contact:
Re: Max frame rate?
I'm using the latest 3.3b firmware and unsure on the seria/usb chipset - I bought the cable that DIY are selling as being compatible (is it?). I'll check the latency settings and change it if not correct.LT401Vette wrote: What firmware are you using?
What USB to serial chip?
What version TunerStudio?
With the current beta TunerStudio, MS2E 3.3b and an FTDI chip USB to serial on Windows 7
I am getting ~52 reads per second. So that isn't a surprising loss.
With the FTDI chip, check the Advanced settings, make sure you set latency to 1, by default it is 16. That has a pretty good performance effect.
G
Mazda MX5 + MS3 Pro
Re: Max frame rate?
Hmmm. Interesting. Last time I looked at realtime() (unless my memory's playing tricks on me again) it was sending bytes one at a time without using the Tx interrupt. So it would need to be called every 0.086ms (86µs) in order to keep the SCI unit busy at 115,200 bps, hence the scattering of calls to realtime() through the mainline. But looking now at recent versions, SCI0.TIE gets set, i.e. the transfer is being done by interrupt, so there is no longer any need for that part of realtime() to be called repeatedly. I haven't looked into what ck_log_clr(), chk_crc(), cp_page() at the top of realtime() do. Perhaps they still need to be called frequently. In that case, for a very minor saving, I suppose the lower part of realtime() could be pulled into a separate function and called, as you say, at just one place in the mainline.gslender wrote:I wonder then if all those calls to "realtime()" are really effective and not just chewing up CPU time in the mainloop when perhaps a single realtime() at the end of the loop would achieve the same results and actually allow the main loop to run a little quicker?
My thinking is that the serial functions aren't actually occurring (for a MS2 using ~60 frame/second) any quicker than the total time it takes to step through the entire main loop - I mean it is only able to grab data from the outpc variables every 16 milliseconds and yet the main loop seems to execute in sub milliseconds... so it is unclear why all the realtime calls???
G
I seem to remember that the avoidance of a SCI Tx interrupt was to avoid jitter in the more important things (sparks and squirts).
Have fun,
Rob.
-
- Site Admin
- Posts: 39617
- Joined: Mon May 03, 2004 1:34 am
- Location: Birmingham, UK
- Contact:
Re: Max frame rate?
Robs is spot on with the historical reasoning there. But if you look at the scope trace, the big hit on frame rate is the 5ms when the firmware is waiting for a command. The processing and sending are quite close to max efficiency.
James
James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk
My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
-
- Super MS/Extra'er
- Posts: 1072
- Joined: Fri Sep 16, 2011 5:29 am
- Location: Brisbane, Australia
- Contact:
Re: Max frame rate?
Sure, but it would seem the numerous realtime() calls are chewing up CPU time with zero benefit yeah? I mean it is just slowing down the mainloop and not much else... or am I missing something?jsmcortina wrote:Robs is spot on with the historical reasoning there. But if you look at the scope trace, the big hit on frame rate is the 5ms when the firmware is waiting for a command. The processing and sending are quite close to max efficiency.
James
g
Mazda MX5 + MS3 Pro
-
- Site Admin
- Posts: 39617
- Joined: Mon May 03, 2004 1:34 am
- Location: Birmingham, UK
- Contact:
Re: Max frame rate?
Yes, but all of those calls are probably a smaller cost than a single 32bit divide.
James
James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk
My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
-
- Super MS/Extra'er
- Posts: 1072
- Joined: Fri Sep 16, 2011 5:29 am
- Location: Brisbane, Australia
- Contact:
Re: Max frame rate?
Mmmm, so your saying that many times of calling realtime() doesn't cost much mainly because rtsci isn't #1 and drops straight through to the bottom at skip_rt and the benefit is that when the serial port is ready, it is filled with the most recent/ready information from the ecu at that time?jsmcortina wrote:Yes, but all of those calls are probably a smaller cost than a single 32bit divide.
James
Is that why all the "realtime()" calls are there ?? to ensure it is realtime...
G
Mazda MX5 + MS3 Pro
-
- Site Admin
- Posts: 39617
- Joined: Mon May 03, 2004 1:34 am
- Location: Birmingham, UK
- Contact:
Re: Max frame rate?
With the change to interrupt driven sending, we likely could remove a few. However, I'd expect the change in mainloop time to be barely measurable.gslender wrote:Is that why all the "realtime()" calls are there ?? to ensure it is realtime...
James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk
My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
-
- Super MS/Extra'er
- Posts: 1072
- Joined: Fri Sep 16, 2011 5:29 am
- Location: Brisbane, Australia
- Contact:
Re: Max frame rate?
Removed all but one (1) realtime() call out of the mainloop. Went for a drive and found the logging behaviour to be as consistent as before. Probably need to do some more before/after testing but given how quick the mainloop cycles, I doubt having just one realtime() will impact the overall "realtime-ness or freshness" of the data being sent to the serial buffer.jsmcortina wrote:With the change to interrupt driven sending, we likely could remove a few. However, I'd expect the change in mainloop time to be barely measurable.
Obviously I also need to confirm what the change has produced in terms of benefits, but from a clean code perspective, it would have benefits by keeping the number of bytes used down and reduce clutter etc, I know it is only small amounts, but every byte can impact and needless calls that don't add value surely should be removed - certainly didn't have an ill effects and can't see how it could either.
There is also some calls in the realtime() that I need to better understand - like cp_page() that only really runs if flagbyte6 & FLAGBYTE6_PAGECOPY is set, yet nowhere I could find in the code that actually sets that bit to be on, so from what I can quickly find, nothing would result in that code running, yet it takes up ram space???
G
Mazda MX5 + MS3 Pro
-
- Super MS/Extra'er
- Posts: 1072
- Joined: Fri Sep 16, 2011 5:29 am
- Location: Brisbane, Australia
- Contact:
Re: Max frame rate?
Well, removed (commented out) the entire cp_page() function and no ill effect (at least with my limited testing). I guess it was a redundant bit of code?gslender wrote: There is also some calls in the realtime() that I need to better understand - like cp_page() that only really runs if flagbyte6 & FLAGBYTE6_PAGECOPY is set, yet nowhere I could find in the code that actually sets that bit to be on, so from what I can quickly find, nothing would result in that code running, yet it takes up ram space???
G
Mazda MX5 + MS3 Pro
-
- Super MS/Extra'er
- Posts: 9130
- Joined: Sun May 02, 2004 6:51 am
- Location: Quebec, Canada
- Contact:
Re: Max frame rate?
Look in isr_sci.s and you'll see that it should be ok to remove it.
Jean
Jean
-
- Super MS/Extra'er
- Posts: 1072
- Joined: Fri Sep 16, 2011 5:29 am
- Location: Brisbane, Australia
- Contact:
Re: Max frame rate?
Sweet. Well that's a few more bytes of space and a small improvement in the main loop time.racingmini_mtl wrote:Look in isr_sci.s and you'll see that it should be ok to remove it.
Jean
Mazda MX5 + MS3 Pro
-
- Super MS/Extra'er
- Posts: 1681
- Joined: Tue Oct 27, 2009 6:24 am
- Location: Van Alstyne, Texas
Re: Max frame rate?
FWIW I'm getting 49-52 fps with my old zombie killer Itronix Gobook3/PentiumM @1.8 Ghz, 16550a (real) serial port under Linux 2.6.38.
I get ~10-11 fps with a Class1 BT connection to an HTC Hero running Cyanogenmod 7 (Honeycomb)/Shadowlogger , will check with my Microconnectors dual USB setup tomorrow and also using XP, and BT>TS under Linux and XP.
I get ~10-11 fps with a Class1 BT connection to an HTC Hero running Cyanogenmod 7 (Honeycomb)/Shadowlogger , will check with my Microconnectors dual USB setup tomorrow and also using XP, and BT>TS under Linux and XP.
Always doing things the hard way, MS2 sequential w/ v1.01 mainboard, LS2 coils. 80 mile/day commuter status.
-
- Super MS/Extra'er
- Posts: 1072
- Joined: Fri Sep 16, 2011 5:29 am
- Location: Brisbane, Australia
- Contact:
Re: Max frame rate?
Where do you measure frame rate in TS.... I've drawn a blank?
G
G
Mazda MX5 + MS3 Pro
-
- Super MS/Extra'er
- Posts: 9130
- Joined: Sun May 02, 2004 6:51 am
- Location: Quebec, Canada
- Contact:
Re: Max frame rate?
I don't know if there is a better way now but I count the number of frames in the same second in a log file. Make sure you set the communications to the fastest data rate.
Jean
Jean