Lokales autonomes Datenerfassungssystem (Fortsetzung)

Beginnen Sie auf dieser Seite unter dem Link .

Die bequemste Option zum Verwenden der Informationen zum Einschalten des Anlassers war die Option mit dem PC817-Optokoppler.

Schaltplan
Bild alt

Die Platinen enthalten drei identische Schaltkreise, alles ist in Kartons aus ABS-Kunststoff der Größe 100x100 mm untergebracht.

Fotooptokoppler
Bild alt

Bei Anschluss an Starter mit Halbleiterventilen reicht ihr Leckstrom aus, um den PC817 zu öffnen, und es kommt zu einem falschen Zählerbetrieb. Um diese Situation zu beseitigen nacheinander wird der Schaltung der Optokoppler-LED und der Betriebsanzeige-LED eine weitere hinzugefügt. Dazu wird der Jumper J1 geöffnet und eine zusätzliche LED1 gelötet.

Der empfangende Teil wird am gemacht

Seite 1
Bild alt

Seite 2
Bild alt

Ein Steckbrett, das an den ARDUINO MEGA 2560 angeschlossen ist. Hierzu wird am Ende ein zweireihiger Stecker verwendet. Ein Bildschirm mit einer Auflösung von 240 x 400 wird als Informationsanzeigegerät verwendet.

HX8352B.
Bild alt

Darüber hinaus wird der Anschluss an das ICSP auf der Bildschirmplatine zerlegt und der Micro-SD-Steckplatz wird nicht verwendet. Tatsache ist, dass der „native“ SD-Steckplatz aufgrund eines Konflikts auf dem SPI-Bus nicht verwendet werden kann. Für die Flash-Karte wurde ein separater Kartenleser mit einem 3,3-V-Stabilisator und einem Pufferchip mit drei Ausgangszuständen 74LVS125A verwendet. Hier wartete ein Rechen auf mich. Ein Puffer mit drei Zuständen, aber es funktionierte entweder E01-ML01DP5 oder ein Kartenleser. In den Kommentaren der SdFat-Bibliothek wurde eine Warnung vor Inkompatibilität mit anderen Geräten angezeigt. Der Pegelwandler des TXS0108E wurde entfernt und durch Steckbrücken ersetzt E01-ML01DP5 tolerant gegenüber 5V-Signalen - hat nicht geholfen. Unter Verwendung eines Oszilloskops wurde ein Signalverlust auf der MISO-Leitung festgestellt, wenn ein Kartenleser angeschlossen wurde. Bei sorgfältiger Prüfung wurde festgestellt, dass die Eingänge der Freigabesignale OE von 4 Kanälen 74LVS125A einfach an einen gemeinsamen Draht gelötet wurden und von keinem dritten Zustand die Rede sein konnte. Der Pufferchip wurde als primitiver Pegelwandler von 5 V auf 3,3 V unter Verwendung von 3,3 KOhm-Widerständen verwendet, die in Reihe mit Signalleitungen geschaltet waren. Neben der MISO-Linie. Ihre untere Ausgangstaste zog wahrscheinlich Signale auf Masse. Nachdem festgestellt wurde, dass das MISO-Leitungsfreigabesignal Pin 13 ist, wurde es von der Spur und gerissen

gelötet
Bild alt

zwischen dem Ausgang des Eingangs (9) 74LVS125A der CS-Geräteauswahl und dem Abschlusswiderstand. Wenn jetzt kein Zugriff auf die Speicherkarte besteht, ist der MISO-Puffer deaktiviert und beeinträchtigt den Betrieb eines anderen Geräts nicht.

Layoutplatine
Bild alt

Empfänger bei der Arbeit
Bild alt

Zum Anschließen der Uhr an den DS3231 wird der I2C-Softwarebus (TWI) verwendet.

