Get feed rate from AGO and transform it into weedkiller sprayer computer compatible pulses

I had am email discussion with ardusimple today, and as we know, the rtk2b will not give speed pulse by itself, but the double/triple antenna SBC version does output speed pulse and is available online. Double is 1800.00 US and triple is 2100.00 US roughly. May as well be 1M.
I wouldn’t be surprised if Mattias Hammer could add speed pulse to his dual antenna ino and send it out on one of the unused pins ?

Should be easy to do.

The fake radar signal is expected to be a simple square wave, 0-5v with the frequency proportional to the speed. Usually you tell the implement how many pulses gives 100m traveled. If 1 m/s is set to 100 Hz, then 100m is 10000 pulses if I got that right. Most commercial receivers that can generate a fake radar signal let you configure the pulse rate. And most rate controllers let you tell it how many to expect.

You can grab the speed from the autosteer pgn, and use the tone library to crank out a square wave with an Arduino. Or the counter timer directly, or the pwm library. As @m_elias says, should be a pretty easy project.

Accuracy shouldn’t be an issue as it is probably the most accurate part of the whole sprayer control system.

Adjust your half period based on speed. I can never get this thing to show code properly :frowning:

unsigned long halfPeriod = 5000UL; // 5mS = 1/2 100 Hz
// don’t use a floating # for delay, delayMicroseconds
void setup()
{
pinMode(13, OUTPUT);
digitalWrite (13, HIGH); // known starting level
pinMode(11, OUTPUT);
digitalWrite (11, LOW); // known starting level
}

void loop(){
while (1){ // avoid loop() jitter
PINB = PINB | 0b00101000; // x-x-13-12-11-10-9-8 on Uno,
// toggle output by writing 1 to input register
delayMicroseconds(halfPeriod);
}
}

3 Likes

Anyone fancy taking on writing a small arduino code sketch that can read the PGN via UDP and output the pulse on a pin?! :slight_smile:

I’ll try to do it today … (with emphasis on trying)
edit ech ele via udp it will be difficult

Assume we could nick the code from the autosteer setup to get the UDP connection working / receive the PGN?

If I understood correctly that gpsSpeed is the variable we need AOG, the autoster and ino already uses it, so just convert it into impulses.
if (udpData[0] == 0x7F && udpData[1] == 0xFE) //Data
{
gpsSpeed = udpData[3] * 0.25; //actual speed times 4, single byte

Do we have a spare pin on the autosteer nano? If so might as well use that, if not gunna need a seperate arduino / set of code?

@BrianTee_Admin to cote a code you put 3 ` on a line at the beginning and the end, like à or è (accent grave) in french.

To output this signal I suppose I can’t use the arduino pin directly? What works at theses frequencies? octocoupler, mofset?

@darrenjlobb on the PCB on connector J2 both pin should work. D2 and D5 on nano.

You could use pins D2 or D5, they go to the PCBV2 connector and we don’t use them for anything.
D5 is the PWM pin so it is fine.

https://talk.newagtalk.com/forums/thread-view.asp?tid=785108&DisplayType=flat&setCookie=1

In that link they say 58.94 hertz/MPH and a 1.5 millisecond pulse of voltage.

Here they say 46.56 hz/mph.

1 Like

To format code properly in discourse, use 3 backticks (```) on their own line above and below your code. Be sure there are no spaces on the lines with the backticks, or this will not work.:grinning:

Edit: appologies @Pat, I just seen you already advised this.

Right. You can use anything you want for Hz/speed unit, as long as the sender and receiver agree.

I’m trying to keep up. Are you then just sending a high, low 5v pulse with the speed setting the frequency of the pulse ?

Didn’t Brofarm try this and it didn’t work for him. The number of counts per 100m were different at different speeds.

It didn’t work because he was trying to use the esp’s PWM output. Radar signals are not PWM, but a square wave, with the frequency proportional to the speed. I suppose you could say they are PPM, but from what I can see on my scope, the high and low are equal length of time. Put in another way the pulse count is proportional to the distance traveled.

Yes, @jhmach, that is correct as I understand it. The high and low pulses are of equal width generally.

1 Like

With ESP8266s, I use the PWM output set to 50% but change its frequency as needed. In this particular use, that doesn’t change often so I don’t know what impact that command has on performance.

analogWriteFreq(100Hz up to 40000Hz); // at 40kHz cpu is quite busy
analogWriteRange(1023); // default
analogWrite(pwmIO, 511); // 50% duty, symmetrical square wave

I don’t know how this works on an ESP32 but it’s definitely different on a normal Arduino, there changing freq is not as trivial. The tone library is probably better on a normal Arduino.

Here is some code from an AgTalk user to output speed for monitors. He said it only works between 1 and 30 MPH. A pull down resistor may be needed.

/*=======================================================================================================================
* mm per second to a 41 hertz per mile hour converter.
* 
* Written By Andy Schwering & SG (New Ag Talk Rod Maker)
* April 22 2020
* 
* This is needed for ag monitors that use this standard.
* It uses the I2C serial connection to a ZED and an Arduino Uno.  
* Using Sparkfun SparkFun_Ublox_Arduino_Library.h and the GetGroundSpeed function we take speed and convert it.
* In U-Center enable UBX messages on I2C under ports using the configuration view.  Slave address is default 0x42.
* output pin 8 is the output is for the third party ag monitor. 
* Pin 3 output is used to monitor the I2C connection. Led turn on when connecting and remains on if connection is sucessful
* Ublox messages need to be enabled for my.gps poll time is approx 150 milliseconds
*/

#include <Wire.h>
#include <SparkFun_Ublox_Arduino_Library.h>  
#define I2C_COMMS_IS_GOOD 2
#define MMS_TO_MPH        0.002236936292
#define HZ_PER_MPH        41.0
SFE_UBLOX_GPS myGPS;
long lastTime=0;//internet said i need this to limit i2c traffic
long speed=0;
unsigned long Hertz=0;
void setup() {
   noTone(8); //turns off the speed to ensure no output during setup
   delay(10000); //Delay to allow ZED time to start before we initiate communication
   digitalWrite(I2C_COMMS_IS_GOOD, HIGH);
   delay(2000); // delay to show led on i2c works
   Wire.begin(8);  // join i2c bus with address #8
   if (myGPS.begin() == false)// checks connecton to F9P
   {
       digitalWrite(I2C_COMMS_IS_GOOD, LOW); // turns off LED if connection ws not made
       while (1);
   }
}

void loop() {

  if (millis()-lastTime>400) //This section runs every 400 millis.  It gets speed speed and changes the frequency of the tone generator.
  {
     lastTime=millis();
     speed = myGPS.getGroundSpeed(); //Gets ground speed from GPS in mm per second 2335 is tractor speed 25000 is car speed
     if (speed < 340) // If the speed is lower than 340 mm/second (0.76 MPH) or (31.1 Hz) it forces the output to 0. Tone will not work under 31 Hz 
     {
     speed=(0);  
     noTone (8);
  }
     else {
       Hertz=(speed*MMS_TO_MPH*HZ_PER_MPH);
       tone(8,Hertz);
     }
  }
}
3 Likes