0

Raspberry Pi 3 stepper motor release
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Raspberry Pi 3 stepper motor release

by Skydromer on Thu Jul 18, 2019 3:08 am

Hi,
i tried to release the coils of the stepper motors but it never worked. I read release() was the key here but they still holding onto there torque. Is there a generell known problem or solution?

Skydromer
 
Posts: 23
Joined: Thu Jul 18, 2019 2:56 am

Re: Raspberry Pi 3 stepper motor release

by adafruit_support_carter on Thu Jul 18, 2019 6:58 pm

What hardware are you using to drive the stepper motors?

Can you post your complete code listing.

adafruit_support_carter
 
Posts: 12977
Joined: Tue Nov 29, 2016 2:45 pm

Re: Raspberry Pi 3 stepper motor release

by Skydromer on Fri Jul 19, 2019 12:56 am

Thanks for the reply.

I cant post you the code right now because somehow the raspberry pi shut itself down in the middel of work and wont start again.

But i am using this one: https://www.reichelt.de/raspberry-pi-sh ... D_BwE&&r=1


and coded like the datasheet told me to: https://cdn-reichelt.de/documents/daten ... NG_TDS.pdf

Skydromer
 
Posts: 23
Joined: Thu Jul 18, 2019 2:56 am

Re: Raspberry Pi 3 stepper motor release

by adafruit_support_carter on Fri Jul 19, 2019 12:14 pm

OK. Post full code when you can. The simple example code from the guide doesn't really use release(). So it will help to see your code.

adafruit_support_carter
 
Posts: 12977
Joined: Tue Nov 29, 2016 2:45 pm

Re: Raspberry Pi 3 stepper motor release

by Skydromer on Fri Jul 19, 2019 4:06 pm

It wont be until thursday.

But i can tell you i tried:
mh.getMotor(1).run(Adafruit_MotorHAT.RELEASE)
or
MyStepper.release
or
MyStepper.run(release)
and many more.
But i seems it is no common problem.

Skydromer
 
Posts: 23
Joined: Thu Jul 18, 2019 2:56 am

Re: Raspberry Pi 3 stepper motor release

by Skydromer on Tue Jul 23, 2019 3:02 am

ok here it comes.

Code: Select all | TOGGLE FULL SIZE
from tkinder import*
from Adafruit_MotorHAT import Adafuit_MotorHAT, Adafruit_DCMotor, Adafruit_StepperMotor
from time import sleep
from tkinder import messagebox

import time
import os
import sys
import atexit
imort RPi.GPIO as GPIO



GPIO.setwarnings(False)
GPIO.setmode(GPIO.BOARD)
--Var---
go = 0
loop = 0
testlauft = 0
s = 0
---GPIOs---
schranke = 7
slotschranke = 11
endlage_unten = 15
endlage_oben = 18
GPIO.setup(schranke, GPIO.IN)
GPIO.setup(slotschranke, GPIO.IN)
GPIO.setup(endlage_unten, GPIO.IN)
GPIO.setup(endlage_oben, GPIO.IN)

mh = Adafruit_MotorHat()

def turnOffMotors():

Skydromer
 
Posts: 23
Joined: Thu Jul 18, 2019 2:56 am

Re: Raspberry Pi 3 stepper motor release

by Skydromer on Tue Jul 23, 2019 3:11 am

damn click wrong button
continue

Code: Select all | TOGGLE FULL SIZE
     mh.getMotor(1).run(Adafruit_MotorHAT.RELEASE)
     mh.getMotor(2).run(Adafruit_MotorHAT.RELEASE)
atexit.register(turnOffMotors)

myStepper = mh.getStepper(200, 1)
myStepper.setSpeed(200)
myStepper2 = mh.getStepper(200, 2)
myStepper2.setSpeed(1200000)

def move_right():
     global s
     if GPIO.input(endlage_oben) == GPIO.HIGH:
         myStepper.step(445, Adafruit_MotorHAT.BACKWARD, Adafruit_MotorHAT.SINGLE)
         while GPIO.input(slotschranke) != GPIO.HIGH
                    mySteper.oneStep(Adafruit_MotorHAT.BACKWARD, Adafruit_MotorHAT.INTERLEAVE)
          if testlaeuft == 0:
             turnOffMotors()


and then there is a gui which let me use this function with a button.

Skydromer
 
Posts: 23
Joined: Thu Jul 18, 2019 2:56 am

Re: Raspberry Pi 3 stepper motor release

by adafruit_support_carter on Tue Jul 23, 2019 11:13 am

It looks like you are using an older library. See this guide for info on how to install and use the newer library:
https://learn.adafruit.com/adafruit-dc- ... g-software
and further on in the guide the stepper examples:
https://learn.adafruit.com/adafruit-dc- ... per-motors

adafruit_support_carter
 
Posts: 12977
Joined: Tue Nov 29, 2016 2:45 pm

Re: Raspberry Pi 3 stepper motor release

by Skydromer on Fri Jul 26, 2019 8:30 am

Thanks.

But i have 2 issues with this libaray:

1.There is just the function onestep(), so no modification of there rpm.

2.Just the microsteps and interleave let the motors work fluidly.


Nevertheless release is working XD

Skydromer
 
Posts: 23
Joined: Thu Jul 18, 2019 2:56 am

Re: Raspberry Pi 3 stepper motor release

by Skydromer on Mon Jul 29, 2019 5:56 am

Hm and somehow i can not use the serial controll anymore.


Code: Select all | TOGGLE FULL SIZE
from tkinter import *
from adafruit_motorkit import MotorKit
from picamera import PiCamera
from time import sleep
from pylibdmtx.pylibdmtx import decode
from PIL import Image
from tkinter import messagebox

