Object detection - help making nano talk to AOG

On second thought sending back to AOG basically results ijn the same problem - Back to work on C# code. I think I’m going to try placing it in a different location.

Doen’t this do what you are asking? I believe, the autosteer reads this and imports it to control the manual tool. That manual tool on records during the record session. I’m not familiar with most of this, someone else would know more than myself. But it appears that AOG reads this and turns the work on or off.

image

KentStuff,

I Don’t know what that is for. I’ll have a look in the code and see if I can figure it out. In the mean time I have the code done to bring it in the USB. At least I think I do, I don’t get any errors. I’ll have time in a day or so to try it out. I’ll report back either way.

I’ve been following your efforts on grade control - good work!!

I struggled to find the whole works of that button, but it appears to read a switch in the autosteer serial read. It did not look like it was still active in the arduino code, but may have originally read pin 7. Somewhere on this forum, I saw someone with a full switch board that controlled each section outside of AOG and AOG would respond to each switch. May be something to look for.

Thanks for the compliment on grade control. Been slowly learning C# since early last summer. Prior to that, my last programing was in Fortran in the last millinium. It still amazes me that the computer can process that much information that fast.

Just curious what type of trees are you spraying? We live in pecan country and Hurricane Michael got most of them in our area. The orange groves did much better.

Which version of AoG are you using? On my sprayer, I’m using an older version where my modified autosteer ino monitors 5 analog pressure sensors and when they read a pressure above a certain threshold it tells AoG to turn on that section which paints the screen for me. There’s a certain section control PGN that allows the Arduino to override AoG. I think this is what you want. Off hand, I don’t know the details of that PGN but I could look it up once there’s time.

In the link below is a video of it running backwards. The switch telling the computer what to do. Not sure how to find the original, but this was one of the ones I remember.

Where is the on/off recorded? Does AOG do this? Is this something you will be coding it to do?

1 Like

That’s the one

1 Like

connect arduino with the Machine Serial Port
MTZ8302 Remote Switch code
Serial.println(“127,249,0,0,0,0,0,0,0,2”);//Turn Off Auto Sections
Serial.println(“127,249,0,0,0,0,0,0,0,1”);//Turn On Auto Sections

or with the AutoSteer Serial Port(need to enable WorkSwitch in toolsettings)
Serial.println(“127,253,0,0,0,0,1,0,0,0”);//Turn Off Auto Sections
Serial.println(“127,253,0,0,0,0,0,0,0,0”);//Turn On Auto Sections

2 Likes

m_elias
I’m running 4.3.10.

KentStuff
We.ve got 2 - 3 acre pieces that for years tried to figure out something to make money rather than just mowing for fun. The patches are in city limits so have to keep them mowed. 3 years ago I happened on an article on Chestnuts, the rest is history. We live in NC Iowa - about 60 miles N of where the Derecho? big wind went through mid August.

I’ve seen some of the threads about using external buttons or switches. I need to go back and revisit them!!

SK21
If you record your path ( use the Martian in the upper left corner) 0f AOG - everything you do is recorded, speed, relays, etc. Brian’s video

DanielP
Thanks for the machine code. I’ve watched Brian’s videos on this many times. It’s only when I need to implement something of my own that I really begin to understand how it all works, so I will also make this switch work that way.

1 Like

Ok, I see that now. It doesn’t record if you just click on a section button, but it does if you click auto on or manual on.

The auto sections on code should be a good solution.

I’m stuck and it seems the error I get sends me in a loop. I hope I’ve documented well enough. case dataSwitch is where the error is - I’ve commented with the language.

Controls.Designer.cs Line 510

//Section Manual and Auto
        private void btnManualOffOn_Click(object sender, EventArgs e)
        {
            System.Media.SystemSounds.Asterisk.Play();

            //code added to pass data from Tree detection sensor array
            SerialPort myport = new SerialPort();
            myport.BaudRate = 34800;
            myport.PortName = "com4";
            myport.Open();

            var data = myport.ReadLine();  //arduino sends On or Off
            string v = data.Trim();
            data = v;

            bool dataSwitch;

            if (data == "Off")
                dataSwitch = false;
            else
                dataSwitch = true;
            //end of added


            switch (manualBtnState)
            {   //the case satements stacked below make an 'OR' condition  dataswitch is added
                case dataSwitch:  *//CS0029 Cannot implicitly convert type 'bool' to 'AgOprnGPS.FormGPS.btnStates'*
                case btnStates.Off:
                    manualBtnState = btnStates.On;
                    btnManualOffOn.Image = Properties.Resources.ManualOn;

                    //if Auto is on, turn it off
                    autoBtnState = btnStates.Off;
                    btnSectionOffAutoOn.Image = Properties.Resources.SectionMasterOff;

                    //turn all the sections allowed and update to ON!! Auto changes to ON
                    for (int j = 0; j < tool.numOfSections; j++)
                    {
                        section[j].isAllowedOn = true;
                        section[j].manBtnState = manBtn.Auto;
                    }

                    ManualAllBtnsUpdate();
                    break;

                case btnStates.On:
                    manualBtnState = btnStates.Off;
                    btnManualOffOn.Image = Properties.Resources.ManualOff;

                    //turn section buttons all OFF or Auto if SectionAuto was on or off
                    for (int j = 0; j < tool.numOfSections; j++)
                    {
                        section[j].isAllowedOn = false;
                        section[j].manBtnState = manBtn.On;
                    }

                    //Update the button colors and text
                    ManualAllBtnsUpdate();
                    break;
            }
        }

That switch is checking for a button state not a bool. That’s part of the problem.

But you are in the middle of a button_click doing this. So the only time that this function runs is when the button is clicked, unless called otherwise. So I think what you are needing is to put your serial reader in the main loop. Then let it check for the condition and respond accordingly each time around.

Somewhere in the code, it tells the sections to all be on or individual. I don’t remember, maybe in csections.cs. Search for the phase supersection. I believe it’s around there.

Were you able to send the work switch serial in from the autosteer to see if that shut it off?

I don’t think you need to write any code in AOG. Just connect your sensor nano to either the AutoSteer Port or the Machine Port.

Capture

Then send the Serial.println pgns as DanielP suggested.

1 Like

Alright, I’ll give connecting to the machine port a try… No coding sounds fine to me.

Success - I think - pretty sure. We’ve got 40 MPH wind gust here today so I’m not going to the field I’d lose my sun screen. I have hooked it up and I read sensor changes as would be expected. (This is using DanielP suggestion).

Thanks to all who made suggestions.

1 Like

Good :+1:t3: I’m guessing you’ll do a setup video? And a demo video?

Hobbyfarmer.

I hadn’t thought of any videos, but i’ll sure do my best! Maybe this weekend.

@Ray_Jorgensen :wink:

Here’s a bit of video. The first clip is of the ultrasonic array as I circled a tree. (I’m going slow cause was running out of hands) You can’t see it on the vid but I have a LED that comes on as contact is made. I need to stiffen up the “do dad” It bounces to much and causes the switch to toggle when unwanted. I’ll get that fixed and do a vid of it in “auto” mode.

It works great and I’m :grinning: :grinning: :grinning:

4 Likes