Latest Code Updates

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.
Locked
Bernard Fife
Posts: 1696
Joined: Fri Apr 04, 2008 1:28 pm

Re: Latest Code Updates

Post by Bernard Fife »

All,

I have put the latest 4.112 beta code here:

http://www.msgpio.com/manuals/mshift/V41code.html

This code has one new user settings over the 4.111 code, and has a number of improvements:
- this code exposes a new setting under 'General Settings -> Rev Limits -> Force Auto Mode' that has been in the code for a while but I neglected to put it in the INI. This allows the user to set the circumstances when auto mode is selected from manual mode without user intervention.
- the overall code size has been reduced about 10% (with an even greater increase in speed) by more efficient use of functions, arrays, pointers, and conditional loops. For example, we moved the lever determination code to functions which were then considerably simplified with for() loops. This required a change Input1-4 related variables to Input1-4[] arrays, and some jiggling in their memory locations was required (which required changes in the INI too).
- fixes a bug in manual lever code in which certain voltage values were not recognized, and the user had to set an offsetted value for the lever to be determined correctly.
- completely rewritten user spare port 1/2 logic in a function with arrays, etc., and rearranged related parameters in inpram/INI (as with the gear lever code above). This makes the code smaller and simpler, and makes it easier to add other spare ports in the future, if this is desirable.
- adds 'equal to' to all the conditions (not just the gear) in the spare port logic.
- fixes a minor bug in output4 shift solenoid code.
- adds a limit to make sure pressure control duty cycle is not less than lowest 16x9 pressure control duty cycle of all the table values regardless of rounding/truncating or voltage/temperature adjustments. At high PC frequencies, and/or extreme volts/temps the value could have inadvertently become much lower than intended, and this could possibly (though unlikely) result in line pressures too low for the trans to operate correctly. With this code, that won't happen.
- fixed the metric 4WD odometer calculation bug (4WD correction wasn't being done at all - the 4WD speedo adjustment value wasn't being applied).
- fixes a minor bug in slip calculation (an input value was not being parsed correctly).
- adds DEBUG setting to INI with two input variables under 'Tools -> Debugging Input Variables' (#set DEBUG to display). This setting has no function in the beta code, it was used for development only (but you can't hurt anything by enabling it, either...).

With this code, all the 'low hanging fruit' of efficiency improvements have been picked. These have made the code faster, smaller, and easier to debug and develop; but also more abstract, and harder to understand and explain the flow. Future improvements will be more hard-won. We will keep working on efficiency improvements, of course.

Many thanks to those that contributed with ideas and bug reports (publicly or privately)!

This code has had some testing, but anyone should use it with great caution. In particular, the lever and spare port functions have had a lot of changes (these are the biggest architectural changes in the code since the move to 4.xxx code) so please report any unexpected behavior in a new thread. There may also be some residual problems in the INI (though I have tested and sorted all the ones I could find).

Lance.
"Never wrestle with pigs. You both get dirty and the pig likes it." - George Bernard Shaw
Bernard Fife
Posts: 1696
Joined: Fri Apr 04, 2008 1:28 pm

Re: Latest Code Updates

Post by Bernard Fife »

All,

I have put the latest 4.114 code and INI here:

http://www.msgpio.com/manuals/mshift/fi ... 14.abs.s19
http://www.msgpio.com/manuals/mshift/fi ... t_4114.ini

These fix a digital lever pull-up issue for the beta microTCU testers (doesn't affect GPIO users), as well as a metric odometer issue (many thanks to tobmag). For more background information, see:
viewtopic.php?f=4&t=493&p=3241#p3240
viewtopic.php?f=12&t=503#p3242

I'm not confident that we have got completely to the bottom of the odometer issues, but put this out for people to try and comment on. There may also be comms related issues, please report these in separate threads if you notice serial comms issues with this code but not other versions (like 2.204).

Lance.
"Never wrestle with pigs. You both get dirty and the pig likes it." - George Bernard Shaw
Bernard Fife
Posts: 1696
Joined: Fri Apr 04, 2008 1:28 pm

Re: Latest Code Updates

Post by Bernard Fife »

All,

The latest 4.115 beta code is linked from this page: http://www.msgpio.com/manuals/mshift/V41code.html

Compared to the previous 4.114 beta code, there are no new user settings, however this code:

- Most significantly changes to a speed x time odometer() function to replace old VSS pulse based calculations. The old calculations used the raw VSS count to calculate the distance traveled. This worked fine if the signal was perfect, and if there were no corrections needed.

However, the VSS signal has not been perfect for many users in the real world. As well, using VSS pulses adds complications when switching between 2WD/4WD, using the speedo correction factors, or switching between imperial units and metric.

The new calculations handles all those transitions, as well as a noisy VSS signal, much better by using the final speedo value, multiplied by the time, to calculate the distance traveled over specific intervals (which are themselves speed dependent to improve resolution and response). As long as the speedo is reading correctly (which can usually be accomplished using the filtering options and speedo correction factors), then the odometer ought to be accurate in this new code as well.

In addition, this code:

- Changes the speedo PC PWM, and spare port PWM calculations to properly round intermediate values rather than truncating them and having the difference propagate through calculations,
- Sets the default speedo correction factors all to 0.0, instead of climbing from zero at 100mph to 9.0% at 150 mph in the old code.
- Fixes the metric temperature conversion to report correctly (the older code didn't convert properly due to a bracketing error in a logical condition ),
- Changes the slightly enigmatic NOT_METRIC/METRIC setting in INI to read simpler as IMPERIAL/METRIC (the effect in TS is the same as before),
- Fixes a VSS period bug in INI (it was 1000x too low, and thus often ==0),
- Fixes an instance of the proper units not being displayed in the INI when switching to METRIC,
- Adds fuel efficiency (km/liter) to the metric gauges,
- Fixes an unreported spare port 2 index bug, the code was using the index from spare port 1,
- Changes the name of the parameter VSS_error to VSS_skip, to better represent it as a count of the number of pulses rejected by the filtering limits rather than an error code,
- Allows the shift button duration to be as low as 10.0, rather than the 25.0 it was previously.

Some of these have been discussed in recent threads, others were sorted privately. Many thanks to all who contributed!

As always, use caution with this new code.

Lance.
"Never wrestle with pigs. You both get dirty and the pig likes it." - George Bernard Shaw
Bernard Fife
Posts: 1696
Joined: Fri Apr 04, 2008 1:28 pm

Re: Latest Code Updates

Post by Bernard Fife »

I have put links to 4.116 beta code here: http://www.msgpio.com/manuals/mshift/V41code.html

This code is functionally the same as the 4.115 beta code released yesterday (or is supposed to be the same, at least), but it has some unused variables and code fragments removed to clean things up.

Lance.
"Never wrestle with pigs. You both get dirty and the pig likes it." - George Bernard Shaw
Bernard Fife
Posts: 1696
Joined: Fri Apr 04, 2008 1:28 pm

Re: Latest Code Updates

Post by Bernard Fife »

All,

I have put new 4.117 beta code here: http://www.msgpio.com/manuals/mshift/V41code.html

This code fixes a few bugs and adds new user settings for reverse gear line pressure:

- the manual gear lever determination code was completely re-written, and appears to work properly on my bench after a long night's testing. The old manual lever function had a few problems (that required particular patterns to voltages to be evident), and this new code should be much more general, robust, and coherent. It is also quite a bit smaller than before.

- fixes an issue with the LEDs not being set properly in neutral.

- adds two user reverse pressure limiting settings under 'General Settings -> Shift Factors' called:
-- Line Pressure Options for Reverse: Choose between 1) using a fixed setting (in 100-PWM%), OR 2) using the 16x9 line pressure load for load and speed based limiting.
-- Line Pressure in Reverse: If you chose a 'fixed setting' above, this is the value (in 100-PWM%) that will be used as the line pressure whenever the gear lever is in the reverse position (if you chose to use the table, this value will not be available).

The defaults for the reverse line pressure setting give the same behaviour as the old code (i.e. a fixed setting of 100%).

As usual, I have tested and verified the new features of this code on the bench, but there is much more testing to be done, so use with caution.

Lance.
"Never wrestle with pigs. You both get dirty and the pig likes it." - George Bernard Shaw
Bernard Fife
Posts: 1696
Joined: Fri Apr 04, 2008 1:28 pm

Re: Latest Code Updates

Post by Bernard Fife »

I have put new 4.118 beta code on the web site here: http://www.msgpio.com/manuals/mshift/V41code.html

It fixes a small but fatal bug in the voltage based lever code. This is discussed here: viewtopic.php?f=4&t=378&start=30#p3298 Thanks to ashford for spotting this and bringing it up!

Lance.
"Never wrestle with pigs. You both get dirty and the pig likes it." - George Bernard Shaw
Bernard Fife
Posts: 1696
Joined: Fri Apr 04, 2008 1:28 pm

Re: Latest Code Updates

Post by Bernard Fife »

There is new 4.119 beta code here: http://www.msgpio.com/manuals/mshift/V41code.html

This code:

- fixes the 2-point pressure sensor calibration bugs.

- changes the conditions on the lowest rpm that the line pressure table will be used so that users without a CAN connection to an engine controller and no ISS/tach input can still use the table to set line pressure based on speed and load.

- adds mixed TPS/MAP indexing to the gear/PC tables. The same index is used for both gear tables. The old choices were TPS for all tables, or MAP for all tables. The options are now:
-- MAP
-- TPS
-- TPS for Line Pressure Table/MAP for Gear Tables
-- MAP for Line Pressure Table/TPS for Gear Tables
You will find this setting under 'Tools -> CAN Configuration -> CAN Load Variable'.

If you choose mixed loads, you also need to activate/deactivate some settings under Project -> Project Properties:

- if you are using TPS for Line Pressure Table/MAP for Gear Tables you should make sure:
-- GEARTABLEMAP is activated, and
-- PCTABLEMAP is deactivated

- if you are using MAP for Line Pressure Table/TPS for Gear Tables you should make sure:
-- GEARTABLEMAP is deactivated, and
-- PCTABLEMAP is activated
These will set the appropriate displays (the load axis index and bins) for the tables in TunerStudio.

If you are using only MAP or only TPS (either of the first two options) you only need to make sure LOAD_KPA is activated (for MAP) or deactivated (for TPS).

Also, note that the usual hysteresis limiting applies, except when MAP for Line Pressure Table/TPS for Gear Tables, in which case there is hysteresis on the speed, but not the TPS (this can block shifts on the stim, but with reasonable hysteresis values isn't likely to in real life).

This code has only been tested briefly, use it with great caution!

Lance.
"Never wrestle with pigs. You both get dirty and the pig likes it." - George Bernard Shaw
Bernard Fife
Posts: 1696
Joined: Fri Apr 04, 2008 1:28 pm

Re: Latest Code Updates

Post by Bernard Fife »

The latest 4.122 beta MShift code/INI is linked from here: http://www.msgpio.com/manuals/mshift/V41code.html

Compared to the 4.119 code, this code:
- changes the IMPERIAL setting to CELSIUS to work better with TunerStudio's symbolic unit handling. This will likely set a warning when you load the INI for the first time. Ignore the warning, but go into 'Project -> Project Properties -> Settings' and activate the units you prefer. We will likely split the temperature and distance units in upcoming INIs, so that users (such as those in the UK) can have Celsius temperatures with miles/mph, etc. That hasn't been done in the 4.122 INI yet, though.
- fixes another bug in the 2-pt calculations (a residual code fragment left from testing that 'froze' the value at that specified in the inpram.INdbugV parameter),
- adds metric units to the 2-point calculations when CELSIUS is activated (for both the inputs and the outputs),
- removes the lower rpm limit from the pressure control setting (it was not working well for people with non-CAN set-ups if they didn't have a tach signal).

---------------------------------------------------------------------------------------------------------------------------------

As well, new 1.101 template code has been linked from this web page: http://www.msgpio.com/manuals/iocode/code.htm This code has a number of changes from earlier template code projects, the most notable of which is full CAN pass-through capabilities. You can read more here: viewtopic.php?f=3&p=3349#p3349 This code can be edited and compiled with the free 'special edition' of Codewarrior, see the link for more details of how to obtain and install this software from the Freescale site.

This is a template version of code for the GPIO board allows anyone to write their own applications for the GPIO. The C language code project is designed with the novice programmer in mind, and the configuration and logic is very thoroughly commented. The CAN communications, serial communications, and port set-up is completely finished. The analog-digital converters (ADCs) are set up on some pins/circuits, and there are some timers set up (for things like VR inputs). There are also examples of how to configure outputs.

In most cases, users will need to modify the template code to suit their particular needs (unlike the MShift trans code), and the code is designed to make this possible for the programming neophyte. There are many hints in the comments included in the source code that explain how to change the existing configuration to suit your needs if you wish. The code has a number of example snippets on how to configure the inputs and outputs based on sample parameters to suit your application. In short, it is a quick step towards writing your own GPIO programs in the C programming language to make the board do whatever you like, such as your own custom transmission controller, and I/O expander, ABS controllers, DBW controllers, etc..

Lance.
"Never wrestle with pigs. You both get dirty and the pig likes it." - George Bernard Shaw
Bernard Fife
Posts: 1696
Joined: Fri Apr 04, 2008 1:28 pm

Re: Latest Code Updates

Post by Bernard Fife »

I have put 4.123 beta code here: http://www.msgpio.com/manuals/mshift/V4code.html

This code adds no new user features or settings. What is changed is:

1. All metric conversions have been moved to the INI, and all internal controller calculations are now done exclusively in imperial units. This has a few benefits:

-- the defaults remain physically the same regardless of the units chosen by the user,

-- changing the units immediately converts all the applicable user settings as well as the values received from the controller. This means that things like the shift table speeds will change from mph to kph so that the shift behavior remains the same when changing settings even though the units and numerical values have changed,

-- rounding errors due to integer calculations are vastly reduced because they are now perform by the floating point unit of the PC's processor,

-- ensures that calculations do not overflow/underflow is simpler with just one range of magnitude to handle,

-- less computational power is used by the controller, so it is faster, and the MShift code is smaller,

-- users only have to change the appropriate setting (under Project -> Project Properties -> Settings) to move both the displayed units and the values/parameters from Imperial to Metric or vice-versa,

-- there are now two metric settings - for temperature (CELSIUS) and another new setting for everything else, such as distance, speed, tire diameter, line pressure, etc. (SI_LENGTHS). The abbreviation SI is from the French "Le Système International d'unités" - the official designation for "metric". This additional setting lets users in mixed unit use locations, such as the UK, choose appropriate units for their locale,

-- the 'General Settings -> Units' dialog and parameter have disappeared.

as well:

2. The DEBUG setting has disappeared (the menu is still there, but commented out). This was removed because the settings dialog was getting very crowded, and the DEBUG setting was of limited use, and it is just as easy to un-comment/re-comment it in any case.

One warning: When upgrading from older code, be sure to save the old user parameters in a MSQ, load the new code and set up the new INI, change your units to what you used when creating the older MSQ before finally loading the old MSQ file. Otherwise the values will be converted again (i.e. twice, so they will be incorrect) when you change the units settings. Once the units are set, you don't have to worry about this anymore.

I have tested these changes briefly, but they need more careful examination of course. I put this code out now for people to try. Let us know in a separate thread if you see anything that isn't right.

Lance.
"Never wrestle with pigs. You both get dirty and the pig likes it." - George Bernard Shaw
Bernard Fife
Posts: 1696
Joined: Fri Apr 04, 2008 1:28 pm

Re: Latest Code Updates

Post by Bernard Fife »

The latest in the 4.1xx series of code has been largely stable for a while, with just 'fine-tuning' of the code and INI, so it has now been promoted to 'stable release' status. You can get it here: http://www.msgpio.com/manuals/mshift/V41code.html In the future this code will get bug fixes only.

New functions and features (plus bug fixes, of course) will be added to the 5.xxx series of beta code that you can find here: http://www.msgpio.com/manuals/mshift/V5code.html This code is intended only for experienced, knowledgeable users who are willing and able to safely test unproven features. However the current 5.000 code on the beta site is identical to 4.124, except for the changed signature. 4.1xx and 5.xxx version of code will diverge fairly quickly over time as the code continues to develop.

The old 2.204 release code will continue to be available here: http://www.msgpio.com/manuals/mshift/V2code.html

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