Hi, I'm new to the Reprap forums. A bit of history about me, I'm an electronics tech at work and I've been exploring 3D printing as a hobby for about 2.5 years. I've built my own core XY printer and I've been using Marlin on it and it works great.
So when a project came up at work needing 5 axis stepper control, Marlin was the first thing I looked into. To my surprise 6 axis support has recently been added. We setup an Adafruit Grand Central and a RAMPS 1.4 board and so far Marlin 2.0.9 has been working great on this setup. I've added some simple position error correction using rotary quadrature encoders and some M codes for controlling solenoids and such and all that is working great.
So my next big hurdle is connecting another device to Marlin over RS485. Here is where I've hit a block. If I enable another serial port in Configuration.h:
#define SERIAL_PORT_2 1
#define BAUDRATE_2 9600 // Enable to override BAUDRATE
I get another serial port that translates fine over a MAX3485. I'm using a USB to RS485 adapter to read the signal back into my laptop for testing. I can transmit data from Marlin over RS485 to the external device, but I can't receive anything back. I can confirm that Marlin is reading the serial port correctly (via the MAX3485) because I can send G code and M code through this port and get responses.
If my understanding is correct, this serial port is part of a "multiserial" object that combines several serial ports into one. This allows gcode to be sent over either the USB (my default connection), or the second serial port (RS485 in my case). This also means that data coming into this port is forwarded to the gcode parser so I can't read it for my purposes using Serial.read() etc... I think I also read somewhere that the entire serial port structure was revamped to this new style very recently (2.0.8 maybe?)
So my question is how do I create the second serial port, but have it be independant so that I can send data to my device and receive it's response? I've read through the "docs/Serial.md" file which has helped me understand more, but I'm not the best at C++ and the code is a bit hard for me to follow. Does anyone have some instructions or some example code on how to do what I'm looking for? Or some helpful tips or explanations that might point me in the right direction to figure it out?
Thanks in advance for any help.
So when a project came up at work needing 5 axis stepper control, Marlin was the first thing I looked into. To my surprise 6 axis support has recently been added. We setup an Adafruit Grand Central and a RAMPS 1.4 board and so far Marlin 2.0.9 has been working great on this setup. I've added some simple position error correction using rotary quadrature encoders and some M codes for controlling solenoids and such and all that is working great.
So my next big hurdle is connecting another device to Marlin over RS485. Here is where I've hit a block. If I enable another serial port in Configuration.h:
#define SERIAL_PORT_2 1
#define BAUDRATE_2 9600 // Enable to override BAUDRATE
I get another serial port that translates fine over a MAX3485. I'm using a USB to RS485 adapter to read the signal back into my laptop for testing. I can transmit data from Marlin over RS485 to the external device, but I can't receive anything back. I can confirm that Marlin is reading the serial port correctly (via the MAX3485) because I can send G code and M code through this port and get responses.
If my understanding is correct, this serial port is part of a "multiserial" object that combines several serial ports into one. This allows gcode to be sent over either the USB (my default connection), or the second serial port (RS485 in my case). This also means that data coming into this port is forwarded to the gcode parser so I can't read it for my purposes using Serial.read() etc... I think I also read somewhere that the entire serial port structure was revamped to this new style very recently (2.0.8 maybe?)
So my question is how do I create the second serial port, but have it be independant so that I can send data to my device and receive it's response? I've read through the "docs/Serial.md" file which has helped me understand more, but I'm not the best at C++ and the code is a bit hard for me to follow. Does anyone have some instructions or some example code on how to do what I'm looking for? Or some helpful tips or explanations that might point me in the right direction to figure it out?
Thanks in advance for any help.