EGT over CAN

A forum for discussing the applications and implementations of the DIY general code template for the GPIO and its 25 user inputs and outputs (+ serial & CAN). The code is 99% complete, the user just has to add their own conditional I/O logic and compile (with a free special Edition of CodeWarrior).
Post Reply
martin
Posts: 3
Joined: Wed May 09, 2012 2:32 pm

EGT over CAN

Post by martin »

Hi There. I am struggling to display egt on Tuner studio. I have been battling this for a while and need some help please.
I have built the EGT2 input on the GPIO board, and have 0-5V appearing on the AD4 input pin when the thermocouple is heated.
Tuner studio indicates can pass through is working - I can select the 'Clock-time' to be displayed from the 'Gauge Templates (GPIO)' menu - it counts up in seconds. egt2 just appears as a static number.
I am not sure if I have configured the OutputChannels in the ini's correctly. Code hints in Set Up OUTPC of main.c - template 1.000 says

"corresponding values should be in the MegaTune INI [OutputChannels] section."

does this mean the corresponding values should be in the MS.ini or the GPIO.ini. If they are supposed to be in the MS.ini - how do you correctly set the offset?

I'm more than a little confused here. :oops: Any help would be appreciated.
Bernard Fife
Posts: 1696
Joined: Fri Apr 04, 2008 1:28 pm

Re: EGT over CAN

Post by Bernard Fife »

martin,

If you want to grab the EGTs over CAN, the final EGT value (or the ADC count, if you prefer to do the conversion later in a TunerStudio formula or similar) must be in the GPIO's outpc structure. The outpc structure is where all the OutputChannels are located. All of the output channel values have variable names that start with "outpc.", so they are things like outpc.seconds, outpc.egt1, etc.

For example, you might have this in outpc:

Code: Select all

typedef struct {
 unsigned char seconds;
 signed int egt1;
 singed int egt2;
 ...
} variables;                              // end outpc. structure

variables outpc;
The offset is the count (in bytes) that any particular outpc. variable is from the start of the outpc structure. So the first value has offset zero. Suppose the first value is a char (i.e. one byte long). Then the second variable has offset = 1. If it is an int (2 bytes long), then the third variable has offset 3, and so on.

In the INI, this would look like this:

Code: Select all

[OutputChannels]
seconds           = scalar, U08,    0,     "sec",      1.000, 0.0 
egt1              = scalar, S16,    1,     "deg",      1.000, 0.0 
egt2              = scalar, S16,    3,     "deg",      1.000, 0.0 
where U08 means unsigned and 8 bits long (8 bits = one byte) and S16 means signed and 16 bits long (2 bytes). 1.000 is the value TS should multiply the raw value by, and 0.0 is the value is should add to all incoming values. We rarely use the add value, but the multiplier is often useful because we cannot pass decimal values, so we often compute a value that is 10 times greater (or 100x) then multiply by 0.1000 (or 0.0100) in TS as appropriate to get fractional values.

Note that although I have used the same names in outpc and the INI, this is not a requirement. They can be very different names, since it is the actual memory locations that are used in passing values back and forth. However, using the same names can make debugging simpler sometimes.

If this was mine, I would first get the INI setup and functioning properly with a direct serial connection to the GPIO board before using the CAN pass-through. It's just easier to troubleshoot that way.

Lance.
"Never wrestle with pigs. You both get dirty and the pig likes it." - George Bernard Shaw
martin
Posts: 3
Joined: Wed May 09, 2012 2:32 pm

Re: EGT over CAN

Post by martin »

Lance

Thanks for the detailed reply. From reading all your very well explained notes in the code, I have already made sure egt2 is in the outpc structure (was already there in the project code), and have already had a play with the Output Channels in the GPIO.ini. No joy unfortunately.

I have also tried to connect direct to the GPIO via RS232. I get an error "firmware serial signature entry not found in ECU definition".

When I connect with the downloader I can read the signature fine. S19 files also load fine. I have tried completely remaking the project with virgin files (untouched by me), and still get the same error.

Once again, I have no idea what I am doing wrong. Really appreciate the help.

Martin
Bernard Fife
Posts: 1696
Joined: Fri Apr 04, 2008 1:28 pm

Re: EGT over CAN

Post by Bernard Fife »

Martin,

TunerStudio only recognizes certain signatures as valid. You might either:

- copy the signature from a valid code (MS-II, MS3, or GPIO). For example, for MShift 4.103, the the code it is:

Code: Select all

const char RevNum[20] =  {    // revision no:
  // Only change for major rev and/or interface change. (The last character is added by MS-II.)
    "MShift 4.103       "
  // 123456789.123456789. 
},
 Signature[32] = {            // program title.
  // Change this every time you tweak a feature.  (The last character is added by MS-II.)
    "**  V4.103 MegaShift by B&G  **"
  // 123456789.123456789.123456789.12
 };
and in the INI it is:

Code: Select all

   signature      = "MShift 4.103       " ; MegaShift sends a null at 20th byte.
OR

- ask Phil, TunerStudio's creator, to add your signature to the 'allowed' list. If you post in this forum's TunerStudio sub-forum, Phil will see it shortly.

Lance.
"Never wrestle with pigs. You both get dirty and the pig likes it." - George Bernard Shaw
martin
Posts: 3
Joined: Wed May 09, 2012 2:32 pm

Re: EGT over CAN

Post by martin »

Lance

Thanks for your reply. I still have no success with this. I have tried loading code and .ini with both the original GPIO signature "Template 1.000 " and the MShift signature you have posted. I have tried loading code straight from the website (both ini and freshly compiled template) - no modifications at all. I have tried a different version of Tuner studios - V1.51 (have been on V2.0). No success. Tried connecting using Megatune - put the GPIO.ini file into both mtCfg and carmtCfg - got a different but similar error - "Controller code version does not match signature in Megasquirt-II.ini". Beginning to think I might have stuffed up the hardware - but if the GPIO takes S19 files, and reads the correct signature back okay, how can this be?

Anything else I can try?
Bernard Fife
Posts: 1696
Joined: Fri Apr 04, 2008 1:28 pm

Re: EGT over CAN

Post by Bernard Fife »

put the GPIO.ini file into both mtCfg and carmtCfg - got a different but similar error - "Controller code version does not match signature in Megasquirt-II.ini"
martin,

For MegaTune, I believe you need to rename it to megasquirt-ii.ini. I don't think MT will recognize GPIO.ini on its own (but it has been a long, long time since I used MT, so I could be wrong).

If the code is loading, then the hardware should be okay.

It's certainly not difficult to bugger up the serial comms in the code. The most common way to do this is to have the baud rate set incorrectly, and this is easy to do if the offsets aren't added up correctly in the [Constants] section of the INI.

Lance.
"Never wrestle with pigs. You both get dirty and the pig likes it." - George Bernard Shaw
Post Reply