Arduino IDE Programm
// IMPORTANT: Adafruit_TFTLCD LIBRARY MUST BE SPECIFICALLY // CONFIGURED FOR EITHER THE TFT SHIELD OR THE BREAKOUT BOARD. // SEE RELEVANT COMMENTS IN Adafruit_TFTLCD.h FOR SETUP. //by Open-Smart Team and Catalex Team //catalex_inc@163.com //Store: http://dx.com // https://open-smart.aliexpress.com/store/1199788 //Demo Function: Display graphics, characters //Arduino IDE: 1.6.5 // Board: Arduino UNO R3, Arduino Mega2560,Arduino Leonardo // Board:OPEN-SMART UNO R3 5V / 3.3V, Arduino UNO R3, Arduino Mega2560 //3.2INCH TFT: // https://www.aliexpress.com/store/product/3-2-TFT-LCD-Display-module-Touch-Screen-Shield-board-onboard-temperature-sensor-w-Touch-Pen/1199788_32755473754.html?spm=2114.12010615.0.0.bXDdc3 //OPEN-SMART UNO R3 5V / 3.3V: // https://www.aliexpress.com/store/product/OPEN-SMART-5V-3-3V-Compatible-UNO-R3-CH340G-ATMEGA328P-Development-Board-with-USB-Cable-for/1199788_32758607490.html?spm=2114.12010615.0.0.ckMTaN #include <Adafruit_GFX.h> // Core graphics library //#include <Adafruit_TFTLCD.h> // Hardware-specific library #include <MCUFRIEND_kbv.h> MCUFRIEND_kbv tft; #include "SdFat.h" // Use the SdFat library SdFat SD; SdFile file; File myFile; #define SD_CS_PIN SS #include <SPI.h> //       SPI #include <nRF24L01.h> //      RF24 #include <RF24.h> //      nRF24L01+ RF24 radio(47, 49); #include <DS3231.h> DS3231 rtc(27, 25); Time t; uint16_t r = 6000; uint32_t k = 0; volatile unsigned long data; float leb_1; float leb_2; float leb_3; float leb_4; uint8_t pipe; int rc = 0; uint8_t time_sec_prev; uint8_t time_day_prev; //***********************************************// // If you use OPEN-SMART TFT breakout board // // Reconmmend you to add 5V-3.3V level converting circuit. // Of course you can use OPEN-SMART UNO Black version with 5V/3.3V power switch, // you just need switch to 3.3V. // The control pins for the LCD can be assigned to any digital or // analog pins...but we'll use the analog pins as this allows us to //----------------------------------------| // TFT Breakout -- Arduino UNO / Mega2560 / OPEN-SMART UNO Black // GND -- GND // 3V3 -- 3.3V // CS -- A3 // RS -- A2 // WR -- A1 // RD -- A0 // RST -- RESET // LED -- GND // DB0 -- 8 // DB1 -- 9 // DB2 -- 10 // DB3 -- 11 // DB4 -- 4 // DB5 -- 13 // DB6 -- 6 // DB7 -- 7 // Assign human-readable names to some common 16-bit color values: #define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF #define GRAY 0x8C51 #define GRAYD 0x39E7 //Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET); // If using the shield, all control and data lines are fixed, and // a simpler declaration can optionally be used: // Adafruit_TFTLCD tft; uint16_t g_identifier; String dataString; //String numfileMonth ="1.txt"; char perv [] = {"2.txt"}; //String *numfileMonth="1.txt" (sizeof (numfileMonth)); /////////////////////////////////////////////////////////////////// void setup(void) { rtc.begin(); //   -    // rtc.setDOW(6); //   // rtc.setTime(22, 04, 0); // ,   24 . // rtc.setDate(4, 5, 2019); // , 29  2018. Serial.begin(2000000); ////////   tft.begin(0x65); tft.reset(); tft.setRotation(0); tft.cp437(true); ////////////////// ,  ,   tft.fillScreen(BLACK); tft.setTextColor(WHITE); tft.setTextSize(2); tft.setCursor (8, 0); tft.println ("DEVELOPERS & BUILD" ); tft.setCursor (30, 20); tft.print (utf8rus(" .." )); tft.setCursor (40, 40); tft.print (utf8rus(" .." )); delay (2000); radio.begin(); //   nRF24L01+ radio.setChannel(120); //     ( 0  127) radio.setDataRate (RF24_250KBPS); //     (RF24_250KBPS, RF24_1MBPS, RF24_2MBPS), RF24_1MBPS - 1/ radio.setPALevel (RF24_PA_MAX); //    (RF24_PA_MIN=-18dBm, RF24_PA_LOW=-12dBm, RF24_PA_HIGH=-6dBm, RF24_PA_MAX=0dBm) radio.openReadingPipe (1, 0xAABBCCDD11LL); //  1    1  0xAABBCCDD11,    //  2    2  0xAABBCCDD22,    radio.startListening (); //  ,     // radio.stopListening (); ////////   tft.fillScreen(BLACK); tft.setCursor (8, 0); tft.setTextSize(1); ////////  SD  Serial.println("Initial SD card"); tft.println("Initial SD card"); tft.setCursor (8, 10); ////////  if (!SD.begin(SD_CS_PIN)) { Serial.println("initial failed!"); tft.fillRect ( 8 , 10 , 85 , 7 , RED); tft.setTextColor(BLACK); tft.println("Initial failed!"); return; } tft.setTextColor(WHITE); Serial.println("initialization done"); tft.println("Initialization done"); delay (2000); //////// -      t = rtc.getTime(); time_sec_prev = t.sec; time_day_prev = t.date; ////////  ,         tft.setCursor ( 180 , 0 ); //    tft.fillRect ( 178 , 0 , 65 , 7 , GRAY); //     tft.setTextSize(1); tft.print(rtc.getDateStr()); ////////    tft.setTextSize(2); tft.setCursor (60, 25); tft.println (utf8rus(" I")); ////////        tft.setTextSize(1); tft.setCursor(130, 10); //    2.txt ,       if (SD.exists (perv)) { //tft.setCursor(0, 90); tft.println(perv); Serial.println(perv); } else { myFile = SD.open(perv, FILE_WRITE); //   2.txt ,     myFile.close(); tft.println(perv); Serial.println(perv); } } void loop(void) { ////////       -  if (Serial.available() > 0) { ////////    ,       File myFile = SD.open(perv); // if the file is available, write to it: if (myFile) { while (myFile.available()) { Serial.write(myFile.read()); } myFile.close(); } else { Serial.println("error opening .txt"); } } ////////  t = rtc.getTime(); tft.setTextColor(WHITE); ////////  ,      if ( time_sec_prev != t.sec) { tft.setCursor ( 120 , 0 ); //    tft.fillRect ( 118 , 0 , 50 , 7 , GRAY); //     tft.setTextSize(1); tft.print(rtc.getTimeStr()); //    time_sec_prev = t.sec; } ////////  ,     if ( time_day_prev != t.date) { tft.setCursor ( 180 , 0 ); //    tft.fillRect ( 178 , 0 , 65 , 7 , GRAY); //     tft.setTextSize(1); tft.print(rtc.getDateStr()); //    time_day_prev = t.date; } ////////  ,  if (radio.available(&pipe)) { ////////   , radio.read(&data, sizeof(data)); ////////    ,  if (pipe == 1) { ////////      //   if ( data == 0000 ) { rc = 0; } else { rc ++; } ////////       10  100-   if ( rc == 1 ) { leb_1 = data / 3600.0; } if ( rc == 2 ) { leb_2 = data / 3600.0; } if ( rc == 3 ) { leb_3 = data / 3600.0; } if ( rc == 4 ) { leb_4 = data / 3600.0; } } } r ++; k ++; //   ////////       if ( r >= 6500) { tft.setTextSize(2); tft.fillRect ( 0 , 41 , 180 , 64 , GRAYD); Serial.println ("Lebedki I"); tft.setCursor (0, 41); tft.println (leb_1); Serial.println (leb_1); tft.println (leb_2); Serial.println (leb_2); tft.println (leb_3); Serial.println (leb_3); tft.println (leb_4); Serial.println (leb_4); Serial.println (k); r = 0; } ////////     SD  10 . if ((t.min % 10 == 0) && ( t.sec == 0)) { tft.setTextSize(1); tft.setCursor(200, 10); tft.setTextColor(BLACK); ////////    .csv String dataString = String (rtc.getDateStr()) + ", "+(rtc.getTimeStr()) + ", " + (leb_1) + ", " + (leb_2) + ", " + (leb_3) + ", " + (leb_4) + ", "; ////////        myFile = SD.open(perv, FILE_WRITE); //     "2.txt" - ,    . if (myFile) { myFile.println(dataString); myFile.close(); tft.fillRect ( 198 , 8 , 42 , 10 , GREEN); tft.println("SD OK"); Serial.println("SD OK"); delay (900); // ,   13  ,     } else { tft.fillRect ( 198 , 8 , 42 , 10 , RED); tft.println("SD ERR"); Serial.println("SD ERR"); } } } 

