Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

RE: MotorCape and BBBW w/ PWM and GPIO...
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

RE: MotorCape and BBBW w/ PWM and GPIO...

by silver2row on Fri Oct 12, 2018 11:02 pm

Hello,

Seth here. Here is some Python software in a Flask application and HTML code that promotes a bot to be controlled via online, web page.

For instance:

Code: Select all | TOGGLE FULL SIZE
#!/usr/bin/python

import Adafruit_BBIO.GPIO as GPIO
import Adafruit_BBIO.PWM as PWM
from flask import Flask, render_template                                       
import time

MotorOne = "P8_18"
MotorThree = "P8_14"

GPIO.setup("P8_18", GPIO.OUT)
GPIO.setup("P8_14, GPIO.OUT)

GPIO.output("P8_18, GPIO.LOW)
GPIO.output("P8_14, GPIO.LOW)

DirOne = "P9_16"
DirThree = "P8_13"

app = Flask(__name__)                                           

@app.route("/")                                                                 
@app.route("/<state>")

def updates(state=None):                                                   
    if state == "F":
        PWM.start(DirOne, 100)
        PWM.start(DirThree, 100)
        GPIO.output("P8_18", GPIO.HIGH)
        GPIO.output("P8_14", GPIO.HIGH)
      
    if state == "R":
        PWM.start(DirOne, 75)
        PWM.start(DirThree, 0)      
        GPIO.output("P8_18", GPIO.HIGH)
        GPIO.output("P8_14", GPIO.LOW)
      
    if state == "L":
        PWM.start(DirOne, 0)
        PWM.start(DirThree, 75)
        GPIO.output("P8_18", GPIO.LOW)
        GPIO.output("P8_14", GPIO.HIGH)
      
    if state == "S":
        PWM.start(DirOne, 0)
        PWM.start(DirThree, 0)
        GPIO.output("P8_18", GPIO.LOW)
        GPIO.output("P8_14", GPIO.LOW)
                 
    template_data = {                                                           
        "title" : state,                                                       
    }                                                                           
    return render_template("bobo.html", **template_data)

if __name__ == "__main__":                                                     
    app.run(host="0.0.0.0", port=5000, debug=True)


...

Code: Select all | TOGGLE FULL SIZE
<!DOCTYPE html>                                                           
    <head>                                                         
    <title>{{ status }}</title>                                                                     
    </head>                                     
    <body>                                                                 
    <div style="text-align:center">
    <h1>Done and Done Again!</h1>
        <h1>                                                                   
            <a href="/F" id="on" class="large_button">FORWARD</a>
        <br><br>
            <a href="/L" id="on" class="large_button">LEFT</a>       
            <a href="/R" id="on" class="large_button">RIGHT</a>
        <br><br>
            <a href="/S" id="off" class="large_button">STOP</a>         
        </h1>
    </div>                                                                   
    </body>                                                                     
</html>

...

I turn right, left, and go forward. Oh and I stop too, i.e. so I thought I could.

Seth

P.S. I think reverse is not a viable option so far for some reason. Am I incorrect?
Last edited by silver2row on Mon Oct 15, 2018 8:56 pm, edited 1 time in total.

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: MotorCape and BBBW w/ PWM and GPIO...

by silver2row on Sat Oct 13, 2018 12:17 am

Hello,

I added some REV if statement in that software example and then tried to move in reverse. I have been unsuccessful so far. I think that it is my fault. If anyone might know where I have taken an incorrect turn, please let me know.

Seth

P.S. This software is for the MotorCape from GHI Elect. for BeagleBoard.org people and enthusiasts.
Last edited by silver2row on Mon Oct 15, 2018 9:00 pm, edited 1 time in total.

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: MotorCape and BBBW w/ PWM and GPIO...

by silver2row on Sat Oct 13, 2018 5:07 pm

Hello Once More,

My addition is simple. I make the inverse function available by calling "1" instead of "0" for polarity in the REV or reverse, if statement at the end of that above Python software, e.g. just like the rest of the software if statements.

...

It will refuse to run all software for some reason. Now, I could just have a bum battery. I did test it and it is right below 12v. I am using a 12v Lead Acid battery w/ a BBBW and MotorCape for this example.

Seth

P.S. If you have words of enthusiasm or words of wisdom to share, please take into account that I need support. Share! I hope to hear from you soon.

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: MotorCape and BBBW w/ PWM and GPIO...

by drewfustini on Tue Oct 16, 2018 11:27 am

Is it possible for you to create a GitHub repository for your project and post the link here?

I think it would be easier to comment on code using the features available in GitHub like issues and pull requests.

drewfustini
 
Posts: 941
Joined: Sat Dec 26, 2015 1:19 pm

Re: RE: MotorCape and BBBW w/ PWM and GPIO...

by silver2row on Tue Oct 16, 2018 6:30 pm

Yes Sir,

Please look here: https://github.com/silver2row/motocape. I was trying to make a reverse in the software, e.g. just as w/ the "if" statement for forward but for reverse. Please view it if you can spare some time.

Seth

P.S. I am updating now to better suit my findings. The software now is a bit off since I ran it w/ another version.

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: MotorCape and BBBW w/ PWM and GPIO...

by silver2row on Tue Oct 16, 2018 6:37 pm

Hello Again Sir,

I am glad you replied. Is there an actual way to use PWM or GPIO in reverse, i.e. instead of 55, it would be negative 55 (-55)?

Seth

P.S. I think this is where I am coming up empty. My GPIO pins run the motors while the PWM pins tell my motors that they are started versus stopped.

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: MotorCape and BBBW w/ PWM and GPIO...

by drewfustini on Wed Oct 17, 2018 3:26 pm

Could you post a schematic and photo of how the project is wired up?

drewfustini
 
Posts: 941
Joined: Sat Dec 26, 2015 1:19 pm

Re: RE: MotorCape and BBBW w/ PWM and GPIO...

by silver2row on Wed Oct 17, 2018 9:03 pm

Hello,

Sure...please see it here: https://github.com/silver2row/motocape/ ... apeSCH.pdf.

The positive leads are at the MotorOne and MotorThree positive connections (screw terminals). The GNDs are in their respective place for those two motor numbers, i.e. One and Three.

...

The battery is positive to positive on the Cape screw terminal. GND is again regular. The GND from the battery goes to GND on the Cape.

Seth

P.S. I will do better w/ your idea on photos soon. I need to rearrange some items before taking the photos. Oh and the positive motor connections, soldered, from the motor is marked. It was easy to navigate on these specific motors. There was a red dot for positive.

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: MotorCape and BBBW w/ PWM and GPIO...

by silver2row on Fri Oct 19, 2018 2:13 pm

Hello Sir,

Seth here. I got the set up in photo form now. See below.

Seth

ForAdafruitIII.JPG
This is the battery and two motor set up from the MotorCape.
ForAdafruitIII.JPG (81.28 KiB) Viewed 369 times


...

The center leads are the battery connections. The MotorOne wires are to the right as the MotorThree leads are to the left. Um...I hope this is what you needed. Please let me know if you need anything else.

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: MotorCape and BBBW w/ PWM and GPIO...

by silver2row on Wed Oct 24, 2018 8:45 pm

Hello Sir,

Hello...I was mistaken on how the MotorCape functioned. The Cape works w/ GPIO setting direction and PWM sets the speed of a motor.

Seth
Last edited by silver2row on Thu Oct 25, 2018 12:02 am, edited 1 time in total.

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Re: RE: MotorCape and BBBW w/ PWM and GPIO...

by silver2row on Thu Oct 25, 2018 9:04 pm

Hello Once More,

I got some help from a person on Freenode at #beagle. This person typed up a Python class for me. Nice fellow! Anyway, I used it and everything works like a charm.

...

I am able to move backward. Furthermore, I have been able to move in back-left movements and vice versa w/ the back-right.

Seth

P.S. If you need updated software for the MotorCape, please ask. I can provide any other info. that you may need on this subject. Besides that first couple of panicky questions I had in this forum, thank you. See you later!

silver2row
 
Posts: 177
Joined: Sat Jan 30, 2016 3:42 pm

Please be positive and constructive with your questions and comments.