I tried, found similar projects for parts of it, but as I'm not a programmer, I didn't succeed to compile them in one single project. I suppose that one might use libraries like Rotary, LedControl, AccelStepper. If possible, after the start of the rotation, to be able to still modify the speed (as described above) and apply it by pressing the encoder button a second time. So, rotate the encoder (forward or backwards) to determine the speed, which will be reflected in number of lit LEDs on a LED matrix, then press encoder to start the rotation of the motor. Rotary button press starts the motor rotation. There are 64 LEDs on the matrix, representing 100% of a predetermined speed when all lit. The number of alight LEDs represent the percent of the maximum speed of the stepper NEMA 17. Depending on the direction of rotation, you can add or substract lighted LEDs on the matrix. The speed should be determined / controlled by a combination of a Rotary Encoder and a MAX7219 (8x8 LED matrix, driver included) > Each rotation click of the rotary encoder lights an LED on the matrix, one by one, in order, until the matrix is full. return encoder_output //alternatively, return the absolute valueĮach time this routine is called, it reads off ENC_A / ENC_B on ENC_PORT and determines if the rotation is clock or counter-clockwise, or return the absolute value (via encoder_output).Stepper motor NEMA17 driven by driver TB6600 (12V source) should rotate endlessly at a certain speed. Return encoder_sm //return the relative value (+1 = clockwise, 0, -1 = counterclockwise) Test transition, did things really change? If ( rotating ) delay (1) // wait a little until the bouncing is done Long interval = 500 // interval at which to blink (milliseconds)ĭigitalWrite(encoderPinA, HIGH) // turn on pullup resistorĭigitalWrite(encoderPinB, HIGH) // turn on pullup resistor will quickly become a bigger number than can be stored in an int. the follow variables is a long because the time, measured in miliseconds, Long previousMillis = 0 // will store last time LED was updated Int ledState = LOW // ledState used to set the LED Static boolean rotating=false // debounce managementĬonst int ledPin = 43 // the number of the LED pin #include Īdafruit_SSD1306 display(OLED_MOSI, OLED_CLK, OLED_DC, OLED_RESET, OLED_CS) I know this code is not %100 that is why I'm here. How can I do this? I would guess using the "millis()"?Īfter reading though Coding Academy "Linux Format" there is a fantastic bit about controlling the Arduino from an Android devise this would be the next step to learn instead of using buttons. I cant have to much delay() commands in the code or it will miss the state changes made from the encoder. It has been great fun till I stumbled on getting both the encoder and stepper motor to work together. I have looked at the /Main/RotaryEncoders and have taken bit's to use, study and to try and learn the code. the motor doesnt rotate fluently but brakes and accelerates if the encoder is rotated. Both the encoder and stepper motor will be fitted to a linear actuator. Hi all, I have a problem when an encoder is connected to the Mega board together with a stepper motor. Then to control a stepper motor with the Arduino Motor Shield using buttons with set amounts of steps in ether direction. I want to read the A and B pins from an encoder using interrupts together with an OLED display used as a readout, much like a lathe digital readout.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |