Wheel angle sensor zeroing in v4

Hi all,

The arduino v4 code doesn’t allow the wheel angle sensor zeroing more than the -127 to 127 range of the ‘Wheel angle sensor zero’ slider. Me and some others modified the arduino v3 code in the past to be able to calibrate the sensor. But as the v4 version of AOG is designed to upload the sketch and don’t change the code, just use the settings in AOG. We can’t reach the sensor zero position.

steer settings

The ‘Integral Gain’ is not used anymore in the PID controller code (Brian correct me if I’m wrong). That’s why I choose to use this slider to help adjust the sensor zero in a bigger range. The idea is, adjust the ‘Wheel angle sensor zero’ and if it reach -127 or 127, just increase the ‘Integral Gain’ by 1, rinse, repeat.

Here is the parts of code I modified:

  //Settings Header has been found, 8 bytes are the settings
  if (Serial.available() > 7 && isSettingFound)
  {
    isSettingFound = false;  //reset the flag
    //change the factors as required for your own PID values
    steerSettings.Kp = (float)Serial.read() * 1.0;   // read Kp from AgOpenGPS
    byte Ki = Serial.read();
    steerSettings.Ki = (float)Ki * 1.0;   // read Ki from AgOpenGPS
    steerSettings.Kd = (float)Serial.read() * 1.0;   // read Kd from AgOpenGPS
    steerSettings.Ko = (float)Serial.read() * 0.1;   // read Ko from AgOpenGPS
    byte offset = Serial.read();
    //steerSettings.steeringPositionZero = 1533 + Serial.read();  //read steering zero offset
    //Using Integral to increase the Zeroing range as Ki is not used anymore in the PID controller.
    if (offset <127){
      steerSettings.steeringPositionZero = 1660 - ( Ki*127) + offset;
    }
    else if (offset > 127){
      steerSettings.steeringPositionZero = 1660 + ( Ki*127) + (offset-127);
    }
        
    steerSettings.minPWMValue = Serial.read(); //read the minimum amount of PWM for instant on
    steerSettings.maxIntegralValue = Serial.read()*0.1; //
    steerSettings.steerSensorCounts = Serial.read(); //sent as 10 times the setting displayed in AOG
    EEPROM.put(10, steerSettings);
  }  

Brian, is there any chance we can rename and reuse the slider ‘Integral Gain’ in AOG for this purpose? As Integral gain has been removed from the PID controller code since a while and it seems to run fine, do you think it will be used again in the future?

2 Likes

May I ask why you don’t want to install the WAS properly?

Looks odd to have two sliders for one parameter. If the adjustment range really needs to be extended, shouldn’t the existing parameter be adjusted?

I just want to see strong arguments for any (SW) changes.

Sorry, but I think this communication byte should be reserved for something more important.

If we use a linear potentiometer what is the reason to center it? Can’t we use the range 3v - 4v instead of 2v - 3v? The question can also be, if we need to mount the sensor properly why is there a zeroing slider?

I tried to do something quick without change in the SW but indeed it would be better to increase the slider to a 2 bytes integer and adapt the arduino code as well.

Correct, the same performance from a potentiometer running 3 to 4 or 2 to 3 volts. Still insisting a bit on improving your setup. Why not run it from 2.5 to 3.5 volts (approximately)? Is it difficult/impossible to turn it a bit?

Even better to use it from 1 to 4 or 0.5 to 4.5 Volts, adjusting the arms to get better resolution. Once you try to maximise the performance of your WAS, you end up fixing it pretty close to 2.5 V with wheels centered. Shouldn’t we encourage AOG users towards the best WAS performance?

I certainly would not mind if SW experts have the time and extend the offset range even to cover the full WAS range. Just see it less important than all the million other requests from us who do not have the knowledge to implement these changes. Perhaps you can do it as you already have worked a lot with it.

1 Like

I fully agree with Northernfarmer , and I think Gg1212 ought to get a potentiometer that have full output (almost from 0 to5 V) for the short linear movement he has, or move the connection point to a place with longer movement.
I also wonder why it is difficult to mount the potentiometer so working range is at the middle.
Rotary potentiometers have linear output as well, but I suppose Gg1212 have some kind of a “bar” potentiometer.

Correct, we should probably encourage people to use the maximum range from their potentiometer.
Indeed I can code it myself but let’s see if there is interest for this feature or not…

Anyway, as it is an open source community I choose to share my code in respect to the huge works already done by the community. Feel free to use it or not.
My goal was to give some kind of backward compatibility to farmers who successfully used an uncentered WAS with v3 for a while, not to open a debate on how to properly mount the WAS sensor.

1 Like

I get your point. But isn’t it possible to add that offset in the part of the ino that AOG does not change from gui

Sure it is but I wrote this for people who are not familiar with coding and want to “upload & play”

I was beginning to realize something like that :slight_smile:

I use the factory installed WAS in our Case and had to adjust the steer zero quite a bit more than 127. I can’t just turn the sensor to correct it.
So I would definitely like the slider to have another bit!

1 Like

Interesting. Certainly a strong argument for the adjustment range.

I would have assume higher accuracy from factory installations but could it be from the Ackerman issue? Is the sensor range symmetric around the zero angle? I assume the sensor is part of the front wheel king ping assembly where wheel turns more on one direction than the other. Perhaps the sensor mid value corresponds to the mid value of the king pin turning angle which again differs from the WAS zero (where the tractor drives straight forward).

Makes no difference here but I’m just trying to understand the reason for such a big offset on a factory sensor.

Yes, the sensor is installed in the steering knuckle.
Your theory could be right. The sensor angle can be smaller if it is centered in the range of the single wheel, not of the whole steering.

1 Like

I have used the code from Gg1212 and it works well. My tractor has Ackerman steereing so when I mounted WAS I tried to center it as you suggested, but without increase the length of the WAS arm it was impossible. When turning to the right, my sensor was pulled by the wheel, it would have been destroyed if I did not change the position. In my case this sketch is very usefull

Thanks for the snippet of code. I will give it a try as I am having the same problem which I am unable to center my was. I wonder if we couldn’t just increase the the adjustment by a factor of 5 maybe?

A factor of 5 would be too coarse. Better to just modify the center point to what your zero is in code.

Thanks Brian and all for this wonderful project. I have been following for more than a year but have never posted on a forum ever. I hope this is the right topic for my post.
I like the new version 4.1 but I can’t get my WAS to center in it, It is anywhere from 12 to 5 degrees to the left. I could center it in earlier AOG versions with the steer wizard.
I have: PCB2, cytron, ads1115, mma8452 and princess auto WAS.
I have tried it on 3 princess auto WAS and 1 Delphi with no luck. I have watch every video that I can find that Brian has made and have played with it for days with the “Steer angle sensor Zero” and the “Ackerman” % making sure I send it to the module each time. With maxing them both out I can get it from 12 degrees out to around 5 degrees out. The WAS arm is well centered when I set wheels straight.
Is there something I am missing or something I can do to remedy this?

Welcome DDR. You say was arm is well centered, do you mean fysically?

Yes I do mean physically. With the wheels straight the WAS arm is (as close as I can get it) in the middle of its travel. Hope I answered what you are asking

Yes it does. You must adjust so it electrically is almost in center(about 2,5 V) , then fine tune with slidebar in AOG