\ File globalchimes.f -- Sounding chimes via parallel port I/O interface to GPS -- 19-July-05
\ C:\ForthInc\SwiftForth\GlobalChimes (C) globalchimes at yahoo dot ca
\ ******************************* Please read all comments first ************************************** \
\ Note: Make sure only ONE PS2 MOUSE is enabled in the Windows Device Manager and disable any SERIAL mice or the GPS will
\ make the pointer jump around -- especially on laptops -- plug in the serial port AFTER the PC boots up
\ Note: WIN XP requires SwiftForth PRIORITY to be MINIMUM to stop chime stuttering -- in WIN 98 it is MAXIMUM
\ *** Changes 01-16-05 added microsecond period and microsecond delay displays
\ *** Changes 01-20-05 added initial UTC delay message
\ *** Changes 01-21-05 corrected calculations for headphones delay to 105100 microseconds ( 5.6' to ear level/1.087467'/ms)
\ *** Changes 01-22-05 added print_radio_delay and print_sound_delay words in calc_delay.f
\ *** Changes 01-23-05 added stubs for future radio controlled clock experiments, changed headphones to 105149 microseconds
\ *** Changes 01-28-05 reduced chimefour.wav amplitude to 80 % as chimefour_80.wav and 50% as chimefour_50.wav
\ *** Changes 01-29-05 changed delay call after chimefour starts from MS counter to US counter to lock out other tasks
\ *** Changes 01-30-05 allowed other tasks to run for 300 ms after GPS routine ends
\ *** Changes 01-30-05 moved delay time calculation to include time to call SOUNDCHIME which varies between Windows versions
\ *** Changes 01-30-05 added variable windows_delay to tweak utc_tickdelay to compensate for Windows Sytem lag
\ *** Changes 01-31-05 added variable tweak and a circular buffer to nudge actual delay towards desired delay
\ *** Changes 02-02-05 clipped tweak variable at +-200000
\ *** Changes 02-03-05 made chimefour_50_inverted.wav for some systems that flip the audio phase
\ *** Changes 02-04-05 factored out period and delay displays to enable use without a serial cable
\ *** Changes 02-15-05 added notes about using START, RUN, MSCONFIG to disable startup processes
\ *** Changes 02-19-05 added period_tweak to nudge PerformanceFrequency once so the PERIOD is exactly 1000000 microseconds
\ *** Changes 07-08-05 changed sound file from chimefour_50.wav to OM4_5690.wav based on harmonics of 136.1 Hz - Earth Year
\ *** Changes 07-18-05 added create_chime and active_sound to mmplay_delay.f
\ *** Changes 07-19-05 added file NewChime.f editable by user to hold the name of the latest chime wave file
\ Globalchimes.f is this file
\ SwiftForth 2.2.2.9 is freeware from www.forth.com
\ Winio.dll is free from internals.com
\ BW CPU controller is free nagware from BinaryWork Corp. at members.tripod.com/~Maquisistem/bwcpucontrol.htm (bwcp161.exe)
\ Snsrcfg.exe is free from Garmin at garmin.com at http://www.garmin.com/support/download_details.jsp?id=529
\ Conductor.exe is free from Axiom at axiomnav.com
\ Download all the above files from: Globalchimes download area
\ Note: Multiple GPS units were used for testing -- only ONE GPS is required to trigger the chimes
\ Pins 18-25 of the parallel port are GROUND -- numbered from right to left looking into the DB25 female socket on PC
\ Pin 15 of the parallel port is DATA IN -- bit 3 of status port at 379 hex -- connect to 1 PPS output of GPS A
\ Pin 11 of the parallel port is DATA IN -- bit 7 of status port at 379 hex -- connect to 1 PPS output of GPS B
\ Pin 13 of the parallel port is DATA IN -- bit 4 of status port at 379 hex -- connect to 1 PPS output of GPS C - default
\ The GPS output is a 100 ms TTL positive pulse every 1000 ms with a jitter of 70 ns
\ Pin 2 of the parallel port is YELLOW LED -- bit 0 of data port at 378 hex -- "1PPS echo"
\ Pin 3 of the parallel port is GREEN LED -- bit 1 of data port at 378 hex -- "fix is good"
\ Pin 4 of the parallel port is RED LED -- bit 2 of data port at 378 hex -- "fix is bad"
\ Connect a 330 ohm resistor to each pin (2,3,4) then to the ANODE of each LED -- connect LED cathodes together to pin 22 GND
\ This serves as a remote health indicator and can be run through a 4-conductor telephone type quad cable
\ See file Readme.txt for GPS18LVC SETUP instructions and file Schematic.jpg for the WIRING diagram.
\ GPS18LVC pinout: Red (26AWG thick) Positive POWER +5VDC, Black (26AWG thick) Negative POWER Ground
\ Black (28AWG) Signal Ground, White (28AWG) Transmit Data, Green (28AWG) Receive Data, Yellow (28AWG) 1PPS tick
\ Note that there will be TWO wires connecting to the black Signal Ground
\ Connect Signal Ground (black) to parallel port pin 23 and 1PPS (yellow) to pin 13 using a MALE DB25 connector --
\ Remember that the male pins are numbered normally -- from left to right
\ Connect Signal Ground to serial port pin 5, Transmit Data (white) to pin 2 and Receive Data (green) to pin 3 using a
\ FEMALE DB9 connector -- remember that the female sockets are numbered in reverse -- from right to left
\ GPS18LVC is available from GPS18LVC
\ Create a NEW folder on the C: drive called C:\ForthInc and move to it
\ Create a NEW folder in C:\ForthInc called SwiftForth and move to it
\ Create a NEW folder in C:\ForthInc\SwiftForth called GlobalChimes
\ Place all downloaded files into C:\ForthInc\SwiftForth\GlobalChimes
\ Create a NEW folder in C:\ForthInc\SwiftForth\GlobalChimes called BWCPU
\ Create a NEW folder in C:\ForthInc\SwiftForth\GlobalChimes called Conductor
\ Run SwiftForth-Eval-Current.exe to install SwiftFORTH into folder C:\ForthInc\ with password 28vvqg9ugodn
\ This makes SwiftForth available from the START menu
\ Left click on START and cursor to PROGRAMS, SWIFTFORTH, SWIFTFORTH then right click on SWIFTFORTH and
\ Configure SwiftFORTH's "Start in" folder to C:\ForthInc\SwiftForth\GlobalChimes using the left mouse button to select
\ PROPERTIES then SHORTCUT and replacing USER with SwiftForth\GlobalChimes
\ Double click the downloaded snsrcfg.exe to configure Garmin 18LVC, click COMM to set COM1 4800, click COMM CONNECT to GPS
\ Click CONFIG SENSOR CONFIGURATION Checkmark Pulse Per Second and PPS Length 100 then OK
\ Click CONFIG NMEA Sentence Selection and Checkmark GPGGA, GPGSA, GPGSV and GPRMC leaving others blank, or uncheck then OK
\ Click CONFIG Send Configuration to GPS then click FILE Save As SNSRCFG.cfg SAVE OK and YES to overwrite old file
\ Click COMM Disconnect and cycle the power to the GPS -- turn it OFF and then back ON again -- see snsrcfg.jpg for a screenshot
\ Copy bwcp161s.zip to the NEW folder BWCPU and move to it
\ Double click bwcp161s.zip to extract all files to C:\ForthInc\SwiftForth\GlobalChimes\BWCPU -- type this in manually
\ Run SETUP.EXE to install BW CPU CONTROLLER into its default folder and to add it to the START menu -- move up one level
\ Copy Conductor.zip to the NEW folder Conductor and move to it
\ Double click Conductor.zip to extract all files to C:\ForthInc\SwiftForth\GlobalChimes\Conductor -- type this in manually
\ Run SETUP.EXE to install Conductor into its default folder and to add it to the START menu -- move up one level
\ Double click winio.zip to extract all files to C:\ForthInc\SwiftForth\GlobalChimes -- type this in manually
\ Winio creates its own subfolder called WINIO -- move to it, then move to RELEASE
\ Copy Winio.dll, winio.vxd, winio.sys from RELEASE to C:\ForthInc\SwiftForth\GlobalChimes
\ Power up the Garmin GPS and position it outside making sure the GPS has a clear view of the sky -- even 12 inches
\ out of a window is fine.
\ Connect the COM1 serial and parallel cables.
\ Connect a speaker to the PC audio card output.
\ Run Conductor from the START menu.
\ Click FILE, MESSAGE SET, NMEA MESSAGE SET to start communicating with the GPS.
\ Wait to get an initial 3D fix and exit -- see file Conductor.jpg for a typical display.
\ Close all unnecessary programs on the task bar by right clicking them and selecting EXIT.
\ If you later find that the delay times displayed by the running chimes jump by more than +/- 1000 microseconds,
\ In WIN 98 use: START, RUN, type in: MSCONFIG then click OK.
\ Go to the GENERAL tab and check the SELECTIVE STARTUP box, and leave the LOAD STARTUP GROUP ITEMS box checked for now.
\ Go to the STARTUP tab and uncheck ALL processes there, RECORD which boxes were already unchecked in the first place.
\ Click OK and RESTART the computer to temporarily dedicate the entire system to the chimes.
\ To restore the previous configuration recheck all processes and boxes that you unchecked earlier and restart again
\ In WIN XP: Use START, RUN, type in: MSCONFIG then click OK.
\ Go to the GENERAL tab and check SELECTIVE STARTUP and uncheck LOAD SYSTEM SERVICES and LOAD STARTUP ITEMS.
\ Go to the SERVICES tab and MANUALLY CHECK again WINDOWS AUDIO, PLUG & PLAY, RPC LOCATOR and RPC
\ Click APPLY and RESTART the computer to temporarily dedicate the entire system to the chimes -- cancel warning messages.
\ To restore the previous configuration recheck all processes that you unchecked earlier and restart again
\ Run SwiftFORTH from the START menu
\ Run BW CPU controller 1.6.1 from the START menu and set SF.EXE priority to 24 and close unnecessary processes
\ Wait for the timeout and click EXIT.
\ Scroll to the process second from the top and click it once -- it should be SF.EXE.
\ Now click MAXIMUM and minimize the BWCPU window -- the whole PC will seem to slow down and respond only once per second
\ -- this is OK.
\ See file BWCPU.jpg for a screenshot in WIN 98 -- Note: WIN XP requires SwiftForth PRIORITY to be MINIMUM or 4
\ Now, from the SwiftForth menu click FILE, INCLUDE globalchimes.f to run globalchimes automatically - press any key to stop
\ See the files Include.jpg and Startup.jpg for a screenshot
\ When the 1PPS signal is present, the program will display V for a bad fix and A for a good fix and a running count.
\ After an introductory screen, FORTH should display:
\ Waiting for 1PPS signal and fix information ... press any key to stop.
\ Fix is good -- A 1
\ Fix is good -- A 2...
\ The chimes should sound at this time, otherwise check the PC volume/muting setting and confirm that the speaker is plugged into the correct jack.
\ If you edit globalchimes.f using Notepad, exit SwiftFORTH, restart, INCLUDE globalchimes.f again and type in GLOBALCHIMES
\ Press any key to stop the chimes and to enter command mode to reconfigure time delays, COM ports or to exit.
\ Summary of available commands:
\ Type in 100000 SET_DELAY and press RETURN or ENTER key to set delay to 100 milliseconds.
\ Type in FAR_SPEAKERS or NEAR_SPEAKERS or HEADPHONES or NO_DELAY and press RETURN or ENTER key to set default delay.
\ Type in 17.58 SPEAKERS and press RETURN or ENTER key to set delay for speakers 17.58 feet away from listener's ear.
\ Type in PRINT_DELAY and press RETURN or ENTER key to view current value.
\ Type in 4800 COMPORT COM1 and press RETURN or ENTER key to set baudrate and com port for Axiom and Garmin.
\ Type in GPS? and press RETURN or ENTER key to check communications with GPS and press any key to stop.
\ Type in GLOBALCHIMES or GO and press RETURN or ENTER key to restart.
\ Type in BYE and press RETURN or ENTER key to QUIT.
\ Enjoy the chimes.
\ 73
\ Louis
\ --------------------------------- Program Start ---------------------------------- \
marker gps
vocabulary application
application definitions
: include include ;
include calc_delay.f \ print_radio_delay and print_sound_delay words
include sio_delay.f \ GPS serial port interface
: gps? \ check gps communications
cr ." Press any key to stop. " cr
begin
(com-key?)
if
XKEY-CHAR @ 0 XKEY-FLAG ! emit
then
key?
until
;
include mmplay_delay.f \ which has sound.chime
include winio.f \ which has interface to winio.dll
hex \ set base for parallel port address definitions
\ REMEMBER -- MALE pins are numbered from left to right
\ printer port is FEMALE and numbered right to left
\ use pin 24 for ground -- 18-25 are all ground
378 constant p_data \ pins 2,3,4,5,6,7,8,9 for b0-b7 output D0-D7
379 constant p_status \ pins 15,13,12,10,11 for b3-b7 err,sel,oop,nack,nbus inputs
37A constant p_control \ pins 1,14,16,17,IRQ for b0-b5 nstb,nfeed,ninit,nsel,IRQ outputs
\ remember pin 11 b7 status nBUSY is reversed so invert if sampling clock on p_s7, normal on p_s3
\ remember that open input pins normally pull up HIGH and have to be pulled down for LOW
decimal \ set base for parallel port pin definitions
8 constant p_s3 \ status port pin 15 ERROR or FAULT normal GPS A
16 constant p_s4 \ status port pin 13 SELECT or ONLINE normal GPS C 18LVC -- default
32 constant p_s5 \ status port pin 12 OUTOFPAPER, OOP or PAPER normal
64 constant p_s6 \ status port pin 10 nACK inverted
128 constant p_s7 \ status port pin 11 nBUSY inverted GPS B -- for testing only
variable nmea_found 0 nmea_found ! \ serial cable not connected
variable g_found 0 g_found !
variable rmc_found 0 rmc_found !
variable nmea_pos 0 nmea_pos !
variable loop_counter 0 loop_counter !
2variable period_start 0. period_start 2! \ used for timing actual period between chimes
2variable period_end 0. period_end 2!
2variable delay_end 0. delay_end 2! \ used for timing actual delay from UTC tick
variable ignore_nmea 0 ignore_nmea ! \ this allows override of the serial port in an emergency
variable good_fix 0 good_fix ! \ this allows qualification of 1PPS
variable axiom_gps 0 axiom_gps ! \ this allows toggling GPS types
variable garmin_gps 0 garmin_gps !
variable radio_clock 0 radio_clock ! \ allows use of radio controlled clock for UTC tick
variable active_pin 0 active_pin ! \ which pin is GPS connected to? -- safe default -- all pins inactive
2variable distance_to_WWVB 1349.00 distance_to_WWVB 2! \ distance from Toronto to Boulder, Colorado
2variable distance_to_speaker 5.60 distance_to_speaker 2! \ floor speaker at 5.0 feet is 5.6 feet to listener's ear
: toronto 1349.00 distance_to_WWVB 2! ; \
variable radio_delay 0 radio_delay ! \ for using radio controlled clock -- delay from WWVB in Boulder, Co.
variable sound_delay 0 sound_delay ! \ actual delay from speaker to listener's ear
variable windows_delay 0 windows_delay ! \ Windows 98 and XP have different delays for calling SOUNDCHIME
variable delay_tweak 0 delay_tweak ! \ how much to tweak utc_tickdelay by to bring windows_delay to almost zero
variable period_tweak 0 period_tweak ! \ how much to nudge PerformanceFrequency
create delay_averaging_buffer 20 cells allot delay_averaging_buffer 20 cells erase \
variable average_delay_delta 0 average_delay_delta !
create period_averaging_buffer 10 cells allot period_averaging_buffer 10 cells erase \
variable average_period_delta 0 average_period_delta !
variable flip_phase? 0 flip_phase? ! \ for systems that flip audio phase
: flip_phase 1 flip_phase? ! ;
: normal_phase 0 flip_phase? ! ;
: invert_polarity flip_phase ;
: normal_polarity normal_phase ;
: axiom -1 axiom_gps ! 0 garmin_gps ! 0 radio_clock ! 0 radio_delay ! p_s3 active_pin ! ;
: garmin 0 axiom_gps ! -1 garmin_gps ! 0 radio_clock ! 0 radio_delay ! p_s4 active_pin ! ;
: clock 0 axiom_gps ! 0 garmin_gps ! -1 radio_clock ! distance_to_WWVB 2@ 2 dpl ! (radio_delay) radio_delay !
p_s4 active_pin ! ; \ use same pin as Garmin for input
: speaker_delay ( distance to ear -- ) \ set sound delay
depth if
(sound_delay)
5.60 2 dpl ! (sound_delay) negate + sound_delay !
else
cr cr ." Please enter WHOLE feet with ONE or TWO decimal places first." cr cr
then
;
variable utc_tickdelay 100000 utc_tickdelay ! \ advance or delay UTC tick in microseconds 1 us = 0.001 milliseconds
\ default global delay is 100 milliseconds past UTC tick
: no_delay 0 utc_tickdelay ! ; \ direct 1PPS
: far_speakers 5000 utc_tickdelay ! ; \ allows for speakers up to 100 feet away to be in sync
: near_speakers 100000 utc_tickdelay ! ; \ 100 milliseconds is the default global delay
\ : headphones 105149 utc_tickdelay ! ; \ based on near_speakers being 5.6 feet away = 5.1 ms at ear level
: headphones 100000 0.00 2 dpl ! speaker_delay sound_delay @ - utc_tickdelay ! ; \ this calculation results in 105149
: speakers ( n.nn -- ) speaker_delay 100000 sound_delay @ - 5000 max utc_tickdelay ! ; \ set UTC delay for given distance
: speaker speakers ;
: feet speakers ;
: near 5.60 2 dpl ! ;
: far 108.91 2 dpl ! ;
: set_delay ( n --- ) utc_tickdelay ! ; \ set new UTC delay directly
: print_delay utc_tickdelay @ CR . ." microseconds " CR ; \ print delay
: delay? print_delay ;
binary
11000000 constant control_mask \ mask to flip nack nbusy using XOR on input
decimal
: echo_to_data ( --- ) ( echo normalized status pins to data -- GPS A pin 5, GPS B pin 9, GPS C pin 6)
begin
p_status winio_pc@ ( RED data )
control_mask xor \ flip nACK and nBUSY
p_data winio_pc!
key?
until
;
: delay_ms ( ms --- ) ms ;
: uCOUNTER_tweaked ( -- d )
DCOUNTER 1000000 0 0 SP@ QueryPerformanceFrequency DROP NIP period_tweak @ + M*/ ;
: delay_us ( us_delay --- ) \ uses Pentium microsecond 64-bit performance counter
s>d ucounter_tweaked D+ \ display loop on oscilloscope CH2 -- delayed sweep 100 us per div
begin \ uses QueryPerformanceCounter which wraps around every 100 years on a 4 GHz machine
2dup \ wraparound error is avoided by signed math time1-time2 and checking sign 0<
ucounter_tweaked d- \ eg. an 8-bit counter wraps at (255) FF->0 , if at time (253) FD a delay of 10 is required,
swap drop \ FD+10=7=time1 and the time is checked at FF=time2, math gives 7 - -1 = 8 which is NOT less than 0
0< \ so the counter wraps at 0 and continues until 8, where 7 - 8 = -1 and the loop exits
until \ the same is true of a 64-bit counter
2drop \ Note: the high order part of a double number is on TOP of the stack
;
\ axiom \ AXIOM is commented out
garmin \ here, GARMIN is the default
\ clock \ clock is commented out
near_speakers \ default 100 milliseconds delay
\ headphones \ commented out
: gps_help
cr cr ." See file Readme.txt for GPS18LVC SETUP instructions and file Schematic.jpg for the WIRING diagram. "
CR CR ." Run BWCPU Controller in another window to set program priority -- MAXIMUM WIN 98 or MINIMUM WIN XP; "
CR CR ." Then, type GO and press ENTER to start the chimes, or HELP then ENTER for more commands. "
CR CR ." Power up GPS, position antenna outside, connect parallel and serial ports and multimedia speakers. "
CR CR ." From SwiftForth menu click FILE, INCLUDE globalchimes.f if using SwiftForth Eval version. "
CR CR ." When the 1PPS signal is present, the program will display V for a bad fix and A for a good fix and a running count. "
CR CR ." Press any key to stop the chimes to use the commands below. "
CR CR ." Type in NEW_CHIME OM4_5690.WAV MAKE OM4_5690.WAV ACTIVE and press RETURN to change active wave file. "
CR CR ." Type in ACTIVE? and press RETURN to see current active sound or WAV? and press RETURN to see all sounds in folder. "
CR CR ." Type in 100000 SET_DELAY and press RETURN or ENTER key to set delay to 100 milliseconds. "
CR CR ." Type in FAR_SPEAKERS or NEAR_SPEAKERS or HEADPHONES or NO_DELAY and press RETURN or ENTER key to set default delay. "
CR CR ." Type in 17.58 SPEAKERS and press RETURN or ENTER key to set delay for speakers 17.58 feet away from listener's ear. "
CR CR ." Type in PRINT_DELAY and press RETURN or ENTER key to view current value. "
CR CR ." Type in 4800 COMPORT COM1 and press RETURN or ENTER key to set baudrate and com port for Axiom and Garmin. "
CR CR ." Type in GPS? and press RETURN or ENTER key to check communications with GPS and press any key to stop. "
CR CR ." Type in GLOBALCHIMES or GO and press RETURN or ENTER key to restart. "
CR CR ." Type in BYE and press RETURN or ENTER key to QUIT. "
CR CR ." Edit NewChime.f file with Notepad and substitute the latest chime wave file name for OM4_5690.wav. "
cr cr
;
: help gps_help ;
: gpschimes \ this will wait for a 100 ms GPS pulse every 900 ms and will chime for 1.000000 s
\ if unsynchronized, it will chime every 900 ms
application
4800 COMPORT-COM1 \ ready communications to Axiom GPS and Garmin GPS18LVC (default) at 4800 baud
/winio \ open winio.dll for i/o
gps_help \ display instructions
0 loop_counter ! \ initialize
0 average_delay_delta !
0 average_period_delta !
0 delay_tweak !
0 period_tweak !
delay_averaging_buffer 20 cells erase
period_averaging_buffer 10 cells erase
0 p_data winio_pc! \ turn off all status LEDs
cr cr ." Delay from UTC tick is " utc_tickdelay @ 6 .r ." microseconds"
utc_tickdelay @ 105149 = if ." -- suitable for headphones or visual evoked potentials from YELLOW LED blink"
then
utc_tickdelay @ 100000 = if ." -- suitable for floor-mounted speakers at five feet from listener"
then
." . " cr
cr cr ." Waiting for 1PPS signal and fix information -- all times are in MICROSECONDS ... press any key to stop. " cr cr
ucounter_tweaked period_end 2! \ initialize period counter
\ ------------------------------ Main Loop ------------------------------------
begin
p_status winio_pc@ ( detect positive going edge of 1PPS using winio.dll )
control_mask xor ( normalize nACK and nBUSY )
active_pin @ and 0<> \ is current GPS active? -- GARMIN is default
if
ucounter_tweaked
utc_tickdelay @ delay_tweak @ - 0 max 200000 min delay_us \ default global delay is 100 milliseconds past UTC tick
\ flip_phase? @
\ if sound.OM4_5690 \ for some systems that flip the audio phase
\ else sound.OM4_5690 \ wave file is 1.1 seconds long but is reset 0.1s early by each tick
\ then
play.active
ucounter_tweaked delay_end 2! \ used for timing actual delay past UTC tick including OS time to start chime
period_end 2@ period_start 2! \ for calculating actual 1.000 second period
period_end 2! \ store ucounter
1 p_data winio_pc! ( 1PPS echo output HIGH on data pin 2, yellow LED, at beginning of 200 ms using winio.dll )
200000 delay_us \ delay for 200 ms locking out other tasks to stop initial chime stuttering in WIN XP
0 p_data winio_pc! ( output LOW at end of 200 ms using winio.dll )
delay_end 2@ period_end 2@ d- d>s utc_tickdelay @ - -200000 max 200000 min \ clipped difference from tickdelay \
delay_averaging_buffer loop_counter @ 20 mod cells + ! \ store in circular buffer
0 20 0 do delay_averaging_buffer i cells + @ + loop 20 / average_delay_delta ! \ calculate average difference
average_delay_delta @ 20 / delay_tweak +! \ use only a portion of the difference to increment tweak
delay_tweak @ -200000 max 200000 min delay_tweak ! \ clip tweak for no_delay case
period_end 2@ period_start 2@ d- d>s 1000000 - -10000 max 10000 min \ clipped difference from 1 second \
period_averaging_buffer loop_counter @ 10 mod cells + ! \ store in circular buffer
0 10 0 do period_averaging_buffer i cells + @ + loop 10 / average_period_delta ! \ calculate average difference
loop_counter @ 20 = if \ do only once after 20 averages
average_period_delta @ 0 0 SP@ QueryPerformanceFrequency DROP NIP * 1000000 / period_tweak !
period_tweak @ -10000 max 10000 min period_tweak ! \ clip tweak for no_delay case
then
\ cr ." AVG: " 10 0 do delay_averaging_buffer i cells + @ space . loop space delay_tweak @ ." Delay Tweak: " . cr \ testing only
\ cr ." AVG: " 10 0 do period_averaging_buffer i cells + @ space . loop space period_tweak @ ." Period Tweak: " . cr \ testing only
\ cr ." AVG: " 10 0 do period_averaging_buffer i cells + @ space . loop space average_period_delta @ ." Period Delta: " . space period_tweak @ ." Period Tweak: " . cr \ testing
cr
0 nmea_found !
1 loop_counter +!
300 COUNTER + ( check serial NMEA data until 600 ms )
BEGIN
(com-key?)
if
XKEY-CHAR @ 0 XKEY-FLAG ! 1 nmea_found !
dup [char] $ = if 0 g_found ! 0 rmc_found ! 0 nmea_pos ! \ look for $GPRMC NMEA sentence
else 1 nmea_pos +!
then ( --- counter+200, c )
nmea_pos @ 1 = if
dup [char] G = if -1 g_found ! \ G found
else 0 g_found !
then
then ( --- counter+200, c )
nmea_pos @ 3 = if
dup [char] R = if -1 rmc_found ! \ R found
else 0 rmc_found !
then
then ( --- counter+200, c )
g_found @ rmc_found @ and if \ emit "A" fix is good, or "V" fix is bad qualifier
axiom_gps @ if
nmea_pos @ 18 = if
dup [char] A = if 2 p_data winio_pc! ." Fix is good -- " then \ green LED pin 3
dup [char] V = if 4 p_data winio_pc! ." Fix is bad -- " then \ red LED pin 4
dup emit
then
else \ GARMIN has A or V in different position
nmea_pos @ 14 = if
dup [char] A = if 2 p_data winio_pc! ." Fix is good -- " then \ green LED pin 3
dup [char] V = if 4 p_data winio_pc! ." Fix is bad -- " then \ red LED pin 4
dup emit
then
then
then ( --- counter+200, c )
drop ( --- counter+200, )
then \ strings sent once per second during a good fix or every eight seconds when searching
DUP EXPIRED
UNTIL DROP \ drop the counter+200
nmea_found @ 0= if ." No GPS NMEA -- " then \ serial cable not connected
space loop_counter @ 4 .r 4 spaces \ right justify count
period_end 2@ period_start 2@ d- ." Period: " 7 d.r 3 spaces \ print period
average_period_delta @ ." Average Delta: " 3 .r 4 spaces
delay_end 2@ period_end 2@ d- ." Delay: " 6 d.r 3 spaces \ print delay past UTC tick
average_delay_delta @ ." Average Delta: " 4 .r 4 spaces
delay_tweak @ ." Tweak: " . space
300 ms \ allow other processes to run here
then
key?
until
cr cr ." Type GO and press ENTER to restart the chimes, or HELP then ENTER for more commands." cr cr
winio/
;
: GPSCHIME GPSCHIMES ;
: GLOBALCHIMES GPSCHIMES ;
: GO GPSCHIMES ;
cr cr ." See file Readme.txt for GPS18LVC SETUP instructions and file Schematic.jpg for the WIRING diagram. " type
cr cr ." Run BWCPU Controller in another window to set program priority -- MAXIMUM WIN 98 or MINIMUM WIN XP; " type
cr cr ." Then, type GO and press ENTER to start the chimes, or HELP then ENTER for more commands." type cr cr
include newchime.f \ which has the name of the most recent chime wave file
cr cr
\ go
\ ---------------------------------- Program End ----------------------------------- \
{
Technical Details from Proposal.htm
The UTC second tick (by definition) is guaranteed to be in phase (within one microsecond) everywhere and always
(for all time to come) maximizing the spatial and temporal coherence of all signals in phase with it.
The tick is a "one pulse per second" (1PPS) digital signal provided by inexpensive GPS receivers such as the
Garmin GPS18LVC (production 2004) or Axiom Sandpiper SIRF GPS (surplus -- search for "nmea gps" on EBAY).
The signal is connected to an input pin of a personal computer parallel port (pin 13 or 15) and a simple program
plays a digitized chime wave file through multimedia speakers or headphones (one participant), at a low unobtrusive volume,
upon detecting the leading edge of the signal.
For group sessions, the sound is fed to a PA amplifier and distributed via wires to many floor-mounted six-inch speakers
facing up and spaced fifteen to twenty feet apart with practitioners forming a circle around each speaker, about five feet
away from it, introducing a uniform sound delay of about 4.6 milliseconds at floor level (5/1.087467 feet per millisecond)
and about 5.1 milliseconds at ear level (5.6' from speaker) for each participant.
Once a standard participant-to-speaker spacing and an initial delay (100 milliseconds in the prototype) are agreed upon,
then all similarly configured sessions anywhere and anytime in the world will always be in phase and coherent,
regardless of when a participant joins or leaves any ongoing session, which could be scheduled every three or four hours
(UTC time) or could even run continuously.
Individual participants at home will also be in phase with the standard speaker placement, or the program can introduce
the required 5.1 millisecond audio delay for those wishing to use wired or wireless headphones.
Even deaf people can participate in the meditations by using the diffuse 200 millisecond flash of the yellow 1PPS LED
with an extra 5.1 millisecond delay added in the program (as if using headphones) to be in perfect sync.
Delivery or distribution of the audio chime signal via telephone, satellite, Internet or other media networks is not
recommended due to unknown path delays of up to 500 milliseconds defeating the whole concept of simultaneity.
A prototype using an Axiom GPS (unit A) and a Garmin GPS (unit C) connected to a Windows98 computer is currently in use in
Toronto, Canada and all details, schematics, setup instructions as well as the main program written in SwiftForth
(free from www.forth.com which emails you the password) and the chime wave file will be provided free upon request and
will be posted to a web site -- http://www.connection.com./~louis/globalchimes
Download all files to a NEW folder on the C drive C:\ForthInc\SwiftForth\GlobalChimes and see the readme.txt file.
The prototype has been verified against a second Axiom GPS (unit B), on an HP180 oscilloscope and visually against an
Oregon Scientific clock's blinking colon display and remains synchronized as long as a 3D fix is maintained by the GPS -
the 4800 baud RS232 NMEA data from the GPS is displayed by the program Conductor.exe.
During initial signal acquisition, and only a 2D fix, the tick is sometimes out of phase by 500 milliseconds and is
unusable until a full 3D fix is achieved.
If the signal is lost subsequently, the GPS internal clock takes over in holdover mode and is off (late) by 70 microseconds
(0.07 milliseconds) after one hour for unit A (excellent), 4 milliseconds after one hour for unit B (poor),
and 20 milliseconds for unit C (Garmin) (very poor). Resynchronization after signal reacquisition occurs in 270 seconds
for unit A (good), 45 seconds for unit B (excellent) and 30 seconds for unit C (excellent).
Chime audio jitter is sometimes quite noticeable under Windows98 with the program running at normal priority.
Using BW CPU controller 1.6.1 to set FORTH SF.EXE priority to 24 (highest), and closing all unnecessary programs
eliminates all jitter.
Image chime_four_50.jpg shows the original waveform on the left and an oscilloscope
capture (at 100 milliseconds delay) of the audio from a Win 98 computer on top and a Win XP computer on the bottom --
note that the Win 98 audio phase is flipped and that it lags the Win XP audio by about half a millisecond (400 microseconds).
(BW CPU controller is free nagware from BinaryWork Corp.)
(winio.dll is free from www.internals.com ).
(Conductor.exe and the manual were free from Axiom Navigation Inc. which has now disappeared to Korea).
Keywords:
global chimes global chime globalchimes globalchime gps chimes gps chime gpschimes gpschime utc tick utc chimes
world chimes wwvb swiftforth super radiance effect flying sidhi tm transcendental meditation yogic flying vedic university
research eeg evoked potentials
}