بسم الله الرحمن الرحيم
السلام عليم و رحمة الله و بركاته
كل عام وانتم بخير و المسلمين جميعا
[QUOTE=db2006;1059022]سلمت يداك اخ مشتاق وكل عام وانت بالف خير
هل يمكن التواصل معك لدي استفسار
|
ممكن تعرض اى استفسار هنا لتعم الفائدة او ترسله فى رسالة خاصة ان اردت .
و الله ولى التوفيق
اللهم اجعلنا مؤمنين حقا
و علمنا ما ينفعنا و ينفع بنا
اللهم اكتب لنا الحج و العمرة و اهلنا
[/QUOTE]
وفقك الله اخ مشتاق هذا كرم لا حدود له
كود:
#define triac_control 9
#define sensorPin A1
#define zero_detect 2
volatile byte zero_bit = LOW;
#include <PID_v1.h>
double Setpoint, Input, Output;
double consKp=0.25, consKi=1, consKd=0.5;
PID myPID(&Input, &Output, &Setpoint, consKp, consKi, consKd, DIRECT);
float analogValue = 0;
int analogValue0 = 0;
int analogmin = 4;
int analogmax = 1000;
float kDev = 32.5;
void setup() {
pinMode(triac_control, OUTPUT);
pinMode(zero_detect, INPUT);
attachInterrupt(0, zero_fun, RISING);
Serial.begin(9600);
}
void loop()
{
myPID.SetSampleTime(10);
myPID.SetMode(AUTOMATIC);
myPID.SetOutputLimits(100, 5000);
Input = analogRead(sensorPin);
analogValue = Output/kDev;
analogValue0 = analogmax-analogValue+analogmin;
if (analogValue > analogmax)
{
analogValue = analogmax;
}
Setpoint = 10;
myPID.Compute();
Serial.println(analogValue0);
if (zero_bit == 1){
delayMicroseconds(analogValue0);
digitalWrite(triac_control, 1);
delayMicroseconds(100);
digitalWrite(triac_control, 0);
zero_bit = 0;
}
}
}
void zero_fun() // set bit
{
zero_bit = 1;
}
تعبت وانا احاول ان اوصل لنتيجة لكن دون جدوى ما هي الاخطاء المحتملة (المنطقية) في الكود