(Variable) Rate control

Shouldn’t be too difficult. What would the max pps be? There is a spare byte in PGN32500. It can also be calculated in the arduino from the data already sent. (UPM X Counts/Unit) / 60

Probably about 1000 pps. Max. I was looking at a couple different stepper motors. One is 1000 pulses per revolution, the other is 200 pulses per revolution, but I thought if I used that one I would end up driving it with the driver set to 1/4 steps, so it would end up 800 pulses per revolution. I figure one revolution per second would be about what I need to direct drive the seed meter.

It would take 2 bytes for that. It would be easiest to just calculate it in the arduino. The app would do the same calculation before sending in another pgn. Enter the lbs/ac seeding rate and pulses/lb in the app.

Do you mean you need a pulse output? Not just the data?

Here is some code to output a speed pulse. This could be modified to output pps.

uint32_t SpeedPulseTime;
void SendSpeedPulse()
{
	// https://discourse.agopengps.com/t/get-feed-rate-from-ago-and-transform-it-into-weedkiller-sprayer-computer-compatible-pulses/2958/39
	// PulseCal: hz/mph - 41.0, hz/kmh - 25.5

	if (millis() - SpeedPulseTime > 400) //This section runs every 400 millis.  It gets speed and changes the frequency of the tone generator.
	{
		SpeedPulseTime = millis();
		if (Speed_KMH < 1.22) // If the speed is lower than (0.76 MPH, 1.22 KMH) or (31.1 Hz) it forces the output to 0. Tone will not work under 31 Hz 
		{
			noTone(MDL.SpeedPulse);
		}
		else
		{
			tone(MDL.SpeedPulse, (Speed_KMH * MDL.PulseCal / 10));
		}
	}
}
1 Like

Thanks for the guidance. That code looks like what I need. I was wondering if I could just modify the arduino code or if that would cause other problems. I just received some rc-12-2 boards. I’ll put them together and experiment with some different code. Hopefully it will be fairly simple, if I can just get a pps output to feed to the motor drivers and use the relay board to power the enable pins on the stepper drivers it should all work.

ChatGPT code:

#define OUTPUT_PIN 9 // Pin to output square wave

// User inputs
const float plant_population = 30000.0; // Desired seeds per acre
const float speed_mph = 5.0;            // Planting speed in miles per hour
const float row_width_inches = 30.0;    // Row width in inches

// Conversion factors
const float feet_per_mile = 5280.0;     // Feet in a mile
const float inches_per_foot = 12.0;     // Inches in a foot
const float sq_feet_per_acre = 43560.0; // Square feet in an acre

// Variables for square wave generation
unsigned long previous_toggle_time = 0; // Last time the pin was toggled
float half_period_ms = 0;               // Half of the square wave period (in ms)
bool pin_state = LOW;                   // Current state of the output pin

void setup() {
  pinMode(OUTPUT_PIN, OUTPUT);
  Serial.begin(9600);

  // Calculate pulses per second (PPS)
  float row_spacing_feet = row_width_inches / inches_per_foot; // Convert row width to feet
  float area_per_second = (speed_mph * feet_per_mile / 3600.0) * row_spacing_feet; // Area covered per second in square feet
  float seeds_per_second = plant_population * area_per_second / sq_feet_per_acre;  // Seeds per second

  if (seeds_per_second > 0) {
    half_period_ms = (1000.0 / seeds_per_second) / 2.0; // Half-period in milliseconds
  } else {
    half_period_ms = 0; // No signal if seeds_per_second is invalid
  }

  // Log calculated PPS and period
  Serial.println("Corn Planter Signal Calculation:");
  Serial.print("Plant Population: "); Serial.println(plant_population);
  Serial.print("Speed (mph): "); Serial.println(speed_mph);
  Serial.print("Row Width (inches): "); Serial.println(row_width_inches);
  Serial.print("Pulses Per Second (PPS): "); Serial.println(seeds_per_second);
  Serial.print("Half-Period (ms): "); Serial.println(half_period_ms);
}

