' {$STAMP BS2SX} ' {$PBASIC 2.5} ' ' -----[ Program Description ]--------------------------------------------- ' File...... Nixie_Clock.BS2 ' Purpose... Displays accurate time using Nixie Tubes ' Author.... Jonathan Peakall. Nixie display routine by Jon Williams ' This program gets the time from an atomic clock signal re-broadcast ' locally with a 433mHz transmitter. It then displays the time using Nixie tubes. ' The tubes are driven using 3*74HC595s to 6*14171s. ' -----[ Revision History ]------------------------------------------------ ' -----[ I/O Definitions ]------------------------------------------------- DataOut CON 9 ' 74HC595.14 Clock CON 10 ' 74HC595.11 Latch CON 11 ' 74HC595.12 ' -----[ Constants ]------------------------------------------------------- blank CON 12 ' -----[ Variables ]------------------------------------------------------- mSec VAR Byte seconds VAR Byte ' clock variables minutes VAR Byte hours VAR Byte nixSecs VAR Byte' display seconds nixScLo VAR nixSecs.LOWNIB nixScHi VAR nixSecs.HIGHNIB nixMins VAR Byte' display minutes nixMnLo VAR nixMins.LOWNIB nixMnHi VAR nixMins.HIGHNIB nixHours VAR Byte' display hours nixHrLo VAR nixHours.LOWNIB nixHrHi VAR nixHours.HIGHNIB rawYear VAR Byte 'years value received from WWVB decoder rawDay VAR Word 'days value alt VAR Byte 'leap year,century,DST,days modifier bits junk VAR Byte ' Junk byte for serial communication ' -----[ EEPROM Data ]----------------------------------------------------- ' ' This maps the required output for each digit using the 74141s ' ' ABCD DigitMap DATA %0100, %0101, %0001, %0000, %0111 ' Valid 74141 DATA %0011, %0010, %1000, %1001, %0110 ' codes. DATA %1100 ' Invalid code for blanking ' -----[ Initialization ]-------------------------------------------------- Setup: LOW Latch ' -----[ Program Code ]---------------------------------------------------- Main: GOSUB Update_Clock ' update clock GOSUB Map_Digits ' time -> Nixie maps GOSUB Update_Nixies ' show time on Nixies GOTO Main ' -----[ Subroutines ]----------------------------------------------------- ' This routine reads the digit maps stored in EEPROM to the correct ' positions within the display bytes. Map_Digits: READ DigitMap + (seconds // 16), nixScLo ' read digit maps READ DigitMap + (seconds / 16), nixScHi READ DigitMap + (minutes // 16), nixMnLo READ DigitMap + (minutes / 16), nixMnHi READ DigitMap + (hours // 10), nixHrLo READ DigitMap + (hours / 10), nixHrHi RETURN ' This routine shifts the data out to the '595s Update_Nixies: SHIFTOUT DataOut, Clock, MSBFIRST, [nixHours] ' shift bit maps out SHIFTOUT DataOut, Clock, MSBFIRST, [nixMins] SHIFTOUT DataOut, Clock, MSBFIRST, [nixSecs] PULSOUT Latch, 5 ' latch outputs RETURN ' Fetches time and date from the receiver Update_Clock: SERIN 12,17405,10,No_Data,[WAIT("B"),junk,HEX2 hours, HEX2 minutes, HEX2 seconds, HEX2 mSec, HEX4 rawyear, HEX3 rawDay, BIN8 alt] ' Get time hours = hours.HIGHNIB * 10 + hours.LOWNIB ' Convert the hours to dec format from hex hours = (hours+(24-8))//12 ' Local GMT time correction and display in 12 hour format hours = hours +1 'Daylight Savings time correction IF hours = 0 THEN hours = 12 'Displays 12 instead of 00 DEBUG "ALT: ", BIN alt,CR RETURN No_Data: GOTO Update_Clock END