' Truetime DC 468 simulator of GOES time signal 'Started to create on 11/20/2010 'Use an external exclusive OR gate to sum clock and data. This allows seperate data and clock injection into teh DC468 for testing 'Then use the exOr as manchester encoded data once working. 'Use RA0 at clock and RA1 as data. Data clocked into dc468 on falling 100hz edge. 'The first step is to sync to the mls sync code 2,2,b,e the first 2 actually does not have the lsd so this fits in a binary word '1122 version has correction to 00 and 30 time as 00 and 30. Also lat and long fix '1123 version actually uses a clock for um and tm or a 60 minute endless clock. MLS works but the 100hz 'does not stay locked and sats do not decode 'injecting TC straight into manchester decoder retunes coarse osc no luck still does not lock 'Program message fully decoded at 2240 11/25/2010 'Issue, Clock must be 100.000 hz currently as set a 1 Hz diff and precision pll is drifing. 'pll is 100.001 and clock is 100.002/3 Note clock seq tinkered with to get better alignment. 'This is long enough to decode a message, but will loose lock. '11/26/2010 Add in hrs and days to the system. '11/28 does indeed work but stopped building the clock at decades per hour. Whole clock routine needs a look 'Convert to external 100 hz reference on version 11/28a 'using an external clock the pll does indeed lock '11/30 straightened out operation all locked up on pin ra0. Also fixed latitude to 0 instead of 73 '11/30a has hours and minutes working '12/01 try homebrew software manchester encoder '12/01/2010 This program uses new software traditional manchester encoder 1 = + - and 0 = - +. 'It outputs days and hours but is fixed to prove that the bits and nibbles 'are normal and that it was indeed a traditional manchester encoder 'This now leaves real clock generation to be built '12012010a build a real clock section '12022010 attempt to embed the clock calculation in a bit transmit using clockbit =1 to calculate '12032010b does indeed work now. Needed to establish variable after program start for all of the times. '12032010c move clock calc back to primary loop Clock calc takes 2 us to complete. 'create full clock including 100s of days '12052010 attempt to ingest GPS signal using gprmc seq at 4800 baud '1206 attempt to capture data '1206201 does indeed work to ingest time from GPS and establish clock. No updates yet during some period 'No clendar either. XXXX can not make leading digit hex 9 = 1, so just day of month for calendar '12082010 This is clean day of month program does not sent time message on RB.1 '12082010 attempt time sync every 10 min 'Called subroutine must be below calling sub routine or it won't compile at all '12092010 fix ingest code mask with 0000_1111 remove upper nible '12092010 works set to update on uh = 2 or 02, 12, 22 should see string at 59 sec plus '12102010 retry internal clock generator Does not work again must use 2 chips 'In service 12102010 works using sxb 100 hz divider and sxb encoder DEVICE SX28, OSCHS3, TURBO, STACKX, OPTIONX FREQ 20_000_000 clockdata sub mlsseq sub realdata sub restofdata sub setclock sub MLSa con %0010_001 MLSb con %1110_1011 Interogatea con %1010_1010 'X3 times Interogateb con %1010_101 idx var byte 'used for sending bits to goesdata idxa var byte 'used for 3 X interogate idxb var byte 'used for sync nible count idxc var byte databit var byte MLS var byte syncbit var byte sdata var byte gprmc var byte us var byte 'can dump ts var byte 'can dump maybe need oo and 30 sec tsa var byte um var byte tm var byte uh var byte th var byte ud var byte td var byte hd var byte dataclock pin RA.0 input 'now used for accurate external 100 hz in goesdata pin RA.1 output triggerdata pin RA.2 output PROGRAM Start Start: gosub setclock 'goto startb '________________________________________ Send to clock ____________________________ starta: for idxc = 1 to 10 syncbit = %1010 'send syncbits at 00 seconds gosub realdata next ' time start 360_00:14:xx syncbit = 0 ' TS 00 time sent gosub realdata syncbit = um ' UM gosub realdata syncbit = tm ' TM gosub realdata syncbit = uh ' UH gosub realdata syncbit = th ' TH gosub realdata syncbit = ud ' UD gosub realdata syncbit = td ' TD gosub realdata syncbit = hd ' HD gosub realdata gosub restofdata for idxc = 1 to 10 syncbit = %0101 'send syncbits at 30 seconds gosub realdata next syncbit = 3 ' TS 30 time sent gosub realdata syncbit = um ' UM gosub realdata syncbit = tm ' TM gosub realdata syncbit = uh ' UH gosub realdata syncbit = th ' TH gosub realdata syncbit = ud ' UD gosub realdata syncbit = td ' TD gosub realdata syncbit = hd ' HD gosub realdata gosub restofdata 'startb: '_____________________ Clock calculation __________________________ inc um if um = 10 then um = 0 inc tm if tm = 6 then tm = 0 inc uh if uh = 10 then 'hrs per day uh = 0 inc th if th = 2 then if uh = 4 then th = 0 uh = 0 inc ud endif if ud = 10 then 'days of year ud = 0 inc td if td = 10 then td = 0 inc hd If hd = 3 then if td = 6 then if ud = 6 then hd = 0 td = 0 ud = 0 endif endif endif endif endif endif endif endif endif ' insert clock update here reason it keeps display up to date if uh = 2 then if tm = 0 then ' time sync x2:01:xx 02, 12, 22 utc if um = 1 then gosub setclock endif endif endif goto starta 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Sub Routines XXXXXXXXXXXXXXXXXXXXXXXX 'send remaning data after time always the same restofdata: syncbit = 0 ' sign ut correction gosub realdata syncbit = %0001 ' TS units ut correction set to 0 gosub realdata syncbit = 0 ' HD Sat longitude gosub realdata syncbit = %0111 ' TD 7 gosub realdata syncbit = %0011 ' UD 3 degrees gosub realdata syncbit = %0000 ' td gosub realdata syncbit = %0000 ' hd gosub realdata syncbit = %0000 ' sign gosub realdata syncbit = %0000 ' UD Sat latitude its at equator so 0 gosub realdata syncbit = %0000 ' td gosub realdata syncbit = %0000 ' hd gosub realdata syncbit = %0000 ' sign gosub realdata syncbit = 2 ' Hus sat radious in usec gosub realdata syncbit = 6 ' Tus gosub realdata syncbit = 6 ' Uus gosub realdata ' Fill to rest of 30 second slice with 0's for idxc = 1 to 27 syncbit = %0000 'fill to end of seq with zero nibles lands at 30 sec tic gosub realdata next return 'real data sequence 1 nibble and then mls + interogation seq realdata: for idxb = 1 to 4 'send nibble databit = syncbit & %1 Gosub clockdata syncbit = syncbit >> 1 next 'sends mls sequence mlsseq: MLS = MLSa 'send mlsa for idx = 1 to 7 databit = MLS & %1 Gosub clockdata MLS = MLS >> 1 next MLS = MLSb 'send mlsb for idx = 1 to 8 databit = MLS & %1 Gosub clockdata MLS = MLS >> 1 next 'send fake interogate platform 3 X for idxa = 1 to 3 MLS = interogatea 'send interogate a for idx = 1 to 8 databit = MLS & %1 Gosub clockdata MLS = MLS >> 1 next next MLS = interogateb 'send interogate b 31 total bits 1010_1010 0000_001 for idx = 1 to 7 databit = MLS & %1 Gosub clockdata MLS = MLS >> 1 next return 'Sends a bit out the port as manchester encoded clockdata: triggerdata = databit 'uses trigger data to show real bit non encoded 'Original version of manchester code if databit = 1 then goesdata = 1 ' send 1 + - do loop until dataclock = 0 goesdata = 0 do loop until dataclock = 1 else goesdata = 0 ' send 0 - + do loop until dataclock = 0 goesdata = 1 do loop until dataclock = 1 endif return '_______________________ Setclock ______________________________ setclock: startc: gosub getcharacter 'wait for $GPRMC sentance if sdata <> "G" then goto startc gosub getcharacter if sdata <> "P" then goto startc gosub getcharacter if sdata <> "R" then goto startc gosub getcharacter if sdata <> "M" then goto startc gosub getcharacter if sdata <> "C" then goto startc gosub getcharacter 'get , and through away gosub getcharacter th = sdata th = th and %0000_1111 gosub getcharacter uh = sdata uh = uh and %0000_1111 gosub getcharacter tm = sdata tm = tm and %0000_1111 gosub getcharacter um = sdata um = um and %0000_1111 um = um +1 'bugger value to align minutes really a dirty cheat 'issue is that if using 59 secs the minutes are the 'previous min and not updated causing a 1 min 'time loss. So by adding a 1 it works. 'Not sure what happens on a 00 time as an example "Don't" gosub getcharacter ts = sdata ts = ts and %0000_1111 gosub getcharacter us = sdata us = us and %0000_1111 'time captured to the second 'Is this 59 second?offset by -1 sec to sync to realtime tsa = ts * 10 tsa = tsa + us if tsa < 59 goto startc idxc = 0 'wait for 8 "," to get calendar do getcalendar: gosub getcharacter if sdata = "," then idxc = idxc + 1 else goto getcalendar endif loop until idxc = 8 gosub getcharacter td = sdata td = td and %0000_1111 gosub getcharacter ud = sdata ud = ud and %0000_1111 hd = 0 'just do days of month and try 9 'send out the characters 'gprmc = $aa 'sync character 'gosub sendcharacter 'gprmc = hd 'gosub sendcharacter 'gprmc = td 'gosub sendcharacter 'gprmc = ud 'gosub sendcharacter 'gprmc = " " 'gosub sendcharacter 'gprmc = th 'gosub sendcharacter 'gprmc = uh 'gosub sendcharacter 'gprmc = tm 'gosub sendcharacter 'gprmc = um 'gosub sendcharacter 'gprmc = ts 'gosub sendcharacter 'gprmc = us 'gosub sendcharacter 'gprmc = " " 'gosub sendcharacter return getcharacter: serin rb.0, n4800, sdata return 'sendcharacter: 'serout rb.1, n4800, gprmc 'return