RE: LoadCape and Python w/ Adafruit_BBIO/BBB

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
silver2row
 
Posts: 180
Joined: Sat Jan 30, 2016 3:42 pm

RE: LoadCape and Python w/ Adafruit_BBIO/BBB

Post by silver2row »

Hello,

My name is Seth. I am currently looking to make the LoadCape handle some motors. I have a set of instructions for my BBB in Python. I have been unable to think of any routes to take to make this happen simultaneously w/ both motors.

I have some classes, some functions, and I imported Adafruit_BBIO.GPIO as GPIO and time for use w/ time.sleep.

...

If you want the software, I will provide it. I know I am missing something w/ the first class and how the LoadCape actually works.

...

Sink1 is P9_42 and Sink2 is P9_41 on the BBB. For instance...I would hook up my GNDs to those pins from my motors.

Oh and the two positive leads from the motors go into the VIN along w/ the Positive Lead from the battery on the Cape. The negative lead from the battery goes into the GND screw terminal on the Cape.

Seth

P.S. If you need any photos or schematics, please let me know. I repeat, I can relay the software in case it is my fault and not something outside of my fault. I know it is most likely my issue w/ the Cape. Anyway, if you are using the LoadCape and have time, please reply.

User avatar
drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: RE: LoadCape and Python w/ Adafruit_BBIO/BBB

Post by drewfustini »

Please provide the source code you are attempting to run and the exact errors or warnings that you encounter.

User avatar
silver2row
 
Posts: 180
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: LoadCape and Python w/ Adafruit_BBIO/BBB

Post by silver2row »

Hello,

I am not receiving any errors, actually. The software just does not run as expected but here is the software.

Code: Select all

import Adafruit_BBIO.GPIO as GPIO
import time

# from help on the googlegroups section of bbb.io, i.e. circa 2016...2017.

m1 = "P9_42"
m2 = "P9_41"

class LeftMotor(object):

     def __init__(self, m1):
         self.m1 = m1
         GPIO.setup(self.m1, GPIO.OUT)
         self.stop()

     def stop(self):
         GPIO.output(self.m1, GPIO.LOW)

     def forward(self):
         GPIO.output(self.m1, GPIO.HIGH)

     def reverse(self):
         GPIO.output(self.m1, GPIO.HIGH)

class RightMotor(object):

    def __init__(self, m2):
        self.m2 = m2
        GPIO.setup(self.m2, GPIO.OUT)
        self.stop()

    def stop(self):
        GPIO.output(self.m2, GPIO.LOW)

    def forward(self):
        GPIO.output(self.m2, GPIO.HIGH)

    def reverse(self):
        GPIO.output(self.m2, GPIO.HIGH)

class LeftWheel(object):
    def __init__(self, LeftMotor):
        self.LeftMotor = LeftMotor
        self.stop()

    def stop(self, go=5):
        self.LeftMotor.stop()
        time.sleep(1)

    def forward(self, go=5):
        self.LeftMotor.forward()
        time.sleep(1)

    def reverse(self, go=5):
        self.LeftMotor.reverse()
        time.sleep(1)

    def leftTurnForward(self, go=5):
        self.leftMotor.stop()
        time.sleep(1)

    def rightTurnForward(self, go=5):
        self.LeftMotor.forward()
        time.sleep(1)

    def leftTurnReverse(self, go=5):
        self.LeftMotor.stop()
        time.sleep(1)

    def rightTurnReverse(self, go=5):
        self.LeftMotor.reverse()
        time.sleep(1)

    def leftPivot(self, go=5):
        self.LeftMotor.reverse()
        time.sleep(1)

    def rightPivot(self, go=5):
        self.LeftMotor.forward()
        time.sleep(1)

class RightWheel(object):

    def __init__(self, RightMotor):
        self.RightMotor = RightMotor
        self.stop()

    def stop(self, go=5):
        self.RightMotor.stop()
        time.sleep(1)

    def forward(self, go=5):
        self.RightMotor.forward()
        time.sleep(1)

    def reverse(self, go=5):
        self.RightMotor.reverse()
        time.sleep(1)

    def leftTurnForward(self, go=5):
        self.RightMotor.forward()
        time.sleep(1)

    def rightTurnForward(self, go=5):
        self.RightMotor.stop()
        time.sleep(1)

    def leftTurnReverse(self, go=5):
        self.RightMotor.reverse()
        time.sleep(1)

    def rightTurnReverse(self, go=5):
        self.RightMotor.stop()
        time.sleep(1)

    def leftPivot(self, go=5):
        self.RightMotor.forward()
        time.sleep(1)

    def rightPivot(self, go=5):
        self.RightMotor.reverse()
        time.sleep(1)

Left = LeftWheel(LeftMotor=LeftMotor(m1="P9_42"))

Right = RightWheel(RightMotor=RightMotor(m2="P9_41"))

Left.forward(5)
Right.forward(5)

Left.stop(5)
Right.stop(5)

Left.rightPivot(5)
Right.rightPivot(5)

Left.stop()
Right.stop()

GPIO.cleanup()
...

I thought this would make my motors run simultaneously but I have been unable to make the class and functions be understood to the LoadCape and BBB for the motors to move correctly.

If you or anyone else is working on a project w/ two motors and the LoadCape, please do reply w/ some type of info.

Seth

P.S. If it is me and my software that I have altered from googlegroups from bbb.io/forums, then I understand if no help is available.

User avatar
drewfustini
 
Posts: 944
Joined: Sat Dec 26, 2015 1:19 pm

Re: RE: LoadCape and Python w/ Adafruit_BBIO/BBB

Post by drewfustini »

silver2row wrote: I thought this would make my motors run simultaneously but I have been unable to make the class and functions be understood to the LoadCape and BBB for the motors to move correctly.
You mention the motors to do not run simultaneously.

Do the motors run only one at a time?

User avatar
silver2row
 
Posts: 180
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: LoadCape and Python w/ Adafruit_BBIO/BBB

Post by silver2row »

Yes Sir,

Seth here. The motors are seconds apart for some reason. I have been unable to conclude on "why" so far.

Seth

P.S. So, the MotorOne runs and then seconds later, the MotorTwo runs.

User avatar
silver2row
 
Posts: 180
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: LoadCape and Python w/ Adafruit_BBIO/BBB

Post by silver2row »

Hello Again Sir,

Seth here. Um, look here: https://github.com/silver2row/loadcape. I am about to add some software that you may be interested in.

Seth

P.S. I am going to add a new bunch of software in the form SinkerOneII.py and UseSinkerOneII.py. If it is interesting, please let me know. Okay...I am at a stopping point right now. I am receiving no Python errors any longer but I am having userspace timeouts. These "timeouts" consist of the terminal not doing anything while the software runs. But...the motor does move forward on command when running the software. The terminal just runs and does nothing after the software "finishes." Yikes! I know. If you have any ideas, reply if you can find time.

User avatar
silver2row
 
Posts: 180
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: LoadCape and Python w/ Adafruit_BBIO/BBB

Post by silver2row »

Hello Sir,

Before the Holiday (Christmas), I just wanted to let you know that I have given up, for now, on making GPIO turn in reverse w/ wrappers or in another method.

Seth

P.S. I will just postpone this until later. Sorry to harass you before Christmas.

Locked
Please be positive and constructive with your questions and comments.

Return to “Beagle Bone & Adafruit Beagle Bone products”