Local Autonomous Data Acquisition System (txuas ntxiv)

Pib ntawm qhov chaw no txuas.
Qhov kev xaiv yooj yim tshaj plaws rau kev khaws cov ntaub ntawv hais txog kev tig ntawm lub oob khab tig los ua qhov kev xaiv nrog PC817 optocoupler. Schematic daim duabLocal Autonomous Data Acquisition System (txuas ntxiv)Cov laug cam muaj peb lub voj voog zoo ib yam, txhua yam tau muab tso rau hauv ABS yas thawv, loj 100x100 mm. Yees duab ntawm optocouplersLocal Autonomous Data Acquisition System (txuas ntxiv) Thaum txuas nrog pib cov khoom siv nrog semiconductor li qub, lawv cov xau tam sim no txaus los qhib PC817 thiab lub txee yuav ua rau muaj kev dag ntxias. Txhawm rau tshem tawm cov xwm txheej zoo li no ib qho ntxiv yog ntxiv rau hauv series rau hauv Circuit Court ntawm optocoupler LED thiab kev ua haujlwm qhia LED. Ua li no, jumper J1 yog qhib thiab ib qho ntxiv LED1 yog soldered nyob rau hauv.
Qhov txais tau yog ua rau paj 1Local Autonomous Data Acquisition System (txuas ntxiv)paj 2Local Autonomous Data Acquisition System (txuas ntxiv)txoj kev loj hlob board txuas nrog ARDUINO MEGA 2560. Rau qhov no, ob kab txuas yog siv thaum kawg. Ib lub vijtsam nrog qhov kev daws teeb meem ntawm 240x400, muaj lub zog tiv thaiv thiab lub ntsuas kub ntsuas, yog siv los ua cov ntaub ntawv tso saib. HX8352B.Local Autonomous Data Acquisition System (txuas ntxiv) Ntxiv mus, lub connector rau ICSP ntawm lub rooj tsavxwm screen raug tshem tawm thiab lub micro SD qhov tsis siv. Qhov tseeb yog tias SD socket "neeg" tsis tuaj yeem siv vim muaj kev tsis sib haum xeeb ntawm SPI npav. Rau daim npav flash, ib daim npav nyeem ntawv cais tau siv, uas suav nrog 3,3V stabilizer thiab cov nti tsis muaj peb lub xeev 74LVS125A. Qhov no yog qhov uas tus rake tos kuv. Peb lub xeev tsis nyob, tab sis yog E01-ML01DP5 lossis daim npav nyeem ntawv ua haujlwm. Hauv lub tsev qiv ntawv cov lus pom, SdFat pom cov lus ceeb toom txog kev tsis sib haum nrog lwm cov khoom siv. Cov qib converter ntawm TXS0108E raug tshem tawm thiab hloov nrog jumpers, vim E01-ML01DP5 ua siab ntev rau 5V teeb liab - nws tsis pab. Siv lub oscilloscope, kuaj pom lub teeb liab poob ntawm MISO kab thaum daim npav nyeem ntawv txuas nrog. Thaum ua tib zoo tshuaj xyuas, nws tau pom tias cov tswv yim ntawm cov cim ua kom pom tseeb ntawm OE 4 raws ntawm 74LVS125A tau yooj yim soldered rau ib qho xov hlau thiab tsis tuaj yeem hais lus ntawm peb lub xeev. Tsis siv neeg nti tau siv los ua ib theem pib hloov pauv los ntawm 5V rau 3.3V siv 3,3 KΞ© resistors txuas nrog cov kab teeb liab. Tsuas yog MISO kab. Nws tso zis hauv qab hloov tej zaum yuav nyiam cov teeb liab rau hauv av. Tom qab txiav txim siab tias lub teeb liab ua haujlwm ntawm MISO kab yog tus pin 13, nws raug rho tawm ntawm txoj kab thiabsolderedLocal Autonomous Data Acquisition System (txuas ntxiv)nruab nrab ntawm lub 9LVS74A CS ntaus ntawv xaiv input tus pin (125) thiab txiav tawm resistor. Tam sim no, yog tias tsis muaj kev nkag mus rau daim npav nco, MISO tsis ua haujlwm thiab tsis cuam tshuam nrog kev ua haujlwm ntawm lwm lub cuab yeej.Daim duab qhia kev loj hlobLocal Autonomous Data Acquisition System (txuas ntxiv)Receiver hauv kev ua haujlwmLocal Autonomous Data Acquisition System (txuas ntxiv)DS3231 siv software I2C tsheb npav (TWI) los txuas lub moos.
Arduino IDE Program// TSEEM CEEB: Adafruit_TFTLCD QHOV TSEEB YUAV TSUM TSEEM CEEB
// CONFIGURED RAU LUB TFT ntaub thaiv npog los yog lub BREAKout board.
// Saib cov ntsiab lus tseem ceeb hauv Adafruit_TFTLCD.h FOR SETUP.
// los ntawm Open-Smart Team thiab Catalex Team
//[email tiv thaiv]
// Khw: dx.com ua
// qhib-smart.aliexpress.com/store/1199788
//Demo Function: Tso cov duab, cov cim
// 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:
// 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:
// 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