Zeichen-Transcodierungsprogramm
 /* Recode russian fonts from UTF-8 to Windows-1251 */ String utf8rus(String source) { int i,k; String target; unsigned char n; char m[2] = { '0', '\0' }; k = source.length(); i = 0; while (i < k) { n = source[i]; i++; if (n >= 0xC0) { switch (n) { case 0xD0: { n = source[i]; i++; if (n == 0x81) { n = 0xA8; break; } if (n >= 0x90 && n <= 0xBF) n = n + 0x30;//0x2F break; } case 0xD1: { n = source[i]; i++; if (n == 0x91) { n = 0xB8; break; } if (n >= 0x80 && n <= 0x8F) n = n + 0x70;//0x6F break; } } } m[0] = n; target = target + String(m); } return target; } 

Das Zeichenkonvertierungsprogramm für die kyrillische Ausgabe durch die Adafruit_GFX-Bibliothek befindet sich im selben Ordner wie das Hauptprogramm. Sie müssen auch die Datei glcdfont.c durch eine andere Schriftart in Adafruit_GFX ersetzen. Hier ist die Bibliothek mit dem erforderlichen Ersatz. Weitere Informationen zur Russifizierung finden Sie im Internet.

Zusammenfassend kann ich sagen, dass das System die Erwartungen erfüllt hat und es einfacher geworden ist, die Betriebszeit von Geräten zu überwachen. Obwohl alles auf Steckbrettern montiert ist, gibt es keine dringenden Beschwerden über die Arbeit.

Die ersten Elemente arbeiten seit mehr als sechs Monaten und haben den Winter überstanden. Das neueste Design für 9 überwachte Einheiten ist seit dem 5. März in Betrieb und wird bereits offiziell zur Arbeitszeit registriert.

Source: https://habr.com/ru/post/de451154/


All Articles