Problem with Autosteer PGN and data rates

So Ive run into a problem with PGN exchange with me custom built Seed motor control board running on a mega where I loose connection with AOG. I know its because I am doing too much processing in the loop as I need to read the motor encoder a fan encoder among other things. I can see the watchdog timer creeps up quickly once i introduce the delay. I can reproduce the issue in the default machine_usb_v5.0 code by simply adding a delay(1) in the main loop.

Can anybody explain what is happening here? Is it simply that the serial buffer is getting overrun and so it never gets to receive a full message?

Thanks

Hi did you solve this?

I am also trying to build a seed motor. And am running into a simular problem.
I use a stepper motor and have noticed that when it needs to read data it slowes down a lot.
With my experiment where I only use a potentiometer to set the speed I noticed that it works a lot beter when I only read the potentiovalue once every 3000 loops because this takes a lot of procesing power. This is probably also the case for when i connect it to agopengps to get the speed.

What microcontoller? usb or udp?
Reading data should not be hard on the microcontroller.

From memory, it’s possible that it read only one byte per loop, so be sure to not use any delay(), which you never should anyway.

Can you send the code? sometime it’s only a little detail that need adjustment.

What I have found is that while the microcontroller is reading data from agopengps it doesn’t send pulses to the motor which slows it down.
Both for esp32 and Arduino nano.
For the esp I used the secund core. What I am thinking of doing next is use the arduino to read the data from agopengps and then use the esp to control the motor. And send a simple analog signal from one to the other for the speed.

I didn’t see any issue with driving the motor.?are you using pwm?. I had quite a few serial prints for debugging and when I removed those the problem was dramatically reduced. Still loose aog connection on occasion but very seldom.

Something is very wrong with your code. We use the nano for the older steering modules, they could send and receive messages while reading sensors, outputting PWM and talking to i2c devices.

Reading the motor encoder is the issue depending how you implement as you block while reading the time between a few pulses, however a better approach is to use interrupts or even better a hardware counter.

How does the official Nano autosteer code do it? Doesn’t it work?

X2 on the hardware counter. I am not to sure what type of counters you have available but they will always be faster then using software.

There are hardware counters in the processor you can use. The steering board doesn’t have to monitor an encoder the steering sensor is an analog input. Monitoring a motor encoder means counting pulses over time or measuring time between two pulses