Author Topic: Minimalist frequency meter  (Read 17928 times)

0 Members and 1 Guest are viewing this topic.

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Minimalist frequency meter
« Reply #25 on: April 29, 2014, 12:30:30 am »
The firmware now can accomodate both internal oscillator and a crystal: if the crystal is fitted, it would use the crystal; otherwise, it uses the internal oscillator.

It also drives both common anode or common cathode leds.

On internal oscillator, the meter reads 16.14 - 16.15Mhz after being heated by a hairdryer, when fed a 16.128Mhz signal.
================================
https://dannyelectronics.wordpress.com/
 

Offline neslekkim

  • Super Contributor
  • ***
  • Posts: 1305
  • Country: no
Re: Minimalist frequency meter
« Reply #26 on: April 30, 2014, 09:19:16 pm »
I know nothing about PIC and they are not open-source (free) friendly so I'd rather point people toward truly free things, like arduinos and atmel.

Not opensource friendly?, Based on?
 

Offline scientist

  • Frequent Contributor
  • **
  • !
  • Posts: 317
  • Country: 00
  • User banned.
Re: Minimalist frequency meter
« Reply #27 on: April 30, 2014, 11:39:46 pm »
I know nothing about PIC and they are not open-source (free) friendly so I'd rather point people toward truly free things, like arduinos and atmel.

Not opensource friendly?, Based on?

Based on what arduino.cc says ;)
 

Offline Teemo

  • Regular Contributor
  • *
  • Posts: 58
  • Country: ee
Re: Minimalist frequency meter
« Reply #28 on: May 01, 2014, 10:19:02 pm »
Hello dannyf

Do the PIC heat up when running? I notice you do not have any current limiting resistors for the led display. Or are there resistors already inside led panel?
Or is the current limited only by PIC output port internal resistance?
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Minimalist frequency meter
« Reply #29 on: May 01, 2014, 11:05:20 pm »
No current limiting resistors, other than the pin's output resistance.

The current consumption is about 60ma @ 5v (20ma @ 3.3v). The display is slightly dimmer at 3.3v - you would know only if someone had told you so. Running for hours at 5.0v, the chip is not noticeably warmer via finger touch. The surface of the led is slightly warmer.

I used 0.56" leds. So presummably a smaller one will yield lower current consumption, particularly at 3.3v. or lower if you run the LF version.

================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Minimalist frequency meter
« Reply #30 on: May 01, 2014, 11:12:34 pm »
Here is the brightness comparison, between 3.3v  (on the left) and 5v (on the right).
================================
https://dannyelectronics.wordpress.com/
 

Offline scientist

  • Frequent Contributor
  • **
  • !
  • Posts: 317
  • Country: 00
  • User banned.
Re: Minimalist frequency meter
« Reply #31 on: May 03, 2014, 03:28:44 am »
Did you use the same exposure/white balance settings?
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Minimalist frequency meter
« Reply #32 on: May 03, 2014, 02:38:29 pm »
The meter works down to 2.1v at least.

At 2.1v, current consumption is 6ma, the led is still readable;
At 2.5v, current consumption is 12ma, and the led looks identical to when it was driven at 3.3v

Quote
Did you use the same exposure/white balance settings?

Same setting, same lighting and the same focus area.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Minimalist frequency meter
« Reply #33 on: May 05, 2014, 11:07:23 pm »
Looks like someone has tried it before: http://www.swharden.com/blog/2014-02-27-directly-driving-7-segment-display-with-avr-io-pins/

The basic hardware arrangement is the same: no current limiting resistors.

His code structure is less flexible, however.
================================
https://dannyelectronics.wordpress.com/
 

Offline Stonent

  • Super Contributor
  • ***
  • Posts: 3824
  • Country: us
Re: Minimalist frequency meter
« Reply #34 on: May 07, 2014, 12:03:08 am »
Looks like someone has tried it before: http://www.swharden.com/blog/2014-02-27-directly-driving-7-segment-display-with-avr-io-pins/

The basic hardware arrangement is the same: no current limiting resistors.

His code structure is less flexible, however.

I built my wife an animated Christmas necklace with a 5x7 LED display directly soldered to an ATTiny2313.

The larger the government, the smaller the citizen.
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Minimalist frequency meter
« Reply #35 on: May 07, 2014, 12:35:18 am »
That's interesting.

I also have an 8-digit version of the code - it drives 8-digit 7-segment led displays. That can be easily remapped to drive a 8x8 led matrix.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Minimalist frequency meter
« Reply #36 on: July 02, 2014, 09:21:16 pm »
Coming back to this meter again.

