// Si5351a set up Si5351_write(3,0xFF); //Disable Output Si5351_write(16,0x80); //CLOCK0 Power down Si5351_write(183,0x80); // 8pF PLLA_set(); MS0_set(); Si5351_write(177,0xA0); //Reset PLLA and PLLB Si5351_write(16,0x4F); //CLOCK0 Power up 8mA Si5351_write(3,0xFE); //Enable CLOCK0 }
‐――――――――――――――――――――――――――――――――――――――― // i2c_scanner display on i2cLCD address 0x3E // // // This very simple sketch scans the I2C-bus for devices. // If a device is found, it is reported to the Arduino serial monitor. // Version 5, March 28, 2013 // アドレスは7-bit(127d)まで。拡張アドレスは扱わず // https://playground.arduino.cc/Main/I2cScanner/
long int freq; unsigned char charbuf[10]; // sprintf関数変換時に使う文字配列
void loop() { FreqCounter::f_comp = 8; // Set compensation to 12 FreqCounter::start(1000); // Start counting with gatetime of 100ms while (FreqCounter::f_ready == 0); // wait until counter ready freq = FreqCounter::f_freq; // read result Serial.print("Freq: "); // print result Serial.print(freq); // print result Serial.println("Hz"); // print result
// Print the proper amount of spaces to make it look pretty LCD.SetCursor(0,1); if (freq < 100) LCD.Puts(" "); else if (freq < 10000) LCD.Puts(" "); else if (freq < 1000000) LCD.Puts(" "); else LCD.Puts(" ");
// As there is no service of print at i2cLCD lib, so // we shall use sprintf function sprintf(charbuf, "%ld", freq); LCD.Puts(charbuf); LCD.Puts(" Hz ");
delay(20); LED_Stat=!LED_Stat; digitalWrite(pinLed, LED_Stat); // blink Led }
||<
まずはコンパイルして黙ってそのまま動かすと60Hzでました。電源ノイズ拾って表示してくれています。 To catch the power line noise, it shows as 60 helz.
(後で気が付いてpinmodeでINPUT_PULLUPにしたら、電源ノイズ拾わなくなりました。)Lately I set pinmode of INPUT_PULLUP, I can reject the power line noise.