import serial
import time
import os
import sys
import atexit
import RPi.GPIO as GPIO
#---------------------Variablen-------------------------------------------------------------------
go = 0                           
#---------------------GPIOs-----------------------------------------------------------------------   
tas_p1 = 31                 #GPIO 6
tas_px = 32                 #GPIO 12
tas_be = 29                 #GPIO 5
tas_st = 36                 #GPIO 16               
led_kamera = 12            #GPIO 18
endlage_unten = 15         #GPIO 22
endlage_oben = 18         #GPIO 24
GPIO.setup(tas_p1, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(tas_px, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(tas_be, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(tas_st, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.setup(led_kamera, GPIO.OUT)
GPIO.setup(endlage_oben, GPIO.IN)
GPIO.setup(endlage_unten, GPIO.IN)
#---------------------create a default object, no changes to I2C address or frequency-------------
kit = MotorKit()

print("START")
# Seriellen Port Konfigurieren:
ser = serial.Serial()
# Hier den passenden Port angeben
ser.port = '/dev/ttyS0'
ser.baudrate = 115200
#ser.timeout = 1
# Port öffnen
ser.open()
print("Port geöffnet")

try:
    while 1:
        # Zeile als Bytestring einlesen und
        # mit decode in normalen string konvertieren.
        string = ser.readline()
        print(string)
        try:
            string = string.decode()
            string = string[:len(string)-3]
            if string == "1":
                motor1_init()
            elif string == "2":
                nadelup()
            elif string == "3":
                nadeldown()
            elif string == "4":
                datamatrixscan()
            elif string == "5":
                move_right()
            elif string == "7":
                ser.write("got here\r".encode())
                auto()   
            elif string == "8":
                CancelProgram()
            else:
                ser.write("Falsche Eingabe".encode())
        except:
            print("Decodierungsfehler")
# Keyboard Interrupt abfangen, zum beenden mit [STRG]+[C].
except(KeyboardInterrupt, SystemExit):
    print("\nWird Beendet:")
    ser.close()
    print("Com Port geschlossen!")
    print("\nENDE")
#---------------------Drehtellermotor-Funktion----------------------------------------------------
def motor1_init():
    ser.write("Motoren Init!\r".encode())
    if GPIO.input(endlage_oben) == GPIO.HIGH:                                    # Drehteller dreht nur wenn Nadelkopf oben
        while GPIO.input(tas_p1) != GPIO.HIGH or GPIO.input(tas_px) != GPIO.LOW:
            kit.stepper1.onestep(direction=stepper.BACKWARD, style=stepper.INTERLEAVE)   
        while GPIO.input(tas_be) != GPIO.HIGH:
            kit.stepper1.onestep(direction=stepper.BACKWARD, style=stepper.INTERLEAVE)
        ser.write("Drehteller ist genullt!\r".encode())
        kit.stepper1.release()
    else:
        ser.write("Nadel hochfahren!\r".encode())


here is the code. the function move_right(): and others are jut slightly different than this motor1_init():
Do you people see what is wrong ?
Else i will use the old library.

Skydromer
 
Posts: 23
Joined: Thu Jul 18, 2019 2:56 am

Re: Raspberry Pi 3 stepper motor release

by adafruit_support_carter on Mon Jul 29, 2019 12:53 pm

I don't see your definition of move_right()?

This issue may be related to smooth motion issues with onestep():
https://github.com/adafruit/Adafruit_Ci ... /issues/18

adafruit_support_carter
 
Posts: 12977
Joined: Tue Nov 29, 2016 2:45 pm

Re: Raspberry Pi 3 stepper motor release

by Skydromer on Mon Jul 29, 2019 2:42 pm

i didnt copied move_right() and other defs in there because there are just slightly different in direction or style.
I will try to use time.sleep tomorrow.
But now my ser.readline dont run as it should be.

Skydromer
 
Posts: 23
Joined: Thu Jul 18, 2019 2:56 am

Re: Raspberry Pi 3 stepper motor release

by Skydromer on Tue Jul 30, 2019 1:19 am

sadly time.sleep wont help it just slowing down everything.

Skydromer
 
Posts: 23
Joined: Thu Jul 18, 2019 2:56 am

Re: Raspberry Pi 3 stepper motor release

by Skydromer on Tue Jul 30, 2019 1:40 am

Code: Select all | TOGGLE FULL SIZE
if GPIO.input(endlage_oben) == GPIO.HIGH:                                    # Drehteller dreht nur wenn Nadelkopf oben
   while GPIO.input(tas_p1) != GPIO.HIGH or GPIO.input(tas_px) != GPIO.LOW:
       kit.stepper1.onestep(direction=stepper.BACKWARD, style=stepper.INTERLEAVE)
       time.sleep(0.00038)
   while GPIO.input(tas_be) != GPIO.HIGH:
       kit.stepper1.onestep(direction=stepper.BACKWARD, style=stepper.INTERLEAVE)
       time.sleep(0.00038)
   kit.stepper1.release()
 else:
   print('')


he is running but dont follow those while loops. he wont backdown when the conditions are meet and is still running.

Skydromer
 
Posts: 23
Joined: Thu Jul 18, 2019 2:56 am

Re: Raspberry Pi 3 stepper motor release

by Skydromer on Tue Jul 30, 2019 5:50 am

Maybe it is because the motor kit library stes a GPIO mode and my pins are wrong but dont know where to get that GPIO mode.

Skydromer
 
Posts: 23
Joined: Thu Jul 18, 2019 2:56 am

Please be positive and constructive with your questions and comments.