Since I have only four digits, I thought I would save on the external crystal and go with the internal rc oscillator, running the PIC at 16Mhz.

Here is the meter measuring a 19.44Mhz TCXO (TCO-919R3, 2.5ppm), with the default factory calibration value.

The error rate is 19.46 - 19.44 / 19.44 = 0.10%, not bad for a frequency meter with just two parts (the PIC + LED).
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Minimalist frequency meter
« Reply #37 on: July 02, 2014, 09:32:07 pm »
This particular chip, as well as many other PIC, allows the factory calibration value to be fine-tuned, through OSCTUNE.

I did a series of experiment and here is what I got, again, measuring the same 19.44Mhz oscillator output:

OSCTUNE - Frequency Reading (Mhz)
-3          - 19.53
-2          - 19.52
-1          - 19.50
0          - 19.47
1          - 19.44
2          - 19.43
3          - 19.41

So the default oscillator runs a little bit too slow (-> higher readings). So by trimming the oscillator a little bit faster, we can get more accurate readings.

OSCTUNE = 1 looks to be the right number.

I will revise the firmware so that the osctune value is read off eeprom. This allows the user to calibrate the value to his own oscillator / chip.

Here is a picture of the meter running with OSCTUNE = 1.

The green arrow points to a led that blinks at 1pps -> it indicates gate time / operation of the meter, but more importantly, allows the meter to be trained, in the future, by a high quality reference source, like a gps: with minimal modification, we can make this meter, plus the vctcxo and a gps with 1pps output, into a gps-disciplined oscillator, thus beating the 2.5ppm spec of the tco-919 oscillator we are using.

More on that later.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Minimalist frequency meter
« Reply #38 on: July 02, 2014, 09:57:01 pm »
Here is the simplified schematic.

The led (7 segment 4-digit) sits right on top of the chip. No current limiting resistors.

The code can drive both common anode or common cathode displays: you can leave PB0 either float (for common cathode) or tie it to ground (for common anode).

================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Minimalist frequency meter
« Reply #39 on: July 02, 2014, 09:58:24 pm »
Here is the firm ware, compiled by XC8 1.12.

Save it as a .hex file and burn it to the chip.