void loop() {
  if (half_period_ms > 0) {
    unsigned long current_time = millis();

    // Check if it's time to toggle the pin state
    if (current_time - previous_toggle_time >= half_period_ms) {
      pin_state = !pin_state; // Toggle pin state
      digitalWrite(OUTPUT_PIN, pin_state); // Update pin output
      previous_toggle_time = current_time; // Update last toggle time
    }
  }

  // Add other non-blocking tasks here
}

ChatGPT explanation:

How It Works:

PPS Calculation:

Converts planting parameters (population, speed, and row width) into pulses per second (PPS).

Calculates the half-period in milliseconds:

Half-period (ms)=1000PPS÷2

Half-period (ms)=PPS1000​÷2

Non-Blocking Logic:

Uses millis() to track elapsed time and toggle the pin state at intervals of half_period_ms.

Allows other tasks to run in the loop() while the square wave is generated.

Pin Toggling:

The pin state (HIGH or LOW) is toggled when the elapsed time exceeds the calculated half-period.

Output Signal:

A square wave signal is generated on OUTPUT_PIN with a frequency matching the PPS.

Example Calculation:

For:

plant_population = 30,000 seeds/acre

speed_mph = 5 mph

row_width_inches = 30 inches

The PPS is calculated as:

Row spacing in feet: 30 inches/12=2.5 feet30inches/12=2.5feet.

Area covered per second:

Area/second=(5×5280/3600)×2.5=18.333 sq. ft./second.

Area/second=(5×5280/3600)×2.5=18.333sq. ft./second.

Seeds per second:

Seeds/second=(30,000×18.333)/43,560≈12.63 PPS.

Seeds/second=(30,000×18.333)/43,560≈12.63PPS.

Half-period:

Half-period=100012.63÷2≈39.6 ms.

Half-period=12.631000​÷2≈39.6ms.

The result is a square wave with a frequency of approximately 12.63 Hz.


@SK21 do you see any way of integrating the the RateController app to display in AOG like is being worked on now with the 6.5 on PWM display?

It would take changes in aog to create a window for another app to use. The rate app could reproduce the screen but it would cover aog.

That looks good, thank you!

Greetings from southern Ontario!
I am very nearly ready to start on the electric side of putting a liquid fertilizer system on our corn planter. I have an RC11 board to do the rate control. (I’ll also be using the relays for section control but that’s in a different topic Individual row shutoff for Case Ih Cyclo 955 corn planter )
My question for here is where do I connect the flow meter? It’s a 3 wire Microtrac unit.
And do I need to put any jumpers on the board for what I’m using it for?

Here’s a few pics
(Flow meter is supposed to arrive on Monday)

Do you have a link to the flow meter?

It’s the FM750LF on this page

I use the same flow meter on my sprayer. Works without jumpers. Just 5V, GND and signal.

Awesome! :+1:t3::+1:t3:

I’d like to light an LED when the master switch is on (because it’s momentary it’s not so easy to check when looking away from the tablet). I thought I could use a spare relay on my RC11 board and configure it to ‘master’ but the behaviour is a bit odd. That relay works as I would like, but the section relays are also affected and now don’t off with the master switch, or even with their own switches, until the master switch is turned back on.

I’ve experimented with the ‘master override’ setting but this doesn’t make any difference. I’ve never quite understood what it does.

This is a ‘nice to have’ so if the software is working as designed that’s OK. I suppose I’d like it also to be on when stationary with auto section enabled, which probably neither master nor slave will do.

Also, how do you drag the (small) RC window around the screen in V3.8, to access AOG scroll bars etc?

The idea of the master relay is that it is ahead of the section relays in the power circuit. If it turns off the other relays will be off and not have to be changed. Some users had trouble with the master switch, the ‘master override’ ignores the position of the master switch.

To move the window right click or long press and drag. Did you try the new user-defined screen colors?

Quick question about the RC12/ RC12-2 boards. Can you use two boards at the same time with the rate control app? Would it work to set product 1 up to drive 1 board to control the seed meters and use a second board set up as product 2 to drive the in furrow fertilizer 12v pump?