AA80E 8-speed

A forum for discussing applications and implementations of the MegaShift transmission controller code for the GPIO from B&G. This can control up to 8-speeds and 6 shift solenoids (plus a 16x9 table for controlling a PWM line pressure valve). It has manual and fully automatic modes (16x9 load x speed table), with under and over rev-limit protection, and full data logging of all inputs and outputs (among many other abilities). A TransStim to test your completed board is also available.
Jim Blackwood
Posts: 222
Joined: Tue Dec 07, 2010 9:52 am

Re: AA80E 8-speed

Post by Jim Blackwood »

OK, I'll pursue that. I also have a couple of people searching for any possible student editions of CW at reduced cost, if you're aware of anything that'd help. So just as a guideline can you give me a rough idea of how far above the free version cutoff the present code is? Would I have to pare away for instance 50% or more like 10% ? Looks like this is my winter project.

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

Re: AA80E 8-speed

Post by Bernard Fife »

Jim, The current code compiles at about 39K, so 7K above the 32K limit of the codewarrior special edition.

You might have to combine some included file into the main.c file in order to get under the special edition file number limit as well. I.e. where it says something like:

Code: Select all

#include "ports_pins.h"
you would delete that line and copy/paste the entire contents of the ports_pins.h file into the same spot:

Code: Select all

// This header defines all the I/O port assignments so that
// the main.c, etc. are clear of direct hardware references.

/** I/O Port Quick_Start ******************************************
    --------------------

Function             Port    I/O    ON    OFF   READ               NOTES
--------             ----    ---    --    ---   ----               -----

Brake Sense			 PAD07	  I     --    --    (PORTAD0 & 0x80)   - on/off			
Paddle DOWN			 PAD06    I     --    --    (PORTAD0 & 0x40)   - on/off   	
non-CAN MAP/TPS/MAF  PAD05    I     --    --    ATD0DR5            - ADC count   
line pressure sensor PAD04    I     --    --    ATD0DR4            - ADC count     
Input3				 PAD03	  I     --    --    ATD0DR3            - ADC count  
Temp Sensor			 PAD02	  I     --    --    ATD0DR2            - ADC count    
Input2				 PAD01	  I     --    --    ATD0DR1            - ADC count  
Input1				 PAD00	  I     --    --    ATD0DR0            - ADC count  

Spare Output1        PT7      O     spr1(1);  *pPTTpin[7] &= ~0x80; ---
Paddle UP			 PT6      I     --    --    PTT & 0x40         - on/off
ISS                  PT5      I     Interrupt ISS_timer()          - interrupt called on edge     			
Speedo Output		 PT4	  O		PWMDTY4 = 0;          PWMDTY4 = PWMPER4;    PWMDTY4
TCC					 PT3      O		PWMDTY3 = 0;          PWMDTY3 = PWMPER3;    PWMDTY3
PC					 PT2	  O	    PWMDTY2 = 0;          PWMDTY2 = PWMPER2;    PWMDTY2
Output3				 PT1      O     PWMDTY1 = 0;          PWMDTY1 = PWMPER1;    PWMDTY1
VSS					 PT0	  I     Interrupt VSS_timer()          - interrupt called on edge

LED4  				 PB4      O     PORTB |= 0x10;        PORTB &= ~0x10;       ---

LED3  	  			 PM5      O     *pPTMpin[5] |= 0x20;  *pPTMpin[5] &= ~0x20; ---	   
LED1				 PM4      O     *pPTMpin[4] |= 0x10;  *pPTMpin[4] &= ~0x10; ---
LED2 				 PM3      O     *pPTMpin[3] |= 0x08;  *pPTMpin[3] &= ~0x08; ---
Output2				 PM2      O     *pPTMpin[2] |= 0x04;  *pPTMpin[2] &= ~0x04; ---

Output1			     PE4      O    	PORTE |= 0x10;        PORTE &= ~0x10;       ---
4WD input            PE1      I     --    --  (PORTE & 0x02)       - on/off        

Spare Output2        PA0      O     PORTA |= 0x01;        PORTA &= ~0x01;       ---

	 
*/

// ----------------- INPUTS ------------------------------------
// -------------------------------------------------------------
 
// switchA
#define SWITCHA_ADC 0

// switchB
#define SWITCHB_ADC 1

// temperature
#define TEMPER_ADC 2

// switchC
#define SWITCHC_ADC 3

// line pressure
#define PRESSURE_ADC 4

// non-CAN MAP/TPS/MAF
#define NC_LOAD_ADC 5

// Voltage based shift buttons
#define VOLT_SHIFT_ADC 6

// Brake
#define BRAKE_ADC 7

// Paddle Down PAD06
#define PADDLE_DOWN PORTAD0
#define PADDLE_DOWNpin 0x40

// Paddle Up PT6
#define PADDLE_UP PTT
#define PADDLE_UPpin 0x40

// Brakes PAD07
#define BRAKE PORTAD0
#define BRAKEpin 0x80


