Arduino Nano hand wheel, Marlin, ramps, Octopi

I have created myself a pendent using a encoder handwheel, Lcd, poti for feed rate, menbrane switch matrix and an arduino Nano.

I run it on a lowrider with a ramps board connected to the serial 1 port pins on the ramps Zmax and Zmin,
It works perfectly when I use it for setting up jobs, but when I use octoprint it is causing issues, the job stops and says too many errors, or somelike that… I’m not at the work shop…
Furthermore, I set up out the job with the pendant, place it in its holder and start the job with octoprint that is running on a raspberry pi 4. When the pendant is not connected it works fine.
my arduino code only sends data after an event, so I not sure why its happening…

any ideas??

in the marlin setup of have enable both ports.
#define SERIAL_PORT 0
#define SERIAL_PORT_2 1

my arduino code(Ps Im not a programmer.)…

// Code based on this thing
// https://makerware.thingiverse.com/thing:1563410

#include <Keypad.h>
#include <EEPROM.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,20,2); // set the LCD address to 0x27 for a 16 chars and 2 line display

char Axis = ‘Z’;
char key = ‘3’;
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
float Vorschrub = 0.01;
char keys[ROWS][COLS] = {
{‘1’,‘2’,‘3’,‘A’},
{‘4’,‘5’,‘6’,‘B’},
{‘7’,‘8’,‘9’,‘C’},
{’*’,‘0’,’#’,‘D’}
};

byte rowPins[ROWS] = {11, 10, 9, 8}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5, 4}; //connect to the column pinouts of the keypad
#include <SimpleRotary.h>

//Create an object of keypad
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
SimpleRotary rotary(2,3,-1);

int sensorValue = 0; // value read from the pot
int neusensorValue = 0; // value output to the PWM (analog out)
int sensorPin = 14;
int sensorpercent = 100;

void setup(){
Serial.begin(250000);
lcd.init(); // initialize the lcd
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0,0);
keypad.addEventListener(keypadEvent); // Add an event listener for this keypad
}

