Hi, I need help changing the arduino udp code. I am installing agopen gps hydraulic valves. I have a NO pressure switch. I connect the sensor to the “remote” input (pcb v2). I turn on the turn sensor and set the value to 1. Turning off is not working properly. When I had the NC pressure switch everything worked as it should. What should I change in the autosteer code so that when the pressure switch contacts are closed, the steering will be disconnected?
if (encEnable)
{
thisEnc = digitalRead(REMOTE_PIN);
if (thisEnc != lastEnc)
{
lastEnc = thisEnc;
if ( lastEnc) EncoderFunc();
}
}
You shouldn’t need to change the code. It’s looking for a state change, and having the pressure sensor as an encoder you are just telling it to turn off auto steer at the first change in state it sees. Check in AgIO that the encoder(switch) is functioning as it should. If you expand the the screen there should be spot where you can see if your switches are toggling like they should.
Have you changed the pressure switch or is this a new installation?
You are correct, it will only count the closed-open option.
So you have two ways to fix your problem the first is below. Notice the ! In the last line, this will make it only count the movement from open-closed.
if (encEnable)
{
thisEnc = digitalRead(REMOTE_PIN);
if (thisEnc != lastEnc)
{
lastEnc = thisEnc;
if ( !lastEnc) EncoderFunc();
}
}
Maybe a better option is to read the remote pin and just force autosteer off till the next button press, if you wanted help to make that small change just ask otherwise try adding that ! as shown above
Baraki had posted once that we should just set aog to 0 in count. No need to change ino.
0 is possible, in versions after 5.6.2 (maybe a little earlier, but not 5.4.5)
In the Teensy code I’m using, just set AGOPEN to 0 and it works fine. If you do not want to change the code, just pull up the remote output to GND, e.g. with a 1K resistor, and connect +5/12v to the pressure switch and it will work with the counter set to 1.
Here is the encoder code I use on teensy
// encoder
if (steerConfig.ShaftEncoder)
{
PulseRead = digitalRead(Encoder_Pin);
if ((PulseRead != PulseLast) && (millis() - PulseStart > SWdebounce))
{
PulseStart = millis();
PulseLast = PulseRead;
SwitchPulseCount++;
If i see it right then the sensor closes and opens and that is 1 count or am i wrong? We have trouble with how baraki sensor is working. We want just like Current or pressure sensor. We now need to wiggle the wheel to disengage. I have put the ! in the code but its still not as we want.
What did you mean by “Maybe a better option is to read the remote pin and just force autosteer off till the next button press”
You are right, so use the other side of the pressure switch.
Connect so when in autosteer the switch is closed, (half way through the cycle) when steering wheel is turned by hand the switch open, and you have a full 1 count