Hello Sir,

Mr. Dennis...Seth here. Um, I am attaching the pins on P4 on the L298 Board 
to En A (2) to P9_21 and En B (8) to P9_22 as GPIOs. I am attempting this 
right now. So, I could not get your software to run. I tried this instead 
(so far).

import Adafruit_BBIO.GPIO as GPIO
import time

GPIO.setup("P9_21", GPIO.OUT)
GPIO.setup("P9_22", GPIO.OUT)

GPIO.output("P9_21", GPIO.HIGH)
GPIO.output("P9_22", GPIO.HIGH)

p1 = "P9_21"
p2 = "P9_22"

class BrushedDC(object):
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2
        GPIO.setup(self.p1, GPIO.OUT)
        GPIO.setup(self.p2, GPIO.OUT)
        time.sleep(21)
    def stop(self):
        GPIO.output(self.p1, GPIO.LOW)
        GPIO.output(self.p2, GPIO.LOW)
    def forward(self):
        time.sleep(21)     #safety to avoid shock of reversals
        GPIO.output(self.p1, GPIO.HIGH)
        GPIO.output(self.p2, GPIO.LOW)
    def reverse(self):
        self.time.sleep(21)
        GPIO.output(self.p1, GPIO.LOW)
        GPIO.output(self.p2, GPIO.HIGH)

class Car(object):
    def __init__(self, leftMotor, rightMotor):
        self.leftMotor = leftMotor
        self.rightMotor = rightMotor
        time.sleep(21)
    def stop(self, wait=0):
        self.leftMotor.stop()
        self.rightMotor.stop()
        time.sleep(wait)
    def forward(self, wait=0):
        self.leftMotor.forward()
        self.rightMotor.forward()
        time.sleep(wait)
    def reverse(self, wait=0):
        self.leftMotor.reverse()
        self.rightMotor.reverse()
        time.sleep(wait)
    def leftTurnForward(self, wait=0):
        self.leftMotor.stop()
        self.rightMotor.forward()
        time.sleep(wait)
    def rightTurnForward(self, wait=0):
        self.leftMotor.forward()
        self.rightMotor.stop()
        time.sleep(wait)
    def leftTurnReverse(self, wait=0):
        self.leftMotor.stop()
        self.rightMotor.reverse()
        time.sleep(wait)
    def rightTurnReverse(self, wait=0):
        self.leftMotor.reverse()
        self.rightMotor.stop()
        time.sleep(wait)
    def leftPivot(self, wait=0):
        self.leftMotor.reverse()
        self.rightMotor.forward()
        time.sleep(wait)
    def rightPivot(self, wait=0):
        self.leftMotor.forward()
        self.rightMotor.reverse()
        time.sleep(wait)

#GPIO.cleanup()


So...

This software runs and is done w/ a ms of time but it performs no actions 
just like my last software. 

...

I did remove the P9.12 and P9.15 leads from the Pins on the BBB to the L298 
Board. So, I am attached to En A to P9.21 and En B to P9.22.

Seth

P.S. I will keep plugging at it. I know I changed up your software a lot or 
a little but I was receiving too many errors and I wanted to move on. If 
you have any recommendations so far as to what may drive these motors on 
the L298 Board, please do not hesitate to reply. Thank you again, sir. 