void loop() {
sensorValue = analogRead(sensorPin);
sensorpercent = map(sensorValue, 0, 1023, 0, 101); //Map value 0-1023 to 0-130%
if (sensorpercent != neusensorValue) {
Serial.print(“M220 S”);
Serial.println(sensorpercent);
lcd.print(" “);
lcd.setCursor(12,0);
lcd.print(sensorpercent);
lcd.print(”%");
neusensorValue = sensorpercent;

}

byte i;

// 0 = not turning, 1 = CW, 2 = CCW
i = rotary.rotate();

if ( i == 1 ) {

Serial.println("G91");
Serial.print("G0 ");
Serial.print(Axis);
Serial.println(Vorschrub);
Serial.println("G90");

}

if ( i == 2 ) {

Serial.println("G91");
Serial.print("G0 ");
Serial.print(Axis);
Serial.print("-");
Serial.println(Vorschrub);
Serial.println("G90");

}

char key = keypad.getKey();// Read the key
}
// Taking care of some special events.
void keypadEvent(KeypadEvent key){
switch (keypad.getState()){
case PRESSED:

// Achse
    if (key == '1') {                                     // X =1, Y=2, Z=3
        Axis = 'X';
        lcd.print("        ");
        lcd.setCursor(0,0);
lcd.print("X-Achse");       

}
if (key == ‘2’) {
Axis = ‘Y’;
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print(“Y-Achse”);

    }
    if (key == '3') {
        Axis = 'Z';
        lcd.print("        ");
        lcd.setCursor(0,0);
lcd.print("Z-Achse");       

}
// Vorschub

if ((Axis == 'X'||'Y')&&(key == '4')){
       Vorschrub = 0.1;
       lcd.setCursor(0,1);
        lcd.print("                 ");
        lcd.setCursor(0,1);
        lcd.print(Vorschrub); 
       lcd.print("mm Vorschub"); 
       
}

        
 if ((Axis == 'X'||'Y')&&(key == '5')){
       Vorschrub = 1;
       lcd.setCursor(0,1);
        lcd.print("                 ");
        lcd.setCursor(0,1);
        lcd.print(Vorschrub); 
        lcd.print("mm Vorschub");  

 
}
if ((Axis == 'X'||'Y')&&(key == '6')){
       Vorschrub = 10;
       lcd.setCursor(0,1);
        lcd.print("                 ");
        lcd.setCursor(0,1);
        lcd.print(Vorschrub); 
        lcd.print("mm Vorschub"); 

 
}
if ((Axis == 'Z')&&(key == '4')){
        Vorschrub = 0.01;
        lcd.setCursor(0,1);
        lcd.print("                 ");
        lcd.setCursor(0,1);
        lcd.print(Vorschrub); 
        lcd.print("mm Vorschub"); 

}
if ((Axis == ‘Z’)&&(key == ‘5’)){
Vorschrub = 0.1;
lcd.setCursor(0,1);
lcd.print(" “);
lcd.setCursor(0,1);
lcd.print(Vorschrub);
lcd.print(“mm Vorschub”); ;
}
if ((Axis == ‘Z’)&&(key == ‘6’)){
Vorschrub = 1;
lcd.setCursor(0,1);
lcd.print(” ");
lcd.setCursor(0,1);
lcd.print(Vorschrub, 3);
lcd.print(“mm Vorschub”);

    break;

case RELEASED:
    if (key == '1') {
    
    }
    break;

case HOLD:
    if (key == '*') {
    lcd.backlight();
    delay(200);
    lcd.backlight();
    Serial.println("G92 X0");
    Serial.println("M300 S392 P436");
    
    
    }
    if (key == '0') {
    lcd.backlight();
    delay(200);
    lcd.backlight();
    Serial.println("G92 Y0");
    Serial.println("M300 S392 P436");
    
    }
    if (key == '#') {
    lcd.backlight();
    delay(200);
    lcd.backlight();
    Serial.println("G92 Z0");
    Serial.println("M300 S392 P436");
    
    }
    if (key == 'A') {
    lcd.backlight();
    delay(200);
    lcd.backlight();
    Serial.println("G90");
    Serial.println("G0 Z15");
    Serial.println("G0 X0 Y0");
    }

    if (key == 'D') {
    lcd.backlight();
    delay(200);
    lcd.backlight();
    Serial.println("G92 Y0 X0 Z0");
    Serial.println("M300 S392 P436");
    }
     break;
} 

}
}

3 Likes

They are both talking on the same serial port, right? That seems like it could cause confusion. Can you just disconnect it when running jobs?

If you are using D0 on your Ramps board as the receiver pin for your serial input from your pendant, then Jeffeb3 is right…you have a serial conflict. Looking through some pinout diagrams and a schematic for the Ramps 1.4 board, there are three possible pins you could use for your second serial input:

RX1 - D19
RX2 - D17
RX3 - D15

According to the diagrams, these pins are already in use on the Ramps 1.4 board. The easiest to redefine would be D19. It is used for Z-Max endstop, which I don’t think you are using. My theroy is that if you define Z_MAX_PIN in pins_RAMPS.h to some other unused pin, you can use this pin for your serial input. It is possible that you don’t even have to redefine Z_MAX_PIN and the firmware will work unmodified. This is all theory. I do know that when you enable “#define SERIAL_PORT_2 1” on a Rambo board (which uses the same microprocessor), Serial 1 (RX1 & TX1) become a second serial input/output for the board.

Once you get your question answered and problem solved, would love to know more about the pendant itself!

1 Like

I am not using any end stops on my lowrider, and have tx from the arduino Nano connected to the Rx1-d19 Z-max end stop, on the ramps board.

I know that they after operating on different serial ports, as when I comment out #define SERIAL_PORT_2 1, octoprint works but the the pendant doesnt.

Interesting. The screens work the same way (sending gcode over a second serial) and the seem to work fine with octoprint.

that why I though there is something wrng with my code, but monitoring the serial port does not show that it is sending any data when it octoprint is cutting a job… I was at the workshop for a few hours today to test it and get a copy of the octprint logs and was in a rush and disconnected a motor without turning off the 24vdc supply to the ramps and the smoke can out of the arduino mega and ramps board… so now need to order a new mega before I can test it again… I think I just might upgrade from the mega and ramps board… is there another baord that has access to the serial 1 pins… to solve the problem I might install a touch switch that the pendent is only powered when it is picked up… so that it disconnects the supply to the arduino nano (pendent when its not beening used…) I want to try and make the pendent wireless, with a 18650 cell, and when it sits in the dock it is charging, but I realise for the time it would take me to figure out how to do it im better off just using a cable and spend my times building board… maybe in the future I will figure out how I can do it…

1 Like

It looks like you’ve done all the right things. A couple of suggestions. First, try redefining Z_MAX_PIN in pins_RAMPS.h to an unused pin. You can try any pin other than D0 and D1 in Aux 1, Aux 2, and Aux 3 blocks. D0 and D1 are TX0 and RX0.

If you don’t have display, you can try using RX2 which is the D17 pin. I believe you will need to change the define to:

#define SERIAL_PORT_2 2
1 Like

The serial logs from octoprint can give you a clue too. If you can also write the serial log from the pendant over usb or something, then you’ll def. have the whole story.

The rambo supposedly has extra serial ports, but I tried to configure it for Ryan and we didn’t solve it. We might have been limited by the fact I was trying to do the sw and made Ryan do the hardware testing, so maybe we got our wires crossed.

The skr pro 1.2 has the tft display port, which our firmware configures by default. So that is a good choice.

That’s interesting. I’ve posted on the forum on several topic about getting pendants-like devices running using Serial1 on the Rambo board. I believe they were successful. If I remember correctly, they were using Repetier-Host, not Octoprint on the USB connection. I run a pendant on my machine, but I run headless, so I don’t need a second serial port. If this is still an issue with a Rambo board, I can run some experiements when I get some time.

What I would really like to get working is the tft on the serial port 1. I’ll be honest, we only gave it a half try, but I would like to configure that in the default firmwares, even if Ryan doesn’t end up selling them as a combo.

@vicious1, do you remember why that didn’t work?

I tried it and nothing showed up. I didn’t go much further than trying a few port number variations.

I have had not anytime to test mine, I will order a skr pro, as I have a fysetc 12864 2.1 screen that I was going to use for the pendent but my coding skills where not good enough, to get it to work with the nano, and it was a little over kill… I have installed my old uno cnc shield on the cnc that I use with estlcam while I wait for the new board so I can still use the cnc… as I need the cnc working… so my plan is a Skr pro v1.2 fysetc 1284 2.1, Vipi on the Pi and the pendent that I will try and get working with the skr board, as serial 1 tx rx is connected to the tft pins which I will not be using…

This looks interesting, will you share the full code and video when you are done with the project?