Ilex

Forum Replies Created

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • Ilex
    Participant

    Although in this code there is a //bounding…

    [code]
    // update the menu position
    if ( lcd_turn!=0 && num_menu_items > 1 ) {
    uint8_t originalPosition = menuStack[menuStackDepth].menu_position_sum / LCD_TURN_PER_MENU;
    uint8_t upperBound = num_menu_items * LCD_TURN_PER_MENU;

    // potentially change the menu item
    menuStack[menuStackDepth].menu_position_sum += lcd_turn;
    // bounding
    if(menuStack[menuStackDepth].menu_position_sum < 0) menuStack[menuStackDepth].menu_position_sum=0;
    if(menuStack[menuStackDepth].menu_position_sum >= upperBound) menuStack[menuStackDepth].menu_position_sum = upperBound-1;

    uint8_t menu_position = menuStack[menuStackDepth].menu_position_sum / LCD_TURN_PER_MENU;
    // check for change
    if (originalPosition != menu_position) {
    lcd_dirty=1;
    LCD_clear();
    }

    [/code]

    Ilex
    Participant

    Well, in my thoughts the encoder gets micro-pulses while turning the knob.
    If he gets lets say 4 pulses before the knob ‘clicks’, and he got the command to change cursor at 4 pulses… he would change before ‘click’.
    Euh… not?
    🙂

    Somewhere around here, Dan?

    [code]
    int buttons=0;
    unsigned long next_lcd_read=0;
    const char *update_key;
    void *update_val;

    void LCD_read() {
    long now = millis();

    if(ELAPSED(now,next_lcd_read)) {
    // detect potentiometer changes
    buttons = ((digitalRead(BTN_EN1) == LOW) << BLEN_A)
    | ((digitalRead(BTN_EN2) == LOW) << BLEN_B);
    next_lcd_read=now+30;
    }

    // potentiometer uses grey code. Pattern is 0 3 1 2
    if (lcd_rot_old != buttons) {
    switch (buttons) {
    case ENCROT0: switch( lcd_rot_old ) { case ENCROT3: lcd_turn++; break; case ENCROT1: lcd_turn–; break; } break;
    case ENCROT1: switch( lcd_rot_old ) { case ENCROT0: lcd_turn++; break; case ENCROT2: lcd_turn–; break; } break;
    case ENCROT2: switch( lcd_rot_old ) { case ENCROT1: lcd_turn++; break; case ENCROT3: lcd_turn–; break; } break;
    case ENCROT3: switch( lcd_rot_old ) { case ENCROT2: lcd_turn++; break; case ENCROT0: lcd_turn–; break; } break;
    }
    // for debugging potentiometer
    {
    //if(lcd_turn !=0) Serial.print(lcd_turn>0?’+’:’-‘);
    //else Serial.print(‘ ‘);
    //Serial.print(millis()); Serial.print(‘\t’);
    //Serial.print(lcd_rot_old); Serial.print(‘\t’);
    //Serial.print(buttons); Serial.print(‘\t’);
    //Serial.print(lcd_turn); Serial.print(‘\n’);
    }

    lcd_rot_old = buttons;
    }

    // find click state
    int btn = digitalRead(BTN_ENC);
    if ( btn != lcd_click_old && btn == HIGH ) {
    // when button is released
    lcd_click_now = true;
    }
    lcd_click_old = btn;
    }

    [/code]

    Ilex
    Participant

    Hello Dan, I got the polargraph working without the LCD.
    Stepper, servo etc responds.
    The problem started when connecting the LCD to get rid off the PC.

    Somewhere the encoder is counting wrong. Don’t find which part of the sketch is responsible for that?

    Thx for helping!

    Ilex
    Participant

    Hallo Dan, I tried it already… no good.
    Is this the C-code where to look at?

    Ilex
    Participant

    Hello
    I am completley new to electronics, Arduino Mega-things, Ramps, stepper motors etc…
    When I saw your draw bot I wanted to make such piece of art!
    Got instructions from “Instructables” in which someone made it with Ramps 1.4 and Mega 2560 so I bought that stuff.

    It took me al lot of time, research and trial & error to get somewhere in the software part. Pffiuw!

    Almost there. Almost.
    The RepRap LCD Full Graphic Smart Controller is working except of the encoder rotary.
    I can only go through the menu when I really turn very slowly and carefully!
    I need to make 1/8 turn or so to let the cursor move 1 step.

    Any suggestions?
    Thx in advance!

Viewing 5 posts - 1 through 5 (of 5 total)