Welcome! Log In Create A New Profile

Advanced

No response from Serial on Custom Board

Posted by TheJLo 
No response from Serial on Custom Board
November 14, 2019 05:21PM
Hello Everyone,

This post will be fairly long and detailed so I will start with a brief right here:
I am getting no response on Serial from Marlin on a custom board while using Octoprint as a controller.

Now on to more details... sorry if this is a little long winded, trying to cover every base.

I am trying to get Marlin running on an AthenaII 3D printer which is developed at my University. The printer uses a custom board and custom firmware by default but I want to get it working with Marlin. For more details on the printer itself I've provided links to the printer and custom board below:

Printer: https://www.appropedia.org/AthenaII
Board: https://github.com/phidiasllc/athena_board
Default Firmware: https://github.com/mtu-most/franklin

After installing Octoprint on the controlling computer as well as uploading a compiled version of Marlin onto the board, I get no serial response when trying to connect via Octoprint. The N0 M110 N0*125 codes that Octoprint outputs through serial simply timeouts with no response. I've been trying to figure out what is going on but have made no progress. I've detailed the setup and steps I've done below. Maybe someone can see something I am missing? or knows what I am doing wrong?

The following are some relevant specs for the board (Let me know if you need more):

Printer Board:
Processor  : ATmega1284P
Frequency  : 16MHz Crystal Oscillator
Vcc        : 3.3V
Fuse-bits  : e=0xFF,L=0xF7, H=0xD9
Serial Port: Rx0/Tx0 (Pins 8/9)

Controlling Computer:

Model     : Orange Pi Zero
OS        : Armbian
Controller: Octoprint

These boards are directly connected to each other daughter-board style. I control the Orange Pi computer with SSH. The Octoprint server on the Orange Pi works and can also be accessed by my desktop.

I am compiling Marlin using Arduino 1.8.10 on my desktop and am uploading it via the Orange Pi using avrdude manually through the SPI bus on the AVR. This is how I am using it (athenapi is a linuxgpio SPI programmer):

avrdude -p atmega1284p -c athenapi -U flash:w:Marlin.ino.hex

I am compiling Marlin as through it is being uploaded onto a Sanguinolulu with a 1284P just to get the serial working. I didn't change the configuration other than the board. None of the steppers or other components are connected. It is just the Orange Pi and the ATmega1284P with its circuitry. I don't get any compilation errors other than this:

Error while detecting libraries included by /tmp/arduino_build_437632/sketch/temperature.cpp

From what I have seen, this isn't a huge error as long as it completes compilation and everything should work fine. After transferring the .hex file, uploading goes fine otherwise. AVRdude completes with no errors. The issue starts when I try to send anything to the board through the serial lines. Neither Octoprint nor Minicom get any response from the board. I've tried a series of things to diagnose and fix this issue.

I've changed the Serial Port on Marlin between 0 and 1. According the the fastio headers it should be on serial 0.
I've tried different Marlin versions: 1.1.x, 1.1.x-bugfix, 2.1-dev, 2.0.x-bugfig; with no difference.
I've tried different baud rates on both Marlin and Octoprint. Including having Octoprint sweep through baud rates.
I've checked that Octoprint can send and receive by shorting Rx and Tx. It does, however I can't seem to get it to work when the ATmega1284P is connected...
I've tried checking that other Arduino programs work, they do.
I've uploaded an Arduino serial echo server to see if serial was broken. It appears to work, however minicom gives me the wrong values back... but that might be my minicom setup.

So from what I've tried, it seems there might be some hardware issue with the UART/Serial but the previous firmware used serial as well and had no issues with communicating. Is Marlin more picky about how UART operates? I did have to replace the ATmega1284P once when I fried it on a short but I had no issues with it after the replacement. Maybe its possible I damaged something during my debugging? But I was having this issue before removing the electronics from my printer as well.

I can't seem to wrap my head around why this isn't working. I feel like I might be missing something really simple or obvious. Does anyone have any clue what might be going on?

Thanks in advance,

Jacob 'The JLo'

Edited 1 time(s). Last edit at 11/14/2019 07:15PM by TheJLo.
Re: No response from Serial on Custom Board
November 14, 2019 06:41PM
5v TX on 1284p connected to 3.3v RX on Orange Pi... this doesn't seem wise.
Re: No response from Serial on Custom Board
November 14, 2019 07:13PM
The AVR is being powered with 3.3V so it should be 3.3V logic on the Serial lines... Right? Otherwise that is definitely a problem...

Just thought of something. I was powering the electronics through the power USB on the Pi while I was testing. The system usually uses a 24V supply with a Buck Converter. I have no clue if this will make a difference but I am going to try using the 24V supply instead and see what happens.

