سلام به همه
من میخام دو تا خروجی ایی که از اینتراپت میگیرم رو باهم مقایسه منم
ولی وقتی این برنامه رو آپلود میکنم مقدار f تغییر نمیکنه کسی میتونه کمکم کنه
include “tc_lib.h”
using namespace arduino_due;
#define CAPTURE_TIME_WINDOW 2500000 // usecs
#define ANALOG_PIN 7
#define ANALOG_VALUE 127 // values in the interval [0,255]
capture_tc0_declaration();
auto& capture_pin2=capture_tc0;
volatile float Tx = 0 ;
volatile float f = 0 ;
volatile float t = 0 ;
volatile int m = 0 ;
void setup() {
Serial.begin(19200);
Serial3.begin(38400);
capture_pin2.config(CAPTURE_TIME_WINDOW);
attachInterrupt(digitalPinToInterrupt(2), measure , LOW );
}
void measure (){
uint32_t status,duty,period;
status=capture_pin2.get_duty_and_period(duty,period);
t = (static_cast<double>(duty)/static_cast<double>(capture_pin2.ticks_per_usec()) );
if ( (t > 1400) && (t < 1600))
{ Tx = t ;}
}
void loop() {
if (Tx - f > 1)
{
f = Tx;
m++;
}
delay(20);
Serial3.println(m);
}
این عکس هم عکس خروجی هایی که میخان مقایسه بشن