Added pulse/on-off/bang-bang valve support to AgOpenGPS

I’ve spent some time trying to get the existing on-off pulse style steering valves on our tractor working with AgOpenGPS. Currently these valves are not suitable for use with the software because AOG uses a PWM output to drive steering motors and proportional hydraulic valves. The pulse style valves will somewhat work with high PWM signals, but once the signal becomes smaller, the valve will not open at all. This causes the tractor to oscillate across the line as the valve only opens when the error is large and the PWM signal becomes larger.

In order to get the valves working, I changed how the Arduino outputs the drive signal to the valves. When the PWM signal becomes small enough that the valve will not open anymore, the Arduino instead sends out very short pulses of max PWM drive at a certain interval. By adjusting the delay between pulses, the valves can be make the very small corrections needed to follow a straight line. I also use a steering angle error threshold that uses the pulses to control the valves when the steering error is very small and only small corrections are needed. When the error is large and above the threshold, the original PWM drive system is used in order to steer fast enough to make a u-turn or get onto the line quickly.

By making these changes I’ve been able to get AOG to drive a very straight line which outperforms our Trimble autosteer unit and is still able to make the u-turns or follow a curve.

In the modified AOG software I have added a new tab to the autosteer settings window. This tab contains sliders for the pulse on-time, high and low error pulse delays, and the error threshold.

The pulse on-time is the amount of time that the valve is open during each pulse which determines how far each pulse will steer the wheels. This setting should be set as low as possible so it is open just long enough to make the wheels turn by a very small amount. This allows the steering to make the small corrections required for following the line.
The high and low error pulse delays set the amount of time that the valve is off between each pulse. The high error delay determines the delay when the error is close to the set threshold and the low error delay determines the delay when the error is close to zero. The high error delay will be shorter than the low error delay because when the error is high, you want the pulses to be more rapid in order to steer to the line faster. However, when the error is small, you want the pulses to be less rapid so that it steers more slowly and does not overshoot the line. The length of the delay will vary between the high error delay and low error delay depending on the steering angle error.

The error threshold slider allows you to adjust at what point the system will stop steering with the PWM system and start using the pulse drive system. When the steering angle error is above the set error threshold, AOG will operate exactly as it would without any modifications and steer using a PWM output. When the steering angle error is less than the set error threshold, AOG will steer using pulses based on the above settings. Setting the error threshold to zero will disable the pulse drive system and AOG will operate just like it would with no modifications.

Pulse Steer Settings

The settings in the screenshot are the values that we are using. However, they will vary widely between machines due to the type of valve, hydraulic pressure, etc. The best way I’ve found to get it all set up is to first set the error threshold to its maximum so that the tractor will only be steering with the pulse system. Then, adjust the pulse on-time so that it is set as low as possible while still making the wheels turn slightly. Once the pulse on-time is set as low as possible, get the machine very close to the line and adjust the high and low error delays so that the actual steering angle matches the desired angle in the steer chart as best as possible. After it is set up to drive a straight line, reduce the error threshold so that it is low enough to make the u-turns well but not so low that the steering angle error exceeds the threshold while driving a straight line.

It takes some fine tuning and fiddling but I was able to get our tractor steering very straight and the steering angle error is usually below 0.5 degrees and is rarely larger than 1 degree.

I’ve posted the modified AOG program and support files containing the modified Arduino code here: GitHub - canadaboy25/AgOpenGPS at AgOpenGPSwithPulseControl
Right now it only works with a usb connection to the Arduino as I do not have a system using a UDP connection that I could try it on.

19 Likes

This is great!!

Where do you live in Canada?

I wonder if it works with cetop on / off valves.
I will try to test in the near future.

Thanks!

I’m in northwestern Saskatchewan.

Valve

This is the valve on the tractor that we are using. I imagine it should work for most valves that operate on the on/off principle.

One other thing I should add is we set the adjustment valve in the picture so that the wheels turned at maximum speed. This allowed for the delays to be set quite low in order for the steering to respond quickly.

@canadaboy25
Wow! So what about accuracy? Is it driving in the field the same as proportional valve?

It is very accurate when following an AB line down the field. However, it does not follow the desired u-turn curve exactly due to the error having to accumulate past the set threshold before the faster PWM drive system kicks back in. The error is not very bad though as I was able to land roll a 30 acre field with obstacles completely automatically with the record and playback functionality. The accuracy is not as good as a proportional valve but it is more than usable. It follows the AB line straighter than our Trimble EZ-steer unit does.

4 Likes

Hello, at 0 degrees the angle of the wheels continues to give a command to one valve. This only happens in pulse mode. What could be the reason.

I’m not sure if I’m understanding correctly. Are you meaning that even when the steering angle error is at 0 degrees there is still a command to activate one of the valves?

Yes exactly

AgOpenGps Here’s what it looks like.

Your cytron hooked up correctly?

Checked. It is connected correctly.

Which ino do you use?
Did you set motor driver to cytron and upload from AOG to nano?

i use ino from here- https://github.com/canadaboy25/AgOpenGPS/tree/AgOpenGPSwithPulseControl
the module configuration is set to cytron

Ok make a check: change to ibt_2 and see if there is a difference!
If not you don’t have a match of AOG version and ino.

So I tried your setup out on my hardware and it turns out the freedrive buttons at the bottom of the settings page do not work at all. I forgot to make them work with the pulse drive code as they are never used once you have the system set up. If you make an AB line in AOG and engage the drive, it should work as expected. I will take a look at making the freedrive buttons work when I have time. All the other functions should work as expected.

Sorry about that!

Thanks, I understand that when I go to the field everything will work as you described in post 1.

Thank you very much, I hope this solves my problem of oscillations on the sides to be able to follow the line. I have tried to regulate oil flow, to go up and down lowPWM, and I have not got any improvement. I am looking forward to testing your modification. What is the best antenna position for this new configuration? cabin roof, on the engine … thank you all for your contributions to this project that I am sure will end up being universal and affordable.

Yes, oscillations when following the line is the reason why I added this feature. It can be a bit frustrating to setup because now there are 4 additional settings to play with along with all the other existing settings. We have our antenna on the very front of the tractor roof. Have never tried any other locations.

I will try to find some time to add the pulse support to the latest version of AOG and try to get the free drive buttons working again.