Area 451 Parts Support Forum
February 04, 2012, 11:42:53 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: [1]   Go Down
  Send this topic  |  Print  
Author Topic: How to program your V2.00 cruise control via a ScanGauge II  (Read 1032 times)
0 Members and 1 Guest are viewing this topic.
admin
Administrator

Offline Offline




« on: October 20, 2009, 01:56:24 PM »


                                   
If you are unfamiliar with the 2.00 Firmware announcement, please read "Version 2.00 Beta Firmware Update Ready"
 
   
   
   
 
 
Note that these instructions assume you have a ScanGauge II device.  If you do not, you can select some of the settings via onboard switches.
 
Since our cruise control communicates with the car using the CANBUS network, and the ScanGauge II has the ability to send messages on that same network, it occurred to me that it might be possible to send messages to the cruise control.  And if that turned out to be true, that perhaps certain settings could be adjusted in that way.  Good news!  It can, and it works.  The following set of instructions may not seem very intuitive, but please keep in mind we're working with some tight limitations of the ScanGauge.
 
This is what your ScanGauge II device should look like when you've first started it up and it has successfully established communication with your car:
 

Press the button next to "MORE" a couple times until you see a screen with the "CMNDS" option as so:
 

 
Pressing CMNDS should bring up a screen like so:
 

 
The ScanGauge gives you 10 memory slots (0 through 9) that allow you to store commands for easy repeat use.  You can use the various memory slots if you wish, or you can continually edit and re-edit one slot.  That is up to you.  The < and > buttons cycle through the memory slots.  "EDIT" allows you to input a command and "SEND" will send whatever command is stored in that memory slot.  I should warn you that while it is unlikely sending random commands could ever do any harm to your car I suppose it is possible - so input your commands carefully.  Pressing the EDIT button should bring up a screen something like this (the command will be blank or whatever you had there previously):
 

 
I borrowed these images from the latest SG instructions.  On our unit here, which is maybe 2 years old, we have a plus and minus sign and a right arrow, instead of what is shown above (up arrow and left and right). Either way, the right/left arrows are used to choose which character you're editing, and the up/down arrows (or +/-) cycle that character through the hexadecimal digits.  Our unit also says "SAVE" instead of "OK" but I'm sure it does the same thing.
 
If you've never done any computer programming, the concept of hexadecimal digits is probably foreign to you, so I'll address it here.  Most humans tend to think of numbers as consisting of digits ranging from 0 through 9.  Computers work a little differently and instead they see them as consisting of digits ranging from 0 through 15.  To represent them concisely, all the digits above "10" use letters to represent them.  So 0 through 9 are the same, then 10 is an "A", 11 is a "B" and so on until you get to "F" which is 15.  What's after 15?  Well, just like 10-based numbers, you add a digit.  So after "F" (which is 15) comes "10" (which is 16).  Then 11, 12, 13... 18, 19.  What comes after 19?  If you said "20" you're thinking like a human again  :D   "1A" comes after 19.  Then 1B, 1C... 1E, 1F, 20, 21 and so on.  If you want a cheat sheet, I searched Google for a decimal (normal numbers) to hexadecimal conversion chart.
 
It is common practice to prefix hexadecimal numbers with "0x" so you know the writer isn't referring to regular decimal numbers.  So "0x10" is the same as 16 but "10" is just 10.
 
All scangauge commands and responses are given in hexadecimal format.
 
Input the following command:
 

 
And hit OK.  This brings you back to the previous screen, which you then press the SEND button and you should get a screen much like the edit screen:
 

 
Congratulations!  You just successfully sent your first command to our cruise control!  The above command (609900) queries the cruise control for its version number, and the response is shown to you (60000200).
 
ALL commands and responses start with "60" and all responses have 6 digits following the "60".  This is just a limitation of the ScanGauge.  We had to choose some arbitrary but unused 2 digit value so we chose 60.  If you put something else in there, you may potentially be sending a command to a different system (though odds are you're sending garbage that will just be ignored).  Other than the fact you must put in the 60, you can really ignore it from all the responses.  So the 60000200 response to the version query is really "000200" which is interpreted as "2.00" - the version.  Let's say some future version is 2.14 then the response would be "60000214".  Note that only V2.00 cruise controls (and above) support this.  If you send this command to an older unit, it just won't do anything.
 
After the required "60", all commands consist of 4 additional digits.  The first 2 are the command identifier (IE. which command we are sending) and the last 2 are the command's value.  In the example above, "99" means "get the version".  The "00" has no special meaning in this case and in fact the command would work with any value after the 99 (but shouldn't be blank).  For most of the other commands, the value is important.
 
