I tried modifying the usb .ino file to accommodate my setup. I had the old version 2 .ino file working good but now it was time to update to the 4.3 version. Can someone please take a look at the file and tell me why I can’t get the relay to come on when autosteer is engaged. The code in this .ino is very different so maybe my method won’t work the same.
I need a relay to come on when autosteer is engaged to enable my hydraulic steering block.
I also have tried to add a feature that measures pressure when the steering wheel is turned and if it is over a certain amount it would turn autosteer off.
The problem I have now is my relay board is reverse logic. It takes 5 volts to turn it off and gnd to turn it on. Meaning when autosteer is on the relay is off. When autosteer is off the relay is on. That is backwards and wont work very well for me. I could switch to using the normally closed side of the relay but that means it needs to be on when ever autosteer is off and I am not a fan of that.
I think I will buy a high level trigger relay on amazon and use that instead of the low level trigger relay that I currently have.
I have a little trouble with this concept of low activation for a guide relay, high activation seems safer to me because in the event of a power cut the autoguiding is deactivated which is less risky than seeing the valve Autoguiding unexpectedly activated with power failure.
When power cuts off, there’s also no GND from the arduino, means the relay will also shutoff…
But i have to say, high active relays are better for this solution!
Instead of relays, you can use a mosfet switch that I already mentioned here on the forum. The control is low, fits without any rework and no problems with burned out contacts, and the noise is less than that caused by sparking contacts and causing problems.
When the relay fails i’ll change to a mosfet. However for now I re coded it to use pin 2 like it was before. That way I don’t need to change any hardware for now.
I have a lot of discing to do and really don’t feel like steering haha. I’ll make it all proper on a rainy day.
I could of used pwm2 and just changed the 1 to a 0 and a 0 to a 1 but this way I dont have to open my box again
if (watchdogTimer < 10)
{
//Disable H Bridge for IBT2, hyd aux, etc for cytron
if (aogSettings.CytronDriver)
{
if (aogSettings.isRelayActiveHigh)
{
digitalWrite(PWM2_RPWM, 0);
digitalWrite(2,HIGH); // modified by Slimfarmer on 8-17-2020 Deactivate auto guidance relay <-----------------------------MODIFIED
}
else
{
digitalWrite(PWM2_RPWM, 1);
digitalWrite(2,LOW); // modified by Slimfarmer on 8-17-2020 Activate auto guidance relay <-----------------------------MODIFIED
}
}
else digitalWrite(DIR1_RL_ENABLE, 1);
steerAngleError = steerAngleActual - steerAngleSetPoint; //calculate the steering error
//if (abs(steerAngleError)< steerSettings.lowPWM) steerAngleError = 0;
calcSteeringPID(); //do the pid
motorDrive(); //out to motors the pwm value
}
else
{
//we've lost the comm to AgOpenGPS, or just stop request
//Disable H Bridge for IBT2, hyd aux, etc for cytron
if (aogSettings.CytronDriver)
{
if (aogSettings.isRelayActiveHigh)
{
digitalWrite(PWM2_RPWM, 1);
digitalWrite(2,LOW); // modified by Slimfarmer on 8-17-2020 Activate auto guidance relay <-----------------------------MODIFIED
}
else
{
digitalWrite(PWM2_RPWM, 0);
digitalWrite(2,HIGH); // modified by Slimfarmer on 8-17-2020 Deactivate auto guidance relay <-----------------------------MODIFIED
}
}
else digitalWrite(DIR1_RL_ENABLE, 0); //IBT2
pwmDrive = 0; //turn off steering motor
motorDrive(); //out to motors the pwm value
pulseCount=0;
}
} //end of timed loop
Please edit your code with triple BACKTICKS on a separate line before and after the code or copy these ``` it will make it format for easier viewing and coping.