Main Site Documentation

RE: MotorCape and Making Motors Move


#21

Mr. Brett,

No issue. Please hold. I will reply and post some software.

Seth

P.S. I even got an extra software example from a person that seems to know more than me.


#22

Hello Sir,

Mr. Brett, here is some software w/ ideas as how I think things should go. It is lit for 10 seconds w/ the else clause and then finally to 25% brightness at the end of the else clause.

Here it is. Oh and I will make another post of what the other fellow told me to do in regards to Python and software for this MotorCape.

import Adafruit_BBIO.PWM as PWM
import Adafruit_BBIO.GPIO as GPIO
import time

MotorOne = "P8_18"
LEDs = "P9_16"

while True:
    #arbitrary if statement.
    if 75.0 == (100.0 - 33.3):
        PWM.set_duty_cycle("P9_16", 15.5)
        time.sleep(8)
        print "Um...I think this may be it!"
    #this is what runs and should run a motor w/ the LEDs lit.
    else:
        GPIO.setup("P8_18", GPIO.OUT)
        GPIO.output("P8_18", GPIO.LOW)
        PWM.start("P9_16", 100)
        time.sleep(10)
        print "Ya, ya!"
        PWM.start("P9_16", 25)
        time.sleep(10)
        print "That was it!"

“Ya, ya!” and “That was it!” prints fine and each line runs for 10 seconds.

Seth


#23

Hello Sir,

Mr. Brett, for line 15 of the software, at the line where it states GPIO.output(“P8_18”, GPIO.LOW), I have set it to GPIO.HIGH too.

import Adafruit_BBIO.GPIO as GPIO
import Adafruit_BBIO.PWM as PWM
import time

# definitions

m1_pwm = "P9_16"
m1_dir = "P8_18"
m2_pwm = "P9_14"
m2_dir = "P8_16"
m3_pwm = "P8_13"
m3_dir = "P8_14"
m4_pwm = "P8_19"
m4_dir = "P8_26"

pwm_freq = 2000

# initialization

GPIO.setup( m1_dir, GPIO.OUT )
GPIO.setup( m2_dir, GPIO.OUT )
GPIO.setup( m3_dir, GPIO.OUT )
GPIO.setup( m4_dir, GPIO.OUT )

PWM.start( m1_pwm, 0, pwm_freq )
PWM.start( m2_pwm, 0, pwm_freq )
PWM.start( m3_pwm, 0, pwm_freq )
PWM.start( m4_pwm, 0, pwm_freq )


# tests

GPIO.output( m1_dir, GPIO.LOW )  # m1 forward direction
time.sleep(10)
PWM.set_duty_cycle( m1_pwm, 100 )  # m1 full speed
time.sleep(10)
PWM.set_duty_cycle( m1_pwm,  50 )  # m1 half speed
time.sleep(10)
PWM.set_duty_cycle( m1_pwm,   0 )  # m1 stop
time.sleep(10)

GPIO.output( m1_dir, GPIO.HIGH )  # m1 reverse direction
time.sleep(10)
PWM.set_duty_cycle( m1_pwm, 100 )  # m1 full speed
time.sleep(10)
PWM.set_duty_cycle( m1_pwm,  50 )  # m1 half speed
time.sleep(10)
PWM.set_duty_cycle( m1_pwm,   0 )  # m1 stop
time.sleep(10)

This software is what someone gave to me from #beagle on Freenode. The bbb.io people have a chat set up for people testing their products.

So, I tested the line at the motor terminal from the connection on the MotorCape. It showed flat 0.0v. Also, w/ the L298 drivers, there is supposed to be a call low on GPIO, then a call High on GPIO, and then finally driving the motors should just work. I have noticed b/c of the set up of these Capes, the L298 does not need three pins/three leads to drive the motor forward, reverse, and on/off. I think this is a EEPROM/i2c effect.

Seth

P.S. If you have any other ideas, please contact me again.


#24

ok

Here’s some ideas. First up your logic is um strange :slight_smile: There’s no need to have the IF statement, it’s always false. Second, you define objects for your selected pins, then hard code them. Next, you should do your “configuration” steps outside the loop that runs forever.

I’m no Python programmer and have never even played on on TV, so syntax is possibly way off. Hopefully you get the idea.

import Adafruit_BBIO.PWM as PWM
import Adafruit_BBIO.GPIO as GPIO
import time

MotorOneDirection = “P8_18”
MotorOneEnable = “P9_16”
MotorDirection = GPIO.LOW