So to review... all commands will be entered in this format:  60 XX YY, where 60 is required and never changes, XX is the command ID and YY is the command's value as per below.
 
The response you receive depends on the command sent.  The 99 (version) command returns the version, as just mentioned.  Ignoring the "60" prefix, the FF (factory reset) command either replies with "C1 EA 00" (as close as we could get to "Clear") if successful, or "FA 11 ED" (supposed to read "Failed") if it didn't work.  All other commands respond back with the command you sent, appended with an "01" on the end, or "FA 11 ED" if you sent an invalid value.  For example, if you send "601401" to set a PDIV value of 1, then the response will come back as "60140101" to indicate success.
 
Now for the commands!  Each is given with the ID followed by a brief description and its valid YY values [default value in brackets]
 
Special Commands (YY value is unimportant):
  99 - retrieves version number
  F0 - Debugging command.  Only use if instructed
  F1 - as above
  F2 - as above
  FF - performs a factory reset for all values below. Car must be stationary.
 
Normal Commands
  00 - Select which Pedal Map to use.  Valid YY values are [0x00] through 0x0F.  See Pedal Map section below.
  01 - Retain last set speed in memory?  Valid YY values: [0x00] = no, 0x01 = yes
 
Algorithm Modification Commands
  10 - Sets PGAIN variable.  0x00 - 0xFF [0x01]
  11 - PDIV.  0x01 - 0xFF [0x01]
  12 - PSHIFT. 0x00 - 0xFF [0x0A]
  13 - IGAIN. 0x00 - 0xFF [0x01]
  14 - IDIV.  0x01 - FF [0x02]
  15 - MAX_DELTA_I.  0x00 - 0xFF [0x02]
  16 - INTEGRAL TIMER A.  0x00 - 0xFF [0x00]
  17 - INTEGRAL TIMER B.  0x00 - 0xFF [0xC4]
  18 - Pause integral on pedal saturation?  0x00 = no, 0x01 = yes. [0x01]
  19 - Reset integral during shifting?  0x00 = no, 0x01 = yes. [0x01]
  1A - Halt PID calculations during shifting?  0x00 = no, 0x01 = yes [0x01]
  1B - SHORT_SHIFT.  0x00 - 0xFF [0x19]
  20 - PEDAL_MIN.  0x00 - 0xFF [0x14]
  21 - PEDAL_MAX.  0x00 - 0xFF [0xD0]
  22 - MAX_DELTA_OUTPUT.  0x00 - 0xFF [0x14]
  30 - ACCEL_RATE.  0x00 - 0xFF [0x0F]
  31 - ACCEL_RESUME_DIV.  0x01 - 0xFF [0x30]
  32 - ACCEL_NUDGE_BY.  0x01 - 0xFF [0x01]
  33 - ACCEL_TIMER.  0x01 - 0xFF [0x19]
 
So now you know what command ID refers to which variable/setting and what their valid values are... but what in the heck do they do?  Good question.  These next sections explain in more detail
 
 
Special Commands:  99 was explained above.  Don't use F0 - F3 unless we need ask you to.  FF is your friend if you mess around with all the other items and want to reset it factory (note also that setting any individual YY value to "FF" will reset that command back to default.  For example, sending a command of 60 20 FF will reset the PEDAL_MIN variable to its default value).
 
Normal Commands:  01 simply allows you to choose whether or not the last set cruising speed is retained in nonvolatile memory.  This means when you turn off the car and later restart it that the last set speed will still be available to resume to.  This is potentially handy for those that find they constantly cruise at the same speed.  Only affects the use of the resume feature, and then only when it is the first thing you do with the cruise that trip.  For example, sending the command "60 01 01" turns this feature on.
 
00 (pedal map) is what prompted the V2.00 update!  Choose your map using the command "60 00 0X" where X is 0 through F as per the following:
 
0 = Normal map (how your car normally is)
1 = Normal map +10%
2 =  +20%
3 =  +30%
[... and so on...]
9 =   +90%
A =   +100%
B =   +110%
C =   +120%
D =   +130%
E = EconoMap
F = Bat out of Hell Map
 
The +% maps are linear adjustments to the normal map.  So choosing the +100% map, for example, means when you press your pedal down any amount, your car thinks you've pressed it twice as far.  It also means that at some point you'll reach the electronic limit of your pedal before you've reached the physical limit of it.  Once you've reached that electronic limit, pressing the pedal down further won't do anything (until you reach the kick-down portion of your pedal, which still works normally).
 