# suav nrog // Core graphics tsev qiv ntawv
//#nrog // Cov tsev qiv ntawv kho vajtse tshwj xeeb
# suav nrog
MCUFRIEND_kbv tft;
# suav nrog "SdFat.h" // Siv lub tsev qiv ntawv SdFat
SdFat SD;
SdFile cov ntaub ntawv;
Cov ntaub ntawv myFile;
#define SD_CS_PIN SS

# suav nrog // Txuas lub tsev qiv ntawv los ua haujlwm nrog lub npav SPI
# suav nrog // Txuas cov ntaub ntawv teeb tsa los ntawm lub tsev qiv ntawv RF24
# suav nrog // Txuas lub tsev qiv ntawv ua haujlwm nrog nRF24L24+
RF24 xov tooj cua (47, 49);

# suav nrog

DS3231 rtc(27, 25);
Sijhawm t;

uint16_t r = 6000;
uint32_t k = 0;

volatile unsigned ntev cov ntaub ntawv;
ntab leb_1;
ntab leb_2;
ntab leb_3;
ntab leb_4;

cev 8;.
int rc = 0;

uint8_t time_sec_prev;
uint8_t time_day_prev;

//******************************************************* ********************* //
// Yog tias koj siv OPEN-SMART TFT breakout board //
// Xav kom koj ntxiv 5V-3.3V qib hloov hluav taws xob.
// Tau kawg koj tuaj yeem siv OPEN-SMART UNO Dub version nrog 5V / 3.3V fais fab hloov,
// koj tsuas yog xav tau hloov mus rau 3.3V.
// Cov pins tswj rau LCD tuaj yeem raug xa mus rau ib qho digital lossis
// analog pins...tab sis peb yuav siv cov analog pins raws li qhov no tso cai rau peb
//β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”-|
// TFT Breakout - Arduino UNO / Mega2560 / OPEN-SMART UNO Dub
// GND - GND
// 3V3 - 3.3V
//CS-A3
// RS - A2
// WR - A1
// RD - A0
// RST - RESET
// LED - GND
// Txd0 - 8
// Txd1 - 9
// Txd2 - 10
// Txd3 - 11
// Txd4 - 4
// Txd5 - 13
// Txd6 - 6
// Txd7 - 7

// Muab cov npe tib neeg nyeem tau rau qee qhov 16-ntsis xim xim:
#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 GREY 0x8C51
#define GRAYD 0x39E7

// Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET);
// Yog tias siv cov ntaub thaiv npog, tag nrho cov kev tswj thiab cov kab ntawv raug kho, thiab
// cov lus tshaj tawm yooj yim tuaj yeem xaiv tau siv:
// 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();

// Txhawm rau teem sijhawm, tsis hais cov kab tsim nyog
//rtc.setDOW(6); // Hnub ntawm lub lim tiam
// rtc.setTime(22, 04, 0); // Sijhawm, hauv 24 teev hom.
// rtc.setDate(4, 5, 2019); // Hnub tim, Lub Kaum Hli 29, 2018

Serial.begin (2000000);
//////// Screen pib
tft.begin(0x65);
tft.reset();
tft.setRotation(0);
tft.cp437(tseem);
/////////////////// Cov npe, khoom siv, lub koom haum npe
tft.fillScreen(BLACK);
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.setCursor(8, 0);
tft.println("Tsim & Tsim");
tft.setCursor(30, 20);
tft.print(utf8rus("Constructor V.V." ));
tft.setCursor(40, 40);
tft.print(utf8rus("Turner I.I." ));
ncua (2000);