// 4WD
#define FOUR_WD PORTE
#define FOUR_WDpin 0x02

  
// ------------------------ OUTPUTS ----------------------------
// -------------------------------------------------------------

// Output1
#define OUTPUT1port PORTE
#define OUTPUT1pin 0x10

// Output2
#define OUTPUT2port *pPTMpin[2]
#define OUTPUT2pin 0x04  

// Output3
#define OUTPUT3pwm PWMDTY1
#define OUTPUT3_ON PWMPER1
#define OUTPUT3_OFF 0

// Output4 
#define OUTPUT4port PORTA
#define OUTPUT4pin 0x01
...
...
...
"Never wrestle with pigs. You both get dirty and the pig likes it." - George Bernard Shaw
Jim Blackwood
Posts: 222
Joined: Tue Dec 07, 2010 9:52 am

Re: AA80E 8-speed

Post by Jim Blackwood »

Thanks, good tip. I'll pass it along to Matt as well but I expect I'll be the one doing the work and just asking him to check it when he can. I've got some guys in this weekend working on cars but I hope to download the software later tomorrow.

That sounds like about a 20% reduction is what it will take, but like you say it can be tailored specifically for this tranny so hopefully it is possible.

Jim
Jim Blackwood
Posts: 222
Joined: Tue Dec 07, 2010 9:52 am

Re: AA80E 8-speed

Post by Jim Blackwood »

I've downloaded CodeWarrior and installed it and have been searching through the files to find the port designations but clearly I'm missing something. I downloaded the 5202 zip file and did not find either the main.c or the ports_pins.h file in the unzipped contents so I looked through all the other files before concluding that I'm looking in the wrong place. Any suggestions?

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

Re: AA80E 8-speed

Post by Bernard Fife »

Jim, Start with the hcs12def.h file. It gives the memory location of all the registers. Almost all of the hcs12 registers are 8 bits. There are port registers (PORTE, for example) as well as registers to set up the i/o like the data direction registers (ex. DDRE). For the I/O registers, each port's bit corresponds to the state of the particular pin (0-7, so Port E would be PE0, PE1, ... , PE7). However, you can only read/write a byte at a time. So you need a way to select one specific bit out of the 8 in a byte while ignoring the state of the other bits, and this is done using the & function for inputs and the |= and &= constructs for the outputs. There is more on this in the comments of the code, lots of examples in the code, and lots of more detailed explanations on google (search for "bitwise operations").

Also, the user can (and I have) re-"defined" the ports to make the code easier to read. So in the ports_pin.h file are things like:

Code: Select all

// Output1
#define OUTPUT1port PORTE
#define OUTPUT1pin 0x10
which means I can write:

Code: Select all

OUTPUT1port |= OUTPUT1pin;      // set PE4 high
instead of:

Code: Select all

PORTE |= 0x10;      // set PE4 high
and both statements are identical to:

Code: Select all

PORTE = PORTE | 0x10;      // set PE4 high
where | means "OR" (& is "AND")

That is, if a bit in 0x10 OR PORTE is high (1) then set the corresponding bit in PORTE to 1.

To shut the pin off, we use:

Code: Select all

OUTPUT1port &= ~OUTPUT1pin;      // set PE4 high
where if both the bit in ~0x10 (which is 0x10 = 00010000 in binary, so its compliment (~) is 11101111) AND the corresponding bit in PORTE is high (1) then set the corresponding bit in PORTE to 1. Since bit 4 (starting from the right at 0) is zero, the AND is always false for that bit and PE4 is set to zero (shut off) in PORTE.
"Never wrestle with pigs. You both get dirty and the pig likes it." - George Bernard Shaw
Jim Blackwood
Posts: 222
Joined: Tue Dec 07, 2010 9:52 am

Re: AA80E 8-speed

Post by Jim Blackwood »

I was looking in the wrong directory, got it now. I Matt is home today so I'll show him this latest info and see what we can figure out.

If we settle on the changes we think will work would you be willing to compile it if I send you the altered files?

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

Re: AA80E 8-speed

Post by Bernard Fife »

I could compile code occasionally. But you might find it easier stripping some of the code out, and having the special edition compiler at your own disposal. That's because when you compile it, one (meaning I) often finds syntax errors that need correcting. Then when the code compiles without errors, you have to test it to make sure it does what you want (50/50 for me usually) and doesn't do anything you don't want. So typically getting code modifications done is the result of dozens of compile/test cycles. But if you want to try it, post the complete source code here as a zip file and I will give it a whirl when I have time.
"Never wrestle with pigs. You both get dirty and the pig likes it." - George Bernard Shaw
Jim Blackwood
Posts: 222
Joined: Tue Dec 07, 2010 9:52 am

Re: AA80E 8-speed

Post by Jim Blackwood »

Thanks Lance, that is all I could ask.
As I said, I'm no code jockey and trying to learn as I go. Matt is studying this stuff at NKU and is just this week doing exactly what you are describing with his compiler, though currently working with assembly language. I'm almost amazed they still teach it, but you know academics.

