diff --git a/Doc/Codigos_RS.doc b/Doc/Codigos_RS.doc new file mode 100644 index 0000000..8293dc9 Binary files /dev/null and b/Doc/Codigos_RS.doc differ diff --git a/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/9DOF-Razor-v21.pdf b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/9DOF-Razor-v21.pdf new file mode 100644 index 0000000..b176135 Binary files /dev/null and b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/9DOF-Razor-v21.pdf differ diff --git a/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/ADXL345.pdf b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/ADXL345.pdf new file mode 100644 index 0000000..25b879d Binary files /dev/null and b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/ADXL345.pdf differ diff --git a/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/Codigo_Ejemplo.txt b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/Codigo_Ejemplo.txt new file mode 100644 index 0000000..e2aeba7 --- /dev/null +++ b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/Codigo_Ejemplo.txt @@ -0,0 +1 @@ +https://github.com/ptrbrtz/razor-9dof-ahrs/wiki/Tutorial \ No newline at end of file diff --git a/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/HMC5883L-FDS.pdf b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/HMC5883L-FDS.pdf new file mode 100644 index 0000000..d51e8a2 Binary files /dev/null and b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/HMC5883L-FDS.pdf differ diff --git a/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/ITG-3200.pdf b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/ITG-3200.pdf new file mode 100644 index 0000000..36ab242 Binary files /dev/null and b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/ITG-3200.pdf differ diff --git a/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/SF9DOF_AHRS_ITG3200.rar b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/SF9DOF_AHRS_ITG3200.rar new file mode 100644 index 0000000..d9010d5 Binary files /dev/null and b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/SF9DOF_AHRS_ITG3200.rar differ diff --git a/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/SF9DOF_AHRS_ITG3200.zip b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/SF9DOF_AHRS_ITG3200.zip new file mode 100644 index 0000000..c6bbd63 Binary files /dev/null and b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/SF9DOF_AHRS_ITG3200.zip differ diff --git a/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/SparkFun-9DOF-Razor-IMU-Test-Firmware-master.zip b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/SparkFun-9DOF-Razor-IMU-Test-Firmware-master.zip new file mode 100644 index 0000000..0f0d9a7 Binary files /dev/null and b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/SparkFun-9DOF-Razor-IMU-Test-Firmware-master.zip differ diff --git "a/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/Tutorial \302\267 ptrbrtz_razor-9dof-ahrs Wiki.pdf" "b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/Tutorial \302\267 ptrbrtz_razor-9dof-ahrs Wiki.pdf" new file mode 100644 index 0000000..c75094a Binary files /dev/null and "b/Doc/DataSheet/9_DOF_Razor_ IMU_AHRS/Tutorial \302\267 ptrbrtz_razor-9dof-ahrs Wiki.pdf" differ diff --git a/Doc/DataSheet/ACS714/ACS714.pdf b/Doc/DataSheet/ACS714/ACS714.pdf new file mode 100644 index 0000000..bd71f31 Binary files /dev/null and b/Doc/DataSheet/ACS714/ACS714.pdf differ diff --git a/Doc/DataSheet/ACS714/ACS714_Main_CurrentSensing.pdf b/Doc/DataSheet/ACS714/ACS714_Main_CurrentSensing.pdf new file mode 100644 index 0000000..addd33c Binary files /dev/null and b/Doc/DataSheet/ACS714/ACS714_Main_CurrentSensing.pdf differ diff --git a/Doc/DataSheet/Arduino_MEGA2560/Arduino_MEGA2560_MCU.pdf b/Doc/DataSheet/Arduino_MEGA2560/Arduino_MEGA2560_MCU.pdf new file mode 100644 index 0000000..0e92ec7 Binary files /dev/null and b/Doc/DataSheet/Arduino_MEGA2560/Arduino_MEGA2560_MCU.pdf differ diff --git a/Doc/DataSheet/Arduino_MEGA2560/Arduino_MEGA2560_ref.brd b/Doc/DataSheet/Arduino_MEGA2560/Arduino_MEGA2560_ref.brd new file mode 100644 index 0000000..17f25c1 Binary files /dev/null and b/Doc/DataSheet/Arduino_MEGA2560/Arduino_MEGA2560_ref.brd differ diff --git a/Doc/DataSheet/Arduino_MEGA2560/Arduino_MEGA2560_ref.sch b/Doc/DataSheet/Arduino_MEGA2560/Arduino_MEGA2560_ref.sch new file mode 100644 index 0000000..700a868 Binary files /dev/null and b/Doc/DataSheet/Arduino_MEGA2560/Arduino_MEGA2560_ref.sch differ diff --git a/Doc/DataSheet/Arduino_MEGA2560/arduino-mega2560-reference-design.zip b/Doc/DataSheet/Arduino_MEGA2560/arduino-mega2560-reference-design.zip new file mode 100644 index 0000000..e0948db Binary files /dev/null and b/Doc/DataSheet/Arduino_MEGA2560/arduino-mega2560-reference-design.zip differ diff --git a/Doc/DataSheet/Arduino_MEGA2560/arduino-mega2560-schematic.pdf b/Doc/DataSheet/Arduino_MEGA2560/arduino-mega2560-schematic.pdf new file mode 100644 index 0000000..101e640 Binary files /dev/null and b/Doc/DataSheet/Arduino_MEGA2560/arduino-mega2560-schematic.pdf differ diff --git a/Doc/DataSheet/Bateria_LiPo/Fuente_Regulable_Potencia.doc b/Doc/DataSheet/Bateria_LiPo/Fuente_Regulable_Potencia.doc new file mode 100644 index 0000000..c3622d7 Binary files /dev/null and b/Doc/DataSheet/Bateria_LiPo/Fuente_Regulable_Potencia.doc differ diff --git a/Doc/DataSheet/Bateria_LiPo/Fuente_Regulable_Potencia.jpg b/Doc/DataSheet/Bateria_LiPo/Fuente_Regulable_Potencia.jpg new file mode 100644 index 0000000..94fc4c6 Binary files /dev/null and b/Doc/DataSheet/Bateria_LiPo/Fuente_Regulable_Potencia.jpg differ diff --git a/Doc/DataSheet/Bateria_LiPo/Indicador_Nivel_Carga.pdf b/Doc/DataSheet/Bateria_LiPo/Indicador_Nivel_Carga.pdf new file mode 100644 index 0000000..e58e1b8 Binary files /dev/null and b/Doc/DataSheet/Bateria_LiPo/Indicador_Nivel_Carga.pdf differ diff --git a/Doc/DataSheet/Bateria_LiPo/LinkMan_LK1008D.pdf b/Doc/DataSheet/Bateria_LiPo/LinkMan_LK1008D.pdf new file mode 100644 index 0000000..8d981db Binary files /dev/null and b/Doc/DataSheet/Bateria_LiPo/LinkMan_LK1008D.pdf differ diff --git a/Doc/DataSheet/Bateria_LiPo/calcular-capacidad-reserva-bateria-01.pdf b/Doc/DataSheet/Bateria_LiPo/calcular-capacidad-reserva-bateria-01.pdf new file mode 100644 index 0000000..c81d54f Binary files /dev/null and b/Doc/DataSheet/Bateria_LiPo/calcular-capacidad-reserva-bateria-01.pdf differ diff --git a/Doc/DataSheet/Bateria_LiPo/calcular-capacidad-reserva-bateria-02.jpg b/Doc/DataSheet/Bateria_LiPo/calcular-capacidad-reserva-bateria-02.jpg new file mode 100644 index 0000000..3535111 Binary files /dev/null and b/Doc/DataSheet/Bateria_LiPo/calcular-capacidad-reserva-bateria-02.jpg differ diff --git a/Doc/DataSheet/Bateria_LiPo/recomendaciones_lipo_01.pdf b/Doc/DataSheet/Bateria_LiPo/recomendaciones_lipo_01.pdf new file mode 100644 index 0000000..bd77ead Binary files /dev/null and b/Doc/DataSheet/Bateria_LiPo/recomendaciones_lipo_01.pdf differ diff --git a/Doc/DataSheet/Bateria_LiPo/recomendaciones_lipo_02.pdf b/Doc/DataSheet/Bateria_LiPo/recomendaciones_lipo_02.pdf new file mode 100644 index 0000000..6d27f48 Binary files /dev/null and b/Doc/DataSheet/Bateria_LiPo/recomendaciones_lipo_02.pdf differ diff --git a/Doc/DataSheet/Camaras_IP/BULLET HD PRO 1080P MINI VIDEO CAMARA.pdf b/Doc/DataSheet/Camaras_IP/BULLET HD PRO 1080P MINI VIDEO CAMARA.pdf new file mode 100644 index 0000000..01c1839 Binary files /dev/null and b/Doc/DataSheet/Camaras_IP/BULLET HD PRO 1080P MINI VIDEO CAMARA.pdf differ diff --git a/Doc/DataSheet/Camaras_IP/Camara_CPOECAMD36.pdf b/Doc/DataSheet/Camaras_IP/Camara_CPOECAMD36.pdf new file mode 100644 index 0000000..3e70140 Binary files /dev/null and b/Doc/DataSheet/Camaras_IP/Camara_CPOECAMD36.pdf differ diff --git a/Doc/DataSheet/Camaras_IP/Camara_DCS-5222L_B1_Datasheet_EN_EU.pdf b/Doc/DataSheet/Camaras_IP/Camara_DCS-5222L_B1_Datasheet_EN_EU.pdf new file mode 100644 index 0000000..96437c4 Binary files /dev/null and b/Doc/DataSheet/Camaras_IP/Camara_DCS-5222L_B1_Datasheet_EN_EU.pdf differ diff --git a/Doc/DataSheet/Camaras_IP/Camara_FI9821W_user_manual.pdf b/Doc/DataSheet/Camaras_IP/Camara_FI9821W_user_manual.pdf new file mode 100644 index 0000000..8f3c8b8 Binary files /dev/null and b/Doc/DataSheet/Camaras_IP/Camara_FI9821W_user_manual.pdf differ diff --git a/Doc/DataSheet/Camaras_IP/Camara_FI9826W_.pdf b/Doc/DataSheet/Camaras_IP/Camara_FI9826W_.pdf new file mode 100644 index 0000000..6dc8a99 Binary files /dev/null and b/Doc/DataSheet/Camaras_IP/Camara_FI9826W_.pdf differ diff --git a/Doc/DataSheet/Camaras_IP/Camara_apm-hp803-mpc-ws.pdf b/Doc/DataSheet/Camaras_IP/Camara_apm-hp803-mpc-ws.pdf new file mode 100644 index 0000000..2b3378e Binary files /dev/null and b/Doc/DataSheet/Camaras_IP/Camara_apm-hp803-mpc-ws.pdf differ diff --git a/Doc/DataSheet/Camaras_IP/Camara_vcw221_aug.pdf b/Doc/DataSheet/Camaras_IP/Camara_vcw221_aug.pdf new file mode 100644 index 0000000..7f05924 Binary files /dev/null and b/Doc/DataSheet/Camaras_IP/Camara_vcw221_aug.pdf differ diff --git a/Doc/DataSheet/Controlador_Motores_Puente_9A/Bricogeek_Driver_Motores_9A.pdf b/Doc/DataSheet/Controlador_Motores_Puente_9A/Bricogeek_Driver_Motores_9A.pdf new file mode 100644 index 0000000..78c77de Binary files /dev/null and b/Doc/DataSheet/Controlador_Motores_Puente_9A/Bricogeek_Driver_Motores_9A.pdf differ diff --git a/Doc/DataSheet/Controlador_Motores_Puente_9A/Controlador_Motores_Puente_9A.jpg b/Doc/DataSheet/Controlador_Motores_Puente_9A/Controlador_Motores_Puente_9A.jpg new file mode 100644 index 0000000..c44fca1 Binary files /dev/null and b/Doc/DataSheet/Controlador_Motores_Puente_9A/Controlador_Motores_Puente_9A.jpg differ diff --git a/Doc/DataSheet/Controlador_Motores_Puente_9A/FDS5672.pdf b/Doc/DataSheet/Controlador_Motores_Puente_9A/FDS5672.pdf new file mode 100644 index 0000000..8367660 Binary files /dev/null and b/Doc/DataSheet/Controlador_Motores_Puente_9A/FDS5672.pdf differ diff --git a/Doc/DataSheet/Controlador_Motores_Puente_9A/Tabla_Control.jpg b/Doc/DataSheet/Controlador_Motores_Puente_9A/Tabla_Control.jpg new file mode 100644 index 0000000..519b90d Binary files /dev/null and b/Doc/DataSheet/Controlador_Motores_Puente_9A/Tabla_Control.jpg differ diff --git a/Doc/DataSheet/Controlador_Motores_Puente_9A/www.pololu.com_product_756.pdf b/Doc/DataSheet/Controlador_Motores_Puente_9A/www.pololu.com_product_756.pdf new file mode 100644 index 0000000..e9d6f75 Binary files /dev/null and b/Doc/DataSheet/Controlador_Motores_Puente_9A/www.pololu.com_product_756.pdf differ diff --git a/Doc/DataSheet/DTM8870_Ejemplo/8870_Arduino.pdf b/Doc/DataSheet/DTM8870_Ejemplo/8870_Arduino.pdf new file mode 100644 index 0000000..14654a5 Binary files /dev/null and b/Doc/DataSheet/DTM8870_Ejemplo/8870_Arduino.pdf differ diff --git a/Doc/DataSheet/DTM8870_Ejemplo/MT8870.pdf b/Doc/DataSheet/DTM8870_Ejemplo/MT8870.pdf new file mode 100644 index 0000000..ae5a410 Binary files /dev/null and b/Doc/DataSheet/DTM8870_Ejemplo/MT8870.pdf differ diff --git a/Doc/DataSheet/DTM8870_Ejemplo/MT8888.pdf b/Doc/DataSheet/DTM8870_Ejemplo/MT8888.pdf new file mode 100644 index 0000000..7865d50 Binary files /dev/null and b/Doc/DataSheet/DTM8870_Ejemplo/MT8888.pdf differ diff --git a/Doc/DataSheet/DTM8870_Ejemplo/untitled.png b/Doc/DataSheet/DTM8870_Ejemplo/untitled.png new file mode 100644 index 0000000..2c324d0 Binary files /dev/null and b/Doc/DataSheet/DTM8870_Ejemplo/untitled.png differ diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/HCMS-29xx_Series.pdf b/Doc/DataSheet/Display_Avago_HCMS_xx/HCMS-29xx_Series.pdf new file mode 100644 index 0000000..af945a9 Binary files /dev/null and b/Doc/DataSheet/Display_Avago_HCMS_xx/HCMS-29xx_Series.pdf differ diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay Arduino Library, using Avago HCMS-29xx displays with Teensy.pdf b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay Arduino Library, using Avago HCMS-29xx displays with Teensy.pdf new file mode 100644 index 0000000..423b0cb Binary files /dev/null and b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay Arduino Library, using Avago HCMS-29xx displays with Teensy.pdf differ diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay.zip b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay.zip new file mode 100644 index 0000000..ccb22a8 Binary files /dev/null and b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay.zip differ diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/HCMS-29xx.fzpz b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/HCMS-29xx.fzpz new file mode 100644 index 0000000..1daf289 Binary files /dev/null and b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/HCMS-29xx.fzpz differ diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/LedDisplay.cpp b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/LedDisplay.cpp new file mode 100644 index 0000000..6a7231b --- /dev/null +++ b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/LedDisplay.cpp @@ -0,0 +1,296 @@ +/* + LedDisplay -- controller library for Avago HCMS-297x displays -- version 0.2 + + Copyright (c) 2009 Tom Igoe. Some right reserved. + + Revisions on version 0.2 and 0.3 by Mark Liebman, 27 Jan 2010 + * extended a bit to support up to four (4) 8 character displays. + + Controls an Avago HCMS29xx display. This display has 8 characters, each 5x7 LEDs + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +*/ + + +#include "LedDisplay.h" + +// Pascal Stang's 5x7 font library: +#include "font5x7.h" +// The font library is stored in program memory: +#include +#include + +/* + * Constructor. Initializes the pins and the instance variables. + */ +LedDisplay::LedDisplay(uint8_t _dataPin, + uint8_t _registerSelect, + uint8_t _clockPin, + uint8_t _chipEnable, + uint8_t _resetPin, + uint8_t _displayLength) +{ + // Define pins for the LED display: + this->dataPin = _dataPin; // connects to the display's data in + this->registerSelect = _registerSelect; // the display's register select pin + this->clockPin = _clockPin; // the display's clock pin + this->chipEnable = _chipEnable; // the display's chip enable pin + this->resetPin = _resetPin; // the display's reset pin + this->displayLength = _displayLength; // number of bytes needed to pad the string + this->cursorPos = 0; // position of the cursor in the display + char stringBuffer[displayLength+1]; // default array that the displayString will point to + + // fill stringBuffer with spaces, and a trailing 0: + for (int i = 0; i < displayLength; i++) { + stringBuffer[i] = ' '; + } + stringBuffer[displayLength] = '\0'; + + this->setString(stringBuffer); // give displayString a default buffer +} + +/* + * Initialize the display. + */ + +void LedDisplay::begin() { + // set pin modes for connections: + pinMode(dataPin, OUTPUT); + pinMode(registerSelect, OUTPUT); + pinMode(clockPin, OUTPUT); + pinMode(chipEnable, OUTPUT); + pinMode(resetPin, OUTPUT); + + // reset the display: + digitalWrite(resetPin, LOW); + delay(10); + digitalWrite(resetPin, HIGH); + + // load dot register with lows + loadDotRegister(); + + loadControlRegister(B10000001); // set serial mode. see table 1, footnote 1 + // set control register 0 for max brightness, and no sleep: + // added: ML send multiple inits to 2nd, 3rd, 4th display, etc. + // set control register 0 for max brightness, and no sleep: + loadControlRegister(B01111111); + loadControlRegister(B01111111); + loadControlRegister(B01111111); + loadControlRegister(B01111111); + loadControlRegister(B01111111); + loadControlRegister(B01111111); + loadControlRegister(B01111111); + // set control register 1 so all 8 characters display: + // loadControlRegister(B10000001); + + + +} + +/* + * Clear the display + */ + +void LedDisplay::clear() { + for (int displayPos = 0; displayPos < displayLength; displayPos++) { + char charToShow = ' '; + // put the character in the dot register: + writeCharacter(charToShow, displayPos); + } + + // send the dot register array out to the display: + loadDotRegister(); +} + + +/* + * set the cursor to the home position (0) + */ +void LedDisplay::home() { + // set the cursor to the upper left corner: + this->cursorPos = 0; +} + +/* + * set the cursor anywhere + */ +void LedDisplay::setCursor(int whichPosition){ + this->cursorPos = whichPosition; +} + +/* + * return the cursor position + */ + +int LedDisplay::getCursor() { + return this->cursorPos; +} + +/* + * write a byte out to the display at the cursor position, + * and advance the cursor position. + */ + +#if ARDUINO >= 100 +size_t LedDisplay::write(uint8_t b) { +#else +void LedDisplay::write(uint8_t b) { +#endif + // make sure cursorPos is on the display: + if (cursorPos >= 0 && cursorPos < displayLength) { + // put the character into the dot register: + writeCharacter(b, cursorPos); + // put the character into the displayString: + if (cursorPos < this->stringLength()) { + this->displayString[cursorPos] = b; + } + cursorPos++; + // send the dot register array out to the display: + loadDotRegister(); + } +#if ARDUINO >= 100 + return 1; +#endif +} + + +/* + * Scroll the displayString across the display. left = -1, right = +1 + */ + + +void LedDisplay::scroll(int direction) { + clear(); + cursorPos += direction; + // Loop over the string and take displayLength characters to write to the display: + for (int displayPos = 0; displayPos < displayLength; displayPos++) { + // which character in the strings you want: + int whichCharacter = displayPos - cursorPos; + // length of the string to display: + int stringEnd = strlen(displayString); + // which character you want to show from the string: + char charToShow; + // display the characters until you have no more: + if ((whichCharacter >= 0) && (whichCharacter < stringEnd)) { + charToShow = displayString[whichCharacter]; + } + // if none of the above, show a space: + else { + charToShow = ' '; + } + // put the character in the dot register: + writeCharacter(charToShow, displayPos); + } + // send the dot register array out to the display: + loadDotRegister(); +} + + +/* + * set displayString + */ + +void LedDisplay::setString(char* _displayString) { + this->displayString = _displayString; +} + + +/* + * return displayString + */ + +char* LedDisplay::getString() { + return displayString; +} + + +/* + * return displayString length + */ + + +int LedDisplay::stringLength() { + return strlen(displayString); +} + + + +/* + * set brightness (0 - 15) + */ + + +void LedDisplay::setBrightness(uint8_t bright) +{ + // set the brightness: + loadControlRegister(B01110000 + bright); +} + + +/* this method loads bits into the dot register array. It doesn't + * actually communicate with the display at all, + * it just prepares the data: +*/ + +void LedDisplay::writeCharacter(char whatCharacter, byte whatPosition) { + // calculate the starting position in the array. + // every character has 5 columns made of 8 bits: + byte thisPosition = whatPosition * 5; + + // copy the appropriate bits into the dot register array: + for (int i = 0; i < 5; i++) { + dotRegister[thisPosition+i] = (pgm_read_byte(&Font5x7[((whatCharacter - 0x20) * 5) + i])); + } +} + + +// This method sends 8 bits to one of the control registers: +void LedDisplay::loadControlRegister(int dataByte) { + // select the control registers: + digitalWrite(registerSelect, HIGH); + // enable writing to the display: + digitalWrite(chipEnable, LOW); + // shift the data out: + shiftOut(dataPin, clockPin, MSBFIRST, dataByte); + // disable writing: + digitalWrite(chipEnable, HIGH); +} + +// this method originally sent 320 bits to the dot register: 12_30_09 ML +void LedDisplay::loadDotRegister() { + + // define max data to send, patch for 4 length displays by KaR]V[aN + int maxData = displayLength * 5; + + // select the dot register: + digitalWrite(registerSelect, LOW); + // enable writing to the display: + digitalWrite(chipEnable, LOW); + // shift the data out: + for (int i = 0; i < maxData; i++) { + shiftOut(dataPin, clockPin, MSBFIRST, dotRegister[i]); + } + // disable writing: + digitalWrite(chipEnable, HIGH); +} + +/* + version() returns the version of the library: +*/ +int LedDisplay::version(void) +{ + return 4; +} diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/LedDisplay.h b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/LedDisplay.h new file mode 100644 index 0000000..c9fc50c --- /dev/null +++ b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/LedDisplay.h @@ -0,0 +1,118 @@ +/* + LedDisplay -- controller library for Avago HCMS-297x displays -- version 0.3 + 27 Jan 2010 ML: extended a bit to support up to four (4) 8 character displays. + + Copyright (c) 2009 Tom Igoe. Some right reserved. + + Revisions on version 0.2 and 0.3 by Mark Liebman, 27 Jan 2010 + * extended a bit to support up to four (4) 8 character displays. + + + Controls an Avago HCMS29xx display. This display has 8 characters, each 5x7 LEDs + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Version changes: + * Version 3 adds support for multiple displays. Just change the displayLength to + the total number of characters (for example, 3 8-character displays, displayLength = 24). + +*/ + + +// ensure this library description is only included once +#ifndef LedDisplay_h +#define LedDisplay_h + +// include types & constants of Wiring core API +#if ARDUINO >= 100 +#include "Arduino.h" +#else +#include "WProgram.h" +#endif + +// Pascal Stang's 5x7 font library: +#include "font5x7.h" +// The font library is stored in prgram memory: +#include +// string functions used to manipulate strings: +#include + +// Arduino Print library provides print() and println() functionality +#include "Print.h" + +// library interface description + +class LedDisplay : public Print { + public: + // constructor: + LedDisplay(uint8_t _dataPin, + uint8_t _registerSelect, + uint8_t _clockPin, + uint8_t _chipEnable, + uint8_t _resetPin, + uint8_t _displayLength); + + + // initializer method: + void begin(); + + void clear(); // clear the display + void home(); // set cursor to far left hand position + void setCursor(int whichPosition); // set cursor to any position + int getCursor(); // get the cursor position + +#if ARDUINO >= 100 + virtual size_t write(uint8_t b); // write a character to the display and advance cursor +#else + virtual void write(uint8_t b); // write a character to the display and advance cursor +#endif + using Print::write; + + void setString(char* _stringToDisplay); // set the displayString variable + char* getString(); // get the displayString + int stringLength(); // get the length of displayString + + void scroll(int direction); // scroll whatever string is stored in library's displayString variable + + void setBrightness(uint8_t bright); // set display brightness, 0 - 15 + + // Control register setters. for addressing the display directly: + void loadControlRegister(int dataByte); + void loadDotRegister(); + + int version(void); // return library version + + private: + // Character display setters: + void writeCharacter(char whatCharacter, byte whatPosition); // write a character to a buffer which will + // be sent to the display by loadDotRegister() + + int cursorPos; // position of the cursor +// uint8_t dotRegister[40]; // the 320-bit dot register for a single 8 digit LED display +// uint8_t dotRegister[80]; // the pair of 320-bit dot register for two 8 character LED displays + uint8_t dotRegister[160]; // four 320-bit dot registers. 320 for each 8 character LED display + + // Define pins for the LED display: + uint8_t dataPin; // connects to the display's data in + uint8_t registerSelect; // the display's register select pin + uint8_t clockPin; // the display's clock pin + uint8_t chipEnable; // the display's chip enable pin + uint8_t resetPin; // the display's reset pin + uint8_t displayLength; // number of bytes needed to pad the string + char* displayString; // string for scrolling +}; + +#endif + diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_fade/LedDisplay_fade.pde b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_fade/LedDisplay_fade.pde new file mode 100644 index 0000000..2196812 --- /dev/null +++ b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_fade/LedDisplay_fade.pde @@ -0,0 +1,64 @@ +/* + HCMS29xx Display + Language: Arduino/Wiring + + Displays a string on an Avago HCMS-297x display + and fades it up and down. + + http://wiring.org.co/learning/reference/String.html + + created 10 Apr 2009 + modified 11 March 2010 + by Tom Igoe + + */ +#include + +// Define pins for the LED display. +// You can change these, just re-wire your board: +#define dataPin 2 // connects to the display's data in +#define registerSelect 3 // the display's register select pin +#define clockPin 4 // the display's clock pin +#define enable 5 // the display's chip enable pin +#define reset 6 // the display's reset pin + +#define displayLength 8 // number of characters in the display + +// create am instance of the LED display library: +LedDisplay myDisplay = LedDisplay(dataPin, registerSelect, clockPin, +enable, reset, displayLength); + +int brightness = 15; // screen brightness + +void setup() { + Serial.begin(9600); + + // initialize the display library: + myDisplay.begin(); +} + +void loop() { + + for (int brightness = 0; brightness < 16; brightness++) { + // set the display string brightness: + myDisplay.setBrightness(brightness); + // set the cursor to position 1: + myDisplay.setCursor(1); + // print to the display: + myDisplay.print("Fading"); + delay(50); + } + delay(100); + + for (int brightness = 15; brightness >= 0; brightness--) { + // set the display string brightness: + myDisplay.setBrightness(brightness); + // set the cursor to position 1: + myDisplay.setCursor(1); + // print to the display: + myDisplay.print("Fading"); + delay(50); + } + + delay(300); +} diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_print/LedDisplay_print.pde b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_print/LedDisplay_print.pde new file mode 100644 index 0000000..83f9f33 --- /dev/null +++ b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_print/LedDisplay_print.pde @@ -0,0 +1,46 @@ +/* + HCMS Display + Language: Arduino/Wiring + + Displays a string on an Avago HCMS-297x display + + String library based on the Wiring String library: + http://wiring.org.co/learning/reference/String.html + + created 12 Jun. 2008 + modified 11 March 2010 + by Tom Igoe + + */ +#include + +// Define pins for the LED display. +// You can change these, just re-wire your board: +#define dataPin 2 // connects to the display's data in +#define registerSelect 3 // the display's register select pin +#define clockPin 4 // the display's clock pin +#define enable 5 // the display's chip enable pin +#define reset 6 // the display's reset pin + +#define displayLength 8 // number of characters in the display + +// create am instance of the LED display library: +LedDisplay myDisplay = LedDisplay(dataPin, registerSelect, clockPin, +enable, reset, displayLength); + +int brightness = 15; // screen brightness + +void setup() { + // initialize the display library: + myDisplay.begin(); + // set the brightness of the display: + myDisplay.setBrightness(brightness); +} + +void loop() { + // set the cursor to 0: + myDisplay.home(); + // print the millis: + myDisplay.print("ms:"); + myDisplay.print(millis()); +} diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_printAnalog/.DS_Store b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_printAnalog/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_printAnalog/.DS_Store differ diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_printAnalog/LedDisplay_printAnalog.pde b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_printAnalog/LedDisplay_printAnalog.pde new file mode 100644 index 0000000..589cd99 --- /dev/null +++ b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_printAnalog/LedDisplay_printAnalog.pde @@ -0,0 +1,47 @@ +/* + HCMS Display + Language: Arduino/Wiring + + Displays an analog value on an Avago HCMS-297x display + + String library based on the Wiring String library: + http://wiring.org.co/learning/reference/String.html + + created 12 Jun. 2008 + modified 17 Apr 2009 + by Tom Igoe + + */ +#include + +// Define pins for the LED display. +// You can change these, just re-wire your board: +#define dataPin 2 // connects to the display's data in +#define registerSelect 3 // the display's register select pin +#define clockPin 4 // the display's clock pin +#define enable 5 // the display's chip enable pin +#define reset 6 // the display's reset pin + +#define displayLength 8 // number of characters in the display + +// create am instance of the LED display library: +LedDisplay myDisplay = LedDisplay(dataPin, registerSelect, clockPin, +enable, reset, displayLength); + +int brightness = 15; // screen brightness + +void setup() { + // initialize the display library: + myDisplay.begin(); + // set the brightness of the display: + myDisplay.setBrightness(brightness); + Serial.begin(9600); + Serial.println(myDisplay.version(), DEC); +} + +void loop() { + // set the cursor to 1: + myDisplay.setCursor(1); + myDisplay.print("A0: "); + myDisplay.print(analogRead(0), DEC); +} diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_scroll/LedDisplay_scroll.pde b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_scroll/LedDisplay_scroll.pde new file mode 100644 index 0000000..b47a906 --- /dev/null +++ b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_scroll/LedDisplay_scroll.pde @@ -0,0 +1,57 @@ +/* + HCMS Display + Language: Arduino/Wiring + + Displays a string on an Avago HCMS-297x display. + Scrolls the string left and right. + + created 12 Jun. 2008 + modified 11 March 2010 + by Tom Igoe + + */ +#include + +// Define pins for the LED display. +// You can change these, just re-wire your board: +#define dataPin 2 // connects to the display's data in +#define registerSelect 3 // the display's register select pin +#define clockPin 4 // the display's clock pin +#define enable 5 // the display's chip enable pin +#define reset 6 // the display's reset pin + +#define displayLength 8 // number of characters in the display + + +// create am instance of the LED display: +LedDisplay myDisplay = LedDisplay(dataPin, registerSelect, clockPin, +enable, reset, displayLength); + +int brightness = 15; // screen brightness +int myDirection = 1; // direction of scrolling. -1 = left, 1 = right. + +void setup() { + Serial.begin(9600); + // initialize the display library: + myDisplay.begin(); + myDisplay.clear(); + myDisplay.setString("weasels smell funny!"); + myDisplay.setBrightness(brightness); + delay(100); +} + +void loop() { + + // when the string scrolls off the display, reverse scroll direction. + // On the right, it scrolls off at position 8. + // on the left, it scrolls off when the cursor is less than -(the length of the string): + if ((myDisplay.getCursor() > displayLength) || + (myDisplay.getCursor() <= -(myDisplay.stringLength()))) { + myDirection = -myDirection; + delay(1000); + } + + // scroll: + myDisplay.scroll(myDirection); + delay(100); +} diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_scroll_multiple/LedDisplay_scroll_multiple.pde b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_scroll_multiple/LedDisplay_scroll_multiple.pde new file mode 100644 index 0000000..2a53b45 --- /dev/null +++ b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_scroll_multiple/LedDisplay_scroll_multiple.pde @@ -0,0 +1,57 @@ +/* + HCMS Display + Language: Arduino/Wiring + + Displays a string on three Avago HCMS-297x displays. + Scrolls the string left and right. + + created 12 Jun. 2008 + modified 11 March 2010 + by Tom Igoe + + */ +#include + +// Define pins for the LED display. +// You can change these, just re-wire your board: +#define dataPin 2 // connects to the display's data in +#define registerSelect 3 // the display's register select pin +#define clockPin 4 // the display's clock pin +#define enable 5 // the display's chip enable pin +#define reset 6 // the display's reset pin + +#define displayLength 24 // total number of characters in all three displays + + +// create am instance of the LED display: +LedDisplay myDisplay = LedDisplay(dataPin, registerSelect, clockPin, +enable, reset, displayLength); + +int brightness = 15; // screen brightness +int myDirection = 1; // direction of scrolling. -1 = left, 1 = right. + +void setup() { + Serial.begin(9600); + // initialize the display library: + myDisplay.begin(); + myDisplay.clear(); + myDisplay.setString("Aardvarks mark the park after dark."); + myDisplay.setBrightness(brightness); + delay(100); +} + +void loop() { + + // when the string scrolls off the display, reverse scroll direction. + // On the right, it scrolls off at position 8. + // on the left, it scrolls off when the cursor is less than -(the length of the string): + if ((myDisplay.getCursor() > displayLength) || + (myDisplay.getCursor() <= -(myDisplay.stringLength()))) { + myDirection = -myDirection; + delay(1000); + } + + // scroll: + myDisplay.scroll(myDirection); + delay(100); +} diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_scroll_serial/LedDisplay_scroll_serial.pde b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_scroll_serial/LedDisplay_scroll_serial.pde new file mode 100644 index 0000000..da57286 --- /dev/null +++ b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_scroll_serial/LedDisplay_scroll_serial.pde @@ -0,0 +1,96 @@ +/* + HCMS Display + Language: Arduino/Wiring + + Displays a string on an Avago HCMS-297x display + Scrolls the current display string as well. + Anything you send in the serial port is displayed + when the Arduino receives a newline or carriage return. + + String library based on the Wiring String library: + http://wiring.org.co/learning/reference/String.html + + created 12 Jun. 2008 + modified 11 March 2010 + by Tom Igoe + + */ +#include +#include + +#define maxStringLength 180 // max string length + +// Define pins for the LED display. +// You can change these, just re-wire your board: +#define dataPin 2 // connects to the display's data in +#define registerSelect 3 // the display's register select pin +#define clockPin 4 // the display's clock pin +#define enable 5 // the display's chip enable pin +#define reset 6 // the display's reset pin + +#define displayLength 8 // number of chars in the display + +// create am instance of the LED display: +LedDisplay myDisplay = LedDisplay(dataPin, registerSelect, clockPin, +enable, reset, displayLength); + +int brightness = 15; // screen brightness + +int myDirection = 1; // direction of scrolling. -1 = left, 1 = right. + +String displayString; // the string currently being displayed +String bufferString; // the buffer for receiving incoming characters + +void setup() { + Serial.begin(9600); + // set an initial string to display: + displayString = "Hello World!"; + + // initialize the display library: + myDisplay.begin(); + // set the display string, speed,and brightness: + myDisplay.setString(displayString); + myDisplay.setBrightness(brightness); +} + +void loop() { + // get new data in from the serial port: + while (Serial.available()>0) { + // read in new serial: + getSerial(); + }  + + // srcoll left and right: + if ((myDisplay.getCursor() > 8) || + (myDisplay.getCursor() <= -(myDisplay.stringLength()))) { + myDirection = -myDirection; + delay(1000); + } + myDisplay.scroll(myDirection); + delay(100); + +} + +void getSerial() { + // get a new byte in the serial port: + int inByte = Serial.read(); + switch (inByte) { + case '\n': +: + // if you get a newline, + // copy the buffer into the displayString: + displayString = bufferString; + // set the display with the new string: + myDisplay.setString(displayString); + // clear the buffer: + bufferString = ""; + break; + default: + // if you get any ASCII alphanumeric value + // (i.e. anything greater than a space), add it to the buffer: + if (inByte >= ' ') { + bufferString.append(char(inByte)); + } + break; + } +} diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_writeCharacters/LedDisplay_writeCharacters.pde b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_writeCharacters/LedDisplay_writeCharacters.pde new file mode 100644 index 0000000..7444be8 --- /dev/null +++ b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/examples/LedDisplay_writeCharacters/LedDisplay_writeCharacters.pde @@ -0,0 +1,58 @@ +/* + HCMS Display + Language: Arduino/Wiring + + Writes characters on an Avago HCMS-297x display + + String library based on the Wiring String library: + http://wiring.org.co/learning/reference/String.html + + created 12 Jun. 2008 + modified 11 March 2010 + by Tom Igoe + + */ +#include + +// Define pins for the LED display. +// You can change these, just re-wire your board: +#define dataPin 2 // connects to the display's data in +#define registerSelect 3 // the display's register select pin +#define clockPin 4 // the display's clock pin +#define enable 5 // the display's chip enable pin +#define reset 6 // the display's reset pin + +#define displayLength 8 // number of bytes needed to pad the string + +// create am instance of the LED display: +LedDisplay myDisplay = LedDisplay(dataPin, registerSelect, clockPin, +enable, reset, displayLength); + +int brightness = 15; // screen brightness +char myString[] = { + 'p','r','i','n','t','i','n','g'}; +void setup() { + Serial.begin(9600); + + // initialize the display library: + myDisplay.begin(); + myDisplay.setString("Printing"); + myDisplay.home(); + myDisplay.setBrightness(brightness); +} + +void loop() { + + for (int thisPosition = 0; thisPosition < 8; thisPosition++) { + for (int thisChar = ' '; thisChar < 'z'; thisChar++) { + myDisplay.write(thisChar); + myDisplay.setCursor(thisPosition); + delay(3); + } + myDisplay.write(myString[thisPosition]); + delay(10); + } + delay(500); + myDisplay.clear(); + myDisplay.home(); +} diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/font5x7.h b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/font5x7.h new file mode 100644 index 0000000..88a9bb3 --- /dev/null +++ b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/font5x7.h @@ -0,0 +1,119 @@ +/*! \file font5x7.h \brief Graphic LCD Font (Ascii Characters). */ +//***************************************************************************** +// +// File Name : 'font5x7.h' +// Title : Graphic LCD Font (Ascii Charaters) +// Author : Pascal Stang +// Date : 10/19/2001 +// Revised : 10/19/2001 +// Version : 0.1 +// Target MCU : Atmel AVR +// Editor Tabs : 4 +// +//***************************************************************************** + +#ifndef FONT5X7_H +#define FONT5X7_H + +// standard ascii 5x7 font +// defines ascii characters 0x20-0x7F (32-127) +static unsigned char __attribute__ ((progmem)) Font5x7[] = { + 0x00, 0x00, 0x00, 0x00, 0x00,// (space) + 0x00, 0x00, 0x5F, 0x00, 0x00,// ! + 0x00, 0x07, 0x00, 0x07, 0x00,// " + 0x14, 0x7F, 0x14, 0x7F, 0x14,// # + 0x24, 0x2A, 0x7F, 0x2A, 0x12,// $ + 0x23, 0x13, 0x08, 0x64, 0x62,// % + 0x36, 0x49, 0x55, 0x22, 0x50,// & + 0x00, 0x05, 0x03, 0x00, 0x00,// ' + 0x00, 0x1C, 0x22, 0x41, 0x00,// ( + 0x00, 0x41, 0x22, 0x1C, 0x00,// ) + 0x08, 0x2A, 0x1C, 0x2A, 0x08,// * + 0x08, 0x08, 0x3E, 0x08, 0x08,// + + 0x00, 0x50, 0x30, 0x00, 0x00,// , + 0x08, 0x08, 0x08, 0x08, 0x08,// - + 0x00, 0x60, 0x60, 0x00, 0x00,// . + 0x20, 0x10, 0x08, 0x04, 0x02,// / + 0x3E, 0x51, 0x49, 0x45, 0x3E,// 0 + 0x00, 0x42, 0x7F, 0x40, 0x00,// 1 + 0x42, 0x61, 0x51, 0x49, 0x46,// 2 + 0x21, 0x41, 0x45, 0x4B, 0x31,// 3 + 0x18, 0x14, 0x12, 0x7F, 0x10,// 4 + 0x27, 0x45, 0x45, 0x45, 0x39,// 5 + 0x3C, 0x4A, 0x49, 0x49, 0x30,// 6 + 0x01, 0x71, 0x09, 0x05, 0x03,// 7 + 0x36, 0x49, 0x49, 0x49, 0x36,// 8 + 0x06, 0x49, 0x49, 0x29, 0x1E,// 9 + 0x00, 0x36, 0x36, 0x00, 0x00,// : + 0x00, 0x56, 0x36, 0x00, 0x00,// ; + 0x00, 0x08, 0x14, 0x22, 0x41,// < + 0x14, 0x14, 0x14, 0x14, 0x14,// = + 0x41, 0x22, 0x14, 0x08, 0x00,// > + 0x02, 0x01, 0x51, 0x09, 0x06,// ? + 0x32, 0x49, 0x79, 0x41, 0x3E,// @ + 0x7E, 0x11, 0x11, 0x11, 0x7E,// A + 0x7F, 0x49, 0x49, 0x49, 0x36,// B + 0x3E, 0x41, 0x41, 0x41, 0x22,// C + 0x7F, 0x41, 0x41, 0x22, 0x1C,// D + 0x7F, 0x49, 0x49, 0x49, 0x41,// E + 0x7F, 0x09, 0x09, 0x01, 0x01,// F + 0x3E, 0x41, 0x41, 0x51, 0x32,// G + 0x7F, 0x08, 0x08, 0x08, 0x7F,// H + 0x00, 0x41, 0x7F, 0x41, 0x00,// I + 0x20, 0x40, 0x41, 0x3F, 0x01,// J + 0x7F, 0x08, 0x14, 0x22, 0x41,// K + 0x7F, 0x40, 0x40, 0x40, 0x40,// L + 0x7F, 0x02, 0x04, 0x02, 0x7F,// M + 0x7F, 0x04, 0x08, 0x10, 0x7F,// N + 0x3E, 0x41, 0x41, 0x41, 0x3E,// O + 0x7F, 0x09, 0x09, 0x09, 0x06,// P + 0x3E, 0x41, 0x51, 0x21, 0x5E,// Q + 0x7F, 0x09, 0x19, 0x29, 0x46,// R + 0x46, 0x49, 0x49, 0x49, 0x31,// S + 0x01, 0x01, 0x7F, 0x01, 0x01,// T + 0x3F, 0x40, 0x40, 0x40, 0x3F,// U + 0x1F, 0x20, 0x40, 0x20, 0x1F,// V + 0x7F, 0x20, 0x18, 0x20, 0x7F,// W + 0x63, 0x14, 0x08, 0x14, 0x63,// X + 0x03, 0x04, 0x78, 0x04, 0x03,// Y + 0x61, 0x51, 0x49, 0x45, 0x43,// Z + 0x00, 0x00, 0x7F, 0x41, 0x41,// [ + 0x02, 0x04, 0x08, 0x10, 0x20,// "\" + 0x41, 0x41, 0x7F, 0x00, 0x00,// ] + 0x04, 0x02, 0x01, 0x02, 0x04,// ^ + 0x40, 0x40, 0x40, 0x40, 0x40,// _ + 0x00, 0x01, 0x02, 0x04, 0x00,// ` + 0x20, 0x54, 0x54, 0x54, 0x78,// a + 0x7F, 0x48, 0x44, 0x44, 0x38,// b + 0x38, 0x44, 0x44, 0x44, 0x20,// c + 0x38, 0x44, 0x44, 0x48, 0x7F,// d + 0x38, 0x54, 0x54, 0x54, 0x18,// e + 0x08, 0x7E, 0x09, 0x01, 0x02,// f + 0x08, 0x14, 0x54, 0x54, 0x3C,// g + 0x7F, 0x08, 0x04, 0x04, 0x78,// h + 0x00, 0x44, 0x7D, 0x40, 0x00,// i + 0x20, 0x40, 0x44, 0x3D, 0x00,// j + 0x00, 0x7F, 0x10, 0x28, 0x44,// k + 0x00, 0x41, 0x7F, 0x40, 0x00,// l + 0x7C, 0x04, 0x18, 0x04, 0x78,// m + 0x7C, 0x08, 0x04, 0x04, 0x78,// n + 0x38, 0x44, 0x44, 0x44, 0x38,// o + 0x7C, 0x14, 0x14, 0x14, 0x08,// p + 0x08, 0x14, 0x14, 0x18, 0x7C,// q + 0x7C, 0x08, 0x04, 0x04, 0x08,// r + 0x48, 0x54, 0x54, 0x54, 0x20,// s + 0x04, 0x3F, 0x44, 0x40, 0x20,// t + 0x3C, 0x40, 0x40, 0x20, 0x7C,// u + 0x1C, 0x20, 0x40, 0x20, 0x1C,// v + 0x3C, 0x40, 0x30, 0x40, 0x3C,// w + 0x44, 0x28, 0x10, 0x28, 0x44,// x + 0x0C, 0x50, 0x50, 0x50, 0x3C,// y + 0x44, 0x64, 0x54, 0x4C, 0x44,// z + 0x00, 0x08, 0x36, 0x41, 0x00,// { + 0x00, 0x00, 0x7F, 0x00, 0x00,// | + 0x00, 0x41, 0x36, 0x08, 0x00,// } + 0x08, 0x08, 0x2A, 0x1C, 0x08,// -> + 0x08, 0x1C, 0x2A, 0x08, 0x08 // <- +}; + +#endif diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/keywords.txt b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/keywords.txt new file mode 100644 index 0000000..94906ab --- /dev/null +++ b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/keywords.txt @@ -0,0 +1,33 @@ +####################################### +# Syntax Coloring Map for LedDisplay +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +LedDisplay KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +scroll KEYWORD2 +begin KEYWORD2 +clear KEYWORD2 +home KEYWORD2 +setCursor KEYWORD2 +getCursor KEYWORD2 +write KEYWORD2 +setString KEYWORD2 +getString KEYWORD2 +stringLength KEYWORD2 +setBrightness KEYWORD2 +writeCharacter KEYWORD2 +loadControlRegister KEYWORD2 +loadDotRegister KEYWORD2 +version KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/readme.txt b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/readme.txt new file mode 100644 index 0000000..ec58677 --- /dev/null +++ b/Doc/DataSheet/Display_Avago_HCMS_xx/LedDisplay/readme.txt @@ -0,0 +1,140 @@ +LedDisplay Library + +For details, see http://www.arduino.cc/playground/Main/LedDisplay + +This library allows you to send text to an Avago HCMS-29xx LED display. The HCMS 29xx displays are pretty little displays that contain a row of 5x7 LED matrices. + +The displays have a synchronous serial interface. You'll need five digital output lines to control them. The pins are as follows: + + * data - bits in from the microcontroller + * register select - selects whether you're sending display data or control data + * clock - timing clock from the microcontroller + * enable - enables or disables the display + * reset - resets the display + +The library manages all the necessary pin control and data shifting for you. + +Methods: + +LedDisplay(int dataPin, int registerSelect, int clockPin, int chipEnable, int resetPin, int displayLength) - instantiates the library. The first five parameters are the Arduino pin numbers that are connected to the display. The last sets the length of the display (8 for the HCMS-291x and HCMS-297x, 4 for the HCMS-290x and 296x). + +example: + + LedDisplay myDisplay = LedDisplay(2,3,4,5,6,8); + +begin() - initializes and resets the display. + +example: + + myDisplay.begin(); + +Printing methods + +write(char whatCharacter, byte whatPosition) - writes a single character to the display at a particular position + +example: + + myDisplay.write('A', 4); + +LedDisplay inherits all the print() and println() methods from the Print library, so you can use those methods to print to the display, as long as what you print fits within the display. For example here's how to print the millis and a title string to the display: + + myDisplay.print("ms:"); + myDisplay.print(millis()); + +You can also do the usual Print things, like: + + int myInt = 12; + myDisplay.print(myInt, DEC); + // or + myDisplay.print(myInt, HEX); + +Scrolling methods + +If you want to be able to automatically scroll a string of text, you need to use the setString() method first. This method stores a character string in the library instance, so you can then use the scroll() method to move it left and right. + +setString(char* stringToDisplay) - displays a string on the display. If the string is longer than the display, the beginning of the string is displayed. You can use the scroll() method to step the string forward on the display. + +getString() - returns the string to display. + +example: + + // print out the display string for debugging: + Serial.println(myDisplay.getString()); + +stringLength() - returns the length of the display string. See the scrolling example below for usage. + +scroll(int direction) - scrolls the display using the string set by setString(). Negative numbers scroll left, positive numbers scroll right. + +example: + +... + +void setup() { + +... + + // scroll a string that's longer than the display: + myDisplay.setString("This is a very long string"); +} + +void loop() { + + // when the string scrolls off the display, reverse scroll direction. + // On the right, it scrolls off at position 8. + // on the left, it scrolls off when the cursor is less than -(the length of the string): + + if ((myDisplay.cursorPosition() > displayLength) || + (myDisplay.cursorPosition() <= -(myDisplay.stringLength()))) { + myDirection = -myDirection; + delay(1000); + } + + // scroll: + myDisplay.scroll(myDirection); + delay(100); +} + + +Cursor control methods + +clear() - clear the display. + +example: + + myDisplay.clear(); + +home() - set cursor to far left hand position. + +example: + + myDisplay.home(); + +setCursor(int whichPosition) - set cursor to any position. + +example: + + myDisplay.serCursor(4); + +getCursor() - get the cursor position. + +example: + + int cursorPosition = myDisplay.getCursor(); + +Display Control methods + +setBrightness(int bright) - lets you set the brightness from 0 to 15. + +example: + + myDisplay.setBrightness(15); + +If you want to set the opcodes of the display directly (you can learn them from the data sheet), the following methods will do the trick. + +loadControlRegister(int dataByte) - sends 8 bits to one of the control registers. + +loadDotRegister() - sends 320 bits to the dot register + +Version method + +version() - returns the version number of the library. \ No newline at end of file diff --git a/Doc/DataSheet/Display_Avago_HCMS_xx/datos_enlaces.txt b/Doc/DataSheet/Display_Avago_HCMS_xx/datos_enlaces.txt new file mode 100644 index 0000000..fe3f844 --- /dev/null +++ b/Doc/DataSheet/Display_Avago_HCMS_xx/datos_enlaces.txt @@ -0,0 +1,20 @@ + +Displays Avago serie HCMS_xx + +En www.rs-online.es + + +Para 3.3v: + 496-5226 + 496-5204 + 496-5197 + +Para 5V: + 496-5147 + 830-5091 + + + +Ejemplos para Arduino: + +https://www.pjrc.com/teensy/td_libs_LedDisplay.html diff --git a/Doc/DataSheet/EMV1200-40.pdf b/Doc/DataSheet/EMV1200-40.pdf new file mode 100644 index 0000000..d0d5ecf Binary files /dev/null and b/Doc/DataSheet/EMV1200-40.pdf differ diff --git a/Doc/DataSheet/Estacion_Metereologica/ALS-PT19-315C-L177-TR.pdf b/Doc/DataSheet/Estacion_Metereologica/ALS-PT19-315C-L177-TR.pdf new file mode 100644 index 0000000..10af764 Binary files /dev/null and b/Doc/DataSheet/Estacion_Metereologica/ALS-PT19-315C-L177-TR.pdf differ diff --git a/Doc/DataSheet/Estacion_Metereologica/Codigo_Ejemplo.txt b/Doc/DataSheet/Estacion_Metereologica/Codigo_Ejemplo.txt new file mode 100644 index 0000000..97c7094 --- /dev/null +++ b/Doc/DataSheet/Estacion_Metereologica/Codigo_Ejemplo.txt @@ -0,0 +1,2 @@ + +https://github.com/sparkfun/Weather_Shield diff --git a/Doc/DataSheet/Estacion_Metereologica/GP-635T-121130.pdf b/Doc/DataSheet/Estacion_Metereologica/GP-635T-121130.pdf new file mode 100644 index 0000000..40f6cf6 Binary files /dev/null and b/Doc/DataSheet/Estacion_Metereologica/GP-635T-121130.pdf differ diff --git a/Doc/DataSheet/Estacion_Metereologica/HTDU21D.pdf b/Doc/DataSheet/Estacion_Metereologica/HTDU21D.pdf new file mode 100644 index 0000000..4403360 Binary files /dev/null and b/Doc/DataSheet/Estacion_Metereologica/HTDU21D.pdf differ diff --git a/Doc/DataSheet/Estacion_Metereologica/MPL3115A2.pdf b/Doc/DataSheet/Estacion_Metereologica/MPL3115A2.pdf new file mode 100644 index 0000000..856cc12 Binary files /dev/null and b/Doc/DataSheet/Estacion_Metereologica/MPL3115A2.pdf differ diff --git a/Doc/DataSheet/Estacion_Metereologica/Sparkfun.com_tutorials_weather-shield-hookup-guid.pdf b/Doc/DataSheet/Estacion_Metereologica/Sparkfun.com_tutorials_weather-shield-hookup-guid.pdf new file mode 100644 index 0000000..325d98b Binary files /dev/null and b/Doc/DataSheet/Estacion_Metereologica/Sparkfun.com_tutorials_weather-shield-hookup-guid.pdf differ diff --git a/Doc/DataSheet/Estacion_Metereologica/Weather_Shield.pdf b/Doc/DataSheet/Estacion_Metereologica/Weather_Shield.pdf new file mode 100644 index 0000000..d14b0de Binary files /dev/null and b/Doc/DataSheet/Estacion_Metereologica/Weather_Shield.pdf differ diff --git a/Doc/DataSheet/Estacion_Metereologica/github.com_razor-9dof-ahrs_wiki_Tutorial.pdf b/Doc/DataSheet/Estacion_Metereologica/github.com_razor-9dof-ahrs_wiki_Tutorial.pdf new file mode 100644 index 0000000..b097e7b Binary files /dev/null and b/Doc/DataSheet/Estacion_Metereologica/github.com_razor-9dof-ahrs_wiki_Tutorial.pdf differ diff --git a/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master.zip b/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master.zip new file mode 100644 index 0000000..9110d0b Binary files /dev/null and b/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master.zip differ diff --git a/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master/Adafruit_MLX90614.cpp b/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master/Adafruit_MLX90614.cpp new file mode 100644 index 0000000..4c3698e --- /dev/null +++ b/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master/Adafruit_MLX90614.cpp @@ -0,0 +1,84 @@ +/*************************************************** + This is a library for the MLX90614 Temp Sensor + + Designed specifically to work with the MLX90614 sensors in the + adafruit shop + ----> https://www.adafruit.com/products/1748 + ----> https://www.adafruit.com/products/1749 + + These sensors use I2C to communicate, 2 pins are required to + interface + Adafruit invests time and resources providing this open source code, + please support Adafruit and open-source hardware by purchasing + products from Adafruit! + + Written by Limor Fried/Ladyada for Adafruit Industries. + BSD license, all text above must be included in any redistribution + ****************************************************/ + +#include "Adafruit_MLX90614.h" + +Adafruit_MLX90614::Adafruit_MLX90614(uint8_t i2caddr) { + _addr = i2caddr; +} + + +boolean Adafruit_MLX90614::begin(void) { + Wire.begin(); + + /* + for (uint8_t i=0; i<0x20; i++) { + Serial.print(i); Serial.print(" = "); + Serial.println(read16(i), HEX); + } + */ + return true; +} + +////////////////////////////////////////////////////// + + +double Adafruit_MLX90614::readObjectTempF(void) { + return (readTemp(MLX90614_TOBJ1) * 9 / 5) + 32; +} + + +double Adafruit_MLX90614::readAmbientTempF(void) { + return (readTemp(MLX90614_TA) * 9 / 5) + 32; +} + +double Adafruit_MLX90614::readObjectTempC(void) { + return readTemp(MLX90614_TOBJ1); +} + + +double Adafruit_MLX90614::readAmbientTempC(void) { + return readTemp(MLX90614_TA); +} + +float Adafruit_MLX90614::readTemp(uint8_t reg) { + float temp; + + temp = read16(reg); + temp *= .02; + temp -= 273.15; + return temp; +} + +/*********************************************************************/ + +uint16_t Adafruit_MLX90614::read16(uint8_t a) { + uint16_t ret; + + Wire.beginTransmission(_addr); // start transmission to device + Wire.write(a); // sends register address to read from + Wire.endTransmission(false); // end transmission + + Wire.requestFrom(_addr, (uint8_t)3);// send data n-bytes read + ret = Wire.read(); // receive DATA + ret |= Wire.read() << 8; // receive DATA + + uint8_t pec = Wire.read(); + + return ret; +} diff --git a/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master/Adafruit_MLX90614.h b/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master/Adafruit_MLX90614.h new file mode 100644 index 0000000..3dc9eed --- /dev/null +++ b/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master/Adafruit_MLX90614.h @@ -0,0 +1,67 @@ +/*************************************************** + This is a library for the MLX90614 Temp Sensor + + Designed specifically to work with the MLX90614 sensors in the + adafruit shop + ----> https://www.adafruit.com/products/1748 + ----> https://www.adafruit.com/products/1749 + + These sensors use I2C to communicate, 2 pins are required to + interface + Adafruit invests time and resources providing this open source code, + please support Adafruit and open-source hardware by purchasing + products from Adafruit! + + Written by Limor Fried/Ladyada for Adafruied in any redistribution + ****************************************************/ + + +#if (ARDUINO >= 100) + #include "Arduino.h" +#else + #include "WProgram.h" +#endif +#include "Wire.h" + + +#define MLX90614_I2CADDR 0x5A + +// RAM +#define MLX90614_RAWIR1 0x04 +#define MLX90614_RAWIR2 0x05 +#define MLX90614_TA 0x06 +#define MLX90614_TOBJ1 0x07 +#define MLX90614_TOBJ2 0x08 +// EEPROM +#define MLX90614_TOMAX 0x20 +#define MLX90614_TOMIN 0x21 +#define MLX90614_PWMCTRL 0x22 +#define MLX90614_TARANGE 0x23 +#define MLX90614_EMISS 0x24 +#define MLX90614_CONFIG 0x25 +#define MLX90614_ADDR 0x0E +#define MLX90614_ID1 0x3C +#define MLX90614_ID2 0x3D +#define MLX90614_ID3 0x3E +#define MLX90614_ID4 0x3F + + +class Adafruit_MLX90614 { + public: + Adafruit_MLX90614(uint8_t addr = MLX90614_I2CADDR); + boolean begin(); + uint32_t readID(void); + + double readObjectTempC(void); + double readAmbientTempC(void); + double readObjectTempF(void); + double readAmbientTempF(void); + + private: + float readTemp(uint8_t reg); + + uint8_t _addr; + uint16_t read16(uint8_t addr); + void write16(uint8_t addr, uint16_t data); +}; + diff --git a/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master/README.txt b/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master/README.txt new file mode 100644 index 0000000..c1a2c02 --- /dev/null +++ b/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master/README.txt @@ -0,0 +1,20 @@ +This is a library for the MLX90614 temperature sensor + + Designed specifically to work with the MLX90614 sensors in the + adafruit shop + ----> https://www.adafruit.com/products/1748 + ----> https://www.adafruit.com/products/1749 + +These sensors use I2C to communicate, 2 pins are required to interface +Adafruit invests time and resources providing this open source code, +please support Adafruit and open-source hardware by purchasing +products from Adafruit! + +Check out the links above for our tutorials and wiring diagrams + +Written by Limor Fried/Ladyada for Adafruit Industries. +BSD license, all text above must be included in any redistribution + +To download. click the DOWNLOADS button in the top right corner, rename the uncompressed folder Adafruit_MLX90614. Check that the Adafruit_MLX90614 folder contains Adafruit_MLX90614.cpp and Adafruit_MLX90614.h + +Place the Adafruit_MLX90614 library folder your arduinosketchfolder/libraries/ folder. You may need to create the libraries subfolder if its your first library. Restart the IDE. \ No newline at end of file diff --git a/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master/examples/mlxtest/mlxtest.ino b/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master/examples/mlxtest/mlxtest.ino new file mode 100644 index 0000000..536795b --- /dev/null +++ b/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master/examples/mlxtest/mlxtest.ino @@ -0,0 +1,40 @@ +/*************************************************** + This is a library example for the MLX90614 Temp Sensor + + Designed specifically to work with the MLX90614 sensors in the + adafruit shop + ----> https://www.adafruit.com/products/1748 + ----> https://www.adafruit.com/products/1749 + + These sensors use I2C to communicate, 2 pins are required to + interface + Adafruit invests time and resources providing this open source code, + please support Adafruit and open-source hardware by purchasing + products from Adafruit! + + Written by Limor Fried/Ladyada for Adafruit Industries. + BSD license, all text above must be included in any redistribution + ****************************************************/ + +#include +#include + +Adafruit_MLX90614 mlx = Adafruit_MLX90614(); + +void setup() { + Serial.begin(9600); + + Serial.println("Adafruit MLX90614 test"); + + mlx.begin(); +} + +void loop() { + Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempC()); + Serial.print("*C\tObject = "); Serial.print(mlx.readObjectTempC()); Serial.println("*C"); + Serial.print("Ambient = "); Serial.print(mlx.readAmbientTempF()); + Serial.print("*F\tObject = "); Serial.print(mlx.readObjectTempF()); Serial.println("*F"); + + Serial.println(); + delay(500); +} \ No newline at end of file diff --git a/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master/library.properties b/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master/library.properties new file mode 100644 index 0000000..0c187e5 --- /dev/null +++ b/Doc/DataSheet/MLX90614/Adafruit-MLX90614-Library-master/library.properties @@ -0,0 +1,9 @@ +name=Adafruit MLX90614 Library +version=1.0.0 +author=Adafruit +maintainer=Adafruit +sentence=Arduino library for the MLX90614 sensors in the Adafruit shop +paragraph=Arduino library for the MLX90614 sensors in the Adafruit shop +category=Sensors +url=https://github.com/adafruit/Adafruit-MLX90614-Library +architectures=* diff --git a/Doc/DataSheet/MLX90614/MLX90614.pdf b/Doc/DataSheet/MLX90614/MLX90614.pdf new file mode 100644 index 0000000..b790724 Binary files /dev/null and b/Doc/DataSheet/MLX90614/MLX90614.pdf differ diff --git a/Doc/DataSheet/MLX90614/MLX90614_Conexion_01.jpg b/Doc/DataSheet/MLX90614/MLX90614_Conexion_01.jpg new file mode 100644 index 0000000..272a2d3 Binary files /dev/null and b/Doc/DataSheet/MLX90614/MLX90614_Conexion_01.jpg differ diff --git a/Doc/DataSheet/MLX90614/MLX90614_Conexion_02.jpg b/Doc/DataSheet/MLX90614/MLX90614_Conexion_02.jpg new file mode 100644 index 0000000..bdb993d Binary files /dev/null and b/Doc/DataSheet/MLX90614/MLX90614_Conexion_02.jpg differ diff --git a/Doc/DataSheet/Medidor_Corriente_ACS714/ACS714.pdf b/Doc/DataSheet/Medidor_Corriente_ACS714/ACS714.pdf new file mode 100644 index 0000000..a64f5cd Binary files /dev/null and b/Doc/DataSheet/Medidor_Corriente_ACS714/ACS714.pdf differ diff --git a/Doc/DataSheet/RTC_1307/RTClib/README.txt b/Doc/DataSheet/RTC_1307/RTClib/README.txt new file mode 100644 index 0000000..ba3f25b --- /dev/null +++ b/Doc/DataSheet/RTC_1307/RTClib/README.txt @@ -0,0 +1,8 @@ +This is a fork of JeeLab's fantastic real time clock library for Arduino. + +For details on using this library with an RTC module like the DS1307, see the guide at: https://learn.adafruit.com/ds1307-real-time-clock-breakout-board-kit/overview + +To download. click the DOWNLOADS button to the right, and rename the uncompressed folder RTClib. + +Place the RTClib folder in your *arduinosketchfolder*/libraries/ folder. +You may need to create the libraries subfolder if its your first library. Restart the IDE. diff --git a/Doc/DataSheet/RTC_1307/RTClib/RTClib.cpp b/Doc/DataSheet/RTC_1307/RTClib/RTClib.cpp new file mode 100644 index 0000000..ad0f0c6 --- /dev/null +++ b/Doc/DataSheet/RTC_1307/RTClib/RTClib.cpp @@ -0,0 +1,334 @@ +// Code by JeeLabs http://news.jeelabs.org/code/ +// Released to the public domain! Enjoy! + +#include +#include "RTClib.h" +#ifdef __AVR__ + #include + #define WIRE Wire +#else + #define PROGMEM + #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) + #define WIRE Wire1 +#endif + +#define DS1307_ADDRESS 0x68 +#define DS1307_CONTROL 0x07 +#define DS1307_NVRAM 0x08 +#define SECONDS_PER_DAY 86400L + +#define SECONDS_FROM_1970_TO_2000 946684800 + +#if (ARDUINO >= 100) + #include // capital A so it is error prone on case-sensitive filesystems + // Macro to deal with the difference in I2C write functions from old and new Arduino versions. + #define _I2C_WRITE write + #define _I2C_READ read +#else + #include + #define _I2C_WRITE send + #define _I2C_READ receive +#endif + +//////////////////////////////////////////////////////////////////////////////// +// utility code, some of this could be exposed in the DateTime API if needed + +const uint8_t daysInMonth [] PROGMEM = { 31,28,31,30,31,30,31,31,30,31,30,31 }; + +// number of days since 2000/01/01, valid for 2001..2099 +static uint16_t date2days(uint16_t y, uint8_t m, uint8_t d) { + if (y >= 2000) + y -= 2000; + uint16_t days = d; + for (uint8_t i = 1; i < m; ++i) + days += pgm_read_byte(daysInMonth + i - 1); + if (m > 2 && y % 4 == 0) + ++days; + return days + 365 * y + (y + 3) / 4 - 1; +} + +static long time2long(uint16_t days, uint8_t h, uint8_t m, uint8_t s) { + return ((days * 24L + h) * 60 + m) * 60 + s; +} + +//////////////////////////////////////////////////////////////////////////////// +// DateTime implementation - ignores time zones and DST changes +// NOTE: also ignores leap seconds, see http://en.wikipedia.org/wiki/Leap_second + +DateTime::DateTime (uint32_t t) { + t -= SECONDS_FROM_1970_TO_2000; // bring to 2000 timestamp from 1970 + + ss = t % 60; + t /= 60; + mm = t % 60; + t /= 60; + hh = t % 24; + uint16_t days = t / 24; + uint8_t leap; + for (yOff = 0; ; ++yOff) { + leap = yOff % 4 == 0; + if (days < 365 + leap) + break; + days -= 365 + leap; + } + for (m = 1; ; ++m) { + uint8_t daysPerMonth = pgm_read_byte(daysInMonth + m - 1); + if (leap && m == 2) + ++daysPerMonth; + if (days < daysPerMonth) + break; + days -= daysPerMonth; + } + d = days + 1; +} + +DateTime::DateTime (uint16_t year, uint8_t month, uint8_t day, uint8_t hour, uint8_t min, uint8_t sec) { + if (year >= 2000) + year -= 2000; + yOff = year; + m = month; + d = day; + hh = hour; + mm = min; + ss = sec; +} + +DateTime::DateTime (const DateTime& copy): + yOff(copy.yOff), + m(copy.m), + d(copy.d), + hh(copy.hh), + mm(copy.mm), + ss(copy.ss) +{} + +static uint8_t conv2d(const char* p) { + uint8_t v = 0; + if ('0' <= *p && *p <= '9') + v = *p - '0'; + return 10 * v + *++p - '0'; +} + +// A convenient constructor for using "the compiler's time": +// DateTime now (__DATE__, __TIME__); +// NOTE: using F() would further reduce the RAM footprint, see below. +DateTime::DateTime (const char* date, const char* time) { + // sample input: date = "Dec 26 2009", time = "12:34:56" + yOff = conv2d(date + 9); + // Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec + switch (date[0]) { + case 'J': m = date[1] == 'a' ? 1 : m = date[2] == 'n' ? 6 : 7; break; + case 'F': m = 2; break; + case 'A': m = date[2] == 'r' ? 4 : 8; break; + case 'M': m = date[2] == 'r' ? 3 : 5; break; + case 'S': m = 9; break; + case 'O': m = 10; break; + case 'N': m = 11; break; + case 'D': m = 12; break; + } + d = conv2d(date + 4); + hh = conv2d(time); + mm = conv2d(time + 3); + ss = conv2d(time + 6); +} + +// A convenient constructor for using "the compiler's time": +// This version will save RAM by using PROGMEM to store it by using the F macro. +// DateTime now (F(__DATE__), F(__TIME__)); +DateTime::DateTime (const __FlashStringHelper* date, const __FlashStringHelper* time) { + // sample input: date = "Dec 26 2009", time = "12:34:56" + char buff[11]; + memcpy_P(buff, date, 11); + yOff = conv2d(buff + 9); + // Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec + switch (buff[0]) { + case 'J': m = buff[1] == 'a' ? 1 : m = buff[2] == 'n' ? 6 : 7; break; + case 'F': m = 2; break; + case 'A': m = buff[2] == 'r' ? 4 : 8; break; + case 'M': m = buff[2] == 'r' ? 3 : 5; break; + case 'S': m = 9; break; + case 'O': m = 10; break; + case 'N': m = 11; break; + case 'D': m = 12; break; + } + d = conv2d(buff + 4); + memcpy_P(buff, time, 8); + hh = conv2d(buff); + mm = conv2d(buff + 3); + ss = conv2d(buff + 6); +} + +uint8_t DateTime::dayOfWeek() const { + uint16_t day = date2days(yOff, m, d); + return (day + 6) % 7; // Jan 1, 2000 is a Saturday, i.e. returns 6 +} + +uint32_t DateTime::unixtime(void) const { + uint32_t t; + uint16_t days = date2days(yOff, m, d); + t = time2long(days, hh, mm, ss); + t += SECONDS_FROM_1970_TO_2000; // seconds from 1970 to 2000 + + return t; +} + +long DateTime::secondstime(void) const { + long t; + uint16_t days = date2days(yOff, m, d); + t = time2long(days, hh, mm, ss); + return t; +} + +DateTime DateTime::operator+(const TimeSpan& span) { + return DateTime(unixtime()+span.totalseconds()); +} + +DateTime DateTime::operator-(const TimeSpan& span) { + return DateTime(unixtime()-span.totalseconds()); +} + +TimeSpan DateTime::operator-(const DateTime& right) { + return TimeSpan(unixtime()-right.unixtime()); +} + +//////////////////////////////////////////////////////////////////////////////// +// TimeSpan implementation + +TimeSpan::TimeSpan (int32_t seconds): + _seconds(seconds) +{} + +TimeSpan::TimeSpan (int16_t days, int8_t hours, int8_t minutes, int8_t seconds): + _seconds(days*86400L + hours*3600 + minutes*60 + seconds) +{} + +TimeSpan::TimeSpan (const TimeSpan& copy): + _seconds(copy._seconds) +{} + +TimeSpan TimeSpan::operator+(const TimeSpan& right) { + return TimeSpan(_seconds+right._seconds); +} + +TimeSpan TimeSpan::operator-(const TimeSpan& right) { + return TimeSpan(_seconds-right._seconds); +} + +//////////////////////////////////////////////////////////////////////////////// +// RTC_DS1307 implementation + +static uint8_t bcd2bin (uint8_t val) { return val - 6 * (val >> 4); } +static uint8_t bin2bcd (uint8_t val) { return val + 6 * (val / 10); } + +uint8_t RTC_DS1307::begin(void) { + return 1; +} + +uint8_t RTC_DS1307::isrunning(void) { + WIRE.beginTransmission(DS1307_ADDRESS); + WIRE._I2C_WRITE(0); + WIRE.endTransmission(); + + WIRE.requestFrom(DS1307_ADDRESS, 1); + uint8_t ss = WIRE._I2C_READ(); + return !(ss>>7); +} + +void RTC_DS1307::adjust(const DateTime& dt) { + WIRE.beginTransmission(DS1307_ADDRESS); + WIRE._I2C_WRITE(0); + WIRE._I2C_WRITE(bin2bcd(dt.second())); + WIRE._I2C_WRITE(bin2bcd(dt.minute())); + WIRE._I2C_WRITE(bin2bcd(dt.hour())); + WIRE._I2C_WRITE(bin2bcd(0)); + WIRE._I2C_WRITE(bin2bcd(dt.day())); + WIRE._I2C_WRITE(bin2bcd(dt.month())); + WIRE._I2C_WRITE(bin2bcd(dt.year() - 2000)); + WIRE._I2C_WRITE(0); + WIRE.endTransmission(); +} + +DateTime RTC_DS1307::now() { + WIRE.beginTransmission(DS1307_ADDRESS); + WIRE._I2C_WRITE(0); + WIRE.endTransmission(); + + WIRE.requestFrom(DS1307_ADDRESS, 7); + uint8_t ss = bcd2bin(WIRE._I2C_READ() & 0x7F); + uint8_t mm = bcd2bin(WIRE._I2C_READ()); + uint8_t hh = bcd2bin(WIRE._I2C_READ()); + WIRE._I2C_READ(); + uint8_t d = bcd2bin(WIRE._I2C_READ()); + uint8_t m = bcd2bin(WIRE._I2C_READ()); + uint16_t y = bcd2bin(WIRE._I2C_READ()) + 2000; + + return DateTime (y, m, d, hh, mm, ss); +} + +Ds1307SqwPinMode RTC_DS1307::readSqwPinMode() { + int mode; + + WIRE.beginTransmission(DS1307_ADDRESS); + WIRE._I2C_WRITE(DS1307_CONTROL); + WIRE.endTransmission(); + + WIRE.requestFrom((uint8_t)DS1307_ADDRESS, (uint8_t)1); + mode = WIRE._I2C_READ(); + + mode &= 0x93; + return static_cast(mode); +} + +void RTC_DS1307::writeSqwPinMode(Ds1307SqwPinMode mode) { + WIRE.beginTransmission(DS1307_ADDRESS); + WIRE._I2C_WRITE(DS1307_CONTROL); + WIRE._I2C_WRITE(mode); + WIRE.endTransmission(); +} + +void RTC_DS1307::readnvram(uint8_t* buf, uint8_t size, uint8_t address) { + int addrByte = DS1307_NVRAM + address; + WIRE.beginTransmission(DS1307_ADDRESS); + WIRE._I2C_WRITE(addrByte); + WIRE.endTransmission(); + + WIRE.requestFrom((uint8_t) DS1307_ADDRESS, size); + for (uint8_t pos = 0; pos < size; ++pos) { + buf[pos] = WIRE._I2C_READ(); + } +} + +void RTC_DS1307::writenvram(uint8_t address, uint8_t* buf, uint8_t size) { + int addrByte = DS1307_NVRAM + address; + WIRE.beginTransmission(DS1307_ADDRESS); + WIRE._I2C_WRITE(addrByte); + for (uint8_t pos = 0; pos < size; ++pos) { + WIRE._I2C_WRITE(buf[pos]); + } + WIRE.endTransmission(); +} + +uint8_t RTC_DS1307::readnvram(uint8_t address) { + uint8_t data; + readnvram(&data, 1, address); + return data; +} + +void RTC_DS1307::writenvram(uint8_t address, uint8_t data) { + writenvram(address, &data, 1); +} + +//////////////////////////////////////////////////////////////////////////////// +// RTC_Millis implementation + +long RTC_Millis::offset = 0; + +void RTC_Millis::adjust(const DateTime& dt) { + offset = dt.unixtime() - millis() / 1000; +} + +DateTime RTC_Millis::now() { + return (uint32_t)(offset + millis() / 1000); +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/Doc/DataSheet/RTC_1307/RTClib/RTClib.h b/Doc/DataSheet/RTC_1307/RTClib/RTClib.h new file mode 100644 index 0000000..6d6b361 --- /dev/null +++ b/Doc/DataSheet/RTC_1307/RTClib/RTClib.h @@ -0,0 +1,87 @@ +// Code by JeeLabs http://news.jeelabs.org/code/ +// Released to the public domain! Enjoy! + +#ifndef _RTCLIB_H_ +#define _RTCLIB_H_ + +class TimeSpan; + +// Simple general-purpose date/time class (no TZ / DST / leap second handling!) +class DateTime { +public: + DateTime (uint32_t t =0); + DateTime (uint16_t year, uint8_t month, uint8_t day, + uint8_t hour =0, uint8_t min =0, uint8_t sec =0); + DateTime (const DateTime& copy); + DateTime (const char* date, const char* time); + DateTime (const __FlashStringHelper* date, const __FlashStringHelper* time); + uint16_t year() const { return 2000 + yOff; } + uint8_t month() const { return m; } + uint8_t day() const { return d; } + uint8_t hour() const { return hh; } + uint8_t minute() const { return mm; } + uint8_t second() const { return ss; } + uint8_t dayOfWeek() const; + + // 32-bit times as seconds since 1/1/2000 + long secondstime() const; + // 32-bit times as seconds since 1/1/1970 + uint32_t unixtime(void) const; + + DateTime operator+(const TimeSpan& span); + DateTime operator-(const TimeSpan& span); + TimeSpan operator-(const DateTime& right); + +protected: + uint8_t yOff, m, d, hh, mm, ss; +}; + +// Timespan which can represent changes in time with seconds accuracy. +class TimeSpan { +public: + TimeSpan (int32_t seconds = 0); + TimeSpan (int16_t days, int8_t hours, int8_t minutes, int8_t seconds); + TimeSpan (const TimeSpan& copy); + int16_t days() const { return _seconds / 86400L; } + int8_t hours() const { return _seconds / 3600 % 24; } + int8_t minutes() const { return _seconds / 60 % 60; } + int8_t seconds() const { return _seconds % 60; } + int32_t totalseconds() const { return _seconds; } + + TimeSpan operator+(const TimeSpan& right); + TimeSpan operator-(const TimeSpan& right); + +protected: + int32_t _seconds; +}; + +// RTC based on the DS1307 chip connected via I2C and the Wire library +enum Ds1307SqwPinMode { OFF = 0x00, ON = 0x80, SquareWave1HZ = 0x10, SquareWave4kHz = 0x11, SquareWave8kHz = 0x12, SquareWave32kHz = 0x13 }; + +class RTC_DS1307 { +public: + static uint8_t begin(void); + static void adjust(const DateTime& dt); + uint8_t isrunning(void); + static DateTime now(); + static Ds1307SqwPinMode readSqwPinMode(); + static void writeSqwPinMode(Ds1307SqwPinMode mode); + uint8_t readnvram(uint8_t address); + void readnvram(uint8_t* buf, uint8_t size, uint8_t address); + void writenvram(uint8_t address, uint8_t data); + void writenvram(uint8_t address, uint8_t* buf, uint8_t size); +}; + +// RTC using the internal millis() clock, has to be initialized before use +// NOTE: this clock won't be correct once the millis() timer rolls over (>49d?) +class RTC_Millis { +public: + static void begin(const DateTime& dt) { adjust(dt); } + static void adjust(const DateTime& dt); + static DateTime now(); + +protected: + static long offset; +}; + +#endif // _RTCLIB_H_ diff --git a/Doc/DataSheet/RTC_1307/RTClib/examples/datecalc/datecalc.ino b/Doc/DataSheet/RTC_1307/RTClib/examples/datecalc/datecalc.ino new file mode 100644 index 0000000..b148c7c --- /dev/null +++ b/Doc/DataSheet/RTC_1307/RTClib/examples/datecalc/datecalc.ino @@ -0,0 +1,102 @@ +// Simple date conversions and calculations + +#include +#include "RTClib.h" + +void showDate(const char* txt, const DateTime& dt) { + Serial.print(txt); + Serial.print(' '); + Serial.print(dt.year(), DEC); + Serial.print('/'); + Serial.print(dt.month(), DEC); + Serial.print('/'); + Serial.print(dt.day(), DEC); + Serial.print(' '); + Serial.print(dt.hour(), DEC); + Serial.print(':'); + Serial.print(dt.minute(), DEC); + Serial.print(':'); + Serial.print(dt.second(), DEC); + + Serial.print(" = "); + Serial.print(dt.unixtime()); + Serial.print("s / "); + Serial.print(dt.unixtime() / 86400L); + Serial.print("d since 1970"); + + Serial.println(); +} + +void showTimeSpan(const char* txt, const TimeSpan& ts) { + Serial.print(txt); + Serial.print(" "); + Serial.print(ts.days(), DEC); + Serial.print(" days "); + Serial.print(ts.hours(), DEC); + Serial.print(" hours "); + Serial.print(ts.minutes(), DEC); + Serial.print(" minutes "); + Serial.print(ts.seconds(), DEC); + Serial.print(" seconds ("); + Serial.print(ts.totalseconds(), DEC); + Serial.print(" total seconds)"); + Serial.println(); +} + +void setup () { + Serial.begin(57600); + + DateTime dt0 (0, 1, 1, 0, 0, 0); + showDate("dt0", dt0); + + DateTime dt1 (1, 1, 1, 0, 0, 0); + showDate("dt1", dt1); + + DateTime dt2 (2009, 1, 1, 0, 0, 0); + showDate("dt2", dt2); + + DateTime dt3 (2009, 1, 2, 0, 0, 0); + showDate("dt3", dt3); + + DateTime dt4 (2009, 1, 27, 0, 0, 0); + showDate("dt4", dt4); + + DateTime dt5 (2009, 2, 27, 0, 0, 0); + showDate("dt5", dt5); + + DateTime dt6 (2009, 12, 27, 0, 0, 0); + showDate("dt6", dt6); + + DateTime dt7 (dt6.unixtime() + 3600); // One hour later. + showDate("dt7", dt7); + + DateTime dt75 = dt6 + TimeSpan(0, 1, 0, 0); // One hour later with TimeSpan addition. + showDate("dt7.5", dt75); + + DateTime dt8 (dt6.unixtime() + 86400L); // One day later. + showDate("dt8", dt8); + + DateTime dt85 = dt6 + TimeSpan(1, 0, 0, 0); // One day later with TimeSpan addition. + showDate("dt8.5", dt85); + + DateTime dt9 (dt6.unixtime() + 7 * 86400L); // One week later. + showDate("dt9", dt9); + + DateTime dt95 = dt6 + TimeSpan(7, 0, 0, 0); // One week later with TimeSpan addition. + showDate("dt9.5", dt95); + + DateTime dt10 = dt6 + TimeSpan(0, 0, 42, 42); // Fourty two minutes and fourty two seconds later. + showDate("dt10", dt10); + + DateTime dt11 = dt6 - TimeSpan(7, 0, 0, 0); // One week ago. + showDate("dt11", dt11); + + TimeSpan ts1 = dt6 - dt5; + showTimeSpan("dt6-dt5", ts1); + + TimeSpan ts2 = dt10 - dt6; + showTimeSpan("dt10-dt6", ts2); +} + +void loop () { +} diff --git a/Doc/DataSheet/RTC_1307/RTClib/examples/ds1307/ds1307.ino b/Doc/DataSheet/RTC_1307/RTClib/examples/ds1307/ds1307.ino new file mode 100644 index 0000000..d0e6da9 --- /dev/null +++ b/Doc/DataSheet/RTC_1307/RTClib/examples/ds1307/ds1307.ino @@ -0,0 +1,68 @@ +// Date and time functions using a DS1307 RTC connected via I2C and Wire lib + +#include +#include "RTClib.h" + +RTC_DS1307 rtc; + +void setup () { + Serial.begin(57600); +#ifdef AVR + Wire.begin(); +#else + Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due +#endif + rtc.begin(); + + if (! rtc.isrunning()) { + Serial.println("RTC is NOT running!"); + // following line sets the RTC to the date & time this sketch was compiled + rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); + // This line sets the RTC with an explicit date & time, for example to set + // January 21, 2014 at 3am you would call: + // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); + } +} + +void loop () { + DateTime now = rtc.now(); + + Serial.print(now.year(), DEC); + Serial.print('/'); + Serial.print(now.month(), DEC); + Serial.print('/'); + Serial.print(now.day(), DEC); + Serial.print(' '); + Serial.print(now.hour(), DEC); + Serial.print(':'); + Serial.print(now.minute(), DEC); + Serial.print(':'); + Serial.print(now.second(), DEC); + Serial.println(); + + Serial.print(" since midnight 1/1/1970 = "); + Serial.print(now.unixtime()); + Serial.print("s = "); + Serial.print(now.unixtime() / 86400L); + Serial.println("d"); + + // calculate a date which is 7 days and 30 seconds into the future + DateTime future (now.unixtime() + 7 * 86400L + 30); + + Serial.print(" now + 7d + 30s: "); + Serial.print(future.year(), DEC); + Serial.print('/'); + Serial.print(future.month(), DEC); + Serial.print('/'); + Serial.print(future.day(), DEC); + Serial.print(' '); + Serial.print(future.hour(), DEC); + Serial.print(':'); + Serial.print(future.minute(), DEC); + Serial.print(':'); + Serial.print(future.second(), DEC); + Serial.println(); + + Serial.println(); + delay(3000); +} diff --git a/Doc/DataSheet/RTC_1307/RTClib/examples/ds1307SqwPin/ds1307SqwPin.ino b/Doc/DataSheet/RTC_1307/RTClib/examples/ds1307SqwPin/ds1307SqwPin.ino new file mode 100644 index 0000000..d092619 --- /dev/null +++ b/Doc/DataSheet/RTC_1307/RTClib/examples/ds1307SqwPin/ds1307SqwPin.ino @@ -0,0 +1,56 @@ +// SQW/OUT pin mode using a DS1307 RTC connected via I2C. +// +// According to the data sheet (http://datasheets.maxim-ic.com/en/ds/DS1307.pdf), the +// DS1307's SQW/OUT pin can be set to low, high, 1Hz, 4.096kHz, 8.192kHz, or 32.768kHz. +// +// This sketch reads the state of the pin, then iterates through the possible values at +// 5 second intervals. +// + +// NOTE: +// You must connect a pull up resistor (~10kohm) from the SQW pin up to VCC. Without +// this pull up the wave output will not work! + +#include +#include "RTClib.h" + +RTC_DS1307 rtc; + +int mode_index = 0; + +Ds1307SqwPinMode modes[] = {OFF, ON, SquareWave1HZ, SquareWave4kHz, SquareWave8kHz, SquareWave32kHz}; + + +void print_mode() { + Ds1307SqwPinMode mode = rtc.readSqwPinMode(); + + Serial.print("Sqw Pin Mode: "); + switch(mode) { + case OFF: Serial.println("OFF"); break; + case ON: Serial.println("ON"); break; + case SquareWave1HZ: Serial.println("1Hz"); break; + case SquareWave4kHz: Serial.println("4.096kHz"); break; + case SquareWave8kHz: Serial.println("8.192kHz"); break; + case SquareWave32kHz: Serial.println("32.768kHz"); break; + default: Serial.println("UNKNOWN"); break; + } +} + +void setup () { + Serial.begin(57600); + Wire.begin(); + rtc.begin(); + + print_mode(); +} + +void loop () { + rtc.writeSqwPinMode(modes[mode_index++]); + print_mode(); + + if (mode_index > 5) { + mode_index = 0; + } + + delay(5000); +} diff --git a/Doc/DataSheet/RTC_1307/RTClib/examples/ds1307nvram/ds1307nvram.ino b/Doc/DataSheet/RTC_1307/RTClib/examples/ds1307nvram/ds1307nvram.ino new file mode 100644 index 0000000..9f80346 --- /dev/null +++ b/Doc/DataSheet/RTC_1307/RTClib/examples/ds1307nvram/ds1307nvram.ino @@ -0,0 +1,59 @@ +// Example of using the non-volatile RAM storage on the DS1307. +// You can write up to 56 bytes from address 0 to 55. +// Data will be persisted as long as the DS1307 has battery power. + +#include +#include "RTClib.h" + +RTC_DS1307 rtc; + +void printnvram(uint8_t address) { + Serial.print("Address 0x"); + Serial.print(address, HEX); + Serial.print(" = 0x"); + Serial.println(rtc.readnvram(address), HEX); +} + +void setup () { + Serial.begin(57600); +#ifdef AVR + Wire.begin(); +#else + Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due +#endif + rtc.begin(); + + // Print old RAM contents on startup. + Serial.println("Current NVRAM values:"); + for (int i = 0; i < 6; ++i) { + printnvram(i); + } + + // Write some bytes to non-volatile RAM storage. + // NOTE: You can only read and write from addresses 0 to 55 (i.e. 56 byte values). + Serial.println("Writing NVRAM values."); + // Example writing one byte at a time: + rtc.writenvram(0, 0xFE); + rtc.writenvram(1, 0xED); + // Example writing multiple bytes: + uint8_t writeData[4] = { 0xBE, 0xEF, 0x01, 0x02 }; + rtc.writenvram(2, writeData, 4); + + // Read bytes from non-volatile RAM storage. + Serial.println("Reading NVRAM values:"); + // Example reading one byte at a time. + Serial.println(rtc.readnvram(0), HEX); + Serial.println(rtc.readnvram(1), HEX); + // Example reading multiple bytes: + uint8_t readData[4] = {0}; + rtc.readnvram(readData, 4, 2); + Serial.println(readData[0], HEX); + Serial.println(readData[1], HEX); + Serial.println(readData[2], HEX); + Serial.println(readData[3], HEX); + +} + +void loop () { + // Do nothing in the loop. +} diff --git a/Doc/DataSheet/RTC_1307/RTClib/examples/softrtc/softrtc.ino b/Doc/DataSheet/RTC_1307/RTClib/examples/softrtc/softrtc.ino new file mode 100644 index 0000000..d43ffe6 --- /dev/null +++ b/Doc/DataSheet/RTC_1307/RTClib/examples/softrtc/softrtc.ino @@ -0,0 +1,55 @@ +// Date and time functions using just software, based on millis() & timer + +#include +#include "RTClib.h" + +RTC_Millis rtc; + +void setup () { + Serial.begin(57600); + // following line sets the RTC to the date & time this sketch was compiled + rtc.begin(DateTime(F(__DATE__), F(__TIME__))); + // This line sets the RTC with an explicit date & time, for example to set + // January 21, 2014 at 3am you would call: + // rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0)); +} + +void loop () { + DateTime now = rtc.now(); + + Serial.print(now.year(), DEC); + Serial.print('/'); + Serial.print(now.month(), DEC); + Serial.print('/'); + Serial.print(now.day(), DEC); + Serial.print(' '); + Serial.print(now.hour(), DEC); + Serial.print(':'); + Serial.print(now.minute(), DEC); + Serial.print(':'); + Serial.print(now.second(), DEC); + Serial.println(); + + Serial.print(" seconds since 1970: "); + Serial.println(now.unixtime()); + + // calculate a date which is 7 days and 30 seconds into the future + DateTime future (now.unixtime() + 7 * 86400L + 30); + + Serial.print(" now + 7d + 30s: "); + Serial.print(future.year(), DEC); + Serial.print('/'); + Serial.print(future.month(), DEC); + Serial.print('/'); + Serial.print(future.day(), DEC); + Serial.print(' '); + Serial.print(future.hour(), DEC); + Serial.print(':'); + Serial.print(future.minute(), DEC); + Serial.print(':'); + Serial.print(future.second(), DEC); + Serial.println(); + + Serial.println(); + delay(3000); +} diff --git a/Doc/DataSheet/RTC_1307/RTClib/keywords.txt b/Doc/DataSheet/RTC_1307/RTClib/keywords.txt new file mode 100644 index 0000000..26cdc1e --- /dev/null +++ b/Doc/DataSheet/RTC_1307/RTClib/keywords.txt @@ -0,0 +1,37 @@ +####################################### +# Syntax Coloring Map For RTC +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +DateTime KEYWORD1 +RTC_DS1307 KEYWORD1 +RTC_Millis KEYWORD1 +Ds1307SqwPinMode KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +year KEYWORD2 +month KEYWORD2 +day KEYWORD2 +hour KEYWORD2 +minute KEYWORD2 +second KEYWORD2 +dayOfWeek KEYWORD2 +secondstime KEYWORD2 +unixtime KEYWORD2 +begin KEYWORD2 +adjust KEYWORD2 +isrunning KEYWORD2 +now KEYWORD2 +readSqwPinMode KEYWORD2 +writeSqwPinMode KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### + diff --git a/Doc/DataSheet/RTC_1307/__www.tuelectronica.es_tutoriales_arduino_reloj-rtc-i2c-co.pdf b/Doc/DataSheet/RTC_1307/__www.tuelectronica.es_tutoriales_arduino_reloj-rtc-i2c-co.pdf new file mode 100644 index 0000000..469e967 Binary files /dev/null and b/Doc/DataSheet/RTC_1307/__www.tuelectronica.es_tutoriales_arduino_reloj-rtc-i2c-co.pdf differ diff --git a/Doc/DataSheet/RTC_1307/rtclib.rar b/Doc/DataSheet/RTC_1307/rtclib.rar new file mode 100644 index 0000000..8d0c6ba Binary files /dev/null and b/Doc/DataSheet/RTC_1307/rtclib.rar differ diff --git a/Doc/DataSheet/Raspberry_ATXRaspi/Raspberry_Encendido_Apagado.jpg b/Doc/DataSheet/Raspberry_ATXRaspi/Raspberry_Encendido_Apagado.jpg new file mode 100644 index 0000000..d75d164 Binary files /dev/null and b/Doc/DataSheet/Raspberry_ATXRaspi/Raspberry_Encendido_Apagado.jpg differ diff --git a/Doc/DataSheet/Sensor_Ultrasonidos_LV-EZ3/MB1030_Datasheet.pdf b/Doc/DataSheet/Sensor_Ultrasonidos_LV-EZ3/MB1030_Datasheet.pdf new file mode 100644 index 0000000..cce95b2 Binary files /dev/null and b/Doc/DataSheet/Sensor_Ultrasonidos_LV-EZ3/MB1030_Datasheet.pdf differ diff --git a/Doc/DataSheet/Sensor_Ultrasonidos_LV-EZ3/MB1030_Maxbotix.com_Ejemplos.pdf b/Doc/DataSheet/Sensor_Ultrasonidos_LV-EZ3/MB1030_Maxbotix.com_Ejemplos.pdf new file mode 100644 index 0000000..03d9068 Binary files /dev/null and b/Doc/DataSheet/Sensor_Ultrasonidos_LV-EZ3/MB1030_Maxbotix.com_Ejemplos.pdf differ diff --git a/Doc/DataSheet/Sensor_Ultrasonidos_PING/Distance_with_PING.pdf b/Doc/DataSheet/Sensor_Ultrasonidos_PING/Distance_with_PING.pdf new file mode 100644 index 0000000..3b75fff Binary files /dev/null and b/Doc/DataSheet/Sensor_Ultrasonidos_PING/Distance_with_PING.pdf differ diff --git a/Doc/DataSheet/Sensor_Ultrasonidos_PING/PING_documentation.pdf b/Doc/DataSheet/Sensor_Ultrasonidos_PING/PING_documentation.pdf new file mode 100644 index 0000000..4e98e44 Binary files /dev/null and b/Doc/DataSheet/Sensor_Ultrasonidos_PING/PING_documentation.pdf differ diff --git a/Doc/DataSheet/Varios/2N7000.pdf b/Doc/DataSheet/Varios/2N7000.pdf new file mode 100644 index 0000000..4816d0b Binary files /dev/null and b/Doc/DataSheet/Varios/2N7000.pdf differ diff --git a/Doc/DataSheet/Varios/74HCT238.pdf b/Doc/DataSheet/Varios/74HCT238.pdf new file mode 100644 index 0000000..81f9d8b Binary files /dev/null and b/Doc/DataSheet/Varios/74HCT238.pdf differ diff --git a/Doc/DataSheet/Varios/75T2090-IP.pdf b/Doc/DataSheet/Varios/75T2090-IP.pdf new file mode 100644 index 0000000..245ccbc Binary files /dev/null and b/Doc/DataSheet/Varios/75T2090-IP.pdf differ diff --git a/Doc/DataSheet/Varios/ACS714.pdf b/Doc/DataSheet/Varios/ACS714.pdf new file mode 100644 index 0000000..bd71f31 Binary files /dev/null and b/Doc/DataSheet/Varios/ACS714.pdf differ diff --git a/Doc/DataSheet/Varios/Amortiguador_RS-366-3238.pdf b/Doc/DataSheet/Varios/Amortiguador_RS-366-3238.pdf new file mode 100644 index 0000000..8a3acf9 Binary files /dev/null and b/Doc/DataSheet/Varios/Amortiguador_RS-366-3238.pdf differ diff --git a/Doc/DataSheet/Varios/Bricogeek_LED-0001.pdf b/Doc/DataSheet/Varios/Bricogeek_LED-0001.pdf new file mode 100644 index 0000000..a6cfef6 Binary files /dev/null and b/Doc/DataSheet/Varios/Bricogeek_LED-0001.pdf differ diff --git a/Doc/DataSheet/Varios/Conector_USB.jpg b/Doc/DataSheet/Varios/Conector_USB.jpg new file mode 100644 index 0000000..4bec513 Binary files /dev/null and b/Doc/DataSheet/Varios/Conector_USB.jpg differ diff --git a/Doc/DataSheet/Varios/Darlington_Drivers_Allegro_2981_RS-162-795.pdf b/Doc/DataSheet/Varios/Darlington_Drivers_Allegro_2981_RS-162-795.pdf new file mode 100644 index 0000000..e990fd9 Binary files /dev/null and b/Doc/DataSheet/Varios/Darlington_Drivers_Allegro_2981_RS-162-795.pdf differ diff --git a/Doc/DataSheet/Varios/Encoder_TW-700198.pdf b/Doc/DataSheet/Varios/Encoder_TW-700198.pdf new file mode 100644 index 0000000..5b1cfcb Binary files /dev/null and b/Doc/DataSheet/Varios/Encoder_TW-700198.pdf differ diff --git a/Doc/DataSheet/Varios/FDS5672.pdf b/Doc/DataSheet/Varios/FDS5672.pdf new file mode 100644 index 0000000..8367660 Binary files /dev/null and b/Doc/DataSheet/Varios/FDS5672.pdf differ diff --git a/Doc/DataSheet/Varios/Fotodiodo_SFH229.pdf b/Doc/DataSheet/Varios/Fotodiodo_SFH229.pdf new file mode 100644 index 0000000..2ab3581 Binary files /dev/null and b/Doc/DataSheet/Varios/Fotodiodo_SFH229.pdf differ diff --git a/Doc/DataSheet/Varios/H11D2.pdf b/Doc/DataSheet/Varios/H11D2.pdf new file mode 100644 index 0000000..00daa43 Binary files /dev/null and b/Doc/DataSheet/Varios/H11D2.pdf differ diff --git a/Doc/DataSheet/Varios/HEF4051B.pdf b/Doc/DataSheet/Varios/HEF4051B.pdf new file mode 100644 index 0000000..e773b69 Binary files /dev/null and b/Doc/DataSheet/Varios/HEF4051B.pdf differ diff --git a/Doc/DataSheet/Varios/HEF4541B.pdf b/Doc/DataSheet/Varios/HEF4541B.pdf new file mode 100644 index 0000000..285ac86 Binary files /dev/null and b/Doc/DataSheet/Varios/HEF4541B.pdf differ diff --git a/Doc/DataSheet/Varios/HRXL-MaxSonar-WR_Datasheet.pdf b/Doc/DataSheet/Varios/HRXL-MaxSonar-WR_Datasheet.pdf new file mode 100644 index 0000000..06faf8f Binary files /dev/null and b/Doc/DataSheet/Varios/HRXL-MaxSonar-WR_Datasheet.pdf differ diff --git a/Doc/DataSheet/Varios/IS1U60.pdf b/Doc/DataSheet/Varios/IS1U60.pdf new file mode 100644 index 0000000..e689559 Binary files /dev/null and b/Doc/DataSheet/Varios/IS1U60.pdf differ diff --git a/Doc/DataSheet/Varios/L78S05CV.pdf b/Doc/DataSheet/Varios/L78S05CV.pdf new file mode 100644 index 0000000..b4bd210 Binary files /dev/null and b/Doc/DataSheet/Varios/L78S05CV.pdf differ diff --git a/Doc/DataSheet/Varios/L78S12CV.pdf b/Doc/DataSheet/Varios/L78S12CV.pdf new file mode 100644 index 0000000..fdff40d Binary files /dev/null and b/Doc/DataSheet/Varios/L78S12CV.pdf differ diff --git a/Doc/DataSheet/Varios/LCA110.pdf b/Doc/DataSheet/Varios/LCA110.pdf new file mode 100644 index 0000000..93d7244 Binary files /dev/null and b/Doc/DataSheet/Varios/LCA110.pdf differ diff --git a/Doc/DataSheet/Varios/LM3710.pdf b/Doc/DataSheet/Varios/LM3710.pdf new file mode 100644 index 0000000..ff511ab Binary files /dev/null and b/Doc/DataSheet/Varios/LM3710.pdf differ diff --git a/Doc/DataSheet/Varios/Led_RS-712-8120.pdf b/Doc/DataSheet/Varios/Led_RS-712-8120.pdf new file mode 100644 index 0000000..fa0a003 Binary files /dev/null and b/Doc/DataSheet/Varios/Led_RS-712-8120.pdf differ diff --git a/Doc/DataSheet/Varios/Led_RS-720-8908.pdf b/Doc/DataSheet/Varios/Led_RS-720-8908.pdf new file mode 100644 index 0000000..389896f Binary files /dev/null and b/Doc/DataSheet/Varios/Led_RS-720-8908.pdf differ diff --git a/Doc/DataSheet/Varios/Lm2940.pdf b/Doc/DataSheet/Varios/Lm2940.pdf new file mode 100644 index 0000000..f3c98f6 Binary files /dev/null and b/Doc/DataSheet/Varios/Lm2940.pdf differ diff --git a/Doc/DataSheet/Varios/Lm3940.pdf b/Doc/DataSheet/Varios/Lm3940.pdf new file mode 100644 index 0000000..f49332f Binary files /dev/null and b/Doc/DataSheet/Varios/Lm3940.pdf differ diff --git a/Doc/DataSheet/Varios/MAX232.pdf b/Doc/DataSheet/Varios/MAX232.pdf new file mode 100644 index 0000000..5ae5815 Binary files /dev/null and b/Doc/DataSheet/Varios/MAX232.pdf differ diff --git a/Doc/DataSheet/Varios/MAX6814.pdf b/Doc/DataSheet/Varios/MAX6814.pdf new file mode 100644 index 0000000..d54b17e Binary files /dev/null and b/Doc/DataSheet/Varios/MAX6814.pdf differ diff --git a/Doc/DataSheet/Varios/MAX690.pdf b/Doc/DataSheet/Varios/MAX690.pdf new file mode 100644 index 0000000..54e9b78 Binary files /dev/null and b/Doc/DataSheet/Varios/MAX690.pdf differ diff --git a/Doc/DataSheet/Varios/MAX824.pdf b/Doc/DataSheet/Varios/MAX824.pdf new file mode 100644 index 0000000..34781b2 Binary files /dev/null and b/Doc/DataSheet/Varios/MAX824.pdf differ diff --git a/Doc/DataSheet/Varios/MLX90614.pdf b/Doc/DataSheet/Varios/MLX90614.pdf new file mode 100644 index 0000000..b790724 Binary files /dev/null and b/Doc/DataSheet/Varios/MLX90614.pdf differ diff --git a/Doc/DataSheet/Varios/MT8870D.pdf b/Doc/DataSheet/Varios/MT8870D.pdf new file mode 100644 index 0000000..ae5a410 Binary files /dev/null and b/Doc/DataSheet/Varios/MT8870D.pdf differ diff --git a/Doc/DataSheet/Varios/Mosfet_FQP30N06_RS_AMIDATA.pdf b/Doc/DataSheet/Varios/Mosfet_FQP30N06_RS_AMIDATA.pdf new file mode 100644 index 0000000..fba43dd Binary files /dev/null and b/Doc/DataSheet/Varios/Mosfet_FQP30N06_RS_AMIDATA.pdf differ diff --git a/Doc/DataSheet/Varios/PortaFusible_RS-122-2598.pdf b/Doc/DataSheet/Varios/PortaFusible_RS-122-2598.pdf new file mode 100644 index 0000000..f8b4582 Binary files /dev/null and b/Doc/DataSheet/Varios/PortaFusible_RS-122-2598.pdf differ diff --git a/Doc/DataSheet/Varios/Pulsador_RS-811-4059.pdf b/Doc/DataSheet/Varios/Pulsador_RS-811-4059.pdf new file mode 100644 index 0000000..a0ffd9c Binary files /dev/null and b/Doc/DataSheet/Varios/Pulsador_RS-811-4059.pdf differ diff --git a/Doc/DataSheet/Varios/Rele_G2RL-1-E.pdf b/Doc/DataSheet/Varios/Rele_G2RL-1-E.pdf new file mode 100644 index 0000000..09f4433 Binary files /dev/null and b/Doc/DataSheet/Varios/Rele_G2RL-1-E.pdf differ diff --git a/Doc/DataSheet/Varios/Rele_Omron_.pdf b/Doc/DataSheet/Varios/Rele_Omron_.pdf new file mode 100644 index 0000000..68663f2 Binary files /dev/null and b/Doc/DataSheet/Varios/Rele_Omron_.pdf differ diff --git a/Doc/DataSheet/Varios/Rele_RS-699-6020.pdf b/Doc/DataSheet/Varios/Rele_RS-699-6020.pdf new file mode 100644 index 0000000..7fad757 Binary files /dev/null and b/Doc/DataSheet/Varios/Rele_RS-699-6020.pdf differ diff --git a/Doc/DataSheet/Varios/Rele_RS-699-6339.pdf b/Doc/DataSheet/Varios/Rele_RS-699-6339.pdf new file mode 100644 index 0000000..be5a9c7 Binary files /dev/null and b/Doc/DataSheet/Varios/Rele_RS-699-6339.pdf differ diff --git a/Doc/DataSheet/Varios/Rele_RS-808-8465.pdf b/Doc/DataSheet/Varios/Rele_RS-808-8465.pdf new file mode 100644 index 0000000..3def324 Binary files /dev/null and b/Doc/DataSheet/Varios/Rele_RS-808-8465.pdf differ diff --git a/Doc/DataSheet/Varios/Rele_RS-815-5044.pdf b/Doc/DataSheet/Varios/Rele_RS-815-5044.pdf new file mode 100644 index 0000000..37e8de2 Binary files /dev/null and b/Doc/DataSheet/Varios/Rele_RS-815-5044.pdf differ diff --git a/Doc/DataSheet/Varios/Rele_RS-827-6315.pdf b/Doc/DataSheet/Varios/Rele_RS-827-6315.pdf new file mode 100644 index 0000000..5a337c7 Binary files /dev/null and b/Doc/DataSheet/Varios/Rele_RS-827-6315.pdf differ diff --git a/Doc/DataSheet/Varios/Sparkfun_GPS-GP-635T.pdf b/Doc/DataSheet/Varios/Sparkfun_GPS-GP-635T.pdf new file mode 100644 index 0000000..40f6cf6 Binary files /dev/null and b/Doc/DataSheet/Varios/Sparkfun_GPS-GP-635T.pdf differ diff --git a/Doc/DataSheet/Varios/TPL5000.pdf b/Doc/DataSheet/Varios/TPL5000.pdf new file mode 100644 index 0000000..cdc1a00 Binary files /dev/null and b/Doc/DataSheet/Varios/TPL5000.pdf differ diff --git a/Doc/DataSheet/Varios/UDN2981.pdf b/Doc/DataSheet/Varios/UDN2981.pdf new file mode 100644 index 0000000..e990fd9 Binary files /dev/null and b/Doc/DataSheet/Varios/UDN2981.pdf differ diff --git a/Doc/DataSheet/Varios/watch_dog.jpg b/Doc/DataSheet/Varios/watch_dog.jpg new file mode 100644 index 0000000..4030be6 Binary files /dev/null and b/Doc/DataSheet/Varios/watch_dog.jpg differ diff --git a/Doc/Documentacion/Dibujo1.vsd b/Doc/Documentacion/Dibujo1.vsd new file mode 100644 index 0000000..1f422a3 Binary files /dev/null and b/Doc/Documentacion/Dibujo1.vsd differ diff --git a/Doc/Documentacion/Ilustraciones/Bateria_1.gif b/Doc/Documentacion/Ilustraciones/Bateria_1.gif new file mode 100644 index 0000000..954319f Binary files /dev/null and b/Doc/Documentacion/Ilustraciones/Bateria_1.gif differ diff --git a/Doc/Documentacion/Ilustraciones/trex-01.jpg b/Doc/Documentacion/Ilustraciones/trex-01.jpg new file mode 100644 index 0000000..413d1ee Binary files /dev/null and b/Doc/Documentacion/Ilustraciones/trex-01.jpg differ diff --git a/Doc/Documentacion/Ilustraciones/trex-01.png b/Doc/Documentacion/Ilustraciones/trex-01.png new file mode 100644 index 0000000..8c16fa3 Binary files /dev/null and b/Doc/Documentacion/Ilustraciones/trex-01.png differ diff --git a/Doc/Documentacion/Ilustraciones/wrapping_01.png b/Doc/Documentacion/Ilustraciones/wrapping_01.png new file mode 100644 index 0000000..2ff051e Binary files /dev/null and b/Doc/Documentacion/Ilustraciones/wrapping_01.png differ diff --git a/Doc/Documentacion/Ilustraciones/wrapping_02.png b/Doc/Documentacion/Ilustraciones/wrapping_02.png new file mode 100644 index 0000000..0664974 Binary files /dev/null and b/Doc/Documentacion/Ilustraciones/wrapping_02.png differ diff --git a/Doc/Documentacion/Ilustraciones/wrapping_03.png b/Doc/Documentacion/Ilustraciones/wrapping_03.png new file mode 100644 index 0000000..67d7535 Binary files /dev/null and b/Doc/Documentacion/Ilustraciones/wrapping_03.png differ diff --git a/Doc/Documentacion/Ilustraciones/wrapping_04.jpg b/Doc/Documentacion/Ilustraciones/wrapping_04.jpg new file mode 100644 index 0000000..c3fc310 Binary files /dev/null and b/Doc/Documentacion/Ilustraciones/wrapping_04.jpg differ diff --git a/Doc/Documentacion/Raspberry_Encendido_Apagado.jpg b/Doc/Documentacion/Raspberry_Encendido_Apagado.jpg new file mode 100644 index 0000000..d75d164 Binary files /dev/null and b/Doc/Documentacion/Raspberry_Encendido_Apagado.jpg differ diff --git a/Doc/Documentacion/UF_ENE.vsd b/Doc/Documentacion/UF_ENE.vsd new file mode 100644 index 0000000..069ddb6 Binary files /dev/null and b/Doc/Documentacion/UF_ENE.vsd differ diff --git a/Doc/Documentacion/Visio-Power_ON.pdf b/Doc/Documentacion/Visio-Power_ON.pdf new file mode 100644 index 0000000..dcf7580 Binary files /dev/null and b/Doc/Documentacion/Visio-Power_ON.pdf differ diff --git a/Doc/Documentacion/gescom_MEGA2560_V3.doc b/Doc/Documentacion/gescom_MEGA2560_V3.doc new file mode 100644 index 0000000..4f2ffcb Binary files /dev/null and b/Doc/Documentacion/gescom_MEGA2560_V3.doc differ diff --git a/Doc/Documentacion/iROB-EA-V1.0.0.docx b/Doc/Documentacion/iROB-EA-V1.0.0.docx new file mode 100644 index 0000000..fac7dec Binary files /dev/null and b/Doc/Documentacion/iROB-EA-V1.0.0.docx differ diff --git a/Doc/Documentacion/iROB-EA_Etiquetas.doc b/Doc/Documentacion/iROB-EA_Etiquetas.doc new file mode 100644 index 0000000..f588c7d Binary files /dev/null and b/Doc/Documentacion/iROB-EA_Etiquetas.doc differ diff --git a/Doc/Documentacion/iROB-EA_Etiquetas_2.doc b/Doc/Documentacion/iROB-EA_Etiquetas_2.doc new file mode 100644 index 0000000..21a5c02 Binary files /dev/null and b/Doc/Documentacion/iROB-EA_Etiquetas_2.doc differ diff --git a/Doc/Fotos/IMG_20151108_143026.jpg b/Doc/Fotos/IMG_20151108_143026.jpg new file mode 100644 index 0000000..68b7097 Binary files /dev/null and b/Doc/Fotos/IMG_20151108_143026.jpg differ diff --git a/Doc/Fotos/IMG_20151108_143100.jpg b/Doc/Fotos/IMG_20151108_143100.jpg new file mode 100644 index 0000000..31cca8f Binary files /dev/null and b/Doc/Fotos/IMG_20151108_143100.jpg differ diff --git a/Doc/Fotos/IMG_20151108_143159.jpg b/Doc/Fotos/IMG_20151108_143159.jpg new file mode 100644 index 0000000..4ec8041 Binary files /dev/null and b/Doc/Fotos/IMG_20151108_143159.jpg differ diff --git a/Doc/Fotos/IMG_20151108_143228.jpg b/Doc/Fotos/IMG_20151108_143228.jpg new file mode 100644 index 0000000..453582e Binary files /dev/null and b/Doc/Fotos/IMG_20151108_143228.jpg differ diff --git a/Doc/Fotos/IMG_20151108_143301.jpg b/Doc/Fotos/IMG_20151108_143301.jpg new file mode 100644 index 0000000..09208af Binary files /dev/null and b/Doc/Fotos/IMG_20151108_143301.jpg differ diff --git a/Doc/Fotos/IMG_20151108_143322.jpg b/Doc/Fotos/IMG_20151108_143322.jpg new file mode 100644 index 0000000..7e5e767 Binary files /dev/null and b/Doc/Fotos/IMG_20151108_143322.jpg differ diff --git a/Doc/Fotos/IMG_20151108_143337.jpg b/Doc/Fotos/IMG_20151108_143337.jpg new file mode 100644 index 0000000..028ddb3 Binary files /dev/null and b/Doc/Fotos/IMG_20151108_143337.jpg differ diff --git a/Hardware/V1.0.0/Proteccion_RS232.jpg b/Hardware/V1.0.0/Proteccion_RS232.jpg new file mode 100644 index 0000000..ccbbbd5 Binary files /dev/null and b/Hardware/V1.0.0/Proteccion_RS232.jpg differ diff --git a/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_BAT_V1.0.0.T3001 b/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_BAT_V1.0.0.T3001 new file mode 100644 index 0000000..8a8865b Binary files /dev/null and b/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_BAT_V1.0.0.T3001 differ diff --git a/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_DOG_V1.0.0.T3001 b/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_DOG_V1.0.0.T3001 new file mode 100644 index 0000000..23b70dc Binary files /dev/null and b/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_DOG_V1.0.0.T3001 differ diff --git a/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_INC_V1.0.0.T3001 b/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_INC_V1.0.0.T3001 new file mode 100644 index 0000000..814b33f Binary files /dev/null and b/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_INC_V1.0.0.T3001 differ diff --git a/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_MOT_V1.0.0.T3001 b/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_MOT_V1.0.0.T3001 new file mode 100644 index 0000000..9831d98 Binary files /dev/null and b/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_MOT_V1.0.0.T3001 differ diff --git a/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_POW_V1.0.0.T3001 b/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_POW_V1.0.0.T3001 new file mode 100644 index 0000000..7e6ff22 Binary files /dev/null and b/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_POW_V1.0.0.T3001 differ diff --git a/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_SYS_V1.0.0.T3001 b/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_SYS_V1.0.0.T3001 new file mode 100644 index 0000000..b663542 Binary files /dev/null and b/Hardware/V1.0.0/iROB-EA_UF_ENE_SS_SYS_V1.0.0.T3001 differ diff --git a/Software/iROB_EA/Bak/iROB_EA_Hasta_20150717.rar b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150717.rar new file mode 100644 index 0000000..30d3293 Binary files /dev/null and b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150717.rar differ diff --git a/Software/iROB_EA/Bak/iROB_EA_Hasta_20150721.rar b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150721.rar new file mode 100644 index 0000000..12163f4 Binary files /dev/null and b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150721.rar differ diff --git a/Software/iROB_EA/Bak/iROB_EA_Hasta_20150724.rar b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150724.rar new file mode 100644 index 0000000..ad1c9c9 Binary files /dev/null and b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150724.rar differ diff --git a/Software/iROB_EA/Bak/iROB_EA_Hasta_20150727.rar b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150727.rar new file mode 100644 index 0000000..23b3764 Binary files /dev/null and b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150727.rar differ diff --git a/Software/iROB_EA/Bak/iROB_EA_Hasta_20150728.rar b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150728.rar new file mode 100644 index 0000000..2540777 Binary files /dev/null and b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150728.rar differ diff --git a/Software/iROB_EA/Bak/iROB_EA_Hasta_20150729.rar b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150729.rar new file mode 100644 index 0000000..5292dbc Binary files /dev/null and b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150729.rar differ diff --git a/Software/iROB_EA/Bak/iROB_EA_Hasta_20150730.rar b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150730.rar new file mode 100644 index 0000000..6f71b4c Binary files /dev/null and b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150730.rar differ diff --git a/Software/iROB_EA/Bak/iROB_EA_Hasta_20150731.rar b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150731.rar new file mode 100644 index 0000000..5c4fb0f Binary files /dev/null and b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150731.rar differ diff --git a/Software/iROB_EA/Bak/iROB_EA_Hasta_20150909.rar b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150909.rar new file mode 100644 index 0000000..d3640ea Binary files /dev/null and b/Software/iROB_EA/Bak/iROB_EA_Hasta_20150909.rar differ diff --git a/Software/iROB_EA/Bak/iROB_EA_Hasta_20151204.rar b/Software/iROB_EA/Bak/iROB_EA_Hasta_20151204.rar new file mode 100644 index 0000000..ca74329 Binary files /dev/null and b/Software/iROB_EA/Bak/iROB_EA_Hasta_20151204.rar differ diff --git a/Software/iROB_EA/Conversor_ADC_notas_1.jpg b/Software/iROB_EA/Conversor_ADC_notas_1.jpg new file mode 100644 index 0000000..78ae318 Binary files /dev/null and b/Software/iROB_EA/Conversor_ADC_notas_1.jpg differ diff --git a/Software/iROB_EA/Conversor_ADC_notas_2.jpg b/Software/iROB_EA/Conversor_ADC_notas_2.jpg new file mode 100644 index 0000000..08fd98f Binary files /dev/null and b/Software/iROB_EA/Conversor_ADC_notas_2.jpg differ diff --git a/Software/iROB_EA/Conversor_ADC_notas_3.jpg b/Software/iROB_EA/Conversor_ADC_notas_3.jpg new file mode 100644 index 0000000..cad1828 Binary files /dev/null and b/Software/iROB_EA/Conversor_ADC_notas_3.jpg differ diff --git a/Software/iROB_EA/Gescom_MEGA2560_V3_Interfaz.ino b/Software/iROB_EA/Gescom_MEGA2560_V3_Interfaz.ino new file mode 100644 index 0000000..4d96592 --- /dev/null +++ b/Software/iROB_EA/Gescom_MEGA2560_V3_Interfaz.ino @@ -0,0 +1,915 @@ +// ---------------------------------------------------------- +// +// GESCOM +// Gestor de comandos +// Version para Arduino MEGA2560 +// +// Autor: +// Fichero: gescom_MEGA2560_Fn_V3.cpp +// Hardware: - +// Version: 3.0, Junio 2015 +// +// Funcionalidad: Procesador de Comandos +// +// Notas: +// +// +// +// ---------------------------------------------------------- + +#include +#include +#include +#include +#include "UF_SYS.h" +#include +#include + + + + + + + + + +// --------------------------------------------------------- +// +// +// +// FUNCIONES DE IMPLEMENTACION DE COMANDOS +// +// +// +// +// +// +// +// +// --------------------------------------------------------- + + + +// --------------------------------------------------------- +// +// void cmd_Comando_CM_DBG(GESCOM_DATA* gd) +// +// Uso: +// Sintaxis: +// comando: IDE_CMD_DBG +// parametro1: - +// parametro2: - +// +// Retorna: +// +// --------------------------------------------------------- + +void cmd_Comando_CM_DBG(GESCOM_DATA* gd) +{ + // --------------------------------------------------------- + // Generacion del pulso de latido, reset del watchDog como + // medidad de seguridad todas las implementaciones de + // comandos lo ejecutan al entrar + // --------------------------------------------------------- + uf_sys.watchDog_DONE(); + + + + + + + + +} + + + +// --------------------------------------------------------- +// +// void cmd_Comando_CM_RET(GESCOM_DATA* gd) +// +// Uso: +// Sintaxis: +// comando: IDE_CMD_RET +// parametro1: - +// parametro2: - +// +// Retorna: +// +// --------------------------------------------------------- + +void cmd_Comando_CM_RET(GESCOM_DATA* gd) +{ + // --------------------------------------------------------- + // Generacion del pulso de latido, reset del watchDog como + // medidad de seguridad todas las implementaciones de + // comandos lo ejecutan al entrar + // --------------------------------------------------------- + uf_sys.watchDog_DONE(); + + + + + + + +} + + + +// --------------------------------------------------------- +// +// void cmd_Comando_CM_RSV(GESCOM_DATA* gd) +// +// Uso: +// Sintaxis: +// comando: IDE_CMD_S_RSV +// parametro1: - +// parametro2: - +// +// Retorna: +// +// --------------------------------------------------------- + +void cmd_Comando_CM_RSV(GESCOM_DATA* gd) +{ + // --------------------------------------------------------- + // Generacion del pulso de latido, reset del watchDog como + // medidad de seguridad todas las implementaciones de + // comandos lo ejecutan al entrar + // --------------------------------------------------------- + uf_sys.watchDog_DONE(); + + + + + + +} + + + + +// --------------------------------------------------------- +// +// void cmd_Comando_S_MDER(GESCOM_DATA* gd) +// +// Uso: +// Sintaxis: +// comando: IDE_CMD_S_MDER +// parametro1: - +// parametro2: - +// +// Retorna: +// . True Todo correcto +// . False Error en la ejecucion +// +// --------------------------------------------------------- + +void cmd_Comando_S_MDER(GESCOM_DATA* gd) +{ + // --------------------------------------------------------- + // Generacion del pulso de latido, reset del watchDog como + // medidad de seguridad todas las implementaciones de + // comandos lo ejecutan al entrar + // --------------------------------------------------------- + uf_sys.watchDog_DONE(); + + + + + +} + + + +// --------------------------------------------------------- +// +// void cmd_Comando_S_MIZQ( unsigned int tComando, +// +// Uso: +// Sintaxis: +// comando: IDE_CMD_S_MIZQ +// parametro1: - +// parametro2: - +// +// Retorna: +// +// +// --------------------------------------------------------- + +void cmd_Comando_S_MIZQ(GESCOM_DATA* gd) +{ + // --------------------------------------------------------- + // Generacion del pulso de latido, reset del watchDog como + // medidad de seguridad todas las implementaciones de + // comandos lo ejecutan al entrar + // --------------------------------------------------------- + uf_sys.watchDog_DONE(); + + + + + + +} + + + +// --------------------------------------------------------- +// +// void cmd_Comando_B_LIPO(GESCOM_DATA* gd) +// +// Uso: Retorna informacion relacionada con la bateria +// de LiPo +// Sintaxis: +// comando: IDE_CMD_B_LIPO +// parametro1: IDE_PARAM_GET +// parametro2: IDE_PARAM_CHG +// IDE_PARAM_POW +// Retorna: +// . Valor en hexadecimal solicitado +// +// --------------------------------------------------------- + +void cmd_Comando_B_LIPO(GESCOM_DATA* gd) +{ + double iMedida; + double tiempo; + + + // --------------------------------------------------------- + // Generacion del pulso de latido, reset del watchDog como + // medida de seguridad todas las implementaciones de + // comandos lo ejecutan al entrar + // --------------------------------------------------------- + uf_sys.watchDog_DONE(); + + if ( (gd->cnv_Tipo==IDE_T_COMANDO_ENVIO) && (gd->cnv_Param01==IDE_PARAM_GET) ) + { // --------------------------------------------------------- + // + // + // --------------------------------------------------------- + switch(gd->cnv_Param02) + { + case (IDE_PARAM_CHG): + { + iMedida = uf_sys.get_Corriente(PIN_HW_BAT_CHG_LIPO); + dtostrf(iMedida, 4, 1, gd->buffRespCmd); + break; + } + + case (IDE_PARAM_POW): + { // --------------------------------------------------------- + // El consumo de la bateria se obtiene de la suma de los + // consumos de cada motor por eso NO hay un sensor específico + // para medir este consumo. + // --------------------------------------------------------- + + + + + break; + } + + default: + { + + break; + } + } + + } +} + + + +// --------------------------------------------------------- +// +// void cmd_Comando_B_PPAK(GESCOM_DATA* gd) +// +// Uso: Retorna informacion relacionada con la bateria +// de PowerPack +// Sintaxis: +// comando: IDE_CMD_B_PPAK +// parametro1: IDE_PARAM_GET +// parametro2: IDE_PARAM_CHG +// IDE_PARAM_POW +// Retorna: +// . Valor en hexadecimal solicitado +// +// --------------------------------------------------------- + +void cmd_Comando_B_PPAK(GESCOM_DATA* gd) +{ + double iMedida; + double tiempo; + + + // --------------------------------------------------------- + // Generacion del pulso de latido, reset del watchDog como + // medidad de seguridad todas las implementaciones de + // comandos lo ejecutan al entrar + // --------------------------------------------------------- + uf_sys.watchDog_DONE(); + + + if ( (gd->cnv_Tipo==IDE_T_COMANDO_ENVIO) && (gd->cnv_Param01==IDE_PARAM_GET) ) + { // --------------------------------------------------------- + // + // + // + // --------------------------------------------------------- + switch(gd->cnv_Param02) + { + case (IDE_PARAM_CHG): + { + iMedida = uf_sys.get_Corriente(PIN_HW_BAT_CHG_PPAK); + dtostrf(iMedida, 4, 1, gd->buffRespCmd); + break; + } + + case (IDE_PARAM_POW): + { + iMedida = uf_sys.get_Corriente(PIN_HW_BAT_CHG_PPAK); + tiempo = (IDE_CAPACIDAD_BAT_PPAK/iMedida) * 0.7; + dtostrf(tiempo, 4, 1, gd->buffRespCmd); + break; + } + + default: + { + + break; + } + } + } +} + + + +// --------------------------------------------------------- +// +// void cmd_Comando_S_CDBG(GESCOM_DATA* gd) +// +// Uso: Retorna valor del flag hardware que indica si +// esta conectado el conector de DEBUG +// Sintaxis: +// comando: IDE_CMD_S_DBG +// parametro1: IDE_PARAM_GET +// parametro2: IDE_PARAM_NOP +// +// Retorna: +// "00" NO esta conectado +// "01" SI esta conectado +// "02" Error de comando +// +// --------------------------------------------------------- + +void cmd_Comando_S_CDBG(GESCOM_DATA* gd) +{ + int v; + + + // --------------------------------------------------------- + // Generacion del pulso de latido, reset del watchDog como + // medidad de seguridad todas las implementaciones de + // comandos lo ejecutan al entrar + // --------------------------------------------------------- + uf_sys.watchDog_DONE(); + + + if ( (gd->cnv_Tipo==IDE_T_COMANDO_ENVIO) && (gd->cnv_Param01==IDE_PARAM_GET) ) + { // --------------------------------------------------------- + // + // + // + // --------------------------------------------------------- + if ( uf_sys.get_FlgDebug()==true) { sprintf(gd->buffRespCmd,"01"); } + else { sprintf(gd->buffRespCmd,"00"); } + } + else + { + sprintf(gd->buffRespCmd,"02"); + } + +} + + + +// --------------------------------------------------------- +// +// void cmd_Comando_R_TIME( GESCOM_DATA* gd ) +// +// Uso: Control del reloj de tiempo real +// Sintaxis: comando: IDE_CMD_R_TIME +// +// parametro1: IDE_PARAM_GET +// IDE_PARAM_SET +// IDE_PARAM_CHK +// IDE_PARAM_INI +// +// parametro2: IE_PARAM_NOP +// valor +// +// Retorna: +// "00" Error de comando +// "01" Comando ejecutado +// "AAAAMMDD HHMMSS" La fecha/hora actual +// +// --------------------------------------------------------- + +void cmd_Comando_R_TIME(GESCOM_DATA* gd) +{ + int v; + int vAnno; + int vMes; + int vDia; + int vHor; + int vMin; + int vSeg; + int resultado; + int flg; + char buff[IDE_MAXBUFF_GENERICO+1]; + + + // --------------------------------------------------------- + // Generacion del pulso de latido, reset del watchDog como + // medidad de seguridad todas las implementaciones de + // comandos lo ejecutan al entrar + // --------------------------------------------------------- + uf_sys.watchDog_DONE(); + + + resultado = true; + flg = false; + + if ( gd->cnv_Tipo==IDE_T_COMANDO_ENVIO ) + { // --------------------------------------------------------- + // + // + // + // --------------------------------------------------------- + switch(gd->cnv_Param01) + { + case ( IDE_PARAM_GET ): + { // --------------------------------------------------------- + // GET: Retonar Fecha y Hora del RTC + // Retorna: "AAAAMMDD HHMMSS" + // --------------------------------------------------------- + + DateTime now = rtc.now(); + + sprintf( gd->buffRespCmd , + "%04d%02d%02d %02d%02d%02d" , + now.year() , + now.month() , + now.day() , + now.hour() , + now.minute() , + now.second() + ); + flg = true; + break; + } + + case ( IDE_PARAM_SET ): + { // --------------------------------------------------------- + // SET: Establecer Fecha y Hora del RTC + // Espera un string en la forma: "AAAAMMDD HHMMSS" + // Retorna "00" Error + // "01" Ok se ha establecido los nueva fecha/hora + // --------------------------------------------------------- + + v = gd->cnv_Param02; + + if ( gc.getBytes(gd->buffRespCmd,v)==v ) + { + sscanf( gd->buffRespCmd , + "%04d%02d%02d %02d%02d%02d" , + &vAnno , + &vMes , + &vDia , + &vHor , + &vMin , + &vSeg + ); + rtc.adjust(DateTime(vAnno, vMes, vDia, vHor, vMin, vSeg)); + } + else + { + resultado = false; + } + + break; + } + + case ( IDE_PARAM_CHK ): + { // --------------------------------------------------------- + // CHK: Comprobar funcionamiento del RTC + // Retorna "00" No se esta ejecutando + // "01" si se esta ejecutando + // --------------------------------------------------------- + + if (!rtc.isrunning() ) + { + resultado = false; + } + + break; + } + + case ( IDE_PARAM_INI ): + { // --------------------------------------------------------- + // INI: Iniciar RTC + // Retorna "01" + // --------------------------------------------------------- + rtc.begin(); + break; + } + + default: + { + resultado = false; + break; + } + + } + } + else + { + resultado = false; + } + + if (flg==false) + { + if (resultado==false) { sprintf(gd->buffRespCmd,"00"); } + else { sprintf(gd->buffRespCmd,"01"); } + } + +} + + + +// --------------------------------------------------------- +// +// void cmd_Comando_L_LEDS( GESCOM_DATA* gd ) +// +// Uso: Control de los leds +// Sintaxis: +// comando: IDE_CMD_L_LEDS +// +// parametro1: IDE_PARAM_LD1 +// IDE_PARAM_LD2 +// IDE_PARAM_LD3 +// +// parametro2: IDE_PARAM_OFF +// IDE_PARAM__ON +// IDE_PARAM_BLK +// +// Retorna: +// "00" Error de comando +// "01" Comando ejecutado +// +// +// --------------------------------------------------------- + +void cmd_Comando_L_LEDS(GESCOM_DATA* gd) +{ + int pinID; + int resultado; + + + // --------------------------------------------------------- + // Generacion del pulso de latido, reset del watchDog como + // medidad de seguridad todas las implementaciones de + // comandos lo ejecutan al entrar + // --------------------------------------------------------- + uf_sys.watchDog_DONE(); + + + resultado = true; + + if ( gd->cnv_Tipo==IDE_T_COMANDO_ENVIO ) + { // --------------------------------------------------------- + // + // + // + // --------------------------------------------------------- + + if (resultado==true) + { + switch(gd->cnv_Param01) + { + case (IDE_PARAM_LD1): { pinID = PIN_HW_LED_BDEL; break; } + case (IDE_PARAM_LD2): { pinID = PIN_HW_LED_BDET; break; } + case (IDE_PARAM_LD3): { pinID = PIN_HW_LED_RDET; break; } + default: { resultado = false; break; } + } + } + + if (resultado==true) + { + switch(gd->cnv_Param02) + { + case (IDE_PARAM_OFF): { digitalWrite(pinID,LOW); break; } + case (IDE_PARAM__ON): { digitalWrite(pinID,HIGH); break; } + case (IDE_PARAM_BLK): { digitalWrite(pinID,HIGH); break; } + default: { resultado = false; break; } + } + } + } + else + { + resultado = false; + } + + if ( resultado==false) { sprintf(gd->buffRespCmd,"00"); } + else { sprintf(gd->buffRespCmd,"01"); } + +} + + + +// --------------------------------------------------------- +// +// void cmd_Comando_S_MLX9( GESCOM_DATA* gd ) +// +// Uso: Control del sensor de Temperatura MLX 90614 +// Sintaxis: +// comando: IDE_CMD_S_MLX9 +// +// parametro1: IDE_PARAM_GET +// +// parametro2: IDE_PARAM_SMA +// IDE_PARAM_SMB +// +// Retorna: +// +// +// --------------------------------------------------------- + +void cmd_Comando_S_MLX9(GESCOM_DATA* gd) +{ + + int resultado; + + + // --------------------------------------------------------- + // Generacion del pulso de latido, reset del watchDog como + // medidad de seguridad todas las implementaciones de + // comandos lo ejecutan al entrar + // --------------------------------------------------------- + uf_sys.watchDog_DONE(); + + + resultado = true; + + if ( gd->cnv_Tipo==IDE_T_COMANDO_ENVIO ) + { // --------------------------------------------------------- + // + // !!! Comprobar qu el sensor sea la version de 5 voltios + // + // --------------------------------------------------------- + + switch(gd->cnv_Param01) + { + case ( IDE_PARAM_GET ): + { // --------------------------------------------------------- + // GET: Retonar Medicion + // --------------------------------------------------------- + switch(gd->cnv_Param02) + { + case (IDE_PARAM_SSA): { sprintf( gd->buffRespCmd,"%03d",mlx.readAmbientTempC()); break; } + case (IDE_PARAM_SSB): { sprintf( gd->buffRespCmd,"%03d",mlx.readObjectTempC()); break; } + default: { resultado = false; break; } + } + break; + } + default: + { + resultado = false; + break; + } + } + + } + else + { + resultado = false; + } + + if ( resultado==false) { sprintf(gd->buffRespCmd,"000"); } + +} + + + +// --------------------------------------------------------- +// +// void cmd_Comando_C_MIZQ(GESCOM_DATA* gd) +// +// Uso: Control del motor izquierdo +// Sintaxis: +// comando: IDE_CMD_C_MIZQ +// +// parametro1: IDE_PARAM_INI +// IDE_PARAM_GDE +// IDE_PARAM_AVA +// IDE_PARAM_SVE +// IDE_PARAM_STO +// IDE_PARAM_GIZ +// +// parametro2: IDE_PARAM_NOP +// valor +// +// Retorna: +// +// +// --------------------------------------------------------- + +void cmd_Comando_C_MIZQ(GESCOM_DATA* gd) +{ + + int resultado; + +// --------------------------------------------------------- + // Generacion del pulso de latido, reset del watchDog como + // medidad de seguridad todas las implementaciones de + // comandos lo ejecutan al entrar + // --------------------------------------------------------- + uf_sys.watchDog_DONE(); + + + resultado = true; + + if ( gd->cnv_Tipo==IDE_T_COMANDO_ENVIO ) + { // --------------------------------------------------------- + // + // !!! Comprobar qu el sensor sea la version de 5 voltios + // + // --------------------------------------------------------- + + switch(gd->cnv_Param01) + { + case (IDE_PARAM_INI): { mIzq.paro(); break; } + case (IDE_PARAM_AVA): { mIzq.avance(); break; } + case (IDE_PARAM_RET): { mIzq.retroceso(); break; } + case (IDE_PARAM_STO): { mIzq.paro(); break; } + case (IDE_PARAM_SVE): { break; } + default: { resultado = false; break; } + } + + + + + } + else + { + resultado = false; + } + + if ( resultado==false) { sprintf(gd->buffRespCmd,"000"); } + +} + + + + +// --------------------------------------------------------- +// +// void cmd_Comando_C_MDER(GESCOM_DATA* gd) +// +// Uso: Control del motor derecho +// Sintaxis: +// comando: IDE_CMD_C_MDER +// +// parametro1: IDE_PARAM_INI +// IDE_PARAM_GDE +// IDE_PARAM_AVA +// IDE_PARAM_SVE +// IDE_PARAM_STO +// IDE_PARAM_GIZ +// +// parametro2: IDE_PARAM_NOP +// valor +// +// +// Retorna: +// +// +// --------------------------------------------------------- + +void cmd_Comando_C_MDER(GESCOM_DATA* gd) +{ + + int resultado; + + // --------------------------------------------------------- + // Generacion del pulso de latido, reset del watchDog como + // medidad de seguridad todas las implementaciones de + // comandos lo ejecutan al entrar + // --------------------------------------------------------- + uf_sys.watchDog_DONE(); + + + resultado = true; + + if ( gd->cnv_Tipo==IDE_T_COMANDO_ENVIO ) + { // --------------------------------------------------------- + // + // !!! Comprobar qu el sensor sea la version de 5 voltios + // + // --------------------------------------------------------- + + switch(gd->cnv_Param01) + { + case (IDE_PARAM_INI): { mDer.paro(); break; } + case (IDE_PARAM_AVA): { mDer.avance(); break; } + case (IDE_PARAM_RET): { mDer.retroceso(); break; } + case (IDE_PARAM_STO): { mDer.paro(); break; } + case (IDE_PARAM_SVE): { break; } + default: { resultado = false; break; } + } + + + + + } + else + { + resultado = false; + } + + if ( resultado==false) { sprintf(gd->buffRespCmd,"000"); } + +} + + + +// --------------------------------------------------------- +// +// void cmd_Comando_C_RMOV(GESCOM_DATA* gd) +// +// Uso: Generación de movimiento +// Sintaxis: +// comando: IDE_CMD_C_RMOV +// +// parametro1: IDE_PARAM_INI +// IDE_PARAM_GDE +// IDE_PARAM_AVA +// IDE_PARAM_SVE +// IDE_PARAM_STO +// IDE_PARAM_GIZ +// +// parametro2: IDE_PARAM_NOP +// valor +// +// +// Retorna: +// +// +// --------------------------------------------------------- + +void cmd_Comando_C_RMOV(GESCOM_DATA* gd) +{ + + int resultado; + + // --------------------------------------------------------- + // Generacion del pulso de latido, reset del watchDog como + // medidad de seguridad todas las implementaciones de + // comandos lo ejecutan al entrar + // --------------------------------------------------------- + uf_sys.watchDog_DONE(); + + + resultado = true; + + if ( gd->cnv_Tipo==IDE_T_COMANDO_ENVIO ) + { // --------------------------------------------------------- + // + // !!! Comprobar qu el sensor sea la version de 5 voltios + // + // --------------------------------------------------------- + + switch(gd->cnv_Param01) + { + case (IDE_PARAM_INI): { mDer.paro(); mIzq.paro(); break; } + case (IDE_PARAM_AVA): { mDer.avance(); mIzq.avance(); break; } + case (IDE_PARAM_RET): { mDer.retroceso(); mIzq.retroceso(); break; } + case (IDE_PARAM_STO): { mDer.paro(); mIzq.paro(); break; } + case (IDE_PARAM_SVE): { break; } + default: { resultado = false; break; } + } + + } + else + { + resultado = false; + } + + if ( resultado==false) { sprintf(gd->buffRespCmd,"000"); } + +} + diff --git a/Software/iROB_EA/MOTOR_FDS5672.h b/Software/iROB_EA/MOTOR_FDS5672.h new file mode 100644 index 0000000..fc31285 --- /dev/null +++ b/Software/iROB_EA/MOTOR_FDS5672.h @@ -0,0 +1,87 @@ +// --------------------------------------------------------- +// +// Proyecto: iROB-EA +// Version: 1.0 +// Fichero: MOTOR_FDS5672.h +// Autor: +// Hardware: Arduino MEGA 2560 +// Fecha: Abril 2015 +// +// Funcionalidad: Definicion de la clase UF_MOT +// +// Notas: +// +// --------------------------------------------------------- + + +#ifndef MOTOR_FDS5672_H +#define MOTOR_FDS5672_H + + +// --------------------------------------------------------- +// +// Definicion de Pines relacionados con el manejo de esta clase +// +// --------------------------------------------------------- + +#define IDE_MOTOR_FDS5672_PULSO_VAL 1000 // Pulso de validacion + + // NO CAMBIAR estos defines, el valor es la representacion real de FF1 y FF2 +#define IDE_MOTOR_FDS5672_OK 0 // Motor sin fallos +#define IDE_MOTOR_FDS5672_CORTOCIRCUITO 1 // Cortocircuito +#define IDE_MOTOR_FDS5672_TEMPERATURA 2 // Sobre calentamiento +#define IDE_MOTOR_FDS5672_TENSION 3 // Voltaje demasiado bajo + + +// --------------------------------------------------------- +// +// Definicion de la Clase MOTOR_FDS5672 +// +// --------------------------------------------------------- + +class MOTOR_FDS5672 +{ + + // --------------------------------------------------------- + // + // --------------------------------------------------------- + public: + + MOTOR_FDS5672 (int pin_DIR,int pin_PWM,int pin_RST,int pin_FF1,int pin_FF2,int pin_ICC); + void avance (void); + void retroceso (void); + void paro (void); + void velocidad (byte valor); + void inhibir (byte modo); + byte getEstado (void); + + // --------------------------------------------------------- + // + // --------------------------------------------------------- + private: + + void setValores (void); + + int pinDIR; + int pinPWM; + int pinRST; + int pinFF1; + int pinFF2; + int pinICC; + + byte vVelocidad; + byte flgInhibir; +}; + + + + + + + + + +#endif + + + diff --git a/Software/iROB_EA/MOTOR_FDS5672.ino b/Software/iROB_EA/MOTOR_FDS5672.ino new file mode 100644 index 0000000..845698d --- /dev/null +++ b/Software/iROB_EA/MOTOR_FDS5672.ino @@ -0,0 +1,187 @@ + +// --------------------------------------------------------- +// +// Proyecto: iROB-EA +// Version: 1.0 +// Fichero: MOTOR_FDS5672.ino +// Autor: +// Hardware: Arduino MEGA 2560 +// Fecha: Abril 2015 +// +// Funcionalidad: Implmentacion de la clase MOTOR_FDS5672 +// +// Notas: +// +// --------------------------------------------------------- + +#include +#include +#include +#include +#include "iROB_EA.h" +#include "MOTOR_FDS5672.h" + + + + +// --------------------------------------------------------- +// +// UF_SYS::MOTOR_FDS5672( int pin_DIR , +// int pin_PWM , +// int pin_RST , +// int pin_FF1 , +// int pin_FF2 , +// int pin_ICC +// ) +// Constructor +// +// --------------------------------------------------------- + +MOTOR_FDS5672::MOTOR_FDS5672(int pin_DIR,int pin_PWM,int pin_RST,int pin_FF1,int pin_FF2,int pin_ICC) +{ + pinDIR = pin_DIR; // 1º Esto + pinPWM = pin_PWM; + pinRST = pin_RST; + pinFF1 = pin_FF1; + pinFF2 = pin_FF2; + pinICC = pin_ICC; + + vVelocidad = 0; // 2º Esto + flgInhibir = false; + + // 3º Esto + pinMode(pin_DIR,OUTPUT); // Motor derecho, Direccion + pinMode(pin_RST,OUTPUT); // Motor derecho, Reset + pinMode(pin_FF1,INPUT); // Motor derecho, Flag estado (1) + pinMode(pin_FF2,INPUT); // Motor derecho, Flag estado (2) + pinMode(pin_ICC,INPUT); // Motor derecho, sensor de corriente (consumo) + + inhibir(flgInhibir); // 4º Esto + velocidad(vVelocidad); + +} + + + +// --------------------------------------------------------- +// +// void MOTOR_FDS5672::avance (void) +// +// +// --------------------------------------------------------- + +void MOTOR_FDS5672::avance (void) +{ + if ( flgInhibir==false ) + { + digitalWrite(pinDIR,LOW); + setValores(); + } +} + + + +// --------------------------------------------------------- +// +// void MOTOR_FDS5672::retroceso (void) +// +// +// --------------------------------------------------------- + +void MOTOR_FDS5672::retroceso (void) +{ + if ( flgInhibir==false ) + { + digitalWrite(pinDIR,HIGH); + setValores(); + } +} + + + +// --------------------------------------------------------- +// +// void MOTOR_FDS5672::paro (void) +// +// +// --------------------------------------------------------- + +void MOTOR_FDS5672::paro (void) +{ + if ( flgInhibir==false ) + { + digitalWrite(pinRST,HIGH); + } +} + + + +// --------------------------------------------------------- +// +// void MOTOR_FDS5672::velocidad(byte valor) +// +// +// --------------------------------------------------------- + +void MOTOR_FDS5672::velocidad(byte valor) +{ + vVelocidad = valor; + analogWrite(pinPWM,vVelocidad); + setValores(); +} + + + +// --------------------------------------------------------- +// +// void MOTOR_FDS5672::inhibir(byte modo) +// +// +// --------------------------------------------------------- + +void MOTOR_FDS5672::inhibir(byte modo) +{ + flgInhibir = modo; + if ( flgInhibir==true ) { digitalWrite(pinRST,HIGH); } + else { digitalWrite(pinRST,LOW); } + +} + + + +// --------------------------------------------------------- +// +// void MOTOR_FDS5672::setValores(void) +// +// +// --------------------------------------------------------- + +void MOTOR_FDS5672::setValores(void) +{ + digitalWrite(pinRST,HIGH); + delayMicroseconds(IDE_MOTOR_FDS5672_PULSO_VAL); + digitalWrite(pinRST,LOW); +} + + + + +// --------------------------------------------------------- +// +// byte MOTOR_FDS5672::getEstado(void) +// +// +// --------------------------------------------------------- + +byte MOTOR_FDS5672::getEstado(void) +{ + byte estado; + + estado = 0; + if ( digitalRead(pinFF1)==HIGH) { estado = 2; } + if ( digitalRead(pinFF2)==HIGH) { estado += 1; } + + return(estado); +} + + diff --git a/Software/iROB_EA/Pines_Analogicos_Identificar.jpg b/Software/iROB_EA/Pines_Analogicos_Identificar.jpg new file mode 100644 index 0000000..cd3b318 Binary files /dev/null and b/Software/iROB_EA/Pines_Analogicos_Identificar.jpg differ diff --git a/Software/iROB_EA/UF_SYS.h b/Software/iROB_EA/UF_SYS.h new file mode 100644 index 0000000..6e1d92e --- /dev/null +++ b/Software/iROB_EA/UF_SYS.h @@ -0,0 +1,161 @@ +// --------------------------------------------------------- +// +// Proyecto: iROB-EA +// Version: 1.0 +// Fichero: UF_SYS.h +// Autor: +// Hardware: Arduino MEGA 2560 +// Fecha: Abril 2015 +// +// Funcionalidad: Definicion de la clase UF_SYS +// +// Notas: +// +// --------------------------------------------------------- + + +#ifndef IDE_UF_SYS_H +#define IDE_UF_SYS_H + + + +// --------------------------------------------------------- +// +// Definicion de Pines relacionados con el manejo de esta clase +// +// --------------------------------------------------------- + +#define EEPROM_ADDR_NUM_RC 0 // Direccion en EEPROM (offset) de comienzo de la variable que almacena el numero de Reintentos de arranque +#define EEPROM_ADDR_MOD_INI 1 // Direccion en EEPROM (offset) de comienzo de la variable que almacena la clave actual de acceso +#define EEPROM_ADDR_CLV_AE 2 // Direccion en EEPROM (offset) de comienzo de la variable que almacena +#define EEPROM_ADDR_WATCHDOG 6 // Direccion en EEPROM (offset) de comienzo de la variable que almacena +#define EEPROM_ADDR_RECARGAS 7 // Direccion en EEPROM (offset) de comienzo de la variable que almacena + // Las variables se almacenan en EEPROM en este orden: + // ADDR 0: variable EEPROM_ADDR_NUM_RC 1 Byte + // ADDR 1: variable EEPROM_ADDR_MOD_INI 1 Byte + // ADDR 2: variable EEPROM_ADDR_CLV_AE 4 Bytes + // ADDR 3: variable EEPROM_ADDR_WATCHDOG 1 Byte + // ADDR 4: variable EEPROM_ADDR_RECARGAS 2 Bytes + + + + +#define IDE_INICIO_POWER_ON 0 // Inicio de Arduino por power ON ( arranque normal) +#define IDE_INICIO_WATCHDOG 1 // Inicio de Arduino por watchdog + +#define IDE_RELE_SYS_OFF 0 // Rele de power OFF +#define IDE_RELE_CPU_APL 1 // Rele para alimentar la CPU APL +#define IDE_RELE_CAMARA 2 // Rele para alimentar la camara +#define IDE_RELE_MOTORES 3 // Rele para alimentar los motores + +#define IDE_RELE_SYS_PAUSA 250 // Pausa (ms) para activar/Desactivar los reles RE1, RE2, RE3 y RE4 +#define IDE_RELE_ACTIVAR 1 +#define IDE_RELE_DESACTIVAR 0 + + // Usar MEMPROG +#define IDE_STR_INICIO_VERSION "iROB_EA, version 1.00, Junio 2015" +#define IDE_STR_INICIO_WATCHDOG "Arranque por Watchdog" +#define IDE_STR_INICIO_POWER_ON "Arranque por Power ON" +#define IDE_STR_INICIO_POWER_OFF "Apagando Sistema (Power OFF)..." +#define IDE_STR_INICIO_POWER_DOWN "Iniciando Apagado (Power OFF)..." +#define IDE_STR_SINCRO_WATCHDOG_1 "Sincronizando el watchdog..." +#define IDE_STR_SINCRO_WATCHDOG_2 "Watchdog sincronizado" + +#define IDE_SYSTEM_OK 0x00 +#define IDE_SYSTEM_OFF 0xF0 +#define IDE_SYSTEM_WATCHDOG 0x0F + + +#define IDE_DTMF_PAUSA_TONO 300L // DTMF: Tiempo máximo que puede pasar entre tonos cuando se esta introduciendo una clave +#define IDE_OFF_PAUSA 2000 // Pausa antes de apagar el Robot + +#define IDE_MAXBUFF_GENERICO 50 // Tamaño para un buffer temporal generico + +#define IDE_CAPACIDAD_BAT_LIPO 6500 // Capacidad en miliamperios de la Bateria LiPoPack equipada +#define IDE_CAPACIDAD_BAT_PPAK 10400 // Capacidad en miliamperios de la Bateria PowerPack equipada + + + + +// --------------------------------------------------------- +// +// Definicion de la Clase UF_SYS +// +// --------------------------------------------------------- + +class UF_SYS +{ + + // --------------------------------------------------------- + // + // --------------------------------------------------------- + public: + + UF_SYS (void); + void inicio (void); + + void watchDog_DONE (void); + void watchDog_Sincro (void); + void power_OFF (void); + void rele (byte releID,byte estado); + + byte secuenciaInicio (void); + + byte get_NUM_RC (void); + void get_CLV_AE (char* valor); + byte get_MOD_INI (void); + byte get_WATCHDOG (void); + int get_RECARGAS (void); + byte get_DTMF (void); + + byte get_CodigoDTMF (char* buff); + double get_Corriente (byte pinID); + byte get_NivelPPbank (void); + byte get_NivelLiPo (void); + byte get_FlgDebug (void); + + void set_NUM_RC (byte valor); + void set_CLV_AE (char* valor); + void set_MOD_INI (byte valor); + void set_WATCHDOG (byte valor); + void set_RECARGAS (int valor); + + void calibra_SensoresIcc (void); + void recarga_Bateria (void); + + void display_Datos_EEPROM (void); + void display_Modo (void); + unsigned long getTimeExe (byte modo); + void miDelay (unsigned long int retardo); + + + + + // --------------------------------------------------------- + // + // --------------------------------------------------------- + private: + + unsigned long timeExe; // variable para medir el tiempo de ejecucion del bloque principal del programa + // Reloj de Tiempo Real + + int numRecargas; + int offsetIcc_CHG_PPAK; // Offset para la lectura del sensor de corriente de entrada al PowerBank + int offsetIcc_CHG_LIPO; // Offset para la lectura del sensor de corriente de entrada a la bateria LiPo + int offsetIcc_MDER_ICC; // Offset para la lectura del sensor de corriente del motor derecho + int offsetIcc_MIZQ_ICC; // Offset para la lectura del sensor de corriente del motor izquierdo + +}; + + + + + + + + + +#endif + + + diff --git a/Software/iROB_EA/UF_SYS.ino b/Software/iROB_EA/UF_SYS.ino new file mode 100644 index 0000000..1e20398 --- /dev/null +++ b/Software/iROB_EA/UF_SYS.ino @@ -0,0 +1,996 @@ + +// --------------------------------------------------------- +// +// Proyecto: iROB-EA +// Version: 1.0 +// Fichero: UF_SYS.ino +// Autor: +// Hardware: Arduino MEGA 2560 +// Fecha: Abril 2015 +// +// Funcionalidad: Implmentacion de la clase UF_SYS +// +// Notas: +// +// --------------------------------------------------------- + +#include +#include +#include +#include +#include "iROB_EA.h" +#include "UF_SYS.h" + + + + + +// --------------------------------------------------------- +// +// UF_SYS::UF_SYS(void) +// Constructor +// +// --------------------------------------------------------- + +UF_SYS::UF_SYS(void) +{ + + + + + + +} + + + +// --------------------------------------------------------- +// +// void UF_SYS::inicio(void) +// +// +// --------------------------------------------------------- + +void UF_SYS::inicio(void) +{ + byte nIntentos; + byte modo; + + + // --------------------------------------------------------- + // + // Inicio de componentes e interfaces Arduino + // + // --------------------------------------------------------- + + + // --------------------------------------------------------- + // + // + // + // --------------------------------------------------------- + + if ( digitalRead(PIN_HW_DOG_SFLAG)==HIGH ) + { // --------------------------------------------------------- + // + // ARRANQUE POR WATCHDOG + // + // . Reset del watchdog + // . Modo inicio = IDE_INICIO_WATCHDOG + // . + // . + // . + // --------------------------------------------------------- + modo = IDE_INICIO_WATCHDOG; + set_MOD_INI(modo); + display_Datos_EEPROM(); + display_Modo(); + + watchDog_DONE(); + + + + + + } + else + { // --------------------------------------------------------- + // + // ARRANQUE NORMAL + // + // . Se pide codigo de aranque: + // A) Correcto -> Modo inicio = IDE_INICIO_POWER ON + // B) Fallo -> Power OFF + // --------------------------------------------------------- + modo = IDE_INICIO_POWER_ON; + set_MOD_INI(modo); + display_Datos_EEPROM(); + display_Modo(); + + if ( secuenciaInicio()==false ) + { // --------------------------------------------------------- + // NO se puede arrancar --> Power OFF + // --------------------------------------------------------- + power_OFF(); + } + else + { // --------------------------------------------------------- + // Operaciones de inicializacion + // --------------------------------------------------------- + calibra_SensoresIcc(); + + + } + } + +} + + + +// --------------------------------------------------------- +// +// byte UF_SYS::secuenciaInicio(void) +// Retorna: +// . false NO se ha podido iniciar: +// - Falta codigo de arranque +// - Numero maximo de reintentos +// - Etc +// En este caso desde la funcion que la llamó se +// debe ir a power OFF. +// . true Arranque OK en este caso las variables EEPROM: +// Numero reintentos (EPROM_ADDR_NUM_RC) = 0 +// Clave actual (EEPROM_ADDR_CLV_AE) = Clave introducida +// Quedan al salir con esos valores +// +// --------------------------------------------------------- + +byte UF_SYS::secuenciaInicio(void) +{ + byte resultado; + byte flgProceso; + byte nIntentos; + char buff[IDE_CLV_MAXL+1]; + + + resultado = false; + flgProceso = false; + + while( flgProceso==false ) + { // --------------------------------------------------------- + // Bucle de captura de clave + // --------------------------------------------------------- + + nIntentos = get_NUM_RC(); + + if ( nIntentos Codigo +// . False Codigo no intorucido buff --> " " +// +// --------------------------------------------------------- + +byte UF_SYS::get_CodigoDTMF(char* buff) +{ + byte resultado; + byte ind; + byte codigo; + unsigned long tIni; + + + buff[0] = 42; + buff[1] = 42; + buff[2] = 42; + buff[3] = 42; + buff[4] = 0; + ind = 0; + resultado = false; + tIni = millis(); + FNG_DisplayMsg(buff,0); + + while( 1 ) + { + codigo = get_DTMF(); + + if ( codigo!=32 ) + { + tIni = millis(); + if ( codigo==35 ) + { // --------------------------------------------------------- + // + // --------------------------------------------------------- + if ( ind>0 ) + { + ind--; + } + buff[ind] = 42; + } + else + { // --------------------------------------------------------- + // + // --------------------------------------------------------- + buff[ind] = codigo; + ind++; + } + + FNG_DisplayMsg(buff,0); + if ( ind==4 ) + { + resultado = true; + break; + } + } + + if ( (unsigned long)(millis()-tIni)>=IDE_CLV_MAX_TIEMPO ) + { + break; + } + + watchDog_DONE(); + } + + if ( resultado==false ) + { + buff[0] = 32; + buff[1] = 32; + buff[2] = 32; + buff[3] = 32; + } + + return(resultado); +} + + + +// --------------------------------------------------------- +// +// byte UF_SYS::get_DTMF(void) +// +// +// --------------------------------------------------------- + +byte UF_SYS::get_DTMF(void) +{ + byte codigo; + byte captura; + unsigned long tIni; + + codigo = 32; + captura = false; + tIni = millis(); + + while ( 1 ) + { + if ( digitalRead(PIN_HW_DTMF_DV)==HIGH ) + { // --------------------------------------------------------- + // Lee el digito introducido + // --------------------------------------------------------- + codigo = 0; + if ( digitalRead(PIN_HW_DTMF_D0)==HIGH ) { bitSet(codigo,0); } + if ( digitalRead(PIN_HW_DTMF_D1)==HIGH ) { bitSet(codigo,1); } + if ( digitalRead(PIN_HW_DTMF_D2)==HIGH ) { bitSet(codigo,2); } + if ( digitalRead(PIN_HW_DTMF_D3)==HIGH ) { bitSet(codigo,3); } + + switch( codigo ) + { + case(10): { codigo = 48; break; } + case(11): { codigo = 42; break; } + case(12): { codigo = 35; break; } + case(13): { codigo = 65; break; } + case(14): { codigo = 66; break; } + case(15): { codigo = 67; break; } + case(0): { codigo = 68; break; } + default: { codigo += 48; break; } + } + + captura = true; + } + else + { // --------------------------------------------------------- + // --------------------------------------------------------- + if ( captura==true ) + { + break; + } + } + + if ( (unsigned long)(millis()-tIni)>=1000 ) + { + codigo = 32; + break; + } + } + + return( codigo ); +} + + + + +//--------------------------------------------------------- +// +// void UF_SYS::watchDog_DONE(void) +// Funcion para generar la señal de latido ( reset) del +// watchDog, pulso de 1ms +// +// --------------------------------------------------------- + +void UF_SYS::watchDog_DONE(void) +{ + digitalWrite(PIN_HW_DOG_DONE,HIGH); + miDelay(1); + digitalWrite(PIN_HW_DOG_DONE,LOW); +} + + + + +//--------------------------------------------------------- +// +// UF_SYS::watchDog_Sincro(void) +// SOLO se llama al principio, en la funcion setup() +// para "saltarse" la primera reentrada por watchdog +// +// --------------------------------------------------------- + +void UF_SYS::watchDog_Sincro(void) +{ + + + if ( digitalRead(PIN_HW_DOG_SFLAG)==LOW ) + { + + set_WATCHDOG(IDE_SYSTEM_WATCHDOG); + // --------------------------------------------------------- + // Arranque normal, esepera a sincronizar el watchdog + // --------------------------------------------------------- + FNG_DisplayMsg(IDE_MSG_DISPLAY_INI,0); + Serial1.println(""); + Serial1.println(""); + Serial1.println(""); + Serial1.println(IDE_STR_INICIO_VERSION); + Serial1.println(IDE_STR_SINCRO_WATCHDOG_1); + while ( 1 ) + { + miDelay(1); + } + } + else + { + + if ( get_WATCHDOG()==IDE_SYSTEM_OFF ) + { + + power_OFF(); + } + + + if ( get_WATCHDOG()==IDE_SYSTEM_WATCHDOG ) + { + set_WATCHDOG(IDE_SYSTEM_OK); + watchDog_DONE(); + // --------------------------------------------------------- + // + // --------------------------------------------------------- + Serial1.println(IDE_STR_SINCRO_WATCHDOG_2); + } + } + + FNG_DisplayMsg(IDE_MSG_DISPLAY_CLS,0); +} + + + + +// --------------------------------------------------------- +// +// void UF_SYS::power_OFF(void) +// Llamar a esta funcion hace que el iROB-EA +// SE APAGUE DE INMEDIATO +// +// --------------------------------------------------------- + +void UF_SYS::power_OFF(void) +{ + FNG_DisplayMsg(IDE_MSG_DISPLAY_OFF,0); + Serial1.println(IDE_STR_INICIO_POWER_OFF); + miDelay(IDE_OFF_PAUSA); + rele(IDE_RELE_SYS_OFF,true); +} + + + +// --------------------------------------------------------- +// +// void UF_SYS::rele (byte releID,byte estado) +// Funcion para activar/desactivar los reles: +// RE1, RE2, RE3 y RE4 +// +// --------------------------------------------------------- + +void UF_SYS::rele (byte releID,byte estado) +{ + + switch( releID ) + { + case(IDE_RELE_SYS_OFF): + { // --------------------------------------------------------- + // Rele de powerOFF + // --------------------------------------------------------- + digitalWrite(PIN_HW_POW_CNX_A0,HIGH); + digitalWrite(PIN_HW_POW_CNX_A1,LOW); + digitalWrite(PIN_HW_POW_CNX_A2,LOW); + break; + } + + case(IDE_RELE_CPU_APL): + { // --------------------------------------------------------- + // Rele de alimentacion de la CPU APL + // --------------------------------------------------------- + if ( estado==IDE_RELE_ACTIVAR) + { + digitalWrite(PIN_HW_POW_CNX_A0,LOW); + digitalWrite(PIN_HW_POW_CNX_A1,HIGH); + digitalWrite(PIN_HW_POW_CNX_A2,LOW); + } + else + { + digitalWrite(PIN_HW_POW_CNX_A0,HIGH); + digitalWrite(PIN_HW_POW_CNX_A1,HIGH); + digitalWrite(PIN_HW_POW_CNX_A2,LOW); + } + break; + } + + case(IDE_RELE_CAMARA): + { // --------------------------------------------------------- + // Rele de alimentacion de la camara + // --------------------------------------------------------- + if ( estado==IDE_RELE_ACTIVAR) + { + digitalWrite(PIN_HW_POW_CNX_A0,LOW); + digitalWrite(PIN_HW_POW_CNX_A1,LOW); + digitalWrite(PIN_HW_POW_CNX_A2,HIGH); + } + else + { + digitalWrite(PIN_HW_POW_CNX_A0,HIGH); + digitalWrite(PIN_HW_POW_CNX_A1,LOW); + digitalWrite(PIN_HW_POW_CNX_A2,HIGH); + } + break; + } + + case(IDE_RELE_MOTORES): + { // --------------------------------------------------------- + // Rele de alimentacion de los motores + // --------------------------------------------------------- + if ( estado==IDE_RELE_ACTIVAR) + { + digitalWrite(PIN_HW_POW_CNX_A0,LOW); + digitalWrite(PIN_HW_POW_CNX_A1,HIGH); + digitalWrite(PIN_HW_POW_CNX_A2,HIGH); + } + else + { + digitalWrite(PIN_HW_POW_CNX_A0,HIGH); + digitalWrite(PIN_HW_POW_CNX_A1,HIGH); + digitalWrite(PIN_HW_POW_CNX_A2,HIGH); + } + break; + } + } + + // --------------------------------------------------------- + // Al salir, por defecto se queda en la salida Q0 del + // multiplexor que no esta conectada a nada + // --------------------------------------------------------- + miDelay(IDE_RELE_SYS_PAUSA); + digitalWrite(PIN_HW_POW_CNX_A0,LOW); + digitalWrite(PIN_HW_POW_CNX_A1,LOW); + digitalWrite(PIN_HW_POW_CNX_A2,LOW); +} + + + +// --------------------------------------------------------- +// +// byte UF_SYS::get_NUM_RC(void) +// +// +// --------------------------------------------------------- + +byte UF_SYS::get_NUM_RC(void) +{ + byte valor; + valor = EEPROM.read(EEPROM_ADDR_NUM_RC); + return(valor); +} + + + +// --------------------------------------------------------- +// +// void UF_SYS::get_CLV_AE(char* valor) +// +// +// --------------------------------------------------------- + +void UF_SYS::get_CLV_AE(char* valor) +{ + valor[0] = EEPROM.read(EEPROM_ADDR_CLV_AE ); + valor[1] = EEPROM.read(EEPROM_ADDR_CLV_AE + 1); + valor[2] = EEPROM.read(EEPROM_ADDR_CLV_AE + 2); + valor[3] = EEPROM.read(EEPROM_ADDR_CLV_AE + 3); + valor[4] = '\0'; +} + + + +// --------------------------------------------------------- +// +// byte UF_SYS::get_MOD_INI(void) +// +// +// --------------------------------------------------------- + +byte UF_SYS::get_MOD_INI(void) +{ + byte valor; + valor = EEPROM.read(EEPROM_ADDR_MOD_INI); + return(valor); +} + + + +// --------------------------------------------------------- +// +// byte UF_SYS::get_WATCHDOG(void) +// +// +// --------------------------------------------------------- + +byte UF_SYS::get_WATCHDOG(void) +{ + byte valor; + valor = EEPROM.read(EEPROM_ADDR_WATCHDOG); + return(valor); +} + + + +// --------------------------------------------------------- +// +// byte UF_SYS::get_FlgDebug(void) +// +// +// --------------------------------------------------------- + +byte UF_SYS::get_FlgDebug(void) +{ + if ( digitalRead(PIN_HW_CNX_DEBUG)==HIGH) { return (true); } + else { return (false); } +} + + + +// --------------------------------------------------------- +// +// int UF_SYS::get_RECARGAS(void) +// +// +// --------------------------------------------------------- + +int UF_SYS::get_RECARGAS(void) +{ + int valor; + valor = EEPROM.read(EEPROM_ADDR_RECARGAS); + valor <<= 8; + valor += EEPROM.read(EEPROM_ADDR_RECARGAS+1); + return(valor); +} + + + +// --------------------------------------------------------- +// +// void UF_SYS::set_NUM_RC(byte valor) +// +// +// --------------------------------------------------------- + +void UF_SYS::set_NUM_RC(byte valor) +{ + EEPROM.write(EEPROM_ADDR_NUM_RC,valor); +} + + + +// --------------------------------------------------------- +// +// void UF_SYS::set_CLV_AE(char* valor) +// +// +// --------------------------------------------------------- + +void UF_SYS::set_CLV_AE(char* valor) +{ + EEPROM.write(EEPROM_ADDR_CLV_AE ,valor[0]); + EEPROM.write(EEPROM_ADDR_CLV_AE + 1 ,valor[1]); + EEPROM.write(EEPROM_ADDR_CLV_AE + 2 ,valor[2]); + EEPROM.write(EEPROM_ADDR_CLV_AE + 3 ,valor[3]); +} + + + +// --------------------------------------------------------- +// +// void UF_SYS::set_MOD_INI(byte valor) +// +// +// --------------------------------------------------------- + +void UF_SYS::set_MOD_INI(byte valor) +{ + EEPROM.write(EEPROM_ADDR_MOD_INI,valor); +} + + + +// --------------------------------------------------------- +// +// void UF_SYS::set_WATCHDOG(byte valor) +// +// +// --------------------------------------------------------- + +void UF_SYS::set_WATCHDOG(byte valor) +{ + EEPROM.write(EEPROM_ADDR_WATCHDOG,valor); +} + + + +// --------------------------------------------------------- +// +// void UF_SYS::set_RECARGAS(int valor) +// +// +// --------------------------------------------------------- + +void UF_SYS::set_RECARGAS(int valor) +{ + EEPROM.write(EEPROM_ADDR_RECARGAS ,highByte(valor)); + EEPROM.write(EEPROM_ADDR_RECARGAS+1, lowByte(valor)); +} + + + + + +// --------------------------------------------------------- +// +// void UF_SYS::void display_Datos_EEPROM(void) +// +// +// --------------------------------------------------------- + +void UF_SYS::display_Datos_EEPROM(void) +{ + char buff[IDE_CLV_MAXL+1]; + + Serial1.print("Reintentos: "); + Serial1.println(get_NUM_RC(),DEC); + Serial1.print("Clave EEPROM: "); + get_CLV_AE(buff); + Serial1.println(buff); + Serial1.print("Modo inicio: "); + Serial1.println(get_MOD_INI()); + Serial1.flush(); +} + + + +// --------------------------------------------------------- +// +// void UF_SYS::void display_Modo(void) +// +// +// --------------------------------------------------------- + +void UF_SYS::display_Modo(void) +{ + byte modo; + + modo = get_MOD_INI(); + + Serial1.print("Modo inicio: "); + if ( modo==IDE_INICIO_WATCHDOG ){ Serial1.println(IDE_STR_INICIO_WATCHDOG); } + else { Serial1.println(IDE_STR_INICIO_POWER_ON); } + Serial1.flush(); +} + + + +// --------------------------------------------------------- +// +// void UF_SYS::getTimeExe_0(void) +// +// +// --------------------------------------------------------- + +unsigned long UF_SYS::getTimeExe(byte modo) +{ + unsigned long mTime; + + + mTime = 0L; + if (modo==true) + { + timeExe = millis(); + } + else + { + mTime = millis() - timeExe; + Serial1.println(mTime); + Serial1.print(" ms"); + } + + return( mTime); +} + + + +// --------------------------------------------------------- +// +// void UF_SYS::miDelay(unsigned long int retardo) +// +// +// --------------------------------------------------------- +void UF_SYS::miDelay(unsigned long int retardo) +{ + unsigned long int mTime; + + + mTime = millis(); + + + while ( (millis()-mTime) 5000mV/1024 = 4.9mV por paso) + vRango = vMedida - 2500; // Mapea tension medida al rango del sensor ( 5000mV/2 = 2500mV ) + iMedida = vRango / 66; // Calcula Corriente medida (A) + + //Serial1.println(""); + //Serial1.println(""); + + //Serial1.print("ADC: "); + //Serial1.println(vConversor); + + //Serial1.print("vMedida: "); + //dtostrf(vMedida, 4, 1, tmpBuff); + //Serial1.print(tmpBuff); + //Serial1.println("mV"); + + //Serial1.print("vRango: "); + //dtostrf(vRango, 4, 1, tmpBuff); + //Serial1.print(tmpBuff); + //Serial1.println("mV"); + + //Serial1.print("iMedida: "); + //Serial1.print(iMedida); + //dtostrf(iMedida, 4, 1, tmpBuff); + //Serial1.println("Amp"); + + return (iMedida); +} + + + + +// --------------------------------------------------------- +// +// void UF_SYS::calibra_SensoresIcc(void) +// +// Permite fijar el offset de los sensores de corriente +// +// +// Nota: +// Esta funcion DEBE llamarse con el Robot parado y sin que +// se esten recargando las baterias, ya que de lo que se +// trata es de obtener el valor retornado por los sensores +// de corriente SIN ningun consumo. +// Estos offsets se utilizaran luego en las funciones de +// medida de corriente +// +// --------------------------------------------------------- + +void UF_SYS::calibra_SensoresIcc(void) +{ + int vConversor; + + + vConversor = analogRead(PIN_HW_BAT_CHG_PPAK); + offsetIcc_CHG_PPAK = vConversor; // Offset para la lectura del sensor de corriente de entrada al PowerBank + + vConversor = analogRead(PIN_HW_BAT_CHG_LIPO); + offsetIcc_CHG_LIPO = vConversor; // Offset para la lectura del sensor de corriente de entrada a la bateria LiPo + + vConversor = analogRead(PIN_HW_MDER_ICC); + offsetIcc_MDER_ICC = vConversor; // Offset para la lectura del sensor de corriente del motor derecho + + vConversor = analogRead(PIN_HW_MIZQ_ICC); + offsetIcc_MIZQ_ICC = vConversor; // Offset para la lectura del sensor de corriente del motor izquierdo + + + #ifdef APP_MODO_DEBUG + Serial1.print("DEBUG Offset Icc PowerBank: "); + Serial1.println(offsetIcc_CHG_PPAK,DEC); + Serial1.print("DEBUG Offset Icc LiPo: "); + Serial1.println(offsetIcc_CHG_LIPO,DEC); + Serial1.print("DEBUG Offset Icc MotDer: "); + Serial1.println(offsetIcc_MDER_ICC,DEC); + Serial1.print("DEBUG Offset Icc MotIzq: "); + Serial1.println(offsetIcc_MIZQ_ICC,DEC); + #endif +} + + + +// --------------------------------------------------------- +// +// void UF_SYS::recarga_Bateria(void) +// +// +// +// --------------------------------------------------------- + +void UF_SYS::recarga_Bateria(void) +{ + int nRecargas; + + // incrementar el contador de recargas (se guarda en EEPROM) + + + nRecargas = get_RECARGAS() + 1; + set_RECARGAS(nRecargas); + +} + + + + + + diff --git a/Software/iROB_EA/iROB_EA.h b/Software/iROB_EA/iROB_EA.h new file mode 100644 index 0000000..3046323 --- /dev/null +++ b/Software/iROB_EA/iROB_EA.h @@ -0,0 +1,153 @@ + +// --------------------------------------------------------- +// +// Proyecto: iROB-EA +// Version: 1.0 +// Fichero: ROB_EA.h +// Autor: +// Hardware: Arduino MEGA 2560 +// Fecha: Abril 2015 +// +// Funcionalidad: Fichero cabecera ( include ) principal de +// la Aplicacion +// +// Notas: +// +// --------------------------------------------------------- + +#ifndef iROB_EA +#define iROB_EA + + + +// --------------------------------------------------------- +// +// DESCOMENTAR este define para compilar trazas de depuracion +// +// --------------------------------------------------------- + +#define APP_MODO_DEBUG 1 // MODO DEBUG: Descomentar este define + // MODO REAL: Comentar este define + + + +// --------------------------------------------------------- +// +// Definicion de Pines relacionados con el manejo del HW +// +// --------------------------------------------------------- + +#define PIN_HW_DOG_DONE 53 // Señal para latido del watchdog +#define PIN_HW_DOG_SFLAG 12 // Flag asociado al Watchdog, 1: Se ha disparado el Watchdog (inicio por Watchdog) + // 0: NO se ha disparado el Watchdog (inicio por power ON) +#define PIN_HW_OFF_PETICION 2 // Boton de power OFF + +#define PIN_HW_POW_CNX_A0 47 // A0, multiplexor control de reles +#define PIN_HW_POW_CNX_A1 46 // A1, multiplexor control de reles +#define PIN_HW_POW_CNX_A2 45 // A2, multiplexor control de reles + +#define PIN_HW_DTMF_D0 49 // D0, Decodificador DTMF +#define PIN_HW_DTMF_D1 50 // D1, Decodificador DTMF +#define PIN_HW_DTMF_D2 51 // D2, Decodificador DTMF +#define PIN_HW_DTMF_D3 52 // D3, Decodificador DTMF +#define PIN_HW_DTMF_DV 48 // DV, Decodificador DTMF, dato valido + +#define PIN_HW_HCMS_DATA 44 // connects to the display's data in +#define PIN_HW_HCMS_RS 41 // the display's register select pin +#define PIN_HW_HCMS_CLK 43 // the display's clock pin +#define PIN_HW_HCMS_CE 42 // the display's chip enable pin +#define PIN_HW_HCMS_RESET 40 // the display's reset pin + +#define PIN_HW_CNX_DEBUG 13 // Indicador de conector de DEBUG conectado + +#define PIN_HW_MIC_01 A0 // Microfono + +#define PIN_HW_BAT_CHG_PPAK A1 // Sensor de carga de la Bateria PowerBank +#define PIN_HW_BAT_CHG_LIPO A2 // Sensor de carga de la Bateria LiPo + +#define PIN_HW_USR_DERECHO A5 // Sensor ultrasonidos derecho +#define PIN_HW_USR_CENTRAL A6 // Sensor ultrasonidos central +#define PIN_HW_USR_IZQUIERDO A7 // Sensor ultrasonidos izquierdo + +#define PIN_HW_LED_BDEL 39 // Leds blancos delanteros +#define PIN_HW_LED_BDET 38 // Leds blancos traseros +#define PIN_HW_LED_RDET 37 // Leds rojos traseros + +#define PIN_HW_MDER_DIR 0 // Motor derecho, Direccion +#define PIN_HW_MDER_RST 0 // Motor derecho, Reset +#define PIN_HW_MDER_PWM 0 // Motor derecho, PWN, velocidad/paro +#define PIN_HW_MDER_FF1 0 // Motor derecho, Flag estado (1) +#define PIN_HW_MDER_FF2 0 // Motor derecho, Flag estado (2) +#define PIN_HW_MDER_ICC A3 // Motor derecho, sensor de corriente (consumo) + +#define PIN_HW_MIZQ_DIR 0 // Motor izquierdo, Direccion +#define PIN_HW_MIZQ_RST 0 // Motor izquierdo, Reset +#define PIN_HW_MIZQ_PWM 0 // Motor izquierdo, PWN, velocidad/paro +#define PIN_HW_MIZQ_FF1 0 // Motor izquierdo, Flag estado (1) +#define PIN_HW_MIZQ_FF2 0 // Motor izquierdo, Flag estado (2) +#define PIN_HW_MIZQ_ICC A4 // Motor izquierdo, sensor de corriente (consumo) + + +// --------------------------------------------------------- +// +// Definiciones de control generales +// +// --------------------------------------------------------- + + +#define IDE_SERIAL_TRX_9600 9600 // Velocidad 9600 para puertos serie + +#define IDE_CLV_AP "9000" // Clave de arranque, siempre 4 digitos (IDE_CLV_MAXL) +#define IDE_CLV_MAXL 4 // Longitud de la clave de arranque +#define IDE_CLV_MAX_INTENTOS 3 // Numero de intentos máximo de introducir clave de arranque +#define IDE_CLV_MAX_TIEMPO 10000 // Tiempo maximo para introducir una clave de inicio (ms) + +#define IDE_PAUSA_GENERAL 500 // Pausa general de 500ms + +// --------------------------------------------------------- +// +// Definiciones de control relacionadas con el Display +// +// --------------------------------------------------------- + +#define IDE_MSG_DISPLAY_OK " OK " +#define IDE_MSG_DISPLAY_ER " ER " +#define IDE_MSG_DISPLAY_ON " ON " +#define IDE_MSG_DISPLAY_OFF " OFF" +#define IDE_MSG_DISPLAY_DOWN "DOWN" +#define IDE_MSG_DISPLAY_PWD "****" +#define IDE_MSG_DISPLAY_CLS " " +#define IDE_MSG_DISPLAY_BLK "LOCK" +#define IDE_MSG_DISPLAY_INI ".ON." + +#define IDE_MSG_DISPLAY_ER_000 "E000" // NO se utiliza +#define IDE_MSG_DISPLAY_ER_001 "E001" // NO se utiliza +#define IDE_MSG_DISPLAY_ER_002 "E002" // NO se utiliza +#define IDE_MSG_DISPLAY_ER_003 "E003" // NO se utiliza +#define IDE_MSG_DISPLAY_ER_004 "E004" // NO se utiliza + +#define IDE_MAX_DISPLAY_CAR 4 // Numero de caracteres del display + + +// --------------------------------------------------------- +// +// Declaracion de funciones del modulo iROB_EA.ino +// +// --------------------------------------------------------- + + +byte FNG_DisplayMsg (char* msg,unsigned int pausa); +void FNG_Pausa (unsigned int pausa); + + + + + + + + + +#endif + + + diff --git a/Software/iROB_EA/iROB_EA.ino b/Software/iROB_EA/iROB_EA.ino new file mode 100644 index 0000000..3de768e --- /dev/null +++ b/Software/iROB_EA/iROB_EA.ino @@ -0,0 +1,462 @@ + +// --------------------------------------------------------- +// +// Proyecto: iROB-EA +// Version: 1.0 +// Fichero: iROB_EA.ino +// Autor: +// Hardware: Arduino MEGA 2560 +// Fecha: Abril 2015 +// +// Leitmotiv: "Toda Bestia necesita un Cerebro..." +// Dr. Frankenstein, en su laboratorio +// +// Funcionalidad: Modulo principal de la Aplicacion +// +// Notas: +// +// --------------------------------------------------------- + +#include +#include +#include +#include +#include +#include +#include +#include +#include "iROB_EA.h" +#include "UF_SYS.h" +#include "MOTOR_FDS5672.h" +#include +#include + + + + + + + + +// --------------------------------------------------------- +// +// Definicion de Clases y variable GLOBALES +// +// +// . uf_sys Objeto de manejo de funcionalidades basicas +// . uf_mDer Objeto de manejo del motor derecho +// . uf_mIzq Objeto de manejo del motor izquierdo +// . myDisplay Objeto para manejear el display de estado +// . mlx Objeto para manejar el sensor MLX90614 +// . rtc Objeto para manejar el reloj de tiempo real +// . gc Objeto que implementa el gestor de comandos +// . flgPower_OFF Flag para control del flujo principal en +// la funcion loop. +// +// +// +// +// --------------------------------------------------------- + +UF_SYS uf_sys = UF_SYS(); // Implementa la funcionalidad relacionada con la UF_SYS +MOTOR_FDS5672 mDer = MOTOR_FDS5672( PIN_HW_MDER_DIR , + PIN_HW_MDER_PWM , + PIN_HW_MDER_RST , + PIN_HW_MDER_FF1 , + PIN_HW_MDER_FF2 , + PIN_HW_MDER_ICC + ); // Implementa el control del motor derecho +MOTOR_FDS5672 mIzq = MOTOR_FDS5672( PIN_HW_MIZQ_DIR , + PIN_HW_MIZQ_PWM , + PIN_HW_MIZQ_RST , + PIN_HW_MIZQ_FF1 , + PIN_HW_MIZQ_FF2 , + PIN_HW_MIZQ_ICC + ); // Implementa el control del motor izquierdo +LedDisplay myDisplay = LedDisplay( PIN_HW_HCMS_DATA , + PIN_HW_HCMS_RS , + PIN_HW_HCMS_CLK , + PIN_HW_HCMS_CE , + PIN_HW_HCMS_RESET , + 4 + ); // Implementa el control del display +Adafruit_MLX90614 mlx = Adafruit_MLX90614(); // Implementa el sensor de temperatura MELEXIS 90614 +RTC_DS1307 rtc; // Reloj de tiempo real +GESCOM3 gc = GESCOM3( IDE_SERIAL_0 , + false , + IDE_DISPOSITIVO_R00 , + IDE_SERIAL_TRX_9600 + ); // Gestor de comandos +volatile byte flgPower_OFF; // Flag actualizado desde la funcion asociada a la INT 0 ( Boton de OFF) + + + + + +// --------------------------------------------------------- +// +// void setup() +// Funcion para inicializar todos los sistemas del +// iROB-EA +// +// --------------------------------------------------------- + +void setup(void) +{ + #ifdef APP_MODO_DEBUG + unsigned long int t; + t = millis(); + #endif + + // --------------------------------------------------------- + // + // ATENCIÓN: + // Los pines de control de los motores NO se inicializan aqui + // porque yo lo hace el constructor de la clase MOTOR_FDS5672 + // + // --------------------------------------------------------- + + // --------------------------------------------------------- + // + // Inicializacion de los pines I/O (MODO) + // + // --------------------------------------------------------- + + pinMode(PIN_HW_DOG_DONE ,OUTPUT); + pinMode(PIN_HW_DOG_SFLAG,INPUT); + + pinMode(PIN_HW_POW_CNX_A0,OUTPUT); + pinMode(PIN_HW_POW_CNX_A1,OUTPUT); + pinMode(PIN_HW_POW_CNX_A2,OUTPUT); + + pinMode(PIN_HW_DTMF_D0,INPUT); + pinMode(PIN_HW_DTMF_D1,INPUT); + pinMode(PIN_HW_DTMF_D2,INPUT); + pinMode(PIN_HW_DTMF_D3,INPUT); + pinMode(PIN_HW_DTMF_DV,INPUT); + + pinMode(PIN_HW_CNX_DEBUG,INPUT); + + pinMode(PIN_HW_MIC_01,INPUT); + + pinMode(PIN_HW_BAT_CHG_PPAK,INPUT); + pinMode(PIN_HW_BAT_CHG_LIPO,INPUT); + + pinMode(PIN_HW_USR_DERECHO,INPUT); + pinMode(PIN_HW_USR_CENTRAL,INPUT); + pinMode(PIN_HW_USR_IZQUIERDO,INPUT); + + pinMode(PIN_HW_LED_BDEL,OUTPUT); + pinMode(PIN_HW_LED_BDET,OUTPUT); + pinMode(PIN_HW_LED_RDET,OUTPUT); + + + // --------------------------------------------------------- + // + // Inicializacion de los pines I/O (ESTADO) + // + // --------------------------------------------------------- + + digitalWrite(PIN_HW_DOG_DONE,LOW); + + digitalWrite(PIN_HW_LED_BDEL,LOW); + digitalWrite(PIN_HW_LED_BDET,LOW); + digitalWrite(PIN_HW_LED_RDET,LOW); + + // --------------------------------------------------------- + // + // Inicializacion de variables, objetos Globales y elementos + // + // + // --------------------------------------------------------- + + + // --------------------------------------------------------- + // Inicio: + // . Wire.begin() + // . RTC.begin() + // . mlx.begin() + // . myDisplay.begin() + // . flgPower_OFF + // . mDer.inicio() + // . mIzq.inicio() + // + // --------------------------------------------------------- + + Wire.begin(); + + rtc.begin(); + mlx.begin(); + gc.begin(); + myDisplay.begin(); + myDisplay.setBrightness(15); + + flgPower_OFF = false; + + // --------------------------------------------------------- + // Interrupciones: + // INT 0 --> Boton Power OFF + // --------------------------------------------------------- + + attachInterrupt(0, INT_power_OFF, RISING); + + + // --------------------------------------------------------- + // Resto: + // + // --------------------------------------------------------- + + uf_sys.rele(IDE_RELE_CPU_APL,IDE_RELE_DESACTIVAR); + uf_sys.rele(IDE_RELE_CAMARA ,IDE_RELE_DESACTIVAR); + uf_sys.rele(IDE_RELE_MOTORES,IDE_RELE_DESACTIVAR); + + analogReference(DEFAULT); // SIEMPRE se utiliza DEFAULT + + // --------------------------------------------------------- + // + // Inicializacion de puertos serie + // MENOS Serial0 que está asociado con el gestor de comandos + // y se inicializa con gc->begin() + // + // --------------------------------------------------------- + + Serial1.begin(IDE_SERIAL_TRX_9600); // Puerto de DEBUG + + + #ifdef APP_MODO_DEBUG + Serial1.print("DEBUG Tiempo de ejecucion setup: "); + Serial1.print(millis()-t,DEC); + Serial1.println(" mseg."); + #endif + + + // --------------------------------------------------------- + // IMPORTANTE + // + // Para version Funcional, comentar todas las lineas que + // puedan aparecer debajo de este comentario y dejar SOLO: + // + // uf_sys.inicio(); + // uf_sys.watchDog_Sincro(); + // + // --------------------------------------------------------- + + uf_sys.watchDog_Sincro(); // IMPORTANTE: Esta funcion se DEBE llamar en este orden, no mover + // Si sale de esta funcion es porque el arranque ha sido correcto + // A) Watchdog uf_sys.get_MOD_INI() = IDE_INICIO_WATCHDOG + // B) Power ON uf_sys.get_MOD_INI() = IDE_INICIO_POWER_ON + // Si NO sale de esta funcion es porque no se ha introducido la clave correcta o porque + // esta bloqueado y por eso se ha auto-apagado + uf_sys.inicio(); + + // QUITAR LUEGO DE QUE SE EJECUTE UNA VEZ + uf_sys.set_RECARGAS(0); + + #ifdef APP_MODO_DEBUG + Serial1.print("DEBUG Tiempo de ejecucion setup + Inicio: "); + Serial1.print(millis()-t,DEC); + Serial1.println(" mseg."); + #endif +} + + + +// --------------------------------------------------------- +// +// void loop() +// Funcion principal para mantener funcionando iROB-EA +// +// --------------------------------------------------------- + +void loop(void) +{ + byte vAux; + + // --------------------------------------------------------- + // Generacion del pulso de latido, reset del watchDog + // --------------------------------------------------------- + uf_sys.watchDog_DONE(); + + if ( flgPower_OFF==false ) + { // --------------------------------------------------------- + // + // BLOQUE GENERAL DE PROGRAMA + // + // El tiempo maximo de ejecucion de este bloque NO puede + // superar el tiempo maximo del watchdog. + // - El tiempo de watchdog se fija con unos puentes (TPL5000) + // - Tiempo fijado ACTUAL: 16 SEGUNDOS + // + // IMPORTANTE: + // Si se añade codigo aqui y el tiempo necesario para ejecutar + // este bloque es mayor del tiempode watchdog, se debe elegir + // mediante los puentes un tiempo superior de watchdog + // + // --------------------------------------------------------- + + // --------------------------------------------------------- + // + // 1 + // + // RECARGA BATERIA + // + // --------------------------------------------------------- + + uf_sys.recarga_Bateria(); + + // --------------------------------------------------------- + // + // 2 + // + // CONTROL EXTERNO (DEBUG) + // + // --------------------------------------------------------- + vAux = uf_sys.get_FlgDebug(); + mDer.inhibir(vAux); + mIzq.inhibir(vAux); + + + + // ------------------------------------------------------- + // + // 3 + // + // GESTOR DE COMANDOS + // + // La funcion exeGesComando ejecuta el gestor de comandos. + // Si se ha recibido algo en el puerto serie lo procesa y + // envia el resultado obtenido. + // Si no se ha recibido nada retorna inmediatamente. + // + // Esta funcion retorna: + // . IDE_BUFF_RX_OK Se ha recibdo algo valido ( un + // comando y se ha ejecutado ) + // . IDE_BUFF_RX_ER Se ha recibido algo erroneo. + // . IDE_BUFF_RX_VACIO NO se ha recibido nada + // + // Estos defines se encuentran en gescom.h + // + // ------------------------------------------------------- + + //#ifdef APP_MODO_DEBUG + //uf_sys.getTimeExe(true); + //#endif + + gc.exeGesComando(); + + //#ifdef APP_MODO_DEBUG + //uf_sys.getTimeExe(false); + //#endif + + + + + + + + + } + else + { // --------------------------------------------------------- + // + // POWER OFF + // + // Se ha solicitado el APAGADO (power OFF) , indica en la + // variable EEPROM de control modo Salir y provoca un + // watchdog. + // ANTES se DEBE hacer todo lo que proceda antes de apagar + // Rsapberry etc + // --------------------------------------------------------- + + + // --------------------------------------------------------- + // Como medida de seguridad se desactiva el rele de + // alimentacion de los motores antes del power OFF + // --------------------------------------------------------- + uf_sys.rele(IDE_RELE_MOTORES,IDE_RELE_DESACTIVAR); + + + // --------------------------------------------------------- + // + // Secuencia de apagado + // + // --------------------------------------------------------- + + FNG_DisplayMsg(IDE_MSG_DISPLAY_DOWN,0); + Serial1.println(IDE_STR_INICIO_POWER_DOWN); + uf_sys.set_WATCHDOG(IDE_SYSTEM_OFF); + uf_sys.miDelay(IDE_PAUSA_GENERAL*4); + while(1); + } + +} + + + +// --------------------------------------------------------- +// +// void INT_power_OFF(void) +// Funcion conectada a la interrupcion 0 para capturar el +// evento de pulsador pulsado para apagar +// +// --------------------------------------------------------- + +void INT_power_OFF(void) +{ + + flgPower_OFF = true; + +} + + + +// --------------------------------------------------------- +// +// byte FNG_DisplayMsg(char* msg,unsigned int pausa) +// +// --------------------------------------------------------- + +byte FNG_DisplayMsg(char* msg,unsigned int pausa) +{ + byte resultado; + + + resultado = false; + + if ( strlen(msg)<=IDE_MAX_DISPLAY_CAR) + { + myDisplay.home(); + myDisplay.print(msg); + resultado = true; + if ( pausa>0 ) + { + FNG_Pausa(pausa); + } + } + + return (resultado) ; +} + + +// --------------------------------------------------------- +// +// void FNG_Pausa(unsigned int pausa) +// Genera una pausa de los milisegundos indicados +// En la pausa genera el pulso de control del watchdog +// +// --------------------------------------------------------- + +void FNG_Pausa(unsigned int pausa) +{ + unsigned long int tIni; + + tIni = millis(); + while ( 1 ) + { + if ( (unsigned int)(millis()-tIni)>= pausa ) + { + break; + } + uf_sys.watchDog_DONE(); + } +}