radio.begin(); // Pib ua haujlwm nRF24L01+
radio.setChannel(120); // Qhia meej cov ntaub ntawv txais channel (ntawm 0 txog 127)
radio.setDataRate(RF24_250KBPS); // Qhia meej cov ntaub ntawv hloov pauv (RF24_250KBPS, RF24_1MBPS, RF24_2MBPS), RF24_1MBPS - 1Mbit / s
radio.setPALevel(RF24_PA_MAX); // Qhia meej lub zog xa hluav taws xob (RF24_PA_MIN=-18dBm, RF24_PA_LOW=-12dBm, RF24_PA_HIGH=-6dBm, RF24_PA_MAX=0dBm)
radio.openReadingPipe(1, 0xAABBCCDD11LL); // Qhib 1 yeeb nkab nrog tus cim ntawm 1 transmitter 0xAABBCCDD11, kom tau txais cov ntaub ntawv
// Qhib yeeb nkab 2 nrog transmitter ID 2xAABBCCDD0 kom tau txais cov ntaub ntawv
radio.startListening(); // Qhib lub receiver, pib mloog cov kav dej qhib
// radio.stopListening();
//////// Cov ntaub ntawv muab kev pabcuam
tft.fillScreen(BLACK);
tft.setCursor(8, 0);
tft.setTextSize(1);
////////Pib pib sau daim npav SD
Serial.println("Initial SD card");
tft.println("Pib SD card");
tft.setCursor(8, 10);
////////Initializing daim card
yog (!SD.begin(SD_CS_PIN)) {
Serial.println("pib ua tsis tiav!");
tft.fillRect(8, 10, 85, 7, RED);
tft.setTextColor(BLACK);
tft.println("Pib ua tsis tiav!");
rov qab los;
}
tft.setTextColor(WHITE);
Serial.println("initialization ua tiav");
tft.println("Kev pib ua tiav");
ncua (2000);
//////// Nyeem lub sij hawm thiab hnub tim thiab muab lawv rau qhov sib txawv
t = rtc.getTime();
time_sec_prev = t.sec;
time_day_prev = t.date;
////////Forcibly output the date so as not to wait for the date to change for zaub
tft.setCursor(180, 0); // teeb tsa tus cursor txoj hauj lwm
tft.fillRect(178, 0, 65, 7, GREY); // clearing lub sij hawm tso zis cheeb tsam
tft.setTextSize(1);
tft.print(rtc.getDateStr());
////////Tau lub npe ntawm cov khoom tswj
tft.setTextSize(2);
tft.setCursor(60, 25);
tft.println(utf8rus("Winches kuv"));
////////Tsim cov ntaub ntawv teev tseg thiab tso tawm qhov tshwm sim ntawm kev sim tsim
tft.setTextSize(1);
tft.setCursor(130, 10); // yog tias log file 2.txt yog tsim, ces sau rau cov ntaub ntawv yuav txuas ntxiv mus
yog tias (SD.exists(perv)) {
//tft.setCursor(0, 90);
tft.println(perv);
Serial.println(perv);
} Lwm {
myFile = SD.open(perv, FILE_WRITE); // yog cov ntaub ntawv 2.txt tsis muaj, nws yuav raug tsim
myFile.close();
tft.println(perv);
Serial.println(perv);
}
}

