![]() Just add in the 1:2 prescaler and voila! Interrupt every 4 seconds!) Display: To achieve the magic ratio of 1 NET Min per 4 seconds, we can use the 16-bit TMR1 register with a 1:2 prescaler. (The 16-bit TMR1 overflows at 65536 counts, crystal runs at 32768 counts per second. To count NET, the code uses the PIC's built-in Timer1 (TMR1) module with an external 32.768kHz crystal for timekeeping. This is calculated with the ratios 360 NET Deg per 24Hrs and 60 NET Minutes per NET Degree. ![]() The magic ratio to convert regular time to new earth time is 0.25 NET Minutes per 1 second (or 1 NET Minute for every 4 seconds of elapsed time). The code is fairly well documented, but here is quick explanation of what's going on. Here is the source code for the clock in both Assembly (.asm) and Hex (.hex), compiled for the PIC16F627A. If you have a 5V source already, this isn't needed. ![]() I have included a small 5V regulator circuit in the lower corner. You want to make sure you get a high-accuracy crystal, but even then you may need to adjust the value of C1 and C2 to keep time accurately. The 32.768kHz crystal is the main timekeeping device for the clock. One button sets NET Degrees, the other sets NET Minutes. In addition to the displays, there are two buttons multiplexed into the display outputs for the clock setting functions. The displays are driven by 2N3904 transistors, since the PIC I/O ports can't sink enough current for 7 LEDs. You can look up this scheme on the internet, but the basic idea is that only one display is on at any given time but our eye perceives all displays to be on simultaneously due to persistence of vision. Just like any digital clock, the microcontroller uses time-division multiplexing to control five 7-segment displays from only 12 I/O pins. The schematic diagram (see picture) and electronic assembly are fairly straightforward since most of the "magic" happens in the microcontroller code.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |