<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[forum.rcl-radio.ru &mdash; Аналоговый компаратор]]></title>
		<link>http://forum.rcl-radio.ru/viewtopic.php?id=183</link>
		<atom:link href="http://forum.rcl-radio.ru/extern.php?action=feed&amp;tid=183&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «Аналоговый компаратор».]]></description>
		<lastBuildDate>Tue, 28 Jul 2020 08:15:00 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Аналоговый компаратор]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=1931#p1931</link>
			<description><![CDATA[<p>+ ПЕРИОД</p><p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2020/07/77131813146d8b137eb8a23738d53f92.png" alt="http://forum.rcl-radio.ru/uploads/images/2020/07/77131813146d8b137eb8a23738d53f92.png" /></span> </p><br /><div class="codebox"><pre><code>volatile int x;
float t,t1;
bool w,w1;
const float k = 1.006424;
void setup() {
  Serial.begin(9600);
  cli();
 //// таймер ///////////
  TCCR1A = 0;
  TCCR1B = 0;
  TCCR1B |= (1 &lt;&lt; CS10); // делитель 1
  TIMSK1 |= (1 &lt;&lt; TOIE1);
   
  //// компаратор ///////
 ACSR |= (1 &lt;&lt; ACBG);  // подключаем ИОН ко входу AIN0 (D6)
  sei();
}

void loop() {
  while((ACSR &amp; 0x20) == 0x20){}
  while((ACSR &amp; 0x20) != 0x20){x=0;TCNT1 = 0;}
  while((ACSR &amp; 0x20) == 0x20){}
   t1 = x * 65535 + TCNT1;
  while((ACSR &amp; 0x20) != 0x20){}
  while((ACSR &amp; 0x20) == 0x20){x=0;TCNT1 = 0;}
  while((ACSR &amp; 0x20) != 0x20){w=1;}
   t = x * 65535 + TCNT1;
  if(w==1){
    
    w=0; 
    Serial.print(&quot;t1 = &quot;);
    Serial.print(t1/16*k,0); 
    Serial.println(&quot; uS&quot;);
    Serial.print(&quot;t0 = &quot;);
    Serial.print(t/16*k,0); 
    Serial.println(&quot; uS&quot;);
    Serial.print(&quot;T = &quot;);
    Serial.print((t/16+t1/16)*k,0); 
    Serial.println(&quot; uS&quot;);    
    delay(1000);
  }



}

ISR (TIMER1_OVF_vect){x++;}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Tue, 28 Jul 2020 08:15:00 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=1931#p1931</guid>
		</item>
		<item>
			<title><![CDATA[Re: Аналоговый компаратор]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=1926#p1926</link>
			<description><![CDATA[<p>определение длительности и скважности импульса</p><p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2020/07/7fd32f63e6e79fad366b1cacafc5b4b1.png" alt="http://forum.rcl-radio.ru/uploads/images/2020/07/7fd32f63e6e79fad366b1cacafc5b4b1.png" /></span> </p><div class="codebox"><pre><code>volatile int x;
float t,t1;
bool w,w1;
const float k = 1.006391;
void setup() {
  Serial.begin(9600);
  cli();
 //// таймер ///////////
  TCCR1A = 0;
  TCCR1B = 0;
  TCCR1B |= (1 &lt;&lt; CS10); // делитель 1
  TIMSK1 |= (1 &lt;&lt; TOIE1);
   
  //// компаратор ///////
 ACSR |= (1 &lt;&lt; ACBG);  // подключаем ИОН ко входу AIN0 (D6)
  sei();
}

void loop() {
  while((ACSR &amp; 0x20) == 0x20){}
  while((ACSR &amp; 0x20) != 0x20){x=0;TCNT1 = 0;}
  while((ACSR &amp; 0x20) == 0x20){}
   t1 = x * 65535 + TCNT1;
  while((ACSR &amp; 0x20) != 0x20){}
  while((ACSR &amp; 0x20) == 0x20){x=0;TCNT1 = 0;}
  while((ACSR &amp; 0x20) != 0x20){w=1;}
   t = x * 65535 + TCNT1;
  if(w==1){
    
    w=0; 
    Serial.print(&quot;t1 = &quot;);
    Serial.print(t1/16*k,0); 
    Serial.println(&quot; uS&quot;);
    Serial.print(&quot;t0 = &quot;);
    Serial.print(t/16*k,0); 
    Serial.println(&quot; uS&quot;);delay(1000);
  }



}

ISR (TIMER1_OVF_vect){x++;}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Tue, 28 Jul 2020 06:20:26 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=1926#p1926</guid>
		</item>
		<item>
			<title><![CDATA[Re: Аналоговый компаратор]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=1922#p1922</link>
			<description><![CDATA[<p>калибровка</p><p>генератор 8 мгц выход d9</p><div class="codebox"><pre><code>void setup(){
   // см. пример - http://rcl-radio.ru/?p=80812
    DDRB = 0b00000010;       // установить пин PB1 (D9) как выход | выход OC1A
 
    cli();                   // отключить глобальные прерывания
    TCCR1A = 0;              // установить регистр TCCR1A в 0
    TCCR1B = 0;              // установить регистр TCCR1B в 0
 
    TCCR1A |= (1 &lt;&lt; COM1A0); // COM1A1 COM1A0  = bit:01 - изменение состояния вывода OC1A на противоположное при совпадении с A
 
    TCCR1B |= (1 &lt;&lt; WGM12);  // включить CTC режим &gt; сброс таймера по совпадению
    TCCR1B |= (1 &lt;&lt; CS10);   // Установить биты CS10 CS12 на коэффициент деления 1024  
  //  TCCR1B |= (1 &lt;&lt; CS12);   
 
    OCR1A = 1;           
 
    sei();                   // включить глобальные прерывания
}
 
void loop(){ }</code></pre></div><p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2020/07/7ce43dadb99948f84d9af45fe00c1fcb.png" alt="http://forum.rcl-radio.ru/uploads/images/2020/07/7ce43dadb99948f84d9af45fe00c1fcb.png" /></span> </p><br /><div class="codebox"><pre><code>volatile int x;
float f;
bool w;
const float k = 1.00639058;
void setup() {
  Serial.begin(9600);
  cli();
 //// таймер ///////////
  TCCR1A = 0;
  TCCR1B = 0;
  TCCR1B |= (1 &lt;&lt; CS10); // делитель 1
  TIMSK1 |= (1 &lt;&lt; TOIE1);
   
  //// компаратор ///////
 ACSR |= (1 &lt;&lt; ACBG);  // подключаем ИОН ко входу AIN0 (D6)
  sei();
}

void loop() {
  while((ACSR &amp; 0x20) == 0x20){x=0;TCNT1 = 0;}
  while((ACSR &amp; 0x20) == 0x00){w=1;}
  
  if(w==1){
    f = x * 65535 + TCNT1;
    w=0; 
    Serial.print(f/16*k,0); 
    Serial.println(&quot; uS&quot;);delay(500);
  }
}

ISR (TIMER1_OVF_vect){x++;}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Tue, 28 Jul 2020 03:03:17 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=1922#p1922</guid>
		</item>
		<item>
			<title><![CDATA[Re: Аналоговый компаратор]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=1921#p1921</link>
			<description><![CDATA[<p>измерение длительности импульса</p><p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2020/07/212fecf916a6f1f4900f46038131f97d.png" alt="http://forum.rcl-radio.ru/uploads/images/2020/07/212fecf916a6f1f4900f46038131f97d.png" /></span> </p><br /><div class="codebox"><pre><code>volatile int x;
 float f;
bool w;
void setup() {
  Serial.begin(9600);
  cli();
 //// таймер ///////////
  TCCR1A = 0;
  TCCR1B = 0;
  TCCR1B |= (1 &lt;&lt; CS10); // делитель 1
  TIMSK1 |= (1 &lt;&lt; TOIE1);
   
  //// компаратор ///////
  ADCSRA &amp;= ~(1 &lt;&lt; ADEN);  // ADEN = 0
  ADCSRB |= (1 &lt;&lt; ACME);   // ACME = 1
  /////////////////////////// MUX2..0 = ADC0...ADC7
 // ADMUX  |= (1 &lt;&lt; MUX2);           
 // ADMUX  |= (1 &lt;&lt; MUX1); 
  ADMUX  |= (1 &lt;&lt; MUX0); // A1 INPUT, D7 +3.3V
  sei();
}

void loop() {
  while((ACSR &amp; 0x20) == 0x20){x=0;TCNT1 = 0;}
  while((ACSR &amp; 0x20) == 0x00){w=1;}
  
  if(w==1){
    f = x * 65535 + TCNT1;
    w=0; 
    Serial.print(f/16,0); 
    Serial.println(&quot; uS&quot;);delay(500);
  }
}

ISR (TIMER1_OVF_vect){x++;}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Tue, 28 Jul 2020 02:18:06 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=1921#p1921</guid>
		</item>
		<item>
			<title><![CDATA[Re: Аналоговый компаратор]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=1919#p1919</link>
			<description><![CDATA[<div class="codebox"><pre><code>void setup() {
  DDRB |= (1 &lt;&lt; 5);        // выход PB5 как выход (D13)
  ADCSRA &amp;= ~(1 &lt;&lt; ADEN);  // ADEN = 0
  ADCSRB |= (1 &lt;&lt; ACME);   // ACME = 1
  /////////////////////////// MUX2..0 = ADC0...ADC7
 // ADMUX  |= (1 &lt;&lt; MUX2);           
 // ADMUX  |= (1 &lt;&lt; MUX1); 
 // ADMUX  |= (1 &lt;&lt; MUX0); 
}

void loop() {
  while ((ACSR &amp; 0x20) == 0x20) { // если бит ACO регистра ACSR равен 1, то исполнять код в цикле
    PORTB |= (1 &lt;&lt; 5);  // PB5 HIGH
  }
  PORTB &amp;= ~(1 &lt;&lt; 5);   // PB5 LOW
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Mon, 27 Jul 2020 07:45:14 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=1919#p1919</guid>
		</item>
		<item>
			<title><![CDATA[Аналоговый компаратор]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=1909#p1909</link>
			<description><![CDATA[<p>Вход AIN0 подключен к опорному напряжению 1,1 В. На AIN1 (D7) подается напряжение. <br />Выполняется условие:<br />PB5 = 0 - если AIN0&lt;AIN1<br />PB5 = 1 - если AIN0&gt;AIN1</p><br /><div class="codebox"><pre><code>void setup() {
  ACSR |= (1 &lt;&lt; ACBG);  // подключаем ИОН ко входу AIN0 (D6)
  DDRB |= (1 &lt;&lt; 5);     // выход PB5 как выход (D13)
}

void loop() {
  while ((ACSR &amp; 0x20) == 0x20) { // если бит ACO регистра ACSR равен 1, то исполнять код в цикле
    PORTB |= (1 &lt;&lt; 5);  // PB5 HIGH
  }
  PORTB &amp;= ~(1 &lt;&lt; 5);   // PB5 LOW
}</code></pre></div><p>Скетч использует 464 байт (1%) памяти устройства. Всего доступно 32256 байт.<br />Глобальные переменные используют 9 байт (0%) динамической памяти, оставляя 2039 байт для локальных переменных. Максимум: 2048 байт.</p>]]></description>
			<author><![CDATA[null@example.com (liman324)]]></author>
			<pubDate>Thu, 23 Jul 2020 15:44:56 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=1909#p1909</guid>
		</item>
	</channel>
</rss>
