27.04.2021, 17:34 | #1 (permalink) |
Новичок
Регистрация: 27.04.2021
Сообщений: 5
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 10
|
Arduino
Не могу додумать некоторый элемент в схеме и в коде для ардуино. Схема рабочая, код тоже но нужно добавить следующее: Как-то продумать систему ЭРВ (Электронный регулирующий клапан). Т.е. Например Имеем температуру уставки например 19 градусов а текущую температуру 21 градус. Нужно чтоб текущая температура подстроилась под уставку (Т.е. открылся/закрылся ЭРВ) в зависимости от выбранной температуры окружающей среды. Вместо ЭРВ можно использовать светодиод, чтобы показать его работу в целом, но лучше было бы использовать осциллограф. Алгоритм следующий: Если текущая температура выше температуры уставки на 2 градуса - открывается ЭРВ (Тек. темп. опускается до темп. уст. и загорается светодиод, либо идет сигнал на осциллограф). если тек. темп. ниже темп. уст. на 2 градуса - закрывается ЭРВ (т.е. тек. темп. поднимается до темп. уст.) Как это можно реализовать на ардуино и что из себя должен представлять код? Ниже представлю файлы которые сейчас имеются. Спасибо заранее! |
27.04.2021, 17:34 | |
Helpmaster
Member
Регистрация: 08.03.2016
Сообщений: 0
|
Предлагаю вам ознакомится с аналогичными темами на нашем форуме RGB Neopixel и Arduino Arduino Proteus 8.3 Arduino Nano |
28.04.2021, 11:43 | #2 (permalink) |
СпецШирокПрофНоУзкПонятия
Регистрация: 13.03.2015
Сообщений: 2,941
Записей в дневнике: 1
Сказал(а) спасибо: 31
Поблагодарили 31 раз(а) в 8 сообщениях
Репутация: 30768
|
MaxYanuk зачем вы усложняете другим жизнь? кому нужны ваши архивы? выкладывайте сюда свои идеи, схемы в нормальном виде и опишите как сейчас работает устройство
Код:
// written by Dylon Jamna, modified by Micah Beeler // include the library code #include <LiquidCrystal.h>// include the library code int tempPin = A0; // make variables// thermistor is at A0 int tup = 7; //Temp up button int tdown = 9; //Temp down button int tcf = 8; //F to C toggle boolean far = true; //Default F to true boolean cel = false; //Default C to false boolean lightMe; //Light up LED char abbrv; //Shortcut for C or F abbreviation float temp; //Raw temp value float settemp; //Desired temp int defF = 65; //Default Far. int defC = 19; //Default Cel. int upstate = 0; //Temp up button state int downstate = 0; //Temp down button state int tcfstate = 0; //C to F button state int ledPin = 13; //LED's pin LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // lcd is at 12,11,5,4,3,2 on the breadboard void setup() { Serial.begin (9600); // set the serial monitor tx and rx speed lcd.begin(16, 2); // set up all the "blocks" on the display lcd.setCursor(0, 0); // set the cursor to colum 0 row 0 lcd.print("hello, world!"); // display hello world for 1 second lcd.clear(); // clear the lcd pinMode(tup, INPUT); //Set temp up button to input pinMode(tdown, INPUT); //Set temp down button to input pinMode(tcf, INPUT); //Set C to F button to input pinMode(ledPin, OUTPUT); //Set LED to output } void loop() { upstate = digitalRead(tup); //Read state of temp up downstate = digitalRead(tdown); //Read state of temp down tcfstate = digitalRead(tcf); //Read state of C to F button int tvalue = analogRead(tempPin); // make tvalue what ever we read on the tempPin if (tcfstate == LOW) { //If the C to F button is pressed if (far == true) { //And Farenheit is true already far = false; cel = true; //Enable Celsius } else if (far == false) { //Otherwise if Farenheit isn't true far = false; //Enable Farenheit cel = true; } } if (far == true) { //If Farenheit is true temp = farenheit(tvalue); //Caclulate temp in F abbrv = 'F'; //Set label to F } if (cel == true) { //If Celsius is true temp = celsius(tvalue); //Calculate temp in C abbrv = 'C'; //Set label to C } if (upstate == LOW) { //if up button is pressed, defF = defF + 1; //raise desired F by 1 defC = defC + 1; //Raise desired C by 1 } if (downstate == LOW) { //if down button is pressed defF = defF - 1; //lower desired F by 1 defC = defC - 1; //lower desired C by 1 } lcd.setCursor(0, 0); lcd.print("Tek-aya "); lcd.print (temp); // Print the current temp in f lcd.print (abbrv); delay(255); if (cel == true) { lcd.setCursor (0, 1); // set the cursor to 0,1 lcd.print ("Ystavka "); // Print set to and your ideal temperature in f lcd.print (defC); lcd.print (abbrv); } if (far == true) { lcd.setCursor (0, 1); // set the cursor to 0,1 lcd.print ("Desired "); // Print set to and your ideal temperature in f lcd.print (defF); lcd.print (abbrv); } lightUp(temp, defC, defF); //run custom light up command if (lightMe == true) { //if light up is true digitalWrite(ledPin, HIGH); //turn on LED } else if (lightMe == false) { //otherwise digitalWrite(ledPin, LOW); //turn off LED } } // we're done float farenheit(float raw) { //calculate far value float f; //create temporary variable F f = raw / 2.07; //calculate temperature from raw value return f; //return temperature } float celsius(float raw) { //calculate cel value float c; //create temp variable C c = raw / 7.1; //calculate temperature from raw value return c; //return temperature } boolean lightUp(float act, int desC, int desF) { //Decides if LED should light up, imports current temp, desired C, and desired F if (act < desC || act < desF) { //if the actual is less than the desired F or C value lightMe = true; //Turn on the LED } else { //otherwise lightMe = false; //Turn the LED off } return lightMe; //return that value }
__________________
все гениальное просто. чем проще, тем надежнее. |
28.04.2021, 13:53 | #3 (permalink) | |
Новичок
Регистрация: 27.04.2021
Сообщений: 5
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 10
|
Цитата:
Да, согласен, усложнил. На данный момент схема работает следующим образом. При запуске идет измерение окружающей температуры , которую можно изменять на датчике температуры (TMP) и имеется температура Уставки, которую можно изменять кнопками. При изменении температуры на датчике, происходит изменение температуры окружающей среды и на дисплее, так же отображается изменении температуры уставки. Это все что на данный момент "Умеет" схема. Задача следующая: Необходимо, чтобы температура окружающей среды "подстраивалась" под температуру уставки. (Например уставка +5 градусов, а температура окружающей среды +10, значит нужно сделать так, чтобы температура окружающей упала до температуры уставки с погрешностью +- 0.5 градуса.) Причем нужно вот эту вод "подстройку" температур показать при помощи осциллографа. Т.е. Идет температура на "+", соответственно пошел сигнал на осциллограф и наоборот. Это нужно реализовать и в коде. Отсюда и мой вопрос: Как это собственно реализовать? Не могу продумать алгоритм, схему и код для поставленной задачи. |
|
28.04.2021, 13:54 | #4 (permalink) |
Новичок
Регистрация: 27.04.2021
Сообщений: 5
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 10
|
На данный момент код выглядит следующим образом.
Код:
// written by Dylon Jamna, modified by Micah Beeler // include the library code #include <LiquidCrystal.h>// include the library code int tempPin = A0; // make variables// thermistor is at A0 int tup = 7; //Temp up button int tdown = 9; //Temp down button int tcf = 8; //F to C toggle boolean far = true; //Default F to true boolean cel = false; //Default C to false boolean lightMe; //Light up LED char abbrv; //Shortcut for C or F abbreviation float temp; //Raw temp value float settemp; //Desired temp int defF = 65; //Default Far. int defC = 5; //Default Cel. int upstate = 0; //Temp up button state int downstate = 0; //Temp down button state int tcfstate = 0; //C to F button state int ledPin = 13; //LED's pin LiquidCrystal lcd(12, 11, 5, 4, 3, 2); // lcd is at 12,11,5,4,3,2 on the breadboard void setup() { Serial.begin (9600); // set the serial monitor tx and rx speed lcd.begin(16, 2); // set up all the "blocks" on the display lcd.setCursor(0, 0); // set the cursor to colum 0 row 0 lcd.print("hello, world!"); // display hello world for 1 second lcd.clear(); // clear the lcd pinMode(tup, INPUT); //Set temp up button to input pinMode(tdown, INPUT); //Set temp down button to input pinMode(tcf, INPUT); //Set C to F button to input pinMode(ledPin, OUTPUT); //Set LED to output } void loop() { upstate = digitalRead(tup); //Read state of temp up downstate = digitalRead(tdown); //Read state of temp down tcfstate = digitalRead(tcf); //Read state of C to F button int tvalue = analogRead(tempPin); // make tvalue what ever we read on the tempPin if (tcfstate == LOW) { //If the C to F button is pressed if (far == true) { //And Farenheit is true already far = false; cel = true; //Enable Celsius } else if (far == false) { //Otherwise if Farenheit isn't true far = false; //Enable Farenheit cel = true; } } if (far == true) { //If Farenheit is true temp = farenheit(tvalue); //Caclulate temp in F abbrv = 'F'; //Set label to F } if (cel == true) { //If Celsius is true temp = celsius(tvalue); //Calculate temp in C abbrv = 'C'; //Set label to C } if (upstate == LOW) { //if up button is pressed, defF = defF + 1; //raise desired F by 1 defC = defC + 1; //Raise desired C by 1 } if (downstate == LOW) { //if down button is pressed defF = defF - 1; //lower desired F by 1 defC = defC - 1; //lower desired C by 1 } lcd.setCursor(0, 0); lcd.print("Tek-aya "); lcd.print (temp); // Print the current temp in f lcd.print (abbrv); delay(255); if (cel == true) { lcd.setCursor (0, 1); // set the cursor to 0,1 lcd.print ("YctaBka "); // Print set to and your ideal temperature in f lcd.print (defC); lcd.print (abbrv); } if (far == true) { lcd.setCursor (0, 1); // set the cursor to 0,1 lcd.print ("YctaBka "); // Print set to and your ideal temperature in f lcd.print (defF); lcd.print (abbrv); } lightUp(temp, defC, defF); //run custom light up command if (lightMe == true) { //if light up is true digitalWrite(ledPin, HIGH); //turn on LED } else if (lightMe == false) { //otherwise digitalWrite(ledPin, LOW); //turn off LED } } // we're done float farenheit(float raw) { //calculate far value float f; //create temporary variable F f = raw / 2.07; //calculate temperature from raw value return f; //return temperature } float celsius(float raw) { //calculate cel value float c; //create temp variable C c = raw / 7.1; //calculate temperature from raw value return c; //return temperature } boolean lightUp(float act, int desC, int desF) { //Decides if LED should light up, imports current temp, desired C, and desired F if (act < desC || act < desF) { //if the actual is less than the desired F or C value lightMe = true; //Turn on the LED } else { //otherwise lightMe = false; //Turn the LED off } return lightMe; //return that value } |
28.04.2021, 14:00 | #5 (permalink) |
Новичок
Регистрация: 27.04.2021
Сообщений: 5
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 10
|
Извиняюсь за оффтом, не нашел как редактировать текст..
Вообще идея повторить принцип работы холодильного оборудования, но проще. С одним или двумя датчиками температур, с эмуляцией вентиляторов и с работой ЭРВ (Электронный регулирующий клапан). Т.е. ЭРВ открывается - температура окружающей среды падает и наоборот. Проблема в реализации этого самого ЭРВ на ардуино и в написании кода. Естественно само ЭРФ никак не добавить в схему, по этому пришел к решению, что показать работу ЭРВ можно через осциллограф. |
Ads | |
Member
Регистрация: 31.10.2006
Сообщений: 40200
Записей в дневнике: 0
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 55070
|
06.05.2021, 10:24 | #6 (permalink) |
support
Регистрация: 19.08.2007
Адрес: Зея
Сообщений: 15,797
Записей в дневнике: 71
Сказал(а) спасибо: 166
Поблагодарили 203 раз(а) в 86 сообщениях
Репутация: 75760
|
Сейчас есть много решений Iot, в том числе и клапанов с сервоприводами, управляемыми контроллерами. Возможно, вам поможет решить вашу проблему этот материал: Климат-контроль на Arduino [Амперка / Вики]
__________________
Убить всех человеков! |
11.05.2021, 17:09 | #7 (permalink) |
Новичок
Регистрация: 27.04.2021
Сообщений: 5
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 10
|
[QUOTE=AlexZir;2753689]Сейчас есть много решений Iot, в том числе и клапанов с сервоприводами, управляемыми контроллерами.
Спасибо большое. Но я так понимаю это можно собрать и грубо говоря потрогать руками. Но мне нужно для курсового проекта. Т.е. не нужно собирать физическую схему, нужно именно показать эту эмуляцию через софт. |
Ads | |
Member
Регистрация: 31.10.2006
Сообщений: 40200
Записей в дневнике: 0
Сказал(а) спасибо: 0
Поблагодарили 0 раз(а) в 0 сообщениях
Репутация: 55070
|
|
|