The Econo and B.O.O.H. maps are special in that they are nonlinear.  The econo map requires you to press the pedal down harder at the low end of the pedal (IE. city driving) but it "catches up" quickly the further you press it.  You could say it makes your car "feel" more sluggish around town but it also gives you more precise control and that can potentially help you to save fuel.
 
The B.O.O.H map is the opposite - it makes the car feel very excitable where you barely touch the pedal to get quite a reaction.  However, further down the pedal's range it "catches down" quickly such that you have to press it a further distance at higher speeds to get a response.
 
Both of the nonlinear maps have a great advantage over the linear ones in that you still have full access to the pedal's normal range.  It may be doing more or less than normal at any given point on the curve, but it is doing something. The linear ones, again, tap out at some point giving you no further response and this may feel unnatural once you've reached that point.  To give you a visual idea of what they do, I have attached a graph to this post.
 
Algorithm Modification Commands: This section is the most detailed, hardest to understand, and of least interest to most people... so nobody's going to hold it against you if you stop here.
 
First a little cruise control 101.  Cruise controls operate on what is known as a PID loop...  a mathematical algorithm concept which has been around for decades and is a key part of almost any speed/flow/temperature control.  It is relatively straight forward in concept, but the tricky part is "tuning" it for a specific situation.  A good chunk of the work that went into developing the cruise control was spent on tuning the PID loop.  The variables described in this section can allow you to further tune the PID loop to your particular situation.
 
PID stands for Proportional, Integral, Differential.  Sometimes for some systems you get simpler variations of this concept because it is found that one of the components (P, I and/or D) are not required.  Luckily, that is the case with the smart car cruise control.  D effectively gets set to zero, so our PID loop is really only a PI loop.
 
This means our mathematical equation boils down simply to this:
 
How hard we press the pedal = a value directly proportional to how far off the speed is   the integral of the error over time.
 
For those that don't remember your calculus, basically the integral is the sum of all the little errors leading up to the current moment.  So the P term is the "now" and the I term is a result of everything up until now (the "past").  All the values below make adjustments or impose limitations on either P or I in some way.  Enough lesson.  Now a description of the variables.
 
PGAIN and PDIV.  These work together because we can't have true fractional values.  Think of PGAIN as the numerator and PDIV as the denominator. These combine to form a P constant which our error (difference between set speed and actual speed) gets multiplied by.  We started with a value of 0x01 and tuned everything else around that, but you can play with it.  Small changes in this constant can have large effects so take caution.  A larger P gives you more "oomph" at any given moment but too large will cause instability (surging) especially at lower speeds.  Too low and it won't be responsive.
 
PSHIFT.  P is the muscle, and I is the brains of the operation.  The smart is smart enough, and we found that sometimes we need to focus more on the muscle.  If you understand PID theory, then you know that when you are exactly at your set speed (error is zero) then P is also zero and that means "I" is doing all the work.  PSHIFT forces P to be doing something at all times.  There's no harm in setting this as low as zero (that's how PID normally functions).  Setting it too high can be trouble (continual acceleration regardless of error). The default value is 0x0A and I probably wouldn't attempt more than double that (0x14).  PSHIFT's effect is proportional also to the set speed so test across a broad range of speeds if you've made changes.
 
IGAIN and IDIV.  Like PGAIN and PDIV, these are the numerator and denominator to the I constant.  The integral (I) sort of acts as a smoothing force, but also contributes to the power.  "I" can be very tricky and very finicky.  The default value (which is 1 / 2 or 0.5) and you probably don't want to bother with values much over say 5 (IGAIN 5, IDIV 1) and likely best to be under 1.  Raising I will smooth out P's reaction to disturbances (hills, wind, etc) but too high and it will take too long to correct.  Increasing I increases "overshoot".  If I is too low, then the set speed can't be maintained (P can't do it on its own no matter how high you make it!).  If that's the case, you may notice the speed permanently drop at least some right after you press the button.

MAX_DELTA_I.  The PID loops is called a "loop" because it happens over and over again.  MAX_DELTA_I limits how much effect "I" can have on the pedal in any given iteration through the loop.  In a way, it puts a leash on the effect of our "I" term.  Setting to zero is the same as setting IGAIN to zero so you probably don't want to do that.  Any value is valid, but I think you'll probably want to keep it in the single digits.
 
