Basic Arni movement in motors.

master
Drew Bednar 5 years ago
parent 3a26cf4b16
commit 2f783bd8bb

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 KiB

@ -55,3 +55,26 @@ screen -r
```
To kill a screen session press `Ctrl-A` then `k`. You will be prompted to confirm with `y\n` whether to kill the session or not.
## Memory Usage
These two functions can help you determine approximate memory usage.
```
import gc
import os
def df():
s = os.statvfs('//')
return ('{0} MB'.format((s[0]*s[3])/1048576))
def free(full=False):
gc.collect()
F = gc.mem_free()
A = gc.mem_alloc()
T = F+A
P = '{0:.2f}%'.format(F/T*100)
if not full: return P
else : return ('Total:{0} Free:{1} ({2})'.format(T,F,P))
```

@ -11,3 +11,19 @@ on [PCA9685 with Micropython](https://learn.adafruit.com/micropython-hardware-pc
The git repo https://github.com/adafruit/micropython-adafruit-pca9685 is still up. Look at it's
[Docs](https://micropython-pca9685.readthedocs.io/en/latest/)
```
Description:
Brand: DSSERVO
Item: DS3218 20KG Digital Servo
Operating Voltage: 4.8 ~ 6.8 DC Volts
Torque: 18kg.cm(5V), 21.5kg.cm(6.8V)
Speed: 0.16sec/60°(5V), 0.14sec/60°(6.8V)
Dead Brand: 3μs
Motor Type: DC Motor
Gear Type: 25T Copper & Aluminum
Working Frequence: 50-333Hz
Totation: 180°(PWM 500-2500μs) / 270°(PWM 500-2500μs)
Weight: 60 g (2.12 oz)
Size: 40 x 20 x 40.5 mm ( 1.58 x 0.79 x 1.60 in)
```

@ -0,0 +1,156 @@
import machine
import servo
import time
i2c = machine.I2C(scl=machine.Pin(22), sda=machine.Pin(21))
# Tower pro MG90s
servos = servo.Servos(i2c, address=0x40, freq=50, min_us=600, max_us=2400, degrees=180)
INIT_POSITIONS = [
(0, 40),
(1, 90),
(2, 130),
(3, 90),
(4, 60),
(5, 90),
(6, 130),
(7, 90)
]
def init_legs():
for i, a, in INIT_POSITIONS:
servos.position(i, a)
def tip_forward(pause=1):
servos.position(7, 150)
servos.position(1, 30)
time.sleep(pause)
init_legs()
def tip_back(pause=1):
servos.position(3, 150)
servos.position(5, 30)
time.sleep(pause)
init_legs()
def lean_left(pause=1):
servos.position(7, 150)
servos.position(5, 30)
servos.position(3, 60)
servos.position(1, 120)
time.sleep(pause)
init_legs()
def lean_left(pause=1):
servos.position(7, 150)
servos.position(5, 30)
servos.position(3, 60)
servos.position(1, 120)
time.sleep(pause)
init_legs()
def lean_right(pause=1):
servos.position(7, 60)
servos.position(5, 120)
servos.position(3, 150)
servos.position(1, 30)
time.sleep(pause)
init_legs()
def look_left(pause=1):
servos.position(0, 10)
servos.position(2, 100)
servos.position(4, 30)
servos.position(6, 100)
time.sleep(pause)
init_legs()
def look_right(pause=1):
servos.position(0, 70)
servos.position(2, 160)
servos.position(4, 90)
servos.position(6, 160)
time.sleep(pause)
init_legs()
def all_move(pause=1):
moves = (tip_forward, tip_back, lean_left, lean_right, look_left, look_right, turn_left, turn_right, turn_right, turn_left)
for move in moves:
move(pause=pause)
time.sleep(0.5)
def turn_left(pause=None):
servos.position(0, 10)
servos.position(2, 100)
servos.position(4, 30)
servos.position(6, 100)
time.sleep(0.1)
servos.position(7, 120)
servos.position(6, 160)
time.sleep(0.1)
servos.position(7, 90)
time.sleep(0.1)
servos.position(3, 120)
servos.position(2, 160)
time.sleep(0.1)
servos.position(3, 90)
time.sleep(0.1)
servos.position(5, 30)
servos.position(4, 90)
time.sleep(0.1)
servos.position(5, 90)
time.sleep(0.1)
servos.position(1, 30)
servos.position(0, 90)
time.sleep(0.1)
servos.position(1, 90)
time.sleep(0.1)
init_legs()
def turn_right(pause=None):
servos.position(0, 70)
servos.position(2, 160)
servos.position(4, 90)
servos.position(6, 160)
time.sleep(0.1)
# front left
servos.position(1, 30)
servos.position(0, 10)
time.sleep(0.1)
servos.position(1, 90)
time.sleep(0.1)
# back right
servos.position(5, 30)
servos.position(4, 30)
time.sleep(0.1)
servos.position(5, 90)
time.sleep(0.1)
# front right
servos.position(7, 120)
servos.position(6, 60)
time.sleep(0.1)
servos.position(7, 90)
time.sleep(0.1)
# back left
servos.position(3, 120)
servos.position(2, 60)
time.sleep(0.1)
servos.position(3, 90)
time.sleep(0.1)
init_legs()
init_legs()
Loading…
Cancel
Save