Files
darkwater_docs/640.md
2016-09-24 22:42:21 +01:00

3.0 KiB

Introduction

The 640 board is used to drive up to 6 DC motors and 2 Servo motors.

Getting started

Board layout

Setup

Attaching the power

Attaching a Servo

Attaching a motor

Attaching an RC receiver

Programming the 640

Python

Introduction

The Python libraries for the 640 board and some example scripts are available via our GitHub repository. To install them open a terminal window on your Raspberry Pi (unless you are running with only the command line) and enter the following:

$ git clone https://github.com/darkwaterfoundation/darkwater_python_640.git

Example scripts

Now that you have downloaded the 640 libraries you should have a new directory called *darkwater_python_640, so let's move into that directory

$ cd ./darkwater_python_640

If you list the files in this directory, you should see a few test scripts

$ ls -al

640motortest.py

This script will start each motor port, in the forwards direction, in turn from left to right and then do the same backwards. To run the script enter the following:

$ python 640motortest.py

640servotest.py

This script will move any servos connected to the servo headers left, then center, then right. To run the script enter the following:

$ python 640servotest.py

640steppertest.py

This script divides the 6 motor ports into 3 stepper motor ports. Motor 1 and 2 will be stepper 1, motor 3 and 4 will be stepper 2 and motor 5 and 6 will be stepper 3.

Each stepper will be moved forwards and backwards through 200 steps when the test script is run:

$ python 640steppertest.py

The 640 board API

Now you know everything works, it's time to write your own scripts. So create a new python script in your editor, within the darkwater_python_640 directory with a memorable name and add the following lines to import our libraries:

import time
from darkwater_640.darkwater_640 import dw_Controller, dw_Motor, dw_Servo

Create a controller

The dw_controller object controls access to all the elements on the 640 board, so the first thing we need to do is create a controller - we pass in the address of the 640 board as a parameter - the default address is 0x60

dw = dw_Controller( addr=0x60 )

Now that we have the controller created, we can access all the connectors on the board.

Select a Motor

There are 6 motor ports on the 640 board numbered 1 to 6 from left to right (with the ports facing you ).

If we want to control a motor on port number 1 then we need to request the motor object for that port from our controller - this is very easily done with a single line

m1 = dw.getMotor(1)

Motor driving

Select a Servo

Servo control

Node.JS

Introduction

Import libraries

Drive a motor

Motor speed

Servo control

C++

Introduction

Install prerequisites

Drive a motor

Motor speed

Servo control

PPM integration

Expanding the board

Adding an expansion board