Edited 1 time(s). Last edit at 11/14/2019 07:24PM by TheJLo.
Re: No response from Serial on Custom Board
November 14, 2019 07:32PM
Ok so changing to the 24V supply which normally runs the system did not change anything. Still no response from Octoprint.
Re: No response from Serial on Custom Board
November 14, 2019 09:11PM
Running a 1284p @ 16mhz on 3.3v is outside of the recommended specification..

Run it at 5v, and level shift that 5v TX pin... I would bet it now works
Basically your baud rate clocks will not be correct on the avr so it cant talk to anything but itself.
Re: No response from Serial on Custom Board
November 14, 2019 09:54PM
Oof... Ok looks like I'll have to cut a few traces. Might be a little while but I will report my results after I try it.

Would the 1284P be stable at 8MHz at 3.3V? Probably not the best solution but would be an easier modification than changing out the power on the PCB.
Re: No response from Serial on Custom Board
November 14, 2019 10:19PM
8mhz should be fine on 3.3v. Going to need a new 8mhz bootloader (if you have a boot loader) and compile your code for 8mhz

suspect that would be too slow for marlin to run well though... but testing basic serial should be fine.
Re: No response from Serial on Custom Board
November 15, 2019 03:35AM
So I converted the board to run the 1284P at 5V with resistive level shifts for the Tx and MISO lines going to the Orange Pi. The board still runs but the same issue still exists. I tried Marlin again and still got nothing going back to Octoprint. Then I tried to do the echo server again and I am still getting some wonky data back from Minicom. It is set to 8-N-1 at 9600 Baud which was the same settings on Octoprint and Marlin. I have provided the code and output for the echo server below.


Echo Server code on Arduino. Compiled
byte inByte[255];         // incoming serial byte

void setup() {
  // start serial port at 9600 bps and wait for port to open:
  Serial.begin(9600);
  
  //establishContact();  // send a byte to establish contact until receiver responds
}

void loop() {
  // if we get a valid byte, read analog ins:
  if (Serial.available() > 0) {
    // get incoming byte:
    size_t r = Serial.readBytes(inByte, 255);

    Serial.write(inByte, r); // Echo
    
  }
}

Minicom:


Maybe I'm misinterpreting but those are not the right numbers for ASCII Characters.

I've also noticed that the label on the crystal resonator is A120G79 which to me seems to imply a 12 MHz crystal... I haven't heard of anyone running a 1284P at anything other than 8 MHz or 16 MHz so this seems odd to me.
Re: No response from Serial on Custom Board
November 15, 2019 04:15AM
a wrong crystal will also kill serial comms. The baud rates are derived from the crystal speed you tell it is running at...

Presuming your running arduino like environment...
If you suspect it is 12mhz find the appropriate boards.txt file (for me on linux its in ~/.arduino15/packages/Sanguino/hardware/avr/1.0.3

It has a section like this
## Sanguino W/ ATmega1284 or ATmega1284P 16MHz
sanguino.menu.cpu.atmega1284p=ATmega1284 or ATmega1284P (16 MHz)

sanguino.menu.cpu.atmega1284p.upload.maximum_size=130048
sanguino.menu.cpu.atmega1284p.upload.maximum_data_size=16384
sanguino.menu.cpu.atmega1284p.upload.speed=115200

sanguino.menu.cpu.atmega1284p.bootloader.file=optiboot/optiboot_atmega1284p.hex

sanguino.menu.cpu.atmega1284p.build.mcu=atmega1284p
sanguino.menu.cpu.atmega1284p.build.f_cpu=16000000L

Change the last line to sanguino.menu.cpu.atmega1284p.build.f_cpu=12000000L (restart arduino ide after the change, or it wont notice)

See it that make any difference.
Re: No response from Serial on Custom Board
November 15, 2019 05:31PM
So I changed the frequency in the boards file to be 12Mhz. Still the same result for Marlin and for the test Serial Echo server I am now getting "48 74 7c 7c 7f 0c" instead of what is above for the word "Hello\n"... Maybe I fried something in the serial circuitry on the 1284P? I have an extra one I could try to replace it with.
Re: No response from Serial on Custom Board
November 19, 2019 02:19PM
Ok, I got everything working. Turns out that Marlin does not like 12 MHz. The 1.1.x-bugfix wouldn't even compile with it since the FastIO uses lookup tables to determine an appropriate baud frequency. I changed out that 12 MHz crystal for a 16 MHz Ceramic Resonator I had and everything works up to 250000 baud now! Thanks for your help Dust, really appreciate it!
Sorry, only registered users may post in this forum.

Click here to login