new esacpe
This commit is contained in:
142
640.md
142
640.md
@@ -130,7 +130,7 @@ If you are only using the command line on your Raspberry Pi then you will need t
|
||||
|
||||
Type the following to bring up the configuration interface:
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ sudo raspi-config
|
||||
```
|
||||
|
||||
@@ -156,19 +156,19 @@ You have now enabled the interfaces you need to use your board.
|
||||
|
||||
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:
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ git clone https://github.com/darkwaterfoundation/darkwater_python_640.git
|
||||
```
|
||||
|
||||
Next you need to navigate into the new directory so enter:
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ cd ./darkwater_python_640
|
||||
```
|
||||
|
||||
And once in there we can install the libraries with:
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ sudo python setup.py install
|
||||
```
|
||||
|
||||
@@ -178,13 +178,13 @@ Once everything is installed we can have a play with the example scripts include
|
||||
|
||||
Let's move into the examples directory and take a look at what is there.
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ cd ./examples
|
||||
```
|
||||
|
||||
If you list the files in this directory, you should see a few test scripts
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ ls -al
|
||||
```
|
||||
|
||||
@@ -192,7 +192,7 @@ $ ls -al
|
||||
|
||||
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:
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ python 640motortest.py
|
||||
```
|
||||
|
||||
@@ -200,7 +200,7 @@ $ python 640motortest.py
|
||||
|
||||
This script will move any servos connected to the servo headers left, then center, then right. To run the script enter the following:
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ python 640servotest.py
|
||||
```
|
||||
|
||||
@@ -210,7 +210,7 @@ This script divides the 6 motor ports into 3 stepper motor ports. Motor 1 and 2
|
||||
|
||||
Each stepper will be moved forwards and backwards through 400 steps when the test script is run:
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ python 640steppertest.py
|
||||
```
|
||||
|
||||
@@ -218,7 +218,7 @@ $ python 640steppertest.py
|
||||
|
||||
Now you know everything works, it's time to write your own scripts. So create a new python script in your editor with a memorable name and add the following lines to import our libraries:
|
||||
|
||||
``` python
|
||||
```python
|
||||
import time
|
||||
from darkwater_640 import dw_Controller, dw_Motor, dw_Servo, dw_Stepper
|
||||
```
|
||||
@@ -227,7 +227,7 @@ from darkwater_640 import dw_Controller, dw_Motor, dw_Servo, dw_Stepper
|
||||
|
||||
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
|
||||
|
||||
``` python
|
||||
```python
|
||||
dw = dw_Controller( addr=0x60 )
|
||||
```
|
||||
|
||||
@@ -239,7 +239,7 @@ There are 6 motor ports on the 640 board numbered 1 to 6 from left to right (wit
|
||||
|
||||
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
|
||||
|
||||
``` python
|
||||
```python
|
||||
m1 = dw.getMotor(1)
|
||||
```
|
||||
|
||||
@@ -253,7 +253,7 @@ We'll start with the main command to stop the motor
|
||||
|
||||
The off command will switch off the motor and apply the brakes
|
||||
|
||||
``` python
|
||||
```python
|
||||
m1.off()
|
||||
```
|
||||
|
||||
@@ -261,7 +261,7 @@ m1.off()
|
||||
|
||||
We can also stop the motor by using the second command and passing a speed of 0
|
||||
|
||||
``` python
|
||||
```python
|
||||
m1.setMotorSpeed(0)
|
||||
```
|
||||
|
||||
@@ -273,25 +273,25 @@ For now we'll concentrate on the first range.
|
||||
|
||||
To get your motor going forwards at full speed you should set its speed at 255
|
||||
|
||||
``` python
|
||||
```python
|
||||
m1.setMotorSpeed(255)
|
||||
```
|
||||
|
||||
To get your motor going backwards at full speed you should set its speed to -255
|
||||
|
||||
``` python
|
||||
```python
|
||||
m1.setMotorSpeed(-255)
|
||||
```
|
||||
|
||||
The numbers from 0 to the maximum in each direction will drive the motor at a slower speed, so for half speed forwards we'd use
|
||||
|
||||
``` python
|
||||
```python
|
||||
m1.setMotorSpeed(125)
|
||||
```
|
||||
|
||||
And for a slow speed backwards we can use
|
||||
|
||||
``` python
|
||||
```python
|
||||
m1.setMotorSpeed(-50)
|
||||
```
|
||||
|
||||
@@ -301,31 +301,31 @@ If you plan to move from a DC driven robot to an ESC motor powered robot then it
|
||||
|
||||
To get your motor going forwards at full speed you should set its speed to 2000
|
||||
|
||||
``` python
|
||||
```python
|
||||
m1.setMotorSpeed(2000)
|
||||
```
|
||||
|
||||
For full speed reverse you should set the speed to 1000
|
||||
|
||||
``` python
|
||||
```python
|
||||
m1.setMotorSpeed(1000)
|
||||
```
|
||||
|
||||
And to stop the motor we can set the speed to the mid point which is 1500
|
||||
|
||||
``` python
|
||||
```python
|
||||
m1.setMotorSpeed(1500)
|
||||
```
|
||||
|
||||
As before, any number between 1500 and the maximum in each direction will drive the motor at a slower speed, so for half speed forward you'd set the speed to 1750
|
||||
|
||||
``` python
|
||||
```python
|
||||
m1.setMotorSpeed(1750)
|
||||
```
|
||||
|
||||
and half speed in revers would be 1250
|
||||
|
||||
``` python
|
||||
```python
|
||||
m1.setMotorSpeed(1250)
|
||||
```
|
||||
|
||||
@@ -335,7 +335,7 @@ There are two servo ports on the 640 board. They are numbered 1 and 2 with numbe
|
||||
|
||||
You select a servo in the same manner as you select motors, by requesting a servo object from the controller - to select the first servo we use:
|
||||
|
||||
``` python
|
||||
```python
|
||||
s1 = dw.getServo(1)
|
||||
```
|
||||
|
||||
@@ -347,7 +347,7 @@ Once you have a servo object there are currently three commands you can run.
|
||||
|
||||
The off command will switch off your servo and stop any signals being sent to it.
|
||||
|
||||
``` python
|
||||
```python
|
||||
s1.off()
|
||||
```
|
||||
|
||||
@@ -357,7 +357,7 @@ This command will allow you to set the PWM pulse to the Servo in microseconds.
|
||||
|
||||
Most standard servos use a parameter value of 1000 for fully counter-clockwise, 2000 for fully clockwise, and 1500 for the middle - though you may have a wider range on your servo, so you should check the technical documentation for it to get the finer details.
|
||||
|
||||
``` python
|
||||
```python
|
||||
s1.setPWMuS(1500) # middle
|
||||
s1.setPWMuS(2000) # fully clockwise
|
||||
s1.setPWMuS(1000) # fully counter clockwise
|
||||
@@ -367,7 +367,7 @@ s1.setPWMuS(1000) # fully counter clockwise
|
||||
|
||||
This command allows you to specify the PWM pulse in milliseconds rather than seconds.
|
||||
|
||||
``` python
|
||||
```python
|
||||
s1.setPWMmS(1.5) # middle
|
||||
s1.setPWMmS(2.0) # fully clockwise
|
||||
s1.setPWMmS(1.0) # fully counter clockwise
|
||||
@@ -379,7 +379,8 @@ You can control up to 3 stepper motors with the 640 board - each stepper motor u
|
||||
|
||||
Running 5 wire stepper motors is almost the same as 4 wire stepper motos but requires a small extra step which we'll explain at the end.
|
||||
|
||||
Each stepper motor is assigned to a pair of motor ports:
|
||||
Each stepper motor is assigned to a pair of motor ports -
|
||||
|
||||
- **Stepper motor 1** - uses motor ports 1 and 2
|
||||
- **Stepper motor 2** - uses motor ports 3 and 4
|
||||
- **Stepper motor 3** - uses motor ports 5 and 6
|
||||
@@ -390,7 +391,7 @@ The first step is to identify the two wires for each coil on your stepper motor
|
||||
|
||||
Once you have your stepper motor wired up you need to request the relevant stepper motor object from the controller.
|
||||
|
||||
``` python
|
||||
```python
|
||||
stepper1 = dw.getStepper(1)
|
||||
```
|
||||
|
||||
@@ -402,7 +403,7 @@ There are four commands for stepper motors. The first one you'll recognise
|
||||
|
||||
The off command will switch off the stepper motor
|
||||
|
||||
``` python
|
||||
```python
|
||||
stepper1.off()
|
||||
```
|
||||
|
||||
@@ -410,7 +411,7 @@ stepper1.off()
|
||||
|
||||
This command allows you to set the speed of your stepper motor. Pass the number of revolutions per minute that you want your stepper motor to run at.
|
||||
|
||||
``` python
|
||||
```python
|
||||
stepper1.setMotorSpeed(200)
|
||||
```
|
||||
|
||||
@@ -426,7 +427,7 @@ There are two stepping styles available -
|
||||
- **dw_Controller.SINGLE** - this is the simplest method of stepping which activates a single coil at a time to move and hold the motor. This method uses the least amount of power.
|
||||
- **dw_Controller.DOUBLE** - this is a slightly more complex method of stepping which uses to coils to move and hold the motor. This method uses twice as much power as the single step, but is more powerful.
|
||||
|
||||
``` python
|
||||
```python
|
||||
stepper1.oneStep(dw_Controller.FORWARD, dw_Controller.SINGLE)
|
||||
stepper1.oneStep(dw_Controller.REVERSE, dw_Controller.DOUBLE)
|
||||
```
|
||||
@@ -435,7 +436,7 @@ stepper1.oneStep(dw_Controller.REVERSE, dw_Controller.DOUBLE)
|
||||
|
||||
If you want to move the stepper motor a set number of steps then you can use this command. This, however, will stop all processing until the motor has moved the specified number of steps.
|
||||
|
||||
``` python
|
||||
```python
|
||||
stepper1.step(200, dw_Controller.FORWARD, dw_Controller.SINGLE)
|
||||
stepper1.step(200, dw_Controller.REVERSE, dw_Controller.DOUBLE)
|
||||
```
|
||||
@@ -446,19 +447,19 @@ If you want more control and need to move two or more motors at the same time th
|
||||
|
||||
The C++ 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:
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ git clone https://github.com/darkwaterfoundation/darkwater_cplus_640.git
|
||||
```
|
||||
|
||||
Once they are download we can navigate into the new directory and take a look around - so enter:
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ cd ./darkwater_cplus_640
|
||||
```
|
||||
|
||||
Let's list the contents of that new directory by typing
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ ls -al
|
||||
```
|
||||
|
||||
@@ -474,14 +475,14 @@ Take a look in the examples directory and you will see the following available d
|
||||
|
||||
The Motor example will start each motor in turn from 1 through to 6 in a forwards direction, then stop them and do the same in reverse. To build this demo type the following:
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ cd ./Motor
|
||||
$ make
|
||||
```
|
||||
|
||||
Once you are returned to the command prompt you can run the program with the command:
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ sudo ./Motor
|
||||
```
|
||||
|
||||
@@ -489,14 +490,14 @@ $ sudo ./Motor
|
||||
|
||||
The servo example will move each of the two servos on the 640 board backwards and forwards six times. To build this demo type the following:
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ cd ./Servo
|
||||
$ make
|
||||
```
|
||||
|
||||
Once it is compiled you can run it with the command:
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ sudo ./Servo
|
||||
```
|
||||
|
||||
@@ -506,14 +507,14 @@ The PPM example will read the input from a PPM radio control receiver connected
|
||||
|
||||
To build this demo type the following:
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ cd ./PPM
|
||||
$ make
|
||||
```
|
||||
|
||||
Once compiled, attach your CPPM receiver to the CPPM connector (see here CPPM set up) and run the program - you will see the output for each channel on the screen as it runs. Attaching motors to each of the motor connectors will allow you to control them individually by moving the sticks on your RC transmitter.
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ sudo ./PPM
|
||||
```
|
||||
|
||||
@@ -523,7 +524,7 @@ If you have a 9DoF expansion board on your 640 board or are using a SOAR board t
|
||||
|
||||
To compile and run it, type the following
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ cd ./AccelGyroMag
|
||||
$ make
|
||||
$ sudo ./AccelGyroMag
|
||||
@@ -535,7 +536,7 @@ If you take a look at the code in each of the examples you should be able to get
|
||||
|
||||
The first thing we need to do for our program is to import the required libraries - so near the top of your new program you will put
|
||||
|
||||
``` c
|
||||
```c
|
||||
#include "darkwater/DW640.h"
|
||||
#include "darkwater/Util.h"
|
||||
#include <stdlib.h>
|
||||
@@ -543,7 +544,7 @@ The first thing we need to do for our program is to import the required librarie
|
||||
|
||||
If you will be using the CPPM header for input then you will also need to add:
|
||||
|
||||
``` c
|
||||
```c
|
||||
#include <pigpio.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
@@ -551,7 +552,7 @@ If you will be using the CPPM header for input then you will also need to add:
|
||||
|
||||
For this example, we'll include everthing in a *main* function for neatness - have a look at the PPM example code for an alternate set up.
|
||||
|
||||
``` c
|
||||
```c
|
||||
int main()
|
||||
{
|
||||
|
||||
@@ -562,7 +563,7 @@ int main()
|
||||
|
||||
The **DW640** 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 so if you haven't changed the address then you can leave this out.
|
||||
|
||||
``` c
|
||||
```c
|
||||
DW640 dw(0x60);
|
||||
dw.initialize();
|
||||
```
|
||||
@@ -575,7 +576,7 @@ There are 6 motor ports on the 640 board numbered 1 to 6 from left to right (wit
|
||||
|
||||
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
|
||||
|
||||
``` c
|
||||
```c
|
||||
DW_Motor *dw1 = dw.getMotor(1);
|
||||
```
|
||||
|
||||
@@ -589,7 +590,7 @@ We'll start with the main command to stop the motor
|
||||
|
||||
The off command will switch off the motor
|
||||
|
||||
``` c
|
||||
```c
|
||||
dw1->off()
|
||||
```
|
||||
|
||||
@@ -597,7 +598,7 @@ dw1->off()
|
||||
|
||||
We can also stop the motor by using the second command and passing a speed of 0
|
||||
|
||||
``` c
|
||||
```c
|
||||
dw1->setMotorSpeed(0);
|
||||
```
|
||||
|
||||
@@ -609,25 +610,25 @@ For now we'll concentrate on the first range.
|
||||
|
||||
To get your motor going forwards at full speed you should set its speed at 255
|
||||
|
||||
``` c
|
||||
```c
|
||||
dw1->setMotorSpeed(255);
|
||||
```
|
||||
|
||||
To get your motor going backwards at full speed you should set its speed to -255
|
||||
|
||||
``` c
|
||||
```c
|
||||
dw1->setMotorSpeed(-255)
|
||||
```
|
||||
|
||||
The numbers from 0 to the maximum in each direction will drive the motor at a slower speed, so for half speed forwards we'd use
|
||||
|
||||
``` c
|
||||
```c
|
||||
dw1->setMotorSpeed(125)
|
||||
```
|
||||
|
||||
And for a slow speed backwards we can use
|
||||
|
||||
``` c
|
||||
```c
|
||||
dw1->setMotorSpeed(-50)
|
||||
```
|
||||
|
||||
@@ -639,31 +640,31 @@ Both the ESCAPE and 640 boards can use either range, but if you are primarily wo
|
||||
|
||||
To get your motor going forwards at full speed you should set its speed to 2000
|
||||
|
||||
``` c
|
||||
```c
|
||||
dw1->setMotorSpeed(2000)
|
||||
```
|
||||
|
||||
For full speed reverse you should set the speed to 1000
|
||||
|
||||
``` c
|
||||
```c
|
||||
dw1->setMotorSpeed(1000)
|
||||
```
|
||||
|
||||
And to stop the motor we can set the speed to the mid point which is 1500
|
||||
|
||||
``` c
|
||||
```c
|
||||
dw1->setMotorSpeed(1500)
|
||||
```
|
||||
|
||||
As before, any number between 1500 and the maximum in each direction will drive the motor at a slower speed, so for half speed forward you'd set the speed to 1750
|
||||
|
||||
``` c
|
||||
```c
|
||||
dw1->setMotorSpeed(1750)
|
||||
```
|
||||
|
||||
and half speed in reverse would be 1250
|
||||
|
||||
``` c
|
||||
```c
|
||||
dw1->setMotorSpeed(1250)
|
||||
```
|
||||
|
||||
@@ -673,7 +674,7 @@ There are two servo ports on the 640 board. They are numbered from 1 and 2 with
|
||||
|
||||
You select a servo in the same manner as you select motors, by requesting a servo object from the controller - to select the first servo we use:
|
||||
|
||||
``` c
|
||||
```c
|
||||
DW_Servo *s1 = dw.getServo(1);
|
||||
```
|
||||
|
||||
@@ -685,7 +686,7 @@ Once you have a servo object there are currently three commands you can run.
|
||||
|
||||
The off command will switch off your servo and stop any signals being sent to it.
|
||||
|
||||
``` c
|
||||
```c
|
||||
s1->off();
|
||||
```
|
||||
|
||||
@@ -695,7 +696,7 @@ This command will allow you to set the PWM pulse to the Servo in microseconds.
|
||||
|
||||
Most standard servos use a parameter value of 1000 for fully counter-clockwise, 2000 for fully clockwise, and 1500 for the middle - though you may have a wider range on your servo, so you should check the technical documentation for it to get the finer details.
|
||||
|
||||
``` c
|
||||
```c
|
||||
s1->setPWMuS(1500); // middle
|
||||
s1->setPWMuS(2000); // fully clockwise
|
||||
s1->setPWMuS(1000); // fully counter clockwise
|
||||
@@ -705,7 +706,7 @@ s1->setPWMuS(1000); // fully counter clockwise
|
||||
|
||||
This command allows you to specify the PWM pulse in milliseconds rather than seconds.
|
||||
|
||||
``` c
|
||||
```c
|
||||
s1->setPWMmS(1.5); // middle
|
||||
s1->setPWMmS(2.0); // fully clockwise
|
||||
s1->setPWMmS(1.0); // fully counter clockwise
|
||||
@@ -717,7 +718,8 @@ You can control up to 3 stepper motors with the 640 board - each stepper motor u
|
||||
|
||||
Running 5 wire stepper motors is almost the same as 4 wire stepper motors but requires a small extra step which we'll explain at the end.
|
||||
|
||||
Each stepper motor is assigned to a pair of motor ports:
|
||||
Each stepper motor is assigned to a pair of motor ports -
|
||||
|
||||
- **Stepper motor 1** - uses motor ports 1 and 2
|
||||
- **Stepper motor 2** - uses motor ports 3 and 4
|
||||
- **Stepper motor 3** - uses motor ports 5 and 6
|
||||
@@ -728,13 +730,13 @@ The first step is to identify the two wires for each coil on your stepper motor
|
||||
|
||||
Once you have your stepper motor wired up you need to request the relevant stepper motor object from the controller.
|
||||
|
||||
``` c
|
||||
```c
|
||||
DW_Stepper *st1 = dw.getStepper(1);
|
||||
```
|
||||
|
||||
The default stepper object created assumes that your stepper motor has 48 steps per revolution - if you motor has more or less steps per revolution then you can specify this using an alterative command:
|
||||
|
||||
``` c
|
||||
```c
|
||||
DW_Stepper *st1 = dw.getStepper(1, 48);
|
||||
```
|
||||
|
||||
@@ -748,7 +750,7 @@ There are four commands for stepper motors. The first one you'll recognise
|
||||
|
||||
The off command will switch off the stepper motor
|
||||
|
||||
``` c
|
||||
```c
|
||||
st1->off();
|
||||
```
|
||||
|
||||
@@ -756,7 +758,7 @@ st1->off();
|
||||
|
||||
This command allows you to set the speed of your stepper motor. Pass the number of revolutions per minute that you want your stepper motor to run at.
|
||||
|
||||
``` c
|
||||
```c
|
||||
st1->setMotorSpeed(200);
|
||||
```
|
||||
|
||||
@@ -772,7 +774,7 @@ There are two stepping styles available -
|
||||
- **DW_SINGLE** - this is the simplest method of stepping which activates a single coil at a time to move and hold the motor. This method uses the least amount of power.
|
||||
- **DW_DOUBLE** - this is a slightly more complex method of stepping which uses to coils to move and hold the motor. This method uses twice as much power as the single step, but is more powerful.
|
||||
|
||||
``` c
|
||||
```c
|
||||
st1->oneStep(DW_FORWARD, DW_SINGLE);
|
||||
st1->oneStep(DW_REVERSE, DW_DOUBLE);
|
||||
```
|
||||
@@ -781,7 +783,7 @@ st1->oneStep(DW_REVERSE, DW_DOUBLE);
|
||||
|
||||
If you want to move the stepper motor a set number of steps then you can use this command. This, however, will stop all processing until the motor has moved the specified number of steps.
|
||||
|
||||
``` c
|
||||
```c
|
||||
st1->step( 400, DW_FORWARD, DW_SINGLE );
|
||||
st1->step( 400, DW_REVERSE, DW_DOUBLE );
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user