INTEGRAL TIMER (A and B).  First let me explain why we have an A and B.  The ScanGauge is limited to two-digit values and our INTEGRAL TIMER value needs 4.  So our default for A is 0x00 and for B is 0x64 you can look at that as a value of "0x0064".  If you want a value above 0xFF (remember we're talking hex numbers!) then it rolls over from Timer B into Timer A.  So for a value of "0x01BA" for example, you would issue two commands.  First, "60 16 01" for TIMER A and then "60 17 BA" for TIMER B.  The INTEGRAL TIMER controls how fast the PID loop happens.  It may seem counterintuitive, but increasing the value slows the loops down and decreasing it speeds it up.  Too fast (IE. too low of a value) can cause severe overshoot and surging while too slow means you may not be making it up that hill any time soon.
 
Pause integral on pedal saturation.  Since "I" is a sum of its past, we can run into a problem if we are in a situation (say a steep hill) where the car can't get to its set speed no matter how hard it tries. "I" will build and build and then when the situation is resolved (crest the hill) it takes far too long to come back down and you get overshoot.  Setting this option to "yes" (01 - the default) forces "I" to stop building once the pedal gets to its PEDAL_MAX value.  If you never really travel on hills or experience situations where the car can't keep up, then setting this to "no" will allow it to better deal with some shifting situations.
 
Reset integral during shifting.  When your transmission changes gears, its like starting a whole new ballgame.  You're in a different powerband region, your RPM has likely changed significantly, and the position of your pedal should be quite different.  Because of this, we found it best to just wipe the slate clean and start over with the "I" term building.  If you're in a very flat location though, you may find it behaves better if you set this to "no".
 
Halt PID calculations during shifting.  This pauses the entire PID calculation routine during the time the transmission is shifting (IE when the clutch is engaged).  Previously we didn't have this luxury, but now our cruise is aware of the actual lag present during shifting - whether in automatic mode or not.  Without pausing, the cruise control will interpret the lag as a hill or some other disturbance and will try to push the pedal down further.  In practice, this didn't have a whole lot of effect except at slow speeds on steep hills.
 
SHORT_SHIFT.  In conjunction with the above, this determines exactly how long to pause the PID routine.  During tests, we measured that on average it takes 50 "ticks" for a shift to fully complete.  If we waited the full 50, we found too much speed drop during shifting.  We determined that half that value (which is 25, represented in hex as 0x19 - the default setting) worked quite well.  A lower number will bring the gas back on more quickly while a larger number will wait longer.  How long the shift takes depends on a whole lot of things including how worn your clutch is and may vary from car to car.  There's built in protection so that the maximum it will wait is the actual time it takes to complete the shift so if you want to ensure it waits for the full shift just set it to some high number like 0xFE (not 0xFF because that's a special value that resets to default as explained previously).
 
PEDAL_MIN.  This is the lowest value the pedal will drop to while the cruise is on.  As mentioned before, the pedal technically has a range of 0 through 255 (0x00 through 0xFF), however functionally it never goes below 0x0E and setting this value below that could turn on a check engine light.  We set it to default to 0x14.  Why would you want to change it?  If you're ever going on flats or slight downhills and notice a slight "surging" with the cruise on, this is because the pedal going too low (depending on speed) causes the car to engine brake slightly.  You get the same thing if you let go of the gas yourself.  So setting PEDAL_MIN to a slightly higher value will force the gas pedal to be pressed down a little, eliminating that surging.  However, setting it too high will make the car accelerate above the set speed in certain situations and possibly use more fuel as it isn't benefiting from the engine breaking condition (which burns zero fuel as the injectors shut off).  If you play with this value, incrementally change it.  Say you set it to 0x78 (120) - that's like saying the lowest you EVER want the pedal to be is halfway pressed to the floor!  You can imagine that it won't keep speed very well when its never allowed to fall past hard acceleration.
 
PEDAL_MAX.  Just like PEDAL_MIN, but this is the most it can go.  Setting it too low will mean the car may not have the power to go high speeds or get up hills or trigger downshifts if you're in automatic.  Setting it too high can cause unnecessary and frequent shifting and too hard acceleration.  Default value is 0xD0.  Even though I said the pedal has a theoretical limit of 255 (0xFF), in reality it taps out at 218 (0xDA) and then jumps straight to 239 (0xEF) and never goes any higher.  That jump is because of the kickdown feature (forced downshift) of your car.  So don't set this above 0xDA if you don't want the cruise to engage the kickdown (which can result in very frequent up/down shifting on some hills) and I strongly recommend against ever setting it above 0xEF, which may trip a check engine light.  Because of the kickdown, there's no point setting a value between 0xDA and 0xEF.
 
