Python Forum
Robotic arm using raspberry pi 4
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Robotic arm using raspberry pi 4
#1
Question 
Hey guys,

My name is Cesar Chavez I am a student at Bakersfield College. I am in my last year of the program (Industrial Automation) and I was assigned to a very cool project. Basically, programming a tank robot that has a arm built on arm. I was able to program the robot to move in all directions using bluedot library and I found a simple code for the arm. The problem I have is that the arm is not functioning properly. It uses servo motors with 3 wires (brown orange and yellow) powered by raspberry pi 4. It has an elbow, wrist, and gripper. The issue, when the function for the elbow sleeps for 2 seconds, the servo de-energizes and the elbow goes down. It wont hold its position. The same thing happens with the wrist. When the function for the wrist is over and sleeps for 2 seconds the wrist goes down and doesn't hold its position. I super new to python and coding so I have tried a few things like removing sleeping time but it didn't work, I tried adding GPIO.output(11, True) right after sleep(2) but it doesn't work. Any help would be much appreciated. This is the code I have for the arm:

import RPi.GPIO as GPIO
from time import sleeppython


#funtion to control elbow
def SetElbowAngle(angle):
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(11,GPIO.OUT)
        pwm=GPIO.PWM(11,50)
        pwm.start(0)
        
        duty = angle / 18 + 2
        
        GPIO.output(11, True)
        pwm.ChangeDutyCycle(duty)
        sleep(2)
        GPIO.output(11, True)
        pwm.ChangeDutyCycle(0)
        
def SetWristAngle(angle):
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(7,GPIO.OUT)
        pwm=GPIO.PWM(7,50)
        pwm.start(0)
        duty = angle / 18 + 2
        GPIO.output(7, True)
        pwm.ChangeDutyCycle(duty)
        sleep(2)
        GPIO.output(7, True)
        pwm.ChangeDutyCycle(0)
        
        
#funtion to control gripper
def SetGripperAngle(angle):
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(3,GPIO.OUT)
    pwm=GPIO.PWM(3,50)
    pwm.start(0)
    
    duty = angle / 18 + 2
    
    GPIO.output(3, True)
    pwm.ChangeDutyCycle(duty)
    sleep(2)
    GPIO.output(3, False)
    pwm.ChangeDutyCycle(0)
    
#move to starting position
SetElbowAngle(130)
SetWristAngle(70)
SetGripperAngle(0)

#pick the object
SetElbowAngle(110)
SetGripperAngle(0)
SetGripperAngle(130)

#move back
SetElbowAngle(150)
SetWristAngle(50)

#drop the object

SetGripperAngle(130)
SetGripperAngle(0)

pwm.stop()
GPIO.cleanup()
GPIO.setwarnings(False)
Thank you in advanced !!! Heart
Larz60+ write Nov-12-2021, 10:07 AM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode tags on future posts.
Reply


Messages In This Thread
Robotic arm using raspberry pi 4 - by C3sarC - Nov-12-2021, 01:58 AM
RE: Robotic arm using raspberry pi 4 - by Larz60+ - Nov-12-2021, 10:18 AM
RE: Robotic arm using raspberry pi 4 - by C3sarC - Nov-13-2021, 12:24 AM
RE: Robotic arm using raspberry pi 4 - by Larz60+ - Nov-13-2021, 12:56 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020