Dirk (Diskussion | Beiträge) K (→Config) |
Dirk (Diskussion | Beiträge) K (→Configuration Header) |
||
Zeile 23: | Zeile 23: | ||
====ArduIO Library==== | ====ArduIO Library==== | ||
=====Configuration Header===== | =====Configuration Header===== | ||
+ | Datei RP6_ArduIO.h: | ||
+ | <pre>/* **************************************************************************** | ||
+ | * _______________________ | ||
+ | * \| RP6 ROBOT SYSTEM |/ | ||
+ | * \_-_-_-_-_-_-_-_-_-_/ >>> COMMON | ||
+ | * ---------------------------------------------------------------------------- | ||
+ | * ----------------------------- [c]2014 - Dirk ------------------------------- | ||
+ | * **************************************************************************** | ||
+ | * File: RP6_ArduIO.h | ||
+ | * Version: 1.0 | ||
+ | * Target: RP6 Base & Processor Expansion - ATMEGA32 @8.00 or 16.00MHz | ||
+ | * & RP6 M256 WiFi - ATMEGA2560 @16.00MHz | ||
+ | * Author(s): D. Ottensmeyer | ||
+ | * **************************************************************************** | ||
+ | * Description: | ||
+ | * Configuration header file for new ArduIO Board library. | ||
+ | * | ||
+ | * **************************************************************************** | ||
+ | * THE CHANGELOG CAN BE FOUND AT THE END OF THIS FILE! | ||
+ | * **************************************************************************** | ||
+ | */ | ||
+ | |||
+ | #ifndef RP6_ARDUIO_H | ||
+ | #define RP6_ARDUIO_H | ||
+ | |||
+ | |||
+ | /*****************************************************************************/ | ||
+ | // ArduIO hardwired components: | ||
+ | // - I2C PWM Controller (IC3: PCA9685) | ||
+ | // - I2C I/O Expander 1 5V (IC8: PCF8575) | ||
+ | // - I2C I/O Expander 2 5V (IC13: PCF8575) | ||
+ | // - I2C I/O Expander 3 3V3 (IC12: PCF8575) | ||
+ | // - I2C A/D and D/A Converter 1 (IC11: PCF8591) | ||
+ | // - I2C A/D and D/A Converter 2 (IC10: PCF8591) | ||
+ | // - I2C A/D and D/A Converter 3 (IC9: PCF8591) | ||
+ | // - UB Voltage Sensor | ||
+ | // - LEDs | ||
+ | // - PWM Ports | ||
+ | // - Power PWM Ports & H-Bridges | ||
+ | |||
+ | /*****************************************************************************/ | ||
+ | // Includes: | ||
+ | |||
+ | #include "RP6_ArduIOConfig.h" // Configure the target system | ||
+ | |||
+ | /*****************************************************************************/ | ||
+ | // I2C PWM Controller (PCA9685): | ||
+ | // (A5, A4, A3 always 0, A1 always 1!) | ||
+ | #define I2C_ARDUIO_PWM_ADR 0x84 // A2/0 = 0/0 | ||
+ | //#define I2C_ARDUIO_PWM_ADR 0x86 // A2/0 = 0/1 | ||
+ | //#define I2C_ARDUIO_PWM_ADR 0x8c // A2/0 = 1/0 | ||
+ | //#define I2C_ARDUIO_PWM_ADR 0x8e // A2/0 = 1/1 | ||
+ | //#define I2C_ARDUIO_PWM_ADR 0xe0 // ALLCALLADR | ||
+ | |||
+ | // --------------------------------------------------------------- | ||
+ | #define PWM_FREQUENCY 1000 // 1kHz (default) | ||
+ | // --------------------------------------------------------------- | ||
+ | |||
+ | #define CHALL_LED 0 // All LEDs (channels) | ||
+ | |||
+ | /*****************************************************************************/ | ||
+ | // I2C I/O Expander (PCF8575): | ||
+ | // (A1 always 1!) | ||
+ | #define I2C_ARDUIO_IO_1_ADR 0x44 // A2/0 = 0/0 | ||
+ | //#define I2C_ARDUIO_IO_1_ADR 0x46 // A2/0 = 0/1 | ||
+ | //#define I2C_ARDUIO_IO_1_ADR 0x4c // A2/0 = 1/0 | ||
+ | //#define I2C_ARDUIO_IO_1_ADR 0x4e // A2/0 = 1/1 | ||
+ | |||
+ | //#define I2C_ARDUIO_IO_2_ADR 0x44 // A2/0 = 0/0 | ||
+ | #define I2C_ARDUIO_IO_2_ADR 0x46 // A2/0 = 0/1 | ||
+ | //#define I2C_ARDUIO_IO_2_ADR 0x4c // A2/0 = 1/0 | ||
+ | //#define I2C_ARDUIO_IO_2_ADR 0x4e // A2/0 = 1/1 | ||
+ | |||
+ | //#define I2C_ARDUIO_IO_3_ADR 0x44 // A2/0 = 0/0 | ||
+ | //#define I2C_ARDUIO_IO_3_ADR 0x46 // A2/0 = 0/1 | ||
+ | #define I2C_ARDUIO_IO_3_ADR 0x4c // A2/0 = 1/0 | ||
+ | //#define I2C_ARDUIO_IO_3_ADR 0x4e // A2/0 = 1/1 | ||
+ | |||
+ | /*****************************************************************************/ | ||
+ | // I2C A/D and D/A Converter (PCF8591): | ||
+ | // (A1 always 1!) | ||
+ | #define I2C_ARDUIO_AD_1_ADR 0x94 // A2/0 = 0/0 | ||
+ | //#define I2C_ARDUIO_AD_1_ADR 0x96 // A2/0 = 0/1 | ||
+ | //#define I2C_ARDUIO_AD_1_ADR 0x9c // A2/0 = 1/0 | ||
+ | //#define I2C_ARDUIO_AD_1_ADR 0x9e // A2/0 = 1/1 | ||
+ | |||
+ | //#define I2C_ARDUIO_AD_2_ADR 0x94 // A2/0 = 0/0 | ||
+ | #define I2C_ARDUIO_AD_2_ADR 0x96 // A2/0 = 0/1 | ||
+ | //#define I2C_ARDUIO_AD_2_ADR 0x9c // A2/0 = 1/0 | ||
+ | //#define I2C_ARDUIO_AD_2_ADR 0x9e // A2/0 = 1/1 | ||
+ | |||
+ | //#define I2C_ARDUIO_AD_3_ADR 0x94 // A2/0 = 0/0 | ||
+ | //#define I2C_ARDUIO_AD_3_ADR 0x96 // A2/0 = 0/1 | ||
+ | #define I2C_ARDUIO_AD_3_ADR 0x9c // A2/0 = 1/0 | ||
+ | //#define I2C_ARDUIO_AD_3_ADR 0x9e // A2/0 = 1/1 | ||
+ | |||
+ | /*****************************************************************************/ | ||
+ | // UB Voltage Sensor: | ||
+ | // (Connected to A/D and D/A Converter 1 (ADDA_1: IC11), AIN3 (AD13), | ||
+ | // if jumper JP_AD-UB on the ArduIO Board is CLOSED!) | ||
+ | #define ADCVAL_UB_LOW 175 // UB 6.9V | ||
+ | |||
+ | /*****************************************************************************/ | ||
+ | // LEDs: | ||
+ | // (Status LED1..LED4 are connected to LED11..LED8 of the PCA9685!) | ||
+ | #define CHLED1 12 | ||
+ | #define CHLED2 11 | ||
+ | #define CHLED3 10 | ||
+ | #define CHLED4 9 | ||
+ | |||
+ | /*****************************************************************************/ | ||
+ | // PWM Ports: | ||
+ | // (Ports PWM1..PWM4 are connected to LED15..LED12 of the PCA9685!) | ||
+ | #define CHPWM1 16 | ||
+ | #define CHPWM2 15 | ||
+ | #define CHPWM3 14 | ||
+ | #define CHPWM4 13 | ||
+ | |||
+ | /*****************************************************************************/ | ||
+ | // Power PWM Ports & H-Bridges: | ||
+ | // (H-Bridges HB1/HB2 are connected to LED0..LED3/LED4..LED7 of the PCA9685!) | ||
+ | // Power PWM Ports: | ||
+ | #define CHPOWERPWM1_P 1 | ||
+ | #define CHPOWERPWM2_N 2 | ||
+ | #define CHPOWERPWM3_P 3 | ||
+ | #define CHPOWERPWM4_N 4 | ||
+ | #define CHPOWERPWM5_P 5 | ||
+ | #define CHPOWERPWM6_N 6 | ||
+ | #define CHPOWERPWM7_P 7 | ||
+ | #define CHPOWERPWM8_N 8 | ||
+ | |||
+ | // H-Bridges: | ||
+ | #define CHHB1_P1 1 | ||
+ | #define CHHB1_N1 2 | ||
+ | #define CHHB1_P2 3 | ||
+ | #define CHHB1_N2 4 | ||
+ | #define CHHB2_P1 5 | ||
+ | #define CHHB2_N1 6 | ||
+ | #define CHHB2_P2 7 | ||
+ | #define CHHB2_N2 8 | ||
+ | |||
+ | /*****************************************************************************/ | ||
+ | // Interrupt portpin definitions: | ||
+ | // Select INTx portpin definitions depending on RP6_ArduIOConfig.h: | ||
+ | #ifdef ARDUIO_RP6BASE | ||
+ | // Interrupt I/O portpin definitions (RP6Base): | ||
+ | #define IO_ARDUIO_INT1_IN E_INT1 // ADC4 PA4 XBUS Pin 8 | ||
+ | #define IO_ARDUIO_INT1_DDR DDRA | ||
+ | #define IO_ARDUIO_INT1_PIN PINA | ||
+ | #define IO_ARDUIO_INT1_PORT PORTA | ||
+ | #else | ||
+ | #ifdef ARDUIO_RP6CONTROL | ||
+ | // Interrupt I/O portpin definitions (RP6Control M32): | ||
+ | #define IO_ARDUIO_INT1_IN EINT1 // INT0 PD2 XBUS Pin 8 | ||
+ | #define IO_ARDUIO_INT1_DDR DDRD | ||
+ | #define IO_ARDUIO_INT1_PIN PIND | ||
+ | #define IO_ARDUIO_INT1_PORT PORTD | ||
+ | #define IO_ARDUIO_INT2_IN EINT2 // INT1 PD3 XBUS Pin 11 | ||
+ | #define IO_ARDUIO_INT2_DDR DDRD | ||
+ | #define IO_ARDUIO_INT2_PIN PIND | ||
+ | #define IO_ARDUIO_INT2_PORT PORTD | ||
+ | #define IO_ARDUIO_INT3_IN EINT3 // AIN0/INT2 PB2 XBUS Pin 9 | ||
+ | #define IO_ARDUIO_INT3_DDR DDRB | ||
+ | #define IO_ARDUIO_INT3_PIN PINB | ||
+ | #define IO_ARDUIO_INT3_PORT PORTB | ||
+ | #else | ||
+ | #ifdef ARDUIO_RP6M256WIFI | ||
+ | // Interrupt I/O portpin definitions (RP6M256 WiFi): | ||
+ | #define IO_ARDUIO_INT1_IN INT1_PI12 // PCINT12 PJ3 XBUS Pin 8 | ||
+ | #define IO_ARDUIO_INT1_DDR DDRJ | ||
+ | #define IO_ARDUIO_INT1_PIN PINJ | ||
+ | #define IO_ARDUIO_INT1_PORT PORTJ | ||
+ | #define IO_ARDUIO_INT2_IN INT2_PI15 // PCINT15 PJ6 XBUS Pin 11 | ||
+ | #define IO_ARDUIO_INT2_DDR DDRJ | ||
+ | #define IO_ARDUIO_INT2_PIN PINJ | ||
+ | #define IO_ARDUIO_INT2_PORT PORTJ | ||
+ | #define IO_ARDUIO_INT3_IN INT3_PI14 // PCINT14 PJ5 XBUS Pin 9 | ||
+ | #define IO_ARDUIO_INT3_DDR DDRJ | ||
+ | #define IO_ARDUIO_INT3_PIN PINJ | ||
+ | #define IO_ARDUIO_INT3_PORT PORTJ | ||
+ | #define IO_ARDUIO_INTU_IN INTU_PI13 // PCINT13 PJ4 XBUS Pin 7 | ||
+ | #define IO_ARDUIO_INTU_DDR DDRJ | ||
+ | #define IO_ARDUIO_INTU_PIN PINJ | ||
+ | #define IO_ARDUIO_INTU_PORT PORTJ | ||
+ | #else | ||
+ | #error DEFINE "ARDUIO_RP6BASE", "ARDUIO_RP6CONTROL" OR "ARDUIO_RP6M256WIFI" | ||
+ | #error AS TARGET IN RP6_ArduIOConfig.h | ||
+ | #endif | ||
+ | #endif | ||
+ | #endif | ||
+ | |||
+ | /*****************************************************************************/ | ||
+ | /* Arduino Uno Expander definitions */ | ||
+ | /*****************************************************************************/ | ||
+ | // ATTENTION: Using this library you MAY NOT connect an Arduino Uno Board to | ||
+ | // the RP6 ArduIO Board using the Arduino Uno Expander pin headers | ||
+ | // on the ArduIO Board!!! | ||
+ | // BE VERY CAREFUL: | ||
+ | // You may damage the Arduino Uno AND your RP6 ArduIO Board! | ||
+ | // | ||
+ | // Of course you may connect Arduino ADDON boards (shields) to the | ||
+ | // Arduino Uno Expander pin headers on the ArduIO Board. | ||
+ | // BE VERY CAREFUL: | ||
+ | // Not all Arduino shields will work on the RP6 ArduIO Board! | ||
+ | // You may damage the Arduino shield AND your RP6 ArduIO Board! | ||
+ | /*****************************************************************************/ | ||
+ | // Arduino Uno Expander <-> RP6_ArduIO Mapping Table: | ||
+ | // Arduino Uno: ATmega328: RP6_ArduIO: | ||
+ | // Pin Function Pin Functions Pin Name IO ADDA | ||
+ | // ----------------------------------------------------------- | ||
+ | // 0 D0 RX PD0 RXD_PCINT16 P00 GP200 2 | ||
+ | // 1 D1 TX PD1 TXD_PCINT17 P01 GP201 2 | ||
+ | // 2 D2 PD2 INT0_PCINT18 P02 GP202 2 | ||
+ | // 3 D3 PWM PD3 INT1_OC2B_PCINT19 P03 GP203 2 | ||
+ | // 4 D4 PD4 T0_XCK_PCINT20 P04 GP204 2 | ||
+ | // 5 D5 PWM PD5 T1_OC0B_PCINT21 P05 GP205 2 | ||
+ | // 6 D6 PWM PD6 AIN0_OC0A_PCINT22 P06 GP206 2 | ||
+ | // 7 D7 PD7 AIN1_PCINT23 P07 GP207 2 | ||
+ | // 8 D8 PB0 ICP1_CLKO_PCINT0 P15 GP215 2 | ||
+ | // 9 D9 PWM PB1 OC1A_PCINT1 P14 GP214 2 | ||
+ | // 10 D10 PWM PB2 SS_OC1B_PCINT2 P13 GP213 2 | ||
+ | // 11 D11 PWM PB3 MOSI_OC2A_PCINT13 P12 GP212 2 | ||
+ | // 12 D12 PB4 MISO_PCINT4 P11 GP211 2 | ||
+ | // 13 D13 PB5 SCK_PCINT5 P10 GP210 2 | ||
+ | // | ||
+ | // 0 A0 PC0 ADC0_PCINT8 AIN0 AD30 3 | ||
+ | // 1 A1 PC1 ADC1_PCINT9 AIN1 AD31 3 | ||
+ | // 2 A2 PC2 ADC2_PCINT10 AIN2 AD32 3 | ||
+ | // 3 A3 PC3 ADC3_PCINT11 AIN3 AD33 3 | ||
+ | // 4 A4 SDA PC4 ADC4_SDA_PCINT12 SDA | ||
+ | // 5 A5 SCL PC5 ADC5_SCL_PCINT13 SCL | ||
+ | |||
+ | // Arduino Uno Expander ATmega 328 portpin names: | ||
+ | #define IO_ARD_D0_RXD_PCINT16 0 | ||
+ | #define IO_ARD_D1_TXD_PCINT17 1 | ||
+ | #define IO_ARD_D2_INT0_PCINT18 2 | ||
+ | #define IO_ARD_D3_INT1_OC2B_PCINT19 3 | ||
+ | #define IO_ARD_D4_T0_XCK_PCINT20 4 | ||
+ | #define IO_ARD_D5_T1_OC0B_PCINT21 5 | ||
+ | #define IO_ARD_D6_AIN0_OC0A_PCINT22 6 | ||
+ | #define IO_ARD_D7_AIN1_PCINT23 7 | ||
+ | #define IO_ARD_D8_ICP1_CLKO_PCINT0 8 | ||
+ | #define IO_ARD_D9_OC1A_PCINT1 9 | ||
+ | #define IO_ARD_D10_SS_OC1B_PCINT2 10 | ||
+ | #define IO_ARD_D11_MOSI_OC2A_PCINT13 11 | ||
+ | #define IO_ARD_D12_MISO_PCINT4 12 | ||
+ | #define IO_ARD_D13_SCK_PCINT5 13 | ||
+ | |||
+ | #define AD_ARD_A0_ADC0_PCINT8 0 | ||
+ | #define AD_ARD_A1_ADC1_PCINT9 1 | ||
+ | #define AD_ARD_A2_ADC2_PCINT10 2 | ||
+ | #define AD_ARD_A3_ADC3_PCINT11 3 | ||
+ | #define AD_ARD_A4_ADC4_SDA_PCINT12 4 | ||
+ | #define AD_ARD_A5_ADC5_SCL_PCINT13 5 | ||
+ | |||
+ | // Arduino Uno Expander portpin short definitions: | ||
+ | #define IO_ARD_D0_RX 0 | ||
+ | #define IO_ARD_D1_TX 1 | ||
+ | #define IO_ARD_D2 2 | ||
+ | #define IO_ARD_D3_PWM 3 | ||
+ | #define IO_ARD_D4 4 | ||
+ | #define IO_ARD_D5_PWM 5 | ||
+ | #define IO_ARD_D6_PWM 6 | ||
+ | #define IO_ARD_D7 7 | ||
+ | #define IO_ARD_D8 8 | ||
+ | #define IO_ARD_D9_PWM 9 | ||
+ | #define IO_ARD_D10_PWM 10 | ||
+ | #define IO_ARD_D11_PWM 11 | ||
+ | #define IO_ARD_D12 12 | ||
+ | #define IO_ARD_D13 13 | ||
+ | |||
+ | #define AD_ARD_A0 0 | ||
+ | #define AD_ARD_A1 1 | ||
+ | #define AD_ARD_A2 2 | ||
+ | #define AD_ARD_A3 3 | ||
+ | #define AD_ARD_A4_SDA 4 | ||
+ | #define AD_ARD_A5_SCL 5 | ||
+ | |||
+ | /*****************************************************************************/ | ||
+ | // Arduino Uno Expander read/write software examples: | ||
+ | // 1. Writing to the digital portpins (D0..D13): | ||
+ | // io2outs.ARD_D10 = true; | ||
+ | // updateArduIO_IO2(); // Set D10 | ||
+ | // io2outs.ARD_D8 = false; | ||
+ | // updateArduIO_IO2(); // Clear D8 | ||
+ | // setArduIO_IO2(0b0001000000000000); // Set D9 & clear all others | ||
+ | // ==> Bit positions in the io2ins and io2outs word: | ||
+ | // ==> 0b0000000000000000 | ||
+ | // ==> | || | | ||
+ | // ==> D8 |D7 D0 | ||
+ | // ==> D13 | ||
+ | // 2. Reading the digital portpins (D0..D13): | ||
+ | // setArduIO_IO2(0b0011111111111111); // Set all portpins | ||
+ | // ==> Hint: portpins can only be read, if they were SET before onetime!!! | ||
+ | // task_readArduIO_IO2(); // Read D0..D13 | ||
+ | // io_D0 = io2ins.ARD_D0; // This is D0 | ||
+ | // io_D11 = io2ins.ARD_D11; // This is D11 | ||
+ | // all_ios = io2ins.word & 0x3fff; // All portpins in 1 word | ||
+ | // 3. Reading the analog portpins (A0..A3): | ||
+ | // task_readArduIO_AD3(); // Read A0..A3 | ||
+ | // adc_A0 = ad3ins.ARD_A0; // This is A0 | ||
+ | // adc_A3 = ad3ins.ARD_A3; // This is A3 | ||
+ | // 4. Reading all portpins and the interrupt signal: | ||
+ | // task_Arduino_Uno_Exp(); // Read D0..D13, A0..A3 and | ||
+ | // // PCF8575 (2) INT | ||
+ | // int = interrupt_RP6ArduIOstatus.ioexp_2 // This is PCF8575 (2) INT | ||
+ | // ==> Hint 1: This XBUS INT1 indicates a level change on D0..D13!!! | ||
+ | // ==> Hint 2: If the variable interrupt_rp6arduiostatus_changed becomes | ||
+ | // TRUE after execution of this task, INT1 has changed!!! | ||
+ | // ==> Hint 3: Pins 1-2 of jumper JP_INT3V3 must be CLOSED!!! | ||
+ | |||
+ | /*****************************************************************************/ | ||
+ | /* Arduino Uno Expander definitions end */ | ||
+ | /*****************************************************************************/ | ||
+ | |||
+ | #endif | ||
+ | |||
+ | /****************************************************************************** | ||
+ | * Additional info | ||
+ | * **************************************************************************** | ||
+ | * Changelog: | ||
+ | * | ||
+ | * ---> changes are documented in the file "RP6_ArduIOLib.c" | ||
+ | * | ||
+ | * **************************************************************************** | ||
+ | */ | ||
+ | |||
+ | /*****************************************************************************/ | ||
+ | // EOF | ||
+ | </pre> | ||
+ | |||
=====Library Header===== | =====Library Header===== | ||
=====Library Source===== | =====Library Source===== |
Version vom 5. Oktober 2014, 21:40 Uhr
Inhaltsverzeichnis
RP6 ArduIO Erweiterungsmodul
Die RP6-ArduIO Erweiterungsplatine (siehe auch das Vorgängerprojekt,die RP6-MultiIO-Erweiterungsplatine) im üblichen RP6-Layout ist als reine I2C-Erweiterung sowohl für den RP6, als auch für Arduino-Boards und –Shields gedacht. Entwickelt wurde sie zusammen mit einigen Mitgliedern des Roboternetzes von fabqu (Hardwarearbeiten) und Dirk (Softwarearbeiten).
Umfangreiche Dokumentation, sämtliche Beispielprogramme und Bibliotheken, Daten, Teilelisten und eine Lötanleitung finden sich unten in den Weblinks.
Hier wird es mal um die Software für die RP6 ArduIO Platine von fabqu gehen.
Bis dahin ist das hier eine ...
BAUSTELLE ........ BAUSTELLE ........ BAUSTELLE ........ BAUSTELLE ........ BAUSTELLE
Hardware
Der Hardware-Artikel befindet sich HIER.
Software
RP6 M256 WIFI, CONTROL M32, BASE
ArduIO Library
Configuration Header
Datei RP6_ArduIO.h:
/* **************************************************************************** * _______________________ * \| RP6 ROBOT SYSTEM |/ * \_-_-_-_-_-_-_-_-_-_/ >>> COMMON * ---------------------------------------------------------------------------- * ----------------------------- [c]2014 - Dirk ------------------------------- * **************************************************************************** * File: RP6_ArduIO.h * Version: 1.0 * Target: RP6 Base & Processor Expansion - ATMEGA32 @8.00 or 16.00MHz * & RP6 M256 WiFi - ATMEGA2560 @16.00MHz * Author(s): D. Ottensmeyer * **************************************************************************** * Description: * Configuration header file for new ArduIO Board library. * * **************************************************************************** * THE CHANGELOG CAN BE FOUND AT THE END OF THIS FILE! * **************************************************************************** */ #ifndef RP6_ARDUIO_H #define RP6_ARDUIO_H /*****************************************************************************/ // ArduIO hardwired components: // - I2C PWM Controller (IC3: PCA9685) // - I2C I/O Expander 1 5V (IC8: PCF8575) // - I2C I/O Expander 2 5V (IC13: PCF8575) // - I2C I/O Expander 3 3V3 (IC12: PCF8575) // - I2C A/D and D/A Converter 1 (IC11: PCF8591) // - I2C A/D and D/A Converter 2 (IC10: PCF8591) // - I2C A/D and D/A Converter 3 (IC9: PCF8591) // - UB Voltage Sensor // - LEDs // - PWM Ports // - Power PWM Ports & H-Bridges /*****************************************************************************/ // Includes: #include "RP6_ArduIOConfig.h" // Configure the target system /*****************************************************************************/ // I2C PWM Controller (PCA9685): // (A5, A4, A3 always 0, A1 always 1!) #define I2C_ARDUIO_PWM_ADR 0x84 // A2/0 = 0/0 //#define I2C_ARDUIO_PWM_ADR 0x86 // A2/0 = 0/1 //#define I2C_ARDUIO_PWM_ADR 0x8c // A2/0 = 1/0 //#define I2C_ARDUIO_PWM_ADR 0x8e // A2/0 = 1/1 //#define I2C_ARDUIO_PWM_ADR 0xe0 // ALLCALLADR // --------------------------------------------------------------- #define PWM_FREQUENCY 1000 // 1kHz (default) // --------------------------------------------------------------- #define CHALL_LED 0 // All LEDs (channels) /*****************************************************************************/ // I2C I/O Expander (PCF8575): // (A1 always 1!) #define I2C_ARDUIO_IO_1_ADR 0x44 // A2/0 = 0/0 //#define I2C_ARDUIO_IO_1_ADR 0x46 // A2/0 = 0/1 //#define I2C_ARDUIO_IO_1_ADR 0x4c // A2/0 = 1/0 //#define I2C_ARDUIO_IO_1_ADR 0x4e // A2/0 = 1/1 //#define I2C_ARDUIO_IO_2_ADR 0x44 // A2/0 = 0/0 #define I2C_ARDUIO_IO_2_ADR 0x46 // A2/0 = 0/1 //#define I2C_ARDUIO_IO_2_ADR 0x4c // A2/0 = 1/0 //#define I2C_ARDUIO_IO_2_ADR 0x4e // A2/0 = 1/1 //#define I2C_ARDUIO_IO_3_ADR 0x44 // A2/0 = 0/0 //#define I2C_ARDUIO_IO_3_ADR 0x46 // A2/0 = 0/1 #define I2C_ARDUIO_IO_3_ADR 0x4c // A2/0 = 1/0 //#define I2C_ARDUIO_IO_3_ADR 0x4e // A2/0 = 1/1 /*****************************************************************************/ // I2C A/D and D/A Converter (PCF8591): // (A1 always 1!) #define I2C_ARDUIO_AD_1_ADR 0x94 // A2/0 = 0/0 //#define I2C_ARDUIO_AD_1_ADR 0x96 // A2/0 = 0/1 //#define I2C_ARDUIO_AD_1_ADR 0x9c // A2/0 = 1/0 //#define I2C_ARDUIO_AD_1_ADR 0x9e // A2/0 = 1/1 //#define I2C_ARDUIO_AD_2_ADR 0x94 // A2/0 = 0/0 #define I2C_ARDUIO_AD_2_ADR 0x96 // A2/0 = 0/1 //#define I2C_ARDUIO_AD_2_ADR 0x9c // A2/0 = 1/0 //#define I2C_ARDUIO_AD_2_ADR 0x9e // A2/0 = 1/1 //#define I2C_ARDUIO_AD_3_ADR 0x94 // A2/0 = 0/0 //#define I2C_ARDUIO_AD_3_ADR 0x96 // A2/0 = 0/1 #define I2C_ARDUIO_AD_3_ADR 0x9c // A2/0 = 1/0 //#define I2C_ARDUIO_AD_3_ADR 0x9e // A2/0 = 1/1 /*****************************************************************************/ // UB Voltage Sensor: // (Connected to A/D and D/A Converter 1 (ADDA_1: IC11), AIN3 (AD13), // if jumper JP_AD-UB on the ArduIO Board is CLOSED!) #define ADCVAL_UB_LOW 175 // UB 6.9V /*****************************************************************************/ // LEDs: // (Status LED1..LED4 are connected to LED11..LED8 of the PCA9685!) #define CHLED1 12 #define CHLED2 11 #define CHLED3 10 #define CHLED4 9 /*****************************************************************************/ // PWM Ports: // (Ports PWM1..PWM4 are connected to LED15..LED12 of the PCA9685!) #define CHPWM1 16 #define CHPWM2 15 #define CHPWM3 14 #define CHPWM4 13 /*****************************************************************************/ // Power PWM Ports & H-Bridges: // (H-Bridges HB1/HB2 are connected to LED0..LED3/LED4..LED7 of the PCA9685!) // Power PWM Ports: #define CHPOWERPWM1_P 1 #define CHPOWERPWM2_N 2 #define CHPOWERPWM3_P 3 #define CHPOWERPWM4_N 4 #define CHPOWERPWM5_P 5 #define CHPOWERPWM6_N 6 #define CHPOWERPWM7_P 7 #define CHPOWERPWM8_N 8 // H-Bridges: #define CHHB1_P1 1 #define CHHB1_N1 2 #define CHHB1_P2 3 #define CHHB1_N2 4 #define CHHB2_P1 5 #define CHHB2_N1 6 #define CHHB2_P2 7 #define CHHB2_N2 8 /*****************************************************************************/ // Interrupt portpin definitions: // Select INTx portpin definitions depending on RP6_ArduIOConfig.h: #ifdef ARDUIO_RP6BASE // Interrupt I/O portpin definitions (RP6Base): #define IO_ARDUIO_INT1_IN E_INT1 // ADC4 PA4 XBUS Pin 8 #define IO_ARDUIO_INT1_DDR DDRA #define IO_ARDUIO_INT1_PIN PINA #define IO_ARDUIO_INT1_PORT PORTA #else #ifdef ARDUIO_RP6CONTROL // Interrupt I/O portpin definitions (RP6Control M32): #define IO_ARDUIO_INT1_IN EINT1 // INT0 PD2 XBUS Pin 8 #define IO_ARDUIO_INT1_DDR DDRD #define IO_ARDUIO_INT1_PIN PIND #define IO_ARDUIO_INT1_PORT PORTD #define IO_ARDUIO_INT2_IN EINT2 // INT1 PD3 XBUS Pin 11 #define IO_ARDUIO_INT2_DDR DDRD #define IO_ARDUIO_INT2_PIN PIND #define IO_ARDUIO_INT2_PORT PORTD #define IO_ARDUIO_INT3_IN EINT3 // AIN0/INT2 PB2 XBUS Pin 9 #define IO_ARDUIO_INT3_DDR DDRB #define IO_ARDUIO_INT3_PIN PINB #define IO_ARDUIO_INT3_PORT PORTB #else #ifdef ARDUIO_RP6M256WIFI // Interrupt I/O portpin definitions (RP6M256 WiFi): #define IO_ARDUIO_INT1_IN INT1_PI12 // PCINT12 PJ3 XBUS Pin 8 #define IO_ARDUIO_INT1_DDR DDRJ #define IO_ARDUIO_INT1_PIN PINJ #define IO_ARDUIO_INT1_PORT PORTJ #define IO_ARDUIO_INT2_IN INT2_PI15 // PCINT15 PJ6 XBUS Pin 11 #define IO_ARDUIO_INT2_DDR DDRJ #define IO_ARDUIO_INT2_PIN PINJ #define IO_ARDUIO_INT2_PORT PORTJ #define IO_ARDUIO_INT3_IN INT3_PI14 // PCINT14 PJ5 XBUS Pin 9 #define IO_ARDUIO_INT3_DDR DDRJ #define IO_ARDUIO_INT3_PIN PINJ #define IO_ARDUIO_INT3_PORT PORTJ #define IO_ARDUIO_INTU_IN INTU_PI13 // PCINT13 PJ4 XBUS Pin 7 #define IO_ARDUIO_INTU_DDR DDRJ #define IO_ARDUIO_INTU_PIN PINJ #define IO_ARDUIO_INTU_PORT PORTJ #else #error DEFINE "ARDUIO_RP6BASE", "ARDUIO_RP6CONTROL" OR "ARDUIO_RP6M256WIFI" #error AS TARGET IN RP6_ArduIOConfig.h #endif #endif #endif /*****************************************************************************/ /* Arduino Uno Expander definitions */ /*****************************************************************************/ // ATTENTION: Using this library you MAY NOT connect an Arduino Uno Board to // the RP6 ArduIO Board using the Arduino Uno Expander pin headers // on the ArduIO Board!!! // BE VERY CAREFUL: // You may damage the Arduino Uno AND your RP6 ArduIO Board! // // Of course you may connect Arduino ADDON boards (shields) to the // Arduino Uno Expander pin headers on the ArduIO Board. // BE VERY CAREFUL: // Not all Arduino shields will work on the RP6 ArduIO Board! // You may damage the Arduino shield AND your RP6 ArduIO Board! /*****************************************************************************/ // Arduino Uno Expander <-> RP6_ArduIO Mapping Table: // Arduino Uno: ATmega328: RP6_ArduIO: // Pin Function Pin Functions Pin Name IO ADDA // ----------------------------------------------------------- // 0 D0 RX PD0 RXD_PCINT16 P00 GP200 2 // 1 D1 TX PD1 TXD_PCINT17 P01 GP201 2 // 2 D2 PD2 INT0_PCINT18 P02 GP202 2 // 3 D3 PWM PD3 INT1_OC2B_PCINT19 P03 GP203 2 // 4 D4 PD4 T0_XCK_PCINT20 P04 GP204 2 // 5 D5 PWM PD5 T1_OC0B_PCINT21 P05 GP205 2 // 6 D6 PWM PD6 AIN0_OC0A_PCINT22 P06 GP206 2 // 7 D7 PD7 AIN1_PCINT23 P07 GP207 2 // 8 D8 PB0 ICP1_CLKO_PCINT0 P15 GP215 2 // 9 D9 PWM PB1 OC1A_PCINT1 P14 GP214 2 // 10 D10 PWM PB2 SS_OC1B_PCINT2 P13 GP213 2 // 11 D11 PWM PB3 MOSI_OC2A_PCINT13 P12 GP212 2 // 12 D12 PB4 MISO_PCINT4 P11 GP211 2 // 13 D13 PB5 SCK_PCINT5 P10 GP210 2 // // 0 A0 PC0 ADC0_PCINT8 AIN0 AD30 3 // 1 A1 PC1 ADC1_PCINT9 AIN1 AD31 3 // 2 A2 PC2 ADC2_PCINT10 AIN2 AD32 3 // 3 A3 PC3 ADC3_PCINT11 AIN3 AD33 3 // 4 A4 SDA PC4 ADC4_SDA_PCINT12 SDA // 5 A5 SCL PC5 ADC5_SCL_PCINT13 SCL // Arduino Uno Expander ATmega 328 portpin names: #define IO_ARD_D0_RXD_PCINT16 0 #define IO_ARD_D1_TXD_PCINT17 1 #define IO_ARD_D2_INT0_PCINT18 2 #define IO_ARD_D3_INT1_OC2B_PCINT19 3 #define IO_ARD_D4_T0_XCK_PCINT20 4 #define IO_ARD_D5_T1_OC0B_PCINT21 5 #define IO_ARD_D6_AIN0_OC0A_PCINT22 6 #define IO_ARD_D7_AIN1_PCINT23 7 #define IO_ARD_D8_ICP1_CLKO_PCINT0 8 #define IO_ARD_D9_OC1A_PCINT1 9 #define IO_ARD_D10_SS_OC1B_PCINT2 10 #define IO_ARD_D11_MOSI_OC2A_PCINT13 11 #define IO_ARD_D12_MISO_PCINT4 12 #define IO_ARD_D13_SCK_PCINT5 13 #define AD_ARD_A0_ADC0_PCINT8 0 #define AD_ARD_A1_ADC1_PCINT9 1 #define AD_ARD_A2_ADC2_PCINT10 2 #define AD_ARD_A3_ADC3_PCINT11 3 #define AD_ARD_A4_ADC4_SDA_PCINT12 4 #define AD_ARD_A5_ADC5_SCL_PCINT13 5 // Arduino Uno Expander portpin short definitions: #define IO_ARD_D0_RX 0 #define IO_ARD_D1_TX 1 #define IO_ARD_D2 2 #define IO_ARD_D3_PWM 3 #define IO_ARD_D4 4 #define IO_ARD_D5_PWM 5 #define IO_ARD_D6_PWM 6 #define IO_ARD_D7 7 #define IO_ARD_D8 8 #define IO_ARD_D9_PWM 9 #define IO_ARD_D10_PWM 10 #define IO_ARD_D11_PWM 11 #define IO_ARD_D12 12 #define IO_ARD_D13 13 #define AD_ARD_A0 0 #define AD_ARD_A1 1 #define AD_ARD_A2 2 #define AD_ARD_A3 3 #define AD_ARD_A4_SDA 4 #define AD_ARD_A5_SCL 5 /*****************************************************************************/ // Arduino Uno Expander read/write software examples: // 1. Writing to the digital portpins (D0..D13): // io2outs.ARD_D10 = true; // updateArduIO_IO2(); // Set D10 // io2outs.ARD_D8 = false; // updateArduIO_IO2(); // Clear D8 // setArduIO_IO2(0b0001000000000000); // Set D9 & clear all others // ==> Bit positions in the io2ins and io2outs word: // ==> 0b0000000000000000 // ==> | || | // ==> D8 |D7 D0 // ==> D13 // 2. Reading the digital portpins (D0..D13): // setArduIO_IO2(0b0011111111111111); // Set all portpins // ==> Hint: portpins can only be read, if they were SET before onetime!!! // task_readArduIO_IO2(); // Read D0..D13 // io_D0 = io2ins.ARD_D0; // This is D0 // io_D11 = io2ins.ARD_D11; // This is D11 // all_ios = io2ins.word & 0x3fff; // All portpins in 1 word // 3. Reading the analog portpins (A0..A3): // task_readArduIO_AD3(); // Read A0..A3 // adc_A0 = ad3ins.ARD_A0; // This is A0 // adc_A3 = ad3ins.ARD_A3; // This is A3 // 4. Reading all portpins and the interrupt signal: // task_Arduino_Uno_Exp(); // Read D0..D13, A0..A3 and // // PCF8575 (2) INT // int = interrupt_RP6ArduIOstatus.ioexp_2 // This is PCF8575 (2) INT // ==> Hint 1: This XBUS INT1 indicates a level change on D0..D13!!! // ==> Hint 2: If the variable interrupt_rp6arduiostatus_changed becomes // TRUE after execution of this task, INT1 has changed!!! // ==> Hint 3: Pins 1-2 of jumper JP_INT3V3 must be CLOSED!!! /*****************************************************************************/ /* Arduino Uno Expander definitions end */ /*****************************************************************************/ #endif /****************************************************************************** * Additional info * **************************************************************************** * Changelog: * * ---> changes are documented in the file "RP6_ArduIOLib.c" * * **************************************************************************** */ /*****************************************************************************/ // EOF
Library Header
Library Source
Erklärung
RP6 M256 WIFI
Config
Datei RP6_ArduIOConfig.h:
/** * Settings for the RP6_ArduIO Library */ #ifndef RP6_ARDUIOCONFIG_H #define RP6_ARDUIOCONFIG_H /** * Define the target here: * (Use only ONE of them! Never two or three!) */ //#define ARDUIO_RP6BASE //#define ARDUIO_RP6CONTROL #define ARDUIO_RP6M256WIFI #endif
Demo 1
Erklärung
Demo 2
Erklärung
Demo 3
Erklärung
RP6 CONTROL M32
Config
Datei RP6_ArduIOConfig.h:
/** * Settings for the RP6_ArduIO Library */ #ifndef RP6_ARDUIOCONFIG_H #define RP6_ARDUIOCONFIG_H /** * Define the target here: * (Use only ONE of them! Never two or three!) */ //#define ARDUIO_RP6BASE #define ARDUIO_RP6CONTROL //#define ARDUIO_RP6M256WIFI #endif
Demo 1
Erklärung
Demo 2
Erklärung
Demo 3
Erklärung
RP6 BASE
Config
Datei RP6_ArduIOConfig.h:
/** * Settings for the RP6_ArduIO Library */ #ifndef RP6_ARDUIOCONFIG_H #define RP6_ARDUIOCONFIG_H /** * Define the target here: * (Use only ONE of them! Never two or three!) */ #define ARDUIO_RP6BASE //#define ARDUIO_RP6CONTROL //#define ARDUIO_RP6M256WIFI #endif
Demo 1
Erklärung
Demo 2
Erklärung
Demo 3
Erklärung
RP6 CCPRO M128
ArduIO Library
Erklärung
Demo 1
Erklärung
Demo 2
Erklärung
Demo 3
Erklärung
Technische Informationen
Siehe auch
- RP6v2
- RP6
- RP6 - Programmierung
- RP6_Sensor_Board_und_Xtra_Module
- RP6 Kamera - Mitmach-Projekt
- RP6v2 I2C-Portexpander
- RP6v2 USB-RS232-Adapter
- RP6v2 Orientierung
- RP6 Multi IO Projekt
- RP6 Multi IO Projekt - Software
- RP6 ArduIO
- Induktive Ladestation für den RP6
- IR-bake für den RP6
- CCRP5
- Yeti
- Asuro
- C't-Bot
Weblinks
Umfangreiche Dokumentation, sämtliche Beispielprogramme und Bibliotheken, Daten, Teilelisten und eine Lötanleitung finden sich HIER.
HIER findet ihr den Hardware-Artikel.
Autoren
--Dirk 15:52, 16. Sep 2014 (CET)