More docs
This commit is contained in:
parent
9f87895497
commit
4644496a32
|
@ -0,0 +1,46 @@
|
||||||
|
Running the Demo
|
||||||
|
================
|
||||||
|
|
||||||
|
Compiling
|
||||||
|
---------
|
||||||
|
To compile this example you will need make, avrgcc avr-binutils and the avrlibc.
|
||||||
|
If you are reading this I assume you already have an avr toolchain in place.
|
||||||
|
Also you'll need avrdude to flash your avr.
|
||||||
|
|
||||||
|
The makefile takes 3 optional parameters:
|
||||||
|
* **F_CPU** Clock speed of your controller in Hertz (default: 16000000)
|
||||||
|
* **AVRMCU** The name of your microcontroller, currently only atmega8 and atmega32p are supported (default: atemga8)
|
||||||
|
* **ISPPORT** The serial interface for `make flash` (default: /dev/ttyACM0)
|
||||||
|
|
||||||
|
To compile and flash the code run (assuming there is a serial bootloader like optiboot present on your controller):
|
||||||
|
```
|
||||||
|
make
|
||||||
|
make flash
|
||||||
|
```
|
||||||
|
|
||||||
|
If you want to run the code on your Arduino try:
|
||||||
|
```
|
||||||
|
make AVRMCU=atmega32p
|
||||||
|
make AVRMCU=atmega32p flash
|
||||||
|
```
|
||||||
|
|
||||||
|
Afterwards connect the encoder and start a terminal emulator of your choice on your serial interface.
|
||||||
|
If you start sending newlines to the microcontroller, you should see it respond with measurements in plain ASCII.
|
||||||
|
|
||||||
|
You can also run cube_demo.py on this interface if you have PyOpengl and PySerial installed.
|
||||||
|
It might be necessary to change the SERIAL constant on line 16 to the correct interface.
|
||||||
|
|
||||||
|
Connecting the encoder
|
||||||
|
----------------------
|
||||||
|
|
||||||
|
Simply onnect the encoder according to the following table:
|
||||||
|
|
||||||
|
| AS5043 | AVR | Arduino |
|
||||||
|
|--------|------------|----------------|
|
||||||
|
| PROG | GND | GND |
|
||||||
|
| DO | PB4 (MISO) | digital pin 12 |
|
||||||
|
| CLK | PB5 (SCK) | digital pin 13 |
|
||||||
|
| CS | PB2 (SS) | digital pin 10 |
|
||||||
|
| MODE | GND | GND |
|
||||||
|
| VDD5V | +5v | +5v |
|
||||||
|
| VSS | GND | GND |
|
|
@ -13,6 +13,7 @@ ERROR: PyOpenGL not installed properly.
|
||||||
|
|
||||||
import serial
|
import serial
|
||||||
|
|
||||||
|
SERIAL = '/dev/ttyUSB0'
|
||||||
|
|
||||||
angle = 0
|
angle = 0
|
||||||
pos = 0
|
pos = 0
|
||||||
|
@ -53,7 +54,7 @@ def idle():
|
||||||
while len(line) == 0:
|
while len(line) == 0:
|
||||||
ser.write("a")
|
ser.write("a")
|
||||||
line = ser.readline()
|
line = ser.readline()
|
||||||
|
|
||||||
angle = int(line[:-2])
|
angle = int(line[:-2])
|
||||||
print "angle: %d" % angle
|
print "angle: %d" % angle
|
||||||
|
|
||||||
|
@ -63,7 +64,7 @@ def idle():
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=0.032)
|
ser = serial.Serial(SERIAL, 9600, timeout=0.032)
|
||||||
if not ser:
|
if not ser:
|
||||||
print "Unable to open serial port"
|
print "Unable to open serial port"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
Loading…
Reference in New Issue