Anyway he's said he'll have time over the Christmas break to work on it with me, really doesn't want to deal with it right now. So while I wait I'm looking for all instances of AD4 and PT6 in the various files. It'd be great if I could find a way to just highlight those instances without changing anything, I don't know if that is possible. If so I'd like to identify them all first and maybe try to understand what they do before changing anything.

That's my plan for now anyway. I'm hoping Matt can error check my work well enough to get it to compile. Along the way if I can figure out how to strip lines without crippling the code or otherwise screwing it up, then we'll see if it'll compile here before I ask you to do it on the full version, that way maybe we can reduce the burden if we reach that point. I agree with you that if a trimmed down version will run there's really no need to compile the full version, but I'll leave that up to you.

As Matt explained it to me, I'll need to find all instances of AD4 and change them to PT6, find all instances of PT6 and change them to AD4, not get the two mixed up (I'm thinking a 2 stage process with an intermediate identifier like "???" or something not otherwise used in the code), and then we may have to look at what is required to output a single pulse on PT6.

Interestingly, Ben Newell in the UK has characterized the shift trigger as a PWM signal, and it is certainly the case that the solenoid itself is a PWM capable solenoid. But that does not mean it isn't capable of acting like a non-PWM solenoid as well. I can't imagine at this point why you'd need to modulate the flow of the shift trigger, but it may turn out that this is also a means of controlling shift firmness. So perhaps the trigger pulse is best sent as a series of PWM pulses to make up the trigger pulse. It could be easier that way anyhow with the existing GUI and also allow modulation of the trigger pulse itself. (Ben has developed a controller based on two microsquirt modules, but does not feel his code is applicable to the GPIO. I've not heard from him in a couple of weeks, hope I didn't do anything to sour the relationship, but I suspect he's concluded I'm not a potential customer.)

Anyway, that's where matters now stand. I'll keep plugging away at it. I still may find a chance at some point to try triggering a shift with an external switch, but If I do I'll have to get the energized signal off of paddle upshift first, as I'm sure that is interfering with the shift logic. I'd really rather get that done in software as it has to be switched there anyway at some point if there is any hope of close to normal operation.

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

Re: AA80E 8-speed

Post by Bernard Fife »

Jim, It occurred to me that we could make some mutually exclusive sections of the code compile optionally using #ifdefs, so that for example one could either have the digital or voltage based code included and leave the other out (the full code would still have both options). A few options like that ought to get the code size below the special edition's compile limit, and then users like yourself could make any additional mods you want much more easily. I will work on this shortly and post here when I have something worth trying.
"Never wrestle with pigs. You both get dirty and the pig likes it." - George Bernard Shaw
Jim Blackwood
Posts: 222
Joined: Tue Dec 07, 2010 9:52 am

Re: AA80E 8-speed

Post by Jim Blackwood »

Great idea Lance. I see you used an alternative to the hsc12.inc file, probably what you referred to above. I'm going through Huang's HSC12 manual, currently in chapter 4 looking at the I/O ports. I've got to understand all that before I'll get anywhere. I was hoping to find a way to exchange the port assignments of AD4 and PT6 at an early stage, or low level in the code so that further references to one would be redirected to the other. Of course the I/O designation of PT6 would have to be switched as well. Basically I've been looking for the root port designations and definitions.

Further consideration of the required output for PT6 (shift trigger) has led me to suspect that use of a PWM signal to the solenoid is likely to be preferred. My reasoning is that because the transmission valve body goes into limp mode if the signal stays high or low, hydraulically this means limp occurs if the solenoid valve remains closed or fully open. In other words, either full or zero pressure in the circuit. Logic would dictate that the valve must either remain partially open (modulated flow) or change state often enough to keep an accumulator partially charged but not fully pressurized. (There are no accumulators in the valve body that I am aware of or that appeared during visual inspection, and one of the design goals was to eliminate them.) PWM operation is therefore indicated, and the solenoid is indeed a PWM type.

The question is the required opening of the solenoid under shifting and non-shifting conditions. My guess is that a full or nearly full open state is used to initiate a shift and a minimally open state is used otherwise. Likely some experimentation will be required, but initially we could try making it open fully at the same time that the other shift solenoids change state and see how that works. Then perhaps play with tapering off the signal until it goes into limp mode again to determine the minimum signal level. Next after that would be to shorten the transition or taper to allow rapid sequential shifts. This might best be done in TS with a 2 axis line graph such as used for IAC tuning with % open on the vertical axis and a time base of maybe half a second or more on the horizontal, referencing zero to the instant when the other shifting solenoids change state. I wouldn't think there would be any reason to actuate before the zero point. A time base of several seconds to a minute or more would be useful in establishing the minimum open setting but after that would be an impediment.

I hope to finish with the book during the next month, and be working on the changes during that time. Obviously any suggestions from you will be much appreciated. I will continue in the meantime to post comments as seems helpful.

Jim
Post Reply