void loop(void) {
////////Tshuaj xyuas qhov muaj nyob ntawm qhov kev thov kom tso tawm lub cav rau COM chaw nres nkoj saib
yog (Serial.available() > 0) {
yog (1 == Serial.read());
////////Thiab yog tias "1" tau txais, ces cov zis
File myFile = SD.open(perv);
// yog tias cov ntaub ntawv muaj, sau rau nws:
yog tias (myFile) {
thaum (myFile.available()) {
Serial.write(myFile.read());
}
myFile.close();
}
lwm {
Serial.println("yuam kev qhib .txt");
}
}
///////// Lub sijhawm nyeem ntawv
t = rtc.getTime();
tft.setTextColor(WHITE);
//////// Yog tias lub sijhawm hloov pauv, ces tso saib cov ntawv nyeem tshiab
if (time_sec_prev != t.sec) {
tft.setCursor(120, 0); // teeb tsa tus cursor txoj hauj lwm
tft.fillRect(118, 0, 50, 7, GREY); // clearing lub sij hawm tso zis cheeb tsam
tft.setTextSize(1);
tft.print(rtc.getTimeStr()); // tso zis moos nyeem ntawv
time_sec_prev = t.sec;
}
//////// Yog hnub twg tau hloov, ces tso saib hnub tshiab
if (time_day_prev != t.date) {
tft.setCursor(180, 0); // teeb tsa tus cursor txoj hauj lwm
tft.fillRect(178, 0, 65, 7, GREY); // clear date display area
tft.setTextSize(1);
tft.print(rtc.getDateStr()); // tso saib hnub nyeem ntawv
time_day_prev = t.date;
}
//////// Yog muaj xov tooj cua txais tos, ces
yog (radio.available(&pipe)) {
/////////xyuas seb puas tau txais qhov tsis txaus,
radio.read(&data, sizeof(data));
//////// yog qhov chaw xa xov tooj yuav tsum muaj, ces
yog (pipe == 1) {
/////////tos rau qhov synchronizing sequence ntawm zeros los txiav txim
// pib ntawm cov ntaub ntawv thaiv
yog (data == 0000) {
rc = 0;
} Lwm {
rc++;
}
///////// Sau cov txee qhov tseem ceeb thiab suav lawv hauv 10th thiab 100ths ntawm ib teev
yog (rc == 1) {
leb_1 = data / 3600.0;
}

yog (rc == 2) {
leb_2 = data / 3600.0;
}

yog (rc == 3) {
leb_3 = data / 3600.0;
}

yog (rc == 4) {
leb_4 = data / 3600.0;
}
}
}
r++;
k++; // tsuas yog lub txee
//////// Cov ntaub ntawv hloov tshiab nrog rau qee lub sijhawm
yog (r>= 6500) {
tft.setTextSize(2);
tft.fillRect(0, 41, 180, 64, GRAYD);
Serial.println("Lebedki kuv");
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;
}
//////// Sau cov ntaub ntawv rau lub cav ntawm SD txhua 10 feeb.
if ((t.min % 10 == 0) && ( t.sec == 0)) {
tft.setTextSize(1);
tft.setCursor(200, 10);
tft.setTextColor(BLACK);
////////Tsim ib txoj hlua hauv .csv hom
String dataString = String (rtc.getDateStr()) + ", "+(rtc.getTimeStr()) + ", " + (leb_1) + ", " + (leb_2)
+ ", " + (leb_3) + ", " + (leb_4) + ", ";
//////// Sau rau ib cov ntaub ntawv thiab tso tawm cov txiaj ntsig ntawm kev sau ntawv
myFile = SD.open(perv, FILE_WRITE); // yog tias tsis muaj ntaub ntawv npe "2.txt", nws yuav raug tsim.
yog tias (myFile) {
myFile.println(dataString);
myFile.close();
tft.fillRect(198, 8, 42, 10, Ntsuab);
tft.println("SD OK");
Serial.println("SD OK");
ncua (900); // ncua, txwv tsis pub sau 13 qhov kev nyeem zoo ib yam kom txog rau thaum ob tau dhau mus
} Lwm {
tft.fillRect(198, 8, 42, 10, RED);
tft.println("SD ERR");
Serial.println("SD ERR");
}
}
}Kev hloov pauv tus cwj pwm/* Recode Lavxias teb sab fonts los ntawm UTF-8 rau Windows-1251 */

String utf8rus (Txoj hlua qhov chaw)
{
kuv, k;.
Txoj hlua phiaj;
unsigned char n;
char m[2] = {'0', ' ' };

k = source.length(); kuv = 0;

thaum (i <k) {
n = source[i]; i++;

yog (n >= 0xC0) {
switch (n) {
cas 0xD0: {
n = source[i]; i++;
if (n == 0x81) { n = 0xA8; tawg; }
if (n >= 0x90 && n <= 0xBF) n = n + 0x30;//0x2F
tawg;
}
cas 0xD1: {
n = source[i]; i++;
if (n == 0x91) { n = 0xB8; tawg; }
if (n >= 0x80 && n <= 0x8F) n = n + 0x70;//0x6F
tawg;
}
}
}
m[0] = n; phiaj = phiaj + String(m);
}
rov qab hom phiaj;
}Cov kev hloov pauv cov cim rau Cyrillic tso zis siv lub tsev qiv ntawv Adafruit_GFX tau muab tso rau hauv tib lub nplaub tshev nrog rau qhov program tseem ceeb. Koj kuj yuav tsum tau hloov cov ntaub ntawv glcdfont.c hauv Adafruit_GFX nrog cov ntawv sib txawv. nws yog tsev qiv ntawv nrog rau qhov yuav tsum tau hloov. Xav paub ntau ntxiv txog Russification tuaj yeem nrhiav tau yooj yim hauv Is Taws Nem.
Ua kom tiav, kuv yuav hais tias lub kaw lus tau ua tiav raws li qhov kev cia siab, nws tau dhau los ua yooj yim los saib xyuas lub sijhawm ua haujlwm ntawm cov khoom siv. Txawm hais tias txhua yam yog sib sau ua ke ntawm breadboards, tsis muaj kev tsis txaus siab tam sim ntawd txog kev ua haujlwm. Thawj cov ntsiab lus tau ua haujlwm rau ntau tshaj rau lub hlis thiab tau dim lub caij ntuj no. Tseeb tsim Nws tau ua haujlwm rau 9 lub chaw tswj hwm txij li Lub Peb Hlis 5th thiab lub sijhawm ua haujlwm tau raug tso npe siv nws.

Tau qhov twg los: www.hab.com

Ntxiv ib saib