Code: [Select]
:0400000080314D28D6
:1000080080312000111C0C281110B70A0319B80AF6
:10001800911C47289110BB0A0319BC0A3C08033AF3
:10002800E83003193B06031D472818101708F60087
:100038001608F70096019701181411103808B40033
:100048003708B3003608B2003508B1007708F20067
:100058007608F300F401F5017208B1047308B204DC
:100068007408B3047508B4040330B135B20DB30D88
:10007800B40D890B3928B501B601B701B801803034
:10008800BB01BC018E060B1D09000B118331D12366
:10009800090080314F28FF30F801F901FA01FB010E
:1000A800FC01FD01B101B201B301B401B501B60112
:1000B800B701B801B901BA01BB01BC01BD002000FC
:1000C80065289422803100304A2280313F3A00303E
:1000D800031D7228A6015322803100304A22803144
:1000E8003F3921009800951324000D140A30200090
:1000F800A300A4014923803121008E130E13ED22A1
:100108008031003020000D1C0130FC000530A001BA
:10011800CE228031C830A00041307E2280310330A9
:10012800A001A1015A2280318B1762292730A3012F
:10013800A201A1001030A00088302D07A4001330C0
:10014800C5228031D5218031A12280311422200896
:10015800C13E84310A008031FB00B7228031D521AD
:100168008031A122803114222008C13E84310A0046
:100178008031FA00B7228031D5218031A122803127
:1001880014222008C13E84310A0080318038F900E9
:10019800B7228031D5218031A12280311422200854
:1001A800C13E84310A00803155290330A301A201E0
:1001B800A100E830A000F4302D07A4000130C522CA
:1001C8008031D5218031A122803114222008C13EFE
:1001D80084310A008031FB00B7228031D52180317B
:1001E800A122803114222008C13E84310A008031C6
:1001F800FA00B7228031D5218031A1228031142222
:100208002008C13E84310A008131F900B7228031CB
:10021800D5218031A122803114222008C13E8431A9
:100228000A008131803855296430A0003230A1019C
:10023800A201A3012D07A4000030C5228031D521D9
:100248008031A122803114222008C13E84310A0065
:100258008131FB00B7228031D5218031A122803144
:1002680014222008C13E84310A0081318038FA0006
:10027800B7228031D5218031A12280311422200873
:10028800C13E84310A008131F900B7228031D5217D
:100298008031A122803114222008C13E84310A0015
:1002A8008131F800B7228031D52180312308B00090
:1002B8002208AF002108AE002008AD003408B000C5
:1002C8003308AF003208AE003108AD00003030020C
:1002D800031D782998302F02031D782996302E02A5
:1002E800031D782980302D0203189A280030300227
:1002F800031D88290F302F02031D882942302E0242
:10030800031D882940302D020318D92800303002F7
:10031800031D982900302F02031D982927302E022B
:10032800031D982910302D02031818290A30A0003F
:10033800A101A201A3013008A7002F08A6002E08DA
:10034800A5002D08A40014222008C13E84310A000B
:100358008131FB00B7228031D5218031A122803143
:1003680014222008C13E84310A008131FA00B722E4
:100378008031D5218031A122803114222008C13E4C
:1003880084310A008131F900B7228031D5218031CA
:10039800A122803114222008C13E84310A00813113
:1003A8005529A801A901AA01AB01230822042104A7
:1003B800200403190B2AAC01AC0AA31BE829A035B9
:1003C800A10DA20DA30DE029A835A90DAA0DAB0D0D
:1003D80023082702031DFA2922082602031DFA29E9
:1003E80021082502031DFA2920082402031C052AD6
:1003F8002008A4022108A53B2208A63B2308A73B06
:100408002814A336A20CA10CA00CAC0BE8292B08CD
:10041800A3002A08A2002908A1002808A0000800B3
:1004280023082204210420040319412AA801A80A48
:10043800A31B232AA035A10DA20DA30D1B2A230857
:100448002702031D312A22082602031D312A21080A
:100458002502031D312A20082402031C3B2A2008F8
:10046800A4022108A53B2208A63B2308A73BA336E4
:10047800A20CA10CA00CA80B232A2708A30026086D
:10048800A2002508A1002408A00008002000A4005C
:10049800A0002530A101A10AAD2325080800A70066
:1004A8002630A000A101A10A2708722BA400181069
:1004B8009811981718130339A200220EF039A200D8
:1004C8001808CF39220498001815111021001114AA
:1004D8000B1720002009A2002109A300A20A031972
:1004E800A30A2208B9002308BA0097003908960021
:1004F80018140800A3001C119A01A1007830A13635
:100508002105A2002308033922049C009110210030
:1005180091140B1720002008FF3E9B001C150800B3
:100528002100191799161916991523008C018D01A8
:100538002200910193019D0108002308B0002208C0
:10054800AF002108AE002008AD000A30A000A101CC
:10055800A201A3013008A7002F08A6002E08A500B5
:100568002D08A40008000A30A000A101A201A301DF
:100578003008A7002F08A6002E08A5002D08A40003
:1005880008002E3DA50000302F3DA6000030303D6C
:10059800A7000800A2002100951220002208FF3AB7
:1005A800031DD92A21009515E62A21009511073047
:1005B80020002205A10021001508F8392000210497
:1005C8002100950020002003FF3ABD0095008B16FE
:1005D80008007C08003A0030031901302000A00010
:1005E800A00EA00DA00D0D082006BF3940238031B4
:1005F800A00DA00DA00D0D082006F739402380316D
:10060800A00DA00D0D082006FB3940238031A00E57
:10061800A00D0C082006DF3920068C007C08031D7D
:100628008D1603198D127C08031D8D1403198D1066
:100638007C08031D8C1503198C117C08031D8C1470
:1006480003198C107C08031D0C1403190C107C086A
:10065800031D0D1603190D127C08031D0C16031932
:100668000C127C08031D0C1503190C11C030210055
:100678008C0581308D05080020068D007C08003A25
:10068800003003190130A00008000130A302003037
:10069800A43B230A0319240A03190800E430A10023
:1006A800A20158238031492B21086B23803122086D
:1006B800A100A2010130A1020030A23B210A0319C6
:1006C800220A03190800FF306B2380315E2BA0003B
:1006D800A0032008FF3A031908006C2BA400200887
:1006E800A50023009518752B20002408FF3EA200C2
:1006F800FF3003180030A3002208230091002000D7
:1007080023082300920095132000A1032108FF3A33
:1007180003190800230095188E2B20002508860051
:1007280087010108230093002000A50A2300910AED
:100738000319920A03108B1B03148B1315155530DC
:100748009600AA30960095141511031C882B8B1758
:10075800882BA2002208A30023009518B02B2000A4
:1007680020082300910092012000A1032108FF3AEC
:100778000319080023009518BE2B951315142000A3
:100788002308860087012300130881002000A30A9C
:100798002300910A0319920AB82B7C08BA248331E2
:1007A800F00EF00DF00D0D087006BF3970068D00C3
:1007B8007C08BA248331F00DF00DF00D0D08700699
:1007C800F73970068D007C08BA248331F00DF00DDE
:1007D8000D087006FB3970068D007C08BA24833139
:1007E800F00EF00D0C087006DF3970068C007D08DD
:1007F800783E860087010108F100711C0E2C7C08E8
:10080800BA248331F00EF00D0D087006DF3970063A
:100818008D00132C7C08031D8D1603198D12F11CF5
:100828001F2C7C08BA248331F00D0D087006FD39A1
:1008380070068D00242C7C08031D8D1403198D105F
:10084800711D322C7C08BA248331F00DF00DF00DA7
:100858000C087006F73970068C00372C7C08031DCD
:100868008C1503198C11F11D432C7C08BA24833193
:10087800F00D0C087006FD3970068C00482C7C08B9
:10088800031D8C1403198C10711E522C7C08BA2479
:1008980083310C06FE3970068C00572C7C08031D2A
:1008A8000C1403190C10F11E632C7C08BA24833134
:1008B800F00E0D087006EF3970068D00682C7C0864
:1008C800031D0D1603190D12711F742C7C08BA2410
:1008D8008331F00E0C087006EF3970068C00792C05
:1008E8007C08031D0C1603190C12F11F862C7C08BA
:1008F800BA248331F00DF00D0C087006FB39700630
:100908008C00AB2C7C08031D0C1503190C11AB2CA7
:100918007C08031D0D1703190D13FD01FD0A0800BE
:100928007C08031D8D1503198D110230FD00080088
:100938007C08031D0D1503190D110330FD00080077
:100948007C08031D8C1603198C12FD0108007D0814
:10095800003A03198C2C013A0319942C033A031911
:100968009C2C013A0319A42C8C2C0800003A003066
:1009780003190130F000080000343F3406345B34BA
:100988004F3466346D347D3407347F346F345F34CC
:0C0998007C3458345E34793471340034FF
:020000040001F9
:04000E0084C9FFDCC6
:02E0000000001E
:00000001FF
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Minimalist frequency meter
« Reply #40 on: July 02, 2014, 10:05:38 pm »
Burning the hex code:

when you burn the code, you can burn the desired value of OSCTUNE (in 2's compliment) into 0x00 of the eeprom - see the picture below for an example of burning OSCTUNE = 0x01.

In this case, my intosc is too slow so I have to tune it faster -> a positive value.

If your intosc is too fast, you have to tune it down  a little bit -> use a negative value (in 2's compliment, so -1 = 0b111111 = 0x3f, -2 = 0b111110 = 0x3e, ...).

Calibration:

On a virgin chip (eeprom 0x00 has a value of 0xff), the firmware will zero it (so eeprom 0x00 has a value of 0x00), and the default factory calibration is used (1% accuracy per Microchip but typically better than that, as we saw earlier).

If you have a high stability oscillator, you can use the meter to measure the frequency.

Based on the frequency reading from the meter, you can reburn the same firmware, with different values in eeprom 0x00 to get the ferquency reading as close to the known frequency of the reference oscillator as possible.

Then you are done.

================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Minimalist frequency meter
« Reply #41 on: July 04, 2014, 11:39:45 am »
One small improvement.

When running on a high stability clock (like the TCO-919R3 I am experimenting with now), it would be helpful to display more than 4 digits. In fact, 8 digits would be nice.

So here is one version of the minimalist meter running on the TCO-919R3 (19.44Mhz) measuring its own clock. In this case, the meter is alternating showing its highest 4 digits and then lowest 4 digits on a 4-digit led display. To signify the lowest 4 digits, the last digit has its dot segment turned on.

Here the reading should be exactly 1944,0000. Instead, we got 1943,9997. The difference of 3Hz is due to our inability to truly synchronize the time base and the pulse counter.
================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Minimalist frequency meter
« Reply #42 on: July 04, 2014, 01:58:28 pm »
A couple more examples.

1) a 16.128Mhz +/- 100ppm oscillator (EC1100 by Ecliptek).

16,128,000Hz spec vs. 16,127,893Hz actual.

100ppm spec vs. 6.6ppm actual.


================================
https://dannyelectronics.wordpress.com/
 

Offline dannyfTopic starter

  • Super Contributor
  • ***
  • Posts: 8221
  • Country: 00
Re: Minimalist frequency meter
« Reply #43 on: July 04, 2014, 02:01:17 pm »
Example 3: a 8Mhz Epson crystal

8,000,000Hz spec vs. 7,999,792Hz.

20ppm (likely spec) vs. 26ppm.

Maybe the load capacitance was too high.
================================
https://dannyelectronics.wordpress.com/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

- - -
-->