GPIO.setup(MotorOneDirection, GPIO.OUT)
GPIO.output(“P8_18”, MotorDirection)
StartPoint = 100

while True:
PWM.start(MotorOneEnable, StartPoint)
print "On: " + Str(StartPoint)
time.sleep(15)
StartPoint -= 20
if (StartPoint < 0):
StartPoint = 100


#25

Right, so the BBB code should be good - someone with that cape should have confirmed that it works (Which is more than I or others here are able to). Seems to me that the first code (and my modified code) may not work because it doesn’t set the PWM signals right, but either way it should be easy enough to use the second example code in your definitions/setup.

You say you read 0.0v. Where is that referenced to? From a measurement perspective you should measure from the battery GND terminal and you should measure back to both the + and - terminals of the motor connection (because technically the “+” terminal can become grounded when the motor direction is reversed, and the “-” can be positive)

You have a battery charger for your SLA battery, yeah? Have you thought about using it as the power source? What are the specs on it?

You haven’t told us about the motors you have either, it’s possible they’re just not suitable. Are they ones you’ve used on your previous L298 work?


#26

How are you powering up your board? For safer measure, the motor cape needs the beaglebone to be powered using a power source, 5V power for example. You still need the “motor power”, which can be the same power source is that is sufficient for your motors.


#27

Hello Sir(s),

To Gus: Seth here. The battery supply is a 12v 3.3Ah AGM battery. I have the BBBW plugged in via USB for testing purposes. The motor power is derived from the battery, i.e. 12v.

To Brett: Seth here again. Sir, I am going to reapply the wiring to the motors but when I attempt to test the terminals at where the wires meet the motor, I receive a flat, 0.0v from a multimeter. I have the SLA battery out now. It is a 12v 5Ah battery. I can use it.

So…

The SLA 12v reads from the multimeter 12.12v. I will test it and make my reply in another post. Oh and I will test MotorOne, MotorTwo, MotorThree, and MotorFour connections directly from the Cape w/ the multimeter.

For reference: Yes. The motor has been used before and to my knowledge still works fine. Also, I do not have a battery charger for my SLA battery. I will invest in one soon. And yes, I have thought about using it as a power source. I have a cheap bench supply I can use but the directions on that sucker were a bit off to me.

I am tracking down who made it so I can get a new schematic and instruction manual.

Forget that last bunch of jumble. So, I reconnected the power supply from the battery to the Cape. Maybe it was that simple. If you need me to change power supplies, I can and I will.

Seth

P.S. Battery ideas: Permanent Magnet DC Geared Motor by Dayton. 12v DC motor. Ratio: 45:1.

I tested each motor connection from the connections. None of them are working or they are labeled incorrectly. If they are labeled incorrectly, maybe the Power Supply and GND labels are mislabeled, too.


#28

You need 5V power in the barrel jack.


#29

Hello Sir,

So…w/ this specific Cape, I need to apply 5v via the barrel jack instead of using the 5v input from USB. Got it. I will test it. Be right back.

Seth


#30

Sir,

Please forgive me. vdd_5v and not sys_5v was the option made on this Cape.

Seth

P.S. The Cape, this MotorCape, works just fine. I am very sorry to harass everyone w/ all this questions and concerns.


#31

so does this mean you now have it completely working, everything we have done now works as you’d expect it to? If so, that’s great news.


#32

Yes Sir,

One .service file, a chmod cmd, and a barrel jack did it!

Seth

P.S. I will not harass you and your company again over my miscalculations on power supply. This is really my fault for observing info. w/out fully reviewing it.


#33

this is a community, and you’re always welcome. We all have diverse backgrounds, and knowledge, so it’s fine asking us questions about things… as you saw, we’re all willing to help you even if we don’t know what we are talking about :slight_smile:


#34

Glad it is working for you. Share some pictures when you build your project.


#35

Hello Mr. Gus,

Yes sir…I will post again once things are completed.

Seth


#36

Hello Once More Gus or More Times B/c Projects are Cool,

Sir, look here: https://github.com/silver2row/motocape. That is my handle at GitHub w/ the MotorCape addition w/ software. I have a chassis but it is far from ready for a real engine w/ these motor controls.

Seth

P.S. If you want to see my “little bit,” look here: https://youtu.be/0W2CNGT-C2o. It is an older prototype w/ the BBG (BeagleBone Green) and the MotorBridge Cape from Seeed Studio. Anyway, things are changing. Thank you for your support.