MAX_DELTA_OUTPUT.  This is the most "action" the PID loop can contribute to your pedal's position during any given iteration through the loop. Remember that the loop happens many hundreds of times per second so it is wise to put a limit on how much the pedal's position can change in any given fraction of a second.  Raising this value will allow for faster and more powerful responses to disturbances (hills, etc) while lowering it will provide smoother responses.  Too high can cause surging.  Too low will cause more speed variation.
 
ACCEL_RATE.  The idea of ACCEL_RATE is to provide a target acceleration rate to be used during both the accelerate feature (hold the button down while the cruise is engaged to increase the set speed) and the resume feature (hold the button down while the cruise is not engaged to return to previous set speed).  This was to prevent the car from accelerating at an uncomfortably fast rate.  However, in practice the rate of acceleration is mostly limited by your current speed, gear, load and incline anyway. 
 
ACCEL_RESUME_DIV.  This one is difficult to explain.  Basically decreasing this value should increase how hard the car tries to accelerate/resume in its effort to reach ACCEL_RATE, and vice versa.
 
ACCEL_NUDGE_BY.  During accelerate/resume, this is how far down the pedal is incrementally pushed/released by each iteration through the secondary loop (see below) in its effort to accelerate.  It must be at least 1, which is the default.  Setting this too high (which could be a very low number) could render acceleration (during accelerate/resume) extreme and possibly erratic.
 
ACCEL_TIMER.  This timer influence how fast the secondary loop occurs.  The secondary loop is independent of the main PID loop.  This loop happens at a speed of ACCEL_TIMER divided by 100 times per second.  So the default value of 0x19 is 25 / 100 = 0.25 or once every quarter second.  Increasing the number slows the loops down and decreasing it speeds it up.  Every time the loop happens, the code checks to see if we're accelerating as per ACCEL_RATE and adjusts accordingly as per ACCEL_NUDGE_BY and ACCEL_RESUME_DIV.
 
 
Whew!   ;D  That's a lot for you to read, take in and understand.  It was also a lot for me to write!  :P
 
I hope some people find it useful or at least interesting.
 
Art
mvaldes
Customer

Offline Offline

Gender: Male


« Reply #1 on: October 23, 2009, 09:04:30 PM »

Wow Art,
That's quite a mouthful, thanks for the headache. ;D
It'll definitely be fun to play with the pedal maps, that section and the other simpleton commands I understand.
I hope you plan to tell me what values you want inserted if you want us to test changes to your basic algorithm, 'cause otherwise I'm not going to mess with it. I'd probably end up going 90 mph in reverse! ::)
Really though, thank you for your continuing efforts on our behalf. I'm all psyched up to get started.
-Michael
admin
Administrator

Offline Offline




« Reply #2 on: October 23, 2009, 09:59:54 PM »

There's no need to test any PID modifications if you don't want to.  It is there if you want to play with it, and also if your testing (using normal settings) reveals any deficiencies that possibly can be corrected by adjusting values.  In that case, of course I'd give you some suggestions to try.  My hope is that will not be necessary.

I do want the beta testers who have SG devices to test the communication though.  That is most easily done by issuing the 609900 version command.  If you get the version response, then your SG successfully communicates with your 2.00 cruise.  After that, play with some pedal maps.
wizard of ahs
Customer

Offline Offline

Gender: Male


LOVING MY AREA 451 C/C WITH OPTIONAL LED !!


« Reply #3 on: October 24, 2009, 07:42:18 AM »

Thanx Art !

Awesome as ususal  :P
mvaldes
Customer

Offline Offline

Gender: Male


« Reply #4 on: October 24, 2009, 10:33:04 AM »

 Oh, you can definitely count on me playing with the pedal settings (and speed recall) using both the Scangauge and the onboard switches!
intocoasters
Customer

Offline Offline

Gender: Male



« Reply #5 on: October 25, 2009, 07:41:03 PM »

Just got back into town and found a cool little package waiting for me... WOOHOO!

gonna have to print all this out and take it with me. 

Looking forward to trying out the new software (without changing any settings first) just to see if I can feel any differences.  And then on to the pedal maps!

Thank you.
admin
Administrator

Offline Offline




« Reply #6 on: May 06, 2010, 02:22:55 PM »

V2 is now dead.  The information contained above no longer applies.
Pages: [1]   Go Up
  Send this topic  |  Print  
 
 

Powered by MySQL Powered by PHP Powered by SMF 2.0 Beta 3.1 Public | SMF © 2006–2008, Simple Machines LLC Valid XHTML 1.0! Valid CSS!