Счётчик времени круга.
- Войдите на сайт для отправки комментариев
Чт, 01/08/2019 - 15:51
сем привет! Парни помогите пожалуйста разобраться. Короче решил я себе сделать счётчик времени круга на Ардуинке. Проэкт отыскал только на англ языка, короче собрал на макетке, но что то не фурычит. На экране нет никаких надписей. Вот ссылка на статью:https://qps.ru/BWwC0 и ссылка на скеч:https://qps.ru/QOczu . Подключал дисплей и ардуино так:
Arduino nano - LCD 1-RS, 4-4, 5-5, 6-6, 7-7
LCD VSS - 0, VDD- +5, V0- средняя точка резистора, RW- 0, A- +5, K-0
Что я сделал не так?
Статья https://teambarnato.blogspot.com/2016/02/ir-laptimer-using-arduino.html
Скеч https://teambarnato.blogspot.com/2016/02/laptimer-arduino-sketch.html
Что я сделал не так?
1. Не выложили код;
2. Не выложили схему;
3. Не описали как должна работать система
4. Не описали как она работает;
5. Не уточнили чем именно (3) отличается от (4)
6. Не задали ни одного конкретного вопроса.
Если Вы считаете, что Вы что-то выложили, дав ссылку на которыю вылазит ВК и что-то плетёт про фишинг, то ошибаете, код нужно выкладывать здесь. Схему тоже.
Подключил вот так :
В оригинале так:
Как должна работать? Это что то вроде секундомера, только включается не кнопкой, а ик сигналом(когда проезжаешь мимо передатчика.
В сообщение номер 2 я скинул нормальные ссылки, потому что как тут редактировать свои сообщения я не отыскал.
Скеч
/* Lap Timer for Team Barnato karting races by Matt Wall Use at own risk, Sketch is in the public domain but no profit shall be gained from using it. Pin allocation. d0 - No Connection d1 - display RS d2 - IR signal from IR receiver d3 - PWM signal for display backlight d4 - display data pin - d4 d5 - display data pin - d5 d6 - display data pin - d6 d7 - display data pin - d7 d8 - display Enable d9 - no Connection d10 - Sd Card CS d11 - Sd Card MOSI D12 - Sd Card MISO D13 - Sd Card CLK / SCK */ #include <LiquidCrystal.h>// include the LCD library #include <SdFat.h> // include the new sd card library SdFat sd; float lapdelay = 20000;// set the default lap delay to 20 seconds unless updated from SD card file. SdFile myFile; // file to read SD card lap delay data float decade;// to be used in reading sd card float temp;// to be used in reading sd card float number;// to be used in reading sd card int backlight = 3;//PWM for display backlight to be connected to pin 3 int lapcount = 0;// start with a lap count of 0 long start = 500;//set values (system will random asign if left blank) will be changed later long finish = 0;//set values (system will random asign if left blank) will be changed later long laptime = 0;//set values (system will random asign if left blank) will be changed later long elapsed1 = 0;//set values (system will random asign if left blank) will be changed later long elapsed2 = 0;//set values (system will random asign if left blank) will be changed later long oldlaptime = 0;//set values (system will random asign if left blank) will be changed later long delta = 0;//set values (system will random asign if left blank) will be changed later #define IRpin_PIN PIND // assign pin 2 raw mapping to IRpin 2 #define IRpin 2 #define MAXhighPULSE 2000 // Time counts to reset tokens to zero if no beam detected incase of false trigger, 2000 * RESOLUTION = 40ms #define MAXlowPULSE 28 // the maximum pulse count we need. 560us / RESOLUTION = 28 #define MINlowPULSE 18 // the minimum pulse count we need. 360us / RESOLUTION = 18 #define RESOLUTION 20 // Multiplier - will be used to take reading of IRpin every 20ish microseconds int lowpulse = 0; // start with 0 for the pulse length. int highpulse = 0; // start with 0 for the pulse length. int token = 0; // start with 0 count for tokens. We'll need 3 tokens to trigger the timer. // initialize the library with the numbers of the interface pins LiquidCrystal lcd(1, 8, 4, 5, 6, 7); const int chipSelect = 10; //choose the chip select pin for the SD card SdFile myfile; void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); pinMode(backlight, OUTPUT);// Output for the PWM on the backlight // pinMode(10, OUTPUT);// must be set fot the SD Card to work analogWrite(backlight,80); lcd.print(" Team Barnato"); // Print a message to the LCD. delay(2000);// Wait 2 seconds before clearing the LCD. if (!sd.begin(chipSelect, SPI_HALF_SPEED)){// start up the sd card lcd.clear(); lcd.print("SD Card failed!");// Incase no SD card or problem with SD Card delay(10000); } else{ //SD Card is ok lcd.clear(); lcd.print(" SD Card OK");// tell the world the sd card is ok delay(2000);//give people time to read the message } if (sd.exists("times.csv")){//check if the file to record the lap times in already exists? lcd.clear(); lcd.print(" File OK");//tell the world it exists delay(2000);//give people time to read the message } else{ //it doesn't exist lcd.clear(); lcd.print(" Creating File");//tell the world your creating the file myfile.open("times.csv", O_RDWR | O_CREAT | O_APPEND);// create the file myfile.close();// save the file delay(2000);//give people time to read the message if (sd.exists("times.csv")){// re check that the file exists after creating lcd.clear(); lcd.print(" File OK");//tell the world it exists delay(2000);//give people time to read the message } else{// file still not available lcd.clear(); lcd.print("File Error");// tell the world the is a problem delay(5000);// give people time to read the message } } if (myFile.open("lapdelay.txt",O_READ)) // Open SD Card and retreive lap delay information. { lapdelay = 0; // if the file is ok on the sd card then set lapdelay at zero ready for reading the correct delay decade = pow(10, (myFile.available() - 1)); number = 0; while(myFile.available()) { temp = (myFile.read() - '0'); number = temp*decade+number; decade = decade/10; } lapdelay = number*1000; myFile.close(); } lcd.clear(); lcd.print(" Target Lap"); lcd.setCursor(4, 1); lcd.print(lapdelay/1000); lcd.print(" secs"); delay(2000); lcd.clear(); lcd.print(" Ready To Race"); lcd.setCursor(0, 1); lcd.print(" -- Out Lap --"); } void displayResult(){ /*This procedure will calculate the laptime, delta time, display the result to the LCD screen, record the lap time to SD card (not yet working) and finally set a system delay to allow you to pass the start / finish straight without re triggering from other beams*/ laptime=finish-start;// Calculate lap time if (lapcount>0){// will display times after completing the first flying lap. //This section works out the actual lap time float m1,s1,ms1;// create variables for hours,minutes,seconds and milliseconds unsigned long over1;// create variable for the calculation over spill elapsed1=laptime; m1=int(elapsed1/60000); //Calculate the minutes over1=elapsed1%60000; // Work out the remainder s1=int(over1/1000);// Calculate the seconds ms1=over1%1000;//work out the milliseconds lcd.clear(); lcd.setCursor(0, 0);// Set cursor to top left position. lcd.print("LAP");//Print text to LCD lcd.setCursor(9, 0); if (oldlaptime<laptime)// If the last lap was less than the new lap then the delta needs to be a plus value { delta=laptime-oldlaptime; lcd.print("+");//shows these values on screen if new lap was slower then previous lap } else// If the last lap was more than the new lap then the delta needs to be a minus value { delta=oldlaptime-laptime; lcd.print("-");// shows these if your new lap was quicker then the last } float s2,ms2;// create variables for seconds and milliseconds unsigned long over2;// create variable for the calculation over spill s2=int(delta/1000); // work out the delta time ms2=delta%1000; //work out the milliseconds lcd.print(s2,0);//print delta seconds lcd.print("."); if (ms2<100){lcd.print("0");}// if milliseconds is below 100 we need to add a zero if (ms2<10){lcd.print("0");} // if milliseconds is below 10 we need to add another zero lcd.print(ms2,0); lcd.setCursor(0, 1);// move cursor to second line first character lcd.print(lapcount); lcd.setCursor(8, 1);// move cursor to second line 8th character lcd.print(m1,0); lcd.print(":"); lcd.print(s1,0); lcd.print("."); if (ms1<100){lcd.print("0");}// if milliseconds is below 100 we need to add a zero if (ms1<10){lcd.print("0");} // if milliseconds is below 10 we need to add another zero lcd.print(ms1,0); if (myfile.open("times.csv", O_RDWR | O_CREAT | O_APPEND)){// Open SD Card File myfile.print("Lap,");//Start line with Lap myfile.print(lapcount);//add the lap count to the file myfile.print(",");//add a comma for use in excel later myfile.println(laptime);//save laptime and start new line myfile.close();// close and save the file } } else { // this section is only used during the first flying lap. lcd.clear(); lcd.print(" First Lap"); lcd.setCursor(0,1); lcd.print(" Timer Running"); } // This line reserved for entering the save to SD card routine start=finish; // set the new lap start time to the same value as the last lap finish time oldlaptime=laptime;// store new lap time as old lap time for next lap lapcount++;// increase lap count by 1 token = 0; // reset token counter ready for next lap delay(lapdelay);// delay to prevent re triggering if other beams are present. } void loop() { highpulse = lowpulse = 0; // start out with no pulse length while (IRpin_PIN & (1 << IRpin)) { // while irpin is high - no beam is beam is being received. highpulse++; delayMicroseconds(RESOLUTION);// wait some time, the multiplier. if (highpulse >= MAXhighPULSE) { /* check to see if no signal has been received for over 40ms (we should recieve 3 tokens in 4ms, so if we only receive one or two tokens in 40ms it must be a false signal), then reset the token count if true as no/false signal is being received. */ token = 0; highpulse = 0;// reset high pulse counter } } while (! (IRpin_PIN & _BV(IRpin))) {// while irpin is low, signal being received lowpulse++; delayMicroseconds(RESOLUTION); } if ((lowpulse >= MINlowPULSE) && (lowpulse <= MAXlowPULSE)) {// was the pulse length what we expected? token ++; // if so then count 1 token, we need 3 tokens to trigger } if (token == 3) { // If we receive 3 correct pulses then trigger the lap timer. finish=millis();// Record the time displayResult();// run through the display procedure } }Судя по приведённым фото, схеме и скетчу, Вы забыли передатчик сделать. :)
И прочитайте ещё раз замечания Евгения в #2. Вы же на большую часть так и не ответили.