Today I connected two MCP4725 DACs to our 8320T. The two steering wheel sensors that move in tandem I connected together to one DAC output and the 3rd inverted sensor I connected to the other DAC with an inverted output. I would have gladly used three DACs but they’ve limited the onboard I2C address setting to only two address options but it seems to work with only two DACs anyways. So referencing the screenshot in my previous post, I connected pin B & E together to one DAC output and pin H to it’s own DAC with inverted output. Then I used a potentiometer input on an Arduino, mapped from 0-1024 analog input to 12 bit output values I calculated using my previous JD factory voltage measurements and sent those values to the DACs. I also used the LED on IO 13 to indicate when the pot was centered.
And it works!! Other than a SSU warning code, which went away, it worked perfectly to steer the tractor by turning the pot connected to the Arduino. I originally limited the DACs to 1.5 - 3.3 volt output and like that the factory steering wheel had no influence on the steering, the DACs had full control but I felt the DACs couldn’t command enough steering angle and I wanted some factory steering wheel control. After this first experiment, I added a 1.1k current limiting resistor on the inverted (single sensor) DAC output and a 550 ohm resistor to the dual sensor DAC, then I also allowed the DACs to go to the full 0.6 - 4.1 volts output range that the factory system uses. With these changes, the factory steering wheel can still override the DACs a fair bit, and the DACs can also steer a little sharper than before, I think sharp enough for u-turns.
I think the next step is to wire it up more officially, through a relay to disconnect the DACs when autosteer is off, and then add code to the autosteer INO to control the DACs.
In regards to operating WAS-less, I just need to convert the wheel angle method to a matching DAC output value which achieves the desired steering angle.
/*
https://github.com/sparkfun/MCP4725_Breakout
adapted by Matt Elias
2022 05 05
for Arduino (Leo) to control (2) MCP4725
- (1) addr 0x61 on D2/D3 headers (D2/D3 are I2C pins)
- (1) addr 0x60 on I2C header
*/
#include <Wire.h>//Include the Wire library to talk I2C
//This is the I2C Address of the MCP4725, by default (A0 pulled to GND).
//Please note that this breakout is for the MCP4725A0.
#define MCP4725_ADDR 0x60
//For devices with A0 pulled HIGH, use 0x61
#define MCP4725_ADDR2 0x61
float vRef = 4.65; // MCP4725's max output when power via USB
float minVolts = 0.6; // left steering angle (rate of turn) limit, 1.5 was too little even without limiting resistor, 0.6 works well
float centerVolts = 2.37; // center pos on JD factory system
float maxVolts = centerVolts * 2 - minVolts; // symmetrical calc for right steering angle limit
// change section to multiplication instead of division, eliminate previous floats also to optimize
float scale = vRef / 4092; // volts per 12 bit division
int minLimit = minVolts / scale; // minimum 12 bit output value
int centerValue = centerVolts / scale; // center 12 bit output value, only used for informational purposes
int maxLimit = maxVolts / scale; // maximum 12 bit output value
int hyst = 30; // 30 = 2.33-2.41 volts center deadband, seems to work on 8320T
void setup(){
Serial.begin(115200);
Wire.begin();
pinMode(13, OUTPUT); // use built-in LED to show when input POT is centered
digitalWrite(13, LOW);
while(!Serial) // needs removing to operate without Serial connected
Serial << "\r\n\nMin volts: " << minVolts;
Serial << "\r\nCenter volts: " << centerVolts;
Serial << "\r\nMax volts: " << maxVolts;
Serial << "\r\n\nScale * 10^6: " << scale * 1000000;
Serial << "\r\nMin value: " << minLimit;
Serial << "\r\nCenter value: " << centerValue;
Serial << "\r\nMax value: " << maxLimit;
Serial << "\r\n\n";
}
//---------------------------------------------------
void loop(){
int a2d = analogRead(A0);
int output = map(a2d, 0, 1023, minLimit, maxLimit); // map full range of pot to limited output for 8320T, 0.6V - 4.05V
int output_invt = map(a2d, 0, 1023, maxLimit, minLimit); // inverted, 4.05V - 0.6V
if (output > centerValue - hyst && output < centerValue + hyst) digitalWrite(13, HIGH);
else digitalWrite(13, LOW);
Wire.beginTransmission(MCP4725_ADDR);
Wire.write(64); // cmd to update the DAC
Wire.write(output >> 4); // bit shift values into MCP4725
Wire.write((output & 15) << 4);
Wire.endTransmission();
Wire.beginTransmission(MCP4725_ADDR2);
Wire.write(64); // cmd to update the DAC
Wire.write(output_invt >> 4); // bit shift values into MCP4725
Wire.write((output_invt & 15) << 4);
Wire.endTransmission();
}