im interessted in upgrading our Steyr 9094 with AGO GPS.
Caused of tramline control i am using an Arduino Mega already on our tractor.
Thats why i want to use this also for AGO GPS.
If i connect an Arduino Uno with the 4.3.10 Code to my PC, everythin works fine.
The same procedure with the Mega and i dont get a serial connection.
If cut the code to a minimum but it still doesnt work.
Yes, with the minimized Code and the Arduino Uno i get back the data from serial.print in AGO GPS.The TX Led is flashing.
The Mega doesnt even send any data back (the TX Led stays off)
Both work with 16MHz. I changed the Baudrate a little bit wether if this the problem. I also tried another Arduino Mega, still the same.
I doesnt understand whtats the difference between the Mega and the Uno.
I can’t see anything wrong. I successfully ran this on an Uno and Mega 2560. I added a pot on A0 and a switch on D3. The pot is reported for WAS, roll and PWM to AoG, D3 is workSwitch and steerAngleSetPoint is also sent back.
bool isDataFound = false, isSettingFound = false, isMachineFound = false, isAogSettingsFound = false;
int header = 0, tempHeader = 0, temp;
float steerAngleSetPoint;
void setup(){
pinMode(3, INPUT_PULLUP);
Serial.begin(38400);
Serial.print("\r\nBooting");
}
void loop(){
if (Serial.available() > 0 && !isDataFound && !isSettingFound && !isMachineFound && !isAogSettingsFound){
int temp = Serial.read();
header = tempHeader << 8 | temp;
tempHeader = temp;
if (header == 32766) isDataFound = true;
}
if (Serial.available() > 7 && isDataFound == true){
isDataFound = false;
Serial.read(); // unused, old section control byte
Serial.read(); // gps speed * 4
Serial.read(); // dist from line high byte
Serial.read(); // dist from line low byte
steerAngleSetPoint = ((float)(Serial.read() << 8 | Serial.read()))*0.01; // steer angle set point high/low bytes
//Serial.read(); // steer angle set point high byte
//Serial.read(); // steer angle set point low byte
Serial.read(); // unused
Serial.read(); // unused but should read 8 bytes (2 header bytes already read earlier)
Serial.print("127,253,"); // header, num 0 & 1
Serial.print((analogRead(A0) - 512) * 10); // WAS, num 2
Serial.print(",");
Serial.print(steerAngleSetPoint * 100); // steer angle setpoint, num 3
Serial.print(",");
Serial.print("0"); // heading from BNO or 0, num 4
Serial.print(",");
Serial.print((analogRead(A0) - 512) / 3); // roll or 0, num 5
Serial.print(",");
Serial.print(digitalRead(3)); // switch byte, num 6
Serial.print(",");
Serial.print((analogRead(A0) - 512)); // pwm, num 7
Serial.println(",0,0"); // num 8 & 9
Serial.flush();
}
}
Tried your Code but doesnt work on the Mega.
I’ve made a Video but its impossible to do someting wrong https://youtu.be/5RGOUlsJkPo
What i alread tried:
-Another Arduino Mega
-Another USB cable
-reinstalling AGO GPS
-reinstalling Arduino IDE
-Changed the COM port of the Arduino in the Hardware Settings
-Changed the baudrate from 30000 to 48000 in stepps of 1000
-Tried all this things on my Laptop and PC
The last thing i trie now is to buy a new Mega. If this doesnt help i give up the project
Maybe use another computer to upload to the arduino? Long shot but it’s an odd issue. In follow this because I’m having some strange issues trying to alter the code to run on an esp32. Most my fault but some compiler difference related.
In the Arduino Mega spec they say to plug nothing on the 2 serial0 communication pin to have USB serial communication. it’s the only thing I could see.
The code I shared with ran on my 2560 just fine using it’s built-in USB. I suspect every time I connected with AoG via the Mega’s built-in USB it rebooted the Mega and there were no problems.
I tried that, didn’t help because it’s the data coming in on the RX from agopen too fast that causes the port problem. Without a delay from the agopen end, I think it just has to be done with the TTL/USB. Don’t know why
I don’t understand why the TTL adapter makes any difference. On my Arduinos the on board USB adapter works fine. Do you know which chip your on board and TTL adapter are?
Are you connecting through usb hub? I have found my 2560 clones are finicky with how long the cables are and which hubs I use but that usually shows up already when programming. It’s the only cloned board I have had issues with.
It’s not the 328 or 2560 handling the USB. The other chips you mentioned convert the usb to TTL via IO 0 & 1. They also handle auto reset.