Jump to content

Banner.jpg.b89429c566825f6ab32bcafbada449c9.jpg

Juju

New Members
  • Posts

    3
  • Joined

  • Last visited

Reputation

0 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. I am a complete beginner in python, to further learn on the style of coding you mentioned i would just need to research active loops? and thank you for explaining the calculation
  2. Thank you all for replying to my question I appreciate the time taken to reply.
  3. As this is my first post I'm not sure how exactly to word this. I started a project where i am trying to create a DIY RA Drive instead of buying a commercial one, I have successfully created a bracket and my wiring is all completed and works fine, however this may seem ridicule but I don't know how to match the rotation of the stepper to the earths rotation, in other words I am not sure on how to calculate the delay in which I need to send a signal for pulses. Below is the code i am using. i have up to 32 micro steps and am using python on a raspberry pi 3+. I have seen many people complete this project but all guides have been using Arduinos. Below is my code, could someone be so kind as to explain how i would go about the above problem? many thanks As said above the code and hardware works fine it is just the steps and how to match earths rotation i do not understand. from time import sleep import RPi.GPIO as GPIO from tkinter import * from tkinter import messagebox # PUL = 17 # Stepper Drive Pulses DIR = 27 # Controller Direction Bit (High for Controller default / LOW to Force a Direction Change). ENA = 22 # Controller Enable Bit (High to Enable / LOW to Disable). channel = 2 #Relay GPIO is set as channel GPIO.setmode(GPIO.BCM) # GPIO.setup(PUL, GPIO.OUT) GPIO.setup(DIR, GPIO.OUT) GPIO.setup(ENA, GPIO.OUT) GPIO.setup(channel, GPIO.OUT) #Relay GPIO Set up durationFwd = 1000 delay = 0.05 # This is actualy a delay between PUL pulses - effectively sets the mtor rotation speed. print('Speed set to ' + str(delay)) def Relay_on(): GPIO.output(2, GPIO.LOW) # Turn motor on def Relay_off(): GPIO.output(2, GPIO.HIGH) # Turn motor off def Exit(): GPIO.cleanup() exit() def forward(): GPIO.output(ENA, GPIO.HIGH) print('ENA set to HIGH - Controller Enabled') # sleep(.1) # pause due to a possible change direction GPIO.output(DIR, GPIO.LOW) print('DIR set to LOW - Moving Forward at ' + str(delay)) print('Controller PUL being driven.') for x in range(durationFwd): GPIO.output(PUL, GPIO.HIGH) sleep(delay) GPIO.output(PUL, GPIO.LOW) sleep(delay) GPIO.output(ENA, GPIO.LOW) return tk = Tk() tk.geometry("400x300") b1 = Button(tk, text="Relay On", command=Relay_on).place(x=100, y=50) b2 = Button(tk, text="Relay Off", command=Relay_off).place(x=100, y=100) b3 = Button(tk, text="Exit", command=Exit).place(x=100, y=200) b4 = Button(tk, text="Forward", command=forward).place(x=100, y=150) tk.mainloop() GPIO.cleanup() #
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.