Get Serial to Arduino working
-
I am trying to get a an Arduino board to talk to the serial port on an Duet 0.6, Firmware 1.23 (2018-12-24b1)
I have no progress at all.
It is an original UNO R3 board running the code listed below.
In the Duet config I have set M575 P1 B9600 verified by my PanelDue by setting it to 9600.
Arduino connected to a PC using a USB cable. Since the USB occupies the serial port on pin 0 & 1 I am using Software serial to be able to get some feedback for debugging during coding.
The RX & TX from the Duet is connected to pin 10 & 11 on the arduino. (I have tested to swap TX/RX)
I have not had any progress establishing a connection. I am trying to read all the Duet send and then send G92 X0 back to verify i the DWC. Nothing gets printed in the console on the PC, and X-axis does not get homed.
What am I doing wrong here?
Arduino code:
#include <SoftwareSerial.h> SoftwareSerial portDuet(10, 11); void setup() { Serial.begin(9600); while(!Serial) {;} portDuet.begin(9600); Serial.println("Duet port started"); } void loop() { portDuet.listen(); while( portDuet.available() > 0) { char inByte = Serial.read(); Serial.write(inByte); } portDuet.write("G92 X0"); }
-
Use S0 in your M575 command so that the Duet does not expect checksums. However, if it's a 5V Arduino and you connected the Duet TX/RX pins directly to the Arduino Rx/Tx pins, you have probable blown one or both of the serial pins on the Duet. The Duet uses 3.3V signal levels.
-
@dc42
That does not sound good. How should I have done this ? Should there be resistors in line or another arduino board using 3.3v?But the panel due works fine on said pins, so I hope I have not ruined anything, yet....
-
You should use a voltage divider (2 resistors) to connect the Arduino Tx pin to the Duet Rx pin. Going the other way, you might get away with just a 1k series resistor for protection, it depends on how fussy the Arduino is about its input signal level. Ideally you would use a 3.3V to 5V level shifter.
Did you try putting S0 in the M575 command?
-
@dc42
I have turned off checksums, did not help.I read that my panel due quote:
Interface: 2-wire async serial interface with 3.3V signal level (5V tolerant input). An external pullup resistor can be added to improve noise margin when driving 5V printer electronics.
So I connected my arduino board to the panel due and it worked!! I got a message every 8 second. So my code was correct after all.
I have a ESP 8266 Node MCU that I will try, since it has 3.3v pins, to see if it works. If it does I will go for a level shifter for the arduino board or use the Node MCU instead. Perhaps make somthing that can switch between wireless and wired connection to the Duet.
I will not risk using 5v on my 0.6 board any more.
The tinkering continues...
-
@fotomas said in Get Serial to Arduino working:
So I connected my arduino board to the panel due and it worked!! I got a message every 8 second. So my code was correct after all.
That means that your receive code is OK. It doesn't prove that the transmit code is working.
-
@dc42
No, you are so right in that.
Also a working reception from the panel due indicated that i had no reception from the duet .
But one step forward, and learning a lot.