Close

Can Anyone Help?

A project log for Simple & Cheaper CNC Shaper

I love the Shaper Origin, it could solve many needs for the home maker and care taker. But at the price many can't afford it.

konkopkonkop 10/16/2016 at 17:120 Comments

So I have put together most of the electronics. I was working on the encoders first. I can wire + - A (Signal) into the +X endstop and the B into the -X signal. I have started the code but can't seem to get a good signal from the encoder.

I was using J.Carter(of Earth) from Arduino Rotary Encoders but it was never showing a change in direction. When I changed the code to just print A or B I get a bunch of A and every once in a great while a B. It does the same for both encoders. I don't know if I have a bad encoder or not wired correctly. Anyone have any ideas?

#include "U8glib.h"
#include <SPI.h>
#include <SD.h>
  
  #define LCD_PINS_RS 27
  #define LCD_PINS_ENABLE 29
  #define LCD_PINS_D4 37
  #define LCD_PINS_D5 35
  #define LCD_PINS_D6 33
  #define LCD_PINS_D7 31

//**************************************************
// Change this constructor to match your display!!!
//U8GLIB_SH1106_128X64 u8g(LCD_PINS_D4, LCD_PINS_D5, LCD_PINS_D6, LCD_PINS_D7);

void int0()
        {
          Serial.print("A");
        }
 
void int1()
        {
          Serial.print("B");
        }

void setup()
        {
        Serial.begin(9600);
          //setting up encoder A
        digitalWrite(2, HIGH);
        digitalWrite(3, HIGH);
        attachInterrupt(0, int0, CHANGE);
        attachInterrupt(1, int1, CHANGE);
		}
void loop()
        {
          Serial.println();
          delay(1000);
        }

Discussions