<?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=372</link>
		<atom:link href="http://forum.rcl-radio.ru/extern.php?action=feed&amp;tid=372&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «Измеритель фазы».]]></description>
		<lastBuildDate>Thu, 17 Jun 2021 16:21:17 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Измеритель фазы]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=4086#p4086</link>
			<description><![CDATA[<p><span class="postimg"><img src="http://forum.rcl-radio.ru/uploads/images/2021/06/59799d2d0ca6acab186df61c039bac80.jpg" alt="http://forum.rcl-radio.ru/uploads/images/2021/06/59799d2d0ca6acab186df61c039bac80.jpg" /></span></p>]]></description>
			<author><![CDATA[null@example.com (galina)]]></author>
			<pubDate>Thu, 17 Jun 2021 16:21:17 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=4086#p4086</guid>
		</item>
		<item>
			<title><![CDATA[Измеритель фазы]]></title>
			<link>http://forum.rcl-radio.ru/viewtopic.php?pid=4084#p4084</link>
			<description><![CDATA[<p>Здравствуйте <br />Почему чтение на ЖК-дисплее скачет на 3.6 градуса (не меняется плавно а через 3.6 градуса&nbsp; , 100, 103.6, 107.2 ...) и как это исправить. Выход генератора PB7 подключен к входу фазометра PA7, кнопки предназначены для изменения длительности импульсов, пропорциональной фазовому сдвигу.</p><br /><br /><div class="codebox"><pre><code>HardwareTimer pwmtimer4(4);
#include &lt;LiquidCrystal.h&gt;
#include &quot;EmonLib.h&quot;
#include &lt;EEPROM.h&gt;
LiquidCrystal lcd(PA0, PA1, PA2, PA3, PA4, PA5);
///////////
int pin = PA7; // input
float rads = 57.29577951; // 1 radian = approx 57 deg.
float degree = 360;
float frequency = 10000;
float nano = 1 * pow (10,-6); // Multiplication factor to convert nano seconds into seconds

// Define floats to contain calculations

float pf;
float angle;
float pf_max = 0;
float angle_max = 0;
int ctr;
/////////
int i;
int ovfi;
void setup() {
  pinMode(pin, INPUT);// input
  pinMode(PB7, PWM); //Tx
  pinMode(PB14, INPUT_PULLUP);
  pinMode(PB12, INPUT_PULLUP);

  lcd.begin(16, 2);
  EEPROM.read(500, (uint16*)&amp;i);
}
void loop() {
  /////////////////
for (ctr = 0; ctr &lt;= 4; ctr++) // Perform 4 measurements then reset
  {
  // 1st line calculates the phase angle in degrees from differentiated time pulse
  // Function COS uses radians not Degree&#039;s hence conversion made by dividing angle / 57.2958
   angle = ((((pulseIn(pin, HIGH)) * nano)* degree)* frequency);
  // pf = cos(angle / rads); 
   
   if (angle &gt; angle_max) // Test if the angle is maximum angle
     {
      angle_max = angle; // If maximum record in variable &quot;angle_max&quot;
      pf_max = cos(angle_max / rads); // Calc PF from &quot;angle_max&quot;
     }
   }
   if (angle_max &gt; 360) // If the calculation is higher than 360 do following...
   {
    angle_max = 0; // assign the 0 to &quot;angle_max&quot;
    pf_max = 1; // Assign the Unity PF to &quot;pf_max&quot;
   }
   if (angle_max == 0) // If the calculation is higher than 360 do following...
   {
    angle_max = 0; // assign the 0 to &quot;angle_max&quot;
    pf_max = 1; // Assign the Unity PF to &quot;pf_max&quot;
   }
   Serial.print(angle_max, 2); // Print the result
   Serial.print(&quot;,&quot;);
   Serial.println(pf_max, 2);
   
  lcd.clear();
  /*
   lcd.setCursor(0,0);
   lcd.print(&quot;PF=&quot;);
   lcd.setCursor(4,0);
   lcd.print(pf_max);
   lcd.print(&quot; &quot;);
   */
    lcd.setCursor(0, 0);
  lcd.print(&quot;i =&quot;);
  lcd.print(i);
  
   lcd.setCursor(0,1);
   lcd.print(&quot;Ph-Shift=&quot;);
   lcd.setCursor(10,1);
   lcd.print(angle_max);
   lcd.print(&quot; &quot;);
   
   //delay(500);
   angle = 0; // Reset variables for next test
   angle_max = 0;
  //////////////////
  ovfi = 10000 - i;

  pwmtimer4.pause();
  pwmtimer4.setPrescaleFactor(1);
  pwmtimer4.setOverflow( 7200);

  pwmtimer4.setCompare(TIMER_CH2, i );//step = 100/7200 = 0.0138 micro sec = 13.8

  pwmtimer4.refresh();
  pwmtimer4.resume();

  if (digitalRead(PB12) == HIGH)
  {
    if (i &lt; 7200)
      // if (i &lt; 25)
    {
      i++;
      delay(10);
    }
  }

  if (digitalRead(PB14) == HIGH)
  {
    if (i &gt; 0)
    {
      i--;
      delay(10);
    }
  }


  EEPROM.write(500, i);
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (galina)]]></author>
			<pubDate>Thu, 17 Jun 2021 16:17:51 +0000</pubDate>
			<guid>http://forum.rcl-radio.ru/viewtopic.php?pid=4084#p4084</guid>
		</item>
	</channel>
</rss>