On Thursday, May 3, 2018 at 10:15:12 AM UTC-5, Dennis Lee Bieber wrote:
>
> On Wed, 2 May 2018 21:51:08 -0700 (PDT), Mala Dies 
> <[email protected] <javascript:>> declaimed the following: 
>
> >import Adafruit_BBIO.GPIO as GPIO 
> >import time 
> > 
> >GPIO.setup("P9_21", GPIO.OUT) 
> >GPIO.setup("P9_22", GPIO.OUT) 
> >GPIO.setup("P9_12", GPIO.OUT) 
> >GPIO.setup("P9_15", GPIO.OUT) 
> > 
> >m1a = GPIO.output("P9_21", GPIO.HIGH) 
> >m1a = GPIO.output("P9_22", GPIO.HIGH) 
>
>         Meaningless assignments... First, the return from the second line 
> replaces the value returned by the first line, since you used the same 
> name 
> for the return. 
>
>         On the other hand -- based upon the documentation for the library, 
> GPIO.output() doesn't return anything so you are just replacing None with 
> None. 
>
> >m1b = GPIO.output("P9_12", GPIO.HIGH) 
> >m1b = GPIO.output("P9_15", GPIO.HIGH) 
> > 
>         Ditto 
>
>         You've set all control pins high -- which should, for any motor 
> controller I can envision, mean the motors are not powered (BTW -- you did 
> wire the ENABLE A and B pins to something, didn't you? 
>
> >while (True): 
> > 
> >        try: 
> >                for motor in range (0, 101, 1): #starts at 0, steps up to 
> >101 in 1 steps 
> >                    m1a = ("P9_21") 
>
>         Here you assign a string to the name, but you never do anything 
> with 
> the string. So... again a meaningless assignment. 
>
> >                    time.sleep(3) 
> >                    print(motor) 
>
>         And you never do anything with the motor pin itself, so nothing 
> changes. 
>
>         This loop condenses down to just printing integers from 0..100 
> with a 3 
> second pause between them, and it does all of them before moving to the 
> next loop, which does the very same thing. 
>
> >                for motor in range (0, 101, 1): 
> >                    m1a = ("P9_22") 
> >                    time.sleep(3) 
> >                    print(motor) 
> >                for motor in range (100, -1, -1): 
> >                    m1b = ("P9_12") 
> >                    time.sleep(3) 
> >                    print(motor) 
> >                for motor in range (100, -1, -1): 
> >                    m1b = ("P9_15") 
> >                    time.sleep(3) 
> >                    print(motor) 
> > 
>
>         What behavior are you expecting since the above four loops are 
> coded to 
> run on after the other -- nothing is being done in parallel even if you 
> were changing motor pin settings. 
>
> >        except(KeyboardInterrupt): 
> > 
> >                #And final cleanup 
> >                print "You have just ended your camp trip!" 
> >                GPIO.cleanup() 
> >                quit() 
>
>         Your "final cleanup" will only be performed IF you hit <ctrl-c> 
> BEFORE 
> the loops run out. Otherwise, you just fall off the end of the program 
> with 
> no cleanup performed 
>
>
>         My suggestion -- since you are using Python... 
>
>         Open a shell and run Python in interactive mode, and then enter 
> GPIO 
> statements one at a time setting pins to HIGH and LOW, in various 
> combinations, to see what it takes to activate the motors. 
>
>
>         And, just for a giggle (untested as I don't have your hardware 
> present) 
>
> -=-=-=-=- 
> """ 
>     Pseudo-code for fictitious robot-car with two driving wheels, using 
>     brushed DC motors; I do not have the driver board or motors so this 
>     is just text of what I believe would be needed 
>
>     NOTE: THIS IS PYTHON 2.7 SYNTAX; modify as needed for 3.x 
> """ 
>
> import time 
> import Adafruit_BBIO.GPIO as GPIO 
>
> class BrushedDC(object): 
>     def __init__(self, p1, p2): 
>         self.p1 = p1 
>         self.p2 = p2 
>         GPIO.setup(self.p1, GPIO.OUT) 
>         GPIO.setup(self.p2, GPIO.OUT) 
>         self.stop() 
>     def stop(self): 
>         GPIO.output(self.p1, GPIO.LOW) 
>         GPIO.output(self.p2, GPIO.LOW) 
>     def forward(self): 
>         self.stop()     #safety to avoid shock of reversals 
>         GPIO.output(self.p1, GPIO.HIGH) 
>         GPIO.output(self.p2, GPIO.LOW) 
>     def reverse(self): 
>         self.stop() 
>         GPIO.output(self.p1, GPIO.LOW) 
>         GPIO.output(self.p2, GPIO.HIGH) 
>
> class Car(object): 
>     def __init__(self, leftMotor, rightMotor): 
>         self.leftMotor = leftMotor 
>         self.rightMotor = rightMotor 
>         self.stop() 
>     def stop(self, wait=0): 
>         self.leftMotor.stop() 
>         self.rightMotor.stop() 
>         time.sleep(wait) 
>     def forward(self, wait=0): 
>         self.leftMotor.forward() 
>         self.rightMotor.forward() 
>         time.sleep(wait) 
>     def reverse(self, wait=0): 
>         self.leftMotor.reverse() 
>         self.rightMotor.reverse() 
>         time.sleep(wait) 
>     def leftTurnForward(self, wait=0): 
>         self.leftMotor.stop() 
>         self.rightMotor.forward() 
>         time.sleep(wait) 
>     def rightTurnForward(self, wait=0): 
>         self.leftMotor.forward() 
>         self.rightMotor.stop() 
>         time.sleep(wait) 
>     def leftTurnReverse(self, wait=0): 
>         self.leftMotor.stop() 
>         self.rightMotor.reverse() 
>         time.sleep(wait) 
>     def rightTurnReverse(self, wait=0): 
>         self.leftMotor.reverse() 
>         self.rightMotor.stop() 
>         time.sleep(wait) 
>     def leftPivot(self, wait=0): 
>         self.leftMotor.reverse() 
>         self.rightMotor.forward() 
>         time.sleep(wait) 
>     def rightPivot(self, wait=0): 
>         self.leftMotor.forward() 
>         self.rightMotor.reverse() 
>         time.sleep(wait) 
>
>
> myCar = Car(leftMotor=BrushedDC(p1="P9_21", p2="P9_22"), 
>             rightMotor=BrushedDC(p1="P9_12", p2="P9_15")) 
>
> myCar.forward(10) 
> myCar.leftPivot(3) 
> myCar.forward(5) 
> myCar.rightTurnReverse(3) 
> myCar.reverse(10) 
> myCar.stop(10) 
> myCar.rightPivot(30) 
> myCar.forward(5) 
> myCar.rightTurnForward(15) 
> myCar.stop() 
>
> GPIO.cleanup() 
>
> -=-=-=-=-=- 
>
>
>
> -- 
>         Wulfraed                 Dennis Lee Bieber         AF6VN 
>         [email protected] <javascript:>    
> HTTP://wlfraed.home.netcom.com/ 
>
>

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/beagleboard/c0f6ebdd-477c-42d6-b6e9-9af2547a9434%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to