Notices
ECU Flash

DMA logging now working - logging 25x faster than MUT

Thread Tools
 
Search this Thread
 
Old Dec 24, 2007, 12:48 PM
  #16  
Newbie
 
Second Chance's Avatar
 
Join Date: Apr 2006
Location: Lutz
Posts: 83
Likes: 0
Received 0 Likes on 0 Posts
With the strings, you may also want to look into the StringBuilder class.

I would definitely try and keep the conversions from string to floats a minimal as possible.

How big is your project so far?
Old Dec 24, 2007, 01:21 PM
  #17  
Evolved Member
iTrader: (6)
 
donour's Avatar
 
Join Date: May 2004
Location: Tennessee, USA
Posts: 2,502
Received 1 Like on 1 Post
I wish I could help out more, but I don't have access to windows development machines.

d
Old Dec 24, 2007, 02:56 PM
  #18  
Evolved Member
Thread Starter
 
jcsbanks's Avatar
 
Join Date: May 2006
Location: UK
Posts: 2,399
Likes: 0
Received 5 Likes on 4 Posts
I think then that the easy way is to have an array of single precision float for the scaling to convert the ECU replies into real units. I have a multiplier and an adder for all except the coolant and air temps which are not speed sensitive as they won't be in my really fast loop.

The slimmed down project is now only 350 lines of code to do the following except process the DMA reply (I've got rid of all the hard coded ECU model specific stuff and it is all in the xml now even though I know I'm not following the full xml schema it works, I've got rid of all the text boxes, excess buttons, graphs, knock plots etc that were bloating it, far tidier):
Read xml for logging, live mapping and map switching settings
Display above in listviews when app opened
Display live fuel and timing maps with correct dimensions, axes and memory addresses
Connect to the ECU
Open logging file
Request the logged items from the ECU (just send request E5 and await the reply length programmed into the ECU - 14 bytes for first test as below)
(process the DMA reply to a string to write a row to the log file)
Allow live fuel and timing maps to be read/written/edited with short interruptions in normal logging (these are still done through normal MUT rather than DMA - I will add that later)
Close logging file and disconnect from ECU

So it is nearly ready to test after the holiday period. ECU is ready to roll to support all the above already - I just need to write a 14 byte DMA table equivalent to the MUT table containing in sequence my fast loop logging items that are time sensitive.

Last edited by jcsbanks; Dec 24, 2007 at 03:04 PM.
Old Dec 24, 2007, 03:01 PM
  #19  
Newbie
iTrader: (17)
 
burnmacs's Avatar
 
Join Date: Mar 2003
Location: Orlando, FL
Posts: 85
Likes: 0
Received 0 Likes on 0 Posts
Originally Posted by Second Chance
With the strings, you may also want to look into the StringBuilder class.

I would definitely try and keep the conversions from string to floats a minimal as possible.

How big is your project so far?
the optimal .NET string concatenation approach is using StringBuilder initialized to the final string size. The problem is you need to know the final size a priori. Other than SB is about linear where String concatenation is *not* linear with size and number of concats.

I am an embedded developer, in industry, and we're using C# for everything we can now. There was some resistance, but take a look at what MS is doing with C# and you'll be more than pleasantly surprised, especially comparing to managed C++ code.

Try out C# for the GUI over VB.NET, I promise it's worth the switch now. Any of the easy designer stuff you have in VB, you have in C# and it's a much better language. I would be willing to help out time permitting as this is all stuff I've done before, just not with VB code. I've done all of the async callbacks in C# and could help out with that portion of the framework as well.

Mike
Old Dec 24, 2007, 03:49 PM
  #20  
Evolved Member
Thread Starter
 
jcsbanks's Avatar
 
Join Date: May 2006
Location: UK
Posts: 2,399
Likes: 0
Received 5 Likes on 4 Posts
Thanks both for the info on stringbuilder, reading up on this has started to explain some of the performance issues I have seen before.

There is also a lot of heavy string manipulation in my dataset/datagridview stuff for the realtime mapping. You can actually see the datagridview redraw (quickly). Each cell is accessed as a string, this is the only way I got it to work. Can anyone suggest a really quick way to link an integer or floating point array to an editable grid display (editing a fuel or timing map)?
Old Dec 24, 2007, 07:18 PM
  #21  
Evolved Member
iTrader: (22)
 
codgi's Avatar
 
Join Date: Aug 2004
Location: Seattle, WA
Posts: 2,491
Received 41 Likes on 37 Posts
Originally Posted by jcsbanks
Thanks both for the info on stringbuilder, reading up on this has started to explain some of the performance issues I have seen before.

There is also a lot of heavy string manipulation in my dataset/datagridview stuff for the realtime mapping. You can actually see the datagridview redraw (quickly). Each cell is accessed as a string, this is the only way I got it to work. Can anyone suggest a really quick way to link an integer or floating point array to an editable grid display (editing a fuel or timing map)?
Haven't used a datagrid in ages. Going to have to re-install an IDE at home when I go back to work after the holidays . Maps, hash tables or similiar structures found in System.Collections would probably be best but summarize the algorithm you have now and maybe we can come up with something .

The visible redraw is definitely happening because you don't have multi-threading. The main thread in the process for a GUI app is also responsible for taking care of the redraw. When its not locked up, it can do it quickly enough so you don't notice it happening. Redraws, bleeding etc. are always signs that the thread is getting hammered.

An expensive way to stop this from happening would be to prematurely manually force the redraw yourself while doing the logging but then you'd probably end up making the logging loose resolution or some other effect .
Old Dec 25, 2007, 07:11 AM
  #22  
Newbie
iTrader: (17)
 
burnmacs's Avatar
 
Join Date: Mar 2003
Location: Orlando, FL
Posts: 85
Likes: 0
Received 0 Likes on 0 Posts
If you're using it for a map, you're probably going to want to use a DataTable underneath. You can set the DataGridView.DataSource to a BindingSource and set the BindingSource.DataSource to the table. That will allow you to edit the map.

MSDN has a class reference http://msdn2.microsoft.com/en-us/library/ms229335.aspx
Old Dec 25, 2007, 03:57 PM
  #23  
Evolved Member
Thread Starter
 
jcsbanks's Avatar
 
Join Date: May 2006
Location: UK
Posts: 2,399
Likes: 0
Received 5 Likes on 4 Posts
I am finding pretty poor performance on the datagridview in that it takes about 1-2 seconds to redraw the ignition map even when it isn't doing anything else.

This is the setup:

Dim ignition As New DataSet
ignition.Tables.Add("MyIgnTable")
Me.DataGridView2.DataSource = ignition
Me.DataGridView2.DataMember = "MyIgnTable"

Then I write in the row and column values (once, speed doesn't matter).

Then the sub that is called 400 times to update the values:

Private Sub gridign(ByVal x As Integer, ByVal y As Integer, ByVal d As Integer)
ignition.Tables(0).Rows(y).Item(x) = d.ToString 'THIS IS THE SLOW INSTRUCTION
End Sub

I would like to use a 2d array of single precision floating point for the fuel map and integer for the ignition map and use a BindingSource to link these to the DataGridView. All the stuff I can read up on is biased towards loading in databases and I can't find an example to help me simply show and allow editing of the underlying 2d array. Any suggestions?

Last edited by jcsbanks; Dec 25, 2007 at 04:00 PM.
Old Dec 25, 2007, 08:41 PM
  #24  
Newbie
iTrader: (17)
 
burnmacs's Avatar
 
Join Date: Mar 2003
Location: Orlando, FL
Posts: 85
Likes: 0
Received 0 Likes on 0 Posts
I whipped something up real quick in C# for you to look at. The program has a 2D table (just 2 columns) and every second a Timer expires and updates one of the 3 rows in the DataTable underneath. I did the binding i mentioned in my post above and you'll see the updates to the GUI automagically occur.

Mike

Originally Posted by jcsbanks
I am finding pretty poor performance on the datagridview in that it takes about 1-2 seconds to redraw the ignition map even when it isn't doing anything else.

This is the setup:

Dim ignition As New DataSet
ignition.Tables.Add("MyIgnTable")
Me.DataGridView2.DataSource = ignition
Me.DataGridView2.DataMember = "MyIgnTable"

Then I write in the row and column values (once, speed doesn't matter).

Then the sub that is called 400 times to update the values:

Private Sub gridign(ByVal x As Integer, ByVal y As Integer, ByVal d As Integer)
ignition.Tables(0).Rows(y).Item(x) = d.ToString 'THIS IS THE SLOW INSTRUCTION
End Sub

I would like to use a 2d array of single precision floating point for the fuel map and integer for the ignition map and use a BindingSource to link these to the DataGridView. All the stuff I can read up on is biased towards loading in databases and I can't find an example to help me simply show and allow editing of the underlying 2d array. Any suggestions?
Attached Files
File Type: zip
WindowsApplication1.zip (15.0 KB, 7 views)
Old Dec 26, 2007, 02:10 AM
  #25  
Evolved Member
Thread Starter
 
jcsbanks's Avatar
 
Join Date: May 2006
Location: UK
Posts: 2,399
Likes: 0
Received 5 Likes on 4 Posts
Thanks very much. I don't have C#, but I can read Form1.cs in Notepad, which should get me started.
Old Dec 26, 2007, 02:25 AM
  #26  
Evolved Member
Thread Starter
 
jcsbanks's Avatar
 
Join Date: May 2006
Location: UK
Posts: 2,399
Likes: 0
Received 5 Likes on 4 Posts
Downloading C# Express 2008 (can't find 2005 handy) to try it properly.
Old Dec 26, 2007, 07:09 AM
  #27  
Newbie
iTrader: (17)
 
burnmacs's Avatar
 
Join Date: Mar 2003
Location: Orlando, FL
Posts: 85
Likes: 0
Received 0 Likes on 0 Posts
Originally Posted by jcsbanks
Thanks very much. I don't have C#, but I can read Form1.cs in Notepad, which should get me started.
One thing you won't get from Notepad is how I set up the DataTable as a DataSource in the project. The DataGridView's DataSource is set in the designer so you'll have to look at Form1.Designer.cs to see that in InitializeComponent.

I'm not sure if you're familiar with partial classes but it basically allows you to split a class into multiple files but still have all the code behave as if it's all in the same file in the same class. MS uses partials to split up autogen code from user written code in the same class.
Old Dec 26, 2007, 12:58 PM
  #28  
Evolved Member
Thread Starter
 
jcsbanks's Avatar
 
Join Date: May 2006
Location: UK
Posts: 2,399
Likes: 0
Received 5 Likes on 4 Posts
Thanks, it loaded into 2008 Express fine and ran as you intended.

I've managed to get some of my own code working with a datatable and displaying. Will see if the performance is better.
Old Dec 26, 2007, 05:37 PM
  #29  
Newbie
iTrader: (17)
 
burnmacs's Avatar
 
Join Date: Mar 2003
Location: Orlando, FL
Posts: 85
Likes: 0
Received 0 Likes on 0 Posts
Originally Posted by jcsbanks
Thanks, it loaded into 2008 Express fine and ran as you intended.
It's not about what I intended, it's about what you asked for. If it differs in behavior from your expectation, let me know and I'll change it to what you need.

Mike
Old Dec 27, 2007, 02:48 AM
  #30  
Evolved Member
Thread Starter
 
jcsbanks's Avatar
 
Join Date: May 2006
Location: UK
Posts: 2,399
Likes: 0
Received 5 Likes on 4 Posts
Thanks v much. With your example I have managed to use datatables or datasets with various types. However, it was still slow! Eventually I found that having autoresize columns off speeded it up whether strings ints or floats were used. I am trying to work out how to set the column width in the code for a datagridview.


Quick Reply: DMA logging now working - logging 25x faster than MUT



All times are GMT -7. The time now is 01:25 PM.