I'd like to ask the HP 59309A owners on time-nuts if the following symptoms 
sound familiar, and if so, what would the fix be?

o New-to-me HP 59309A clock.
o Late build, 1985 date code on many parts.
o I replaced the big 1900 uF electrolytic before plugging it in.
o Visual inspection very clean, no corrosion, no battery.
o 12v reads 13.1v, 5v reads 5.3v, -2v reads -2.9v.
o Front panel switches and buttons all work as expected.
o Internal and external osc. both work as expected.
o Internal "format" switch set to 0000 i.e. comma, cal, no space.
o GPIB works to *set* the time, using Prologix Ethernet adapter.
o Prologix Ethernet adapter attached directly to the clock, no cables.
o Python code to set via GPIB attached below.
o Setting time via GPIB always works, tried many times.
o Reading time has never worked.  All I get is lots of ASCII 
44444444444444444444444...
o Reading with Prologix ++read command
o Switches set to 1100010 i.e. Listen, ADDR 2 for normal operation
o Tried switches as 0000010 i.e. Talk Only, also resulted in continuous 
4444444444444444444...
o Tried very long delays between every GPIB command, no change.
o Tried removing top cover and running a fan to bring entire clock to 21C, no 
change.
o Tried gently reseating the four boards and three socketed PROMS, no change.

Thanks to TVB for hp59309.c sample Windows Prologix USB code.  I based the 
Python Ethernet code on TVB, to read from the clock he sends command C and then 
++read.  When I do that all I get are a zillion 0x34 '4' characters.

Seems strange that all the GPIB commands work.  I tried R reset, P pause T 
resume D day H hour M minute S second manually and they all work just fine.  I 
have never been able to read anything reasonable though.

As to the Prologix Ethernet adapter, I believe it is working OK electrically as 
I have been using it for weeks at a time reading PPS time intervals from a 
trusty HP 5334B counter, the adapter has read hundreds of thousands times from 
the 5334B.

Is there a trick to using the Prologix to read from the 59309A?

I did notice that the 59309A has at least one trick - in TVB's code where he 
reads the Prologix settings and only writes them if they need to be changed, 
that is actually required(!).  Just writing them every time seems to put the 
adapter into a strange state.

Page 4-2 of the 59309A manual seems to imply that the "Output State Machine" 
generates the GPIB output messages, using input from the "Data Memory".  
AFAICT, those two functional blocks are the only ones that are not working for 
me.

I think A4U18 ROM is OK as it handles GPIB command decoding and R P T D H M S 
commands all work.

A5U15 appears to do the ASCII encoding for SP, CR, LF, ", : so it may or may 
not be OK.

A5U2 is described as "STATE MACHINE ROM (A5U2). This 4K ROM controls the 
operation of the circuits that develop the talk output of the 59309A."  Has 
anyone experienced failure of this ROM, and do the symptoms match what I'm 
seeing?

This is a lovely clock, and while I can't actually think of a reason to *need* 
the GPIB time output, I'd still like to fix it.

Cheers,

Bob Marinelli

#!/usr/bin/python
# Initialize HP 59309A GPIB clock to local time
# Thanks to TVB for http://www.leapsecond.com/tools/hp59309a.c
# For UTC, use datetime.utcnow instead of datetime.now

import datetime, socket, string, sys, time

# IP address of Prologix Controller 
host = "192.168.20.7"

# GPIB address of HP 59309A clock
addr = "2"

# Read one line from Prologix
def gpib_read(s):
  buf = ""
  while (1):
    c = s.recv(1)
    if not c:
      print "Connection closed"
      sys.exit(1)
    if c == '\n':
      return buf
    if c != '\r':
      buf = buf+c

# Send one command and EOL to Prologix
def gpib_send(s, cmd):
  s.send(cmd+"\n")

# Send one GPIB command and return reply
def gpib_query(s, cmd):
  gpib_send(s, cmd)
  gpib_send(s, "++read")
  return gpib_read(s)

# Send Prologix command and return reply
def prologix_query(s, cmd):
  gpib_send(s, cmd)
  return gpib_read(s)

prologix_cfg = [
  ("++savecfg",     "0"),    # do not update eeprom
  ("++mode",        "1"),    # device=0 controller=1
  ("++auto",        "0"),    # automatic read-after-write
  ("++eoi",         "0"),    # disable EOI
  ("++eos",         "3"),    # 0=CR+LF 1=CR 2=LF 3=none
  ("++read_tmo_ms", "1000"), # set read timeout (milliseconds)
  ("++addr",        addr)    # user-supplied gpib address
] 

# Initialize Prologix, only change as needed
def prologix_init(s):
  for cmd, val in prologix_cfg:
    old = prologix_query(s, cmd)
    if old != val:
      gpib_send(s, cmd + " " + val)

# Quiesce Prologix
def prologix_done(s):
  gpib_send(s, "++loc")
  gpib_send(s, "++mode 0")

if __name__ == "__main__":
  s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  s.settimeout(2)
     
  # Connect to Prologix on port 1234
  try :
    s.connect((host, 1234))
  except :
    print "Unable to connect to", host
    sys.exit(1)

  # Confirm we are talking to Prologix
  if "Prologix" not in prologix_query(s, "++ver"):
    print "Wrong IP address or not a Prologix controller"
    sys.exit(1)

  # Initialize Prologix as controller, no auto read
  prologix_init(s)

  was = datetime.datetime.now()
  while (1):
    now = datetime.datetime.now()
    if was.second != now.second:
      break
  
  time.sleep(0.2) # This plus 58309A internal delay works for me
  gpib_send(s, "R")

  # Repeat D days, M months, H hours and S seconds
  # Note that count of 0 i.e. null cmd seems ok
  tt = now.timetuple()
  gpib_send(s, "D" * ( tt.tm_yday - 1 ))
  gpib_send(s, "H" * tt.tm_hour)
  gpib_send(s, "M" * tt.tm_min)
  gpib_send(s, "S" * tt.tm_sec)

  prologix_done(s)
  print "Clock was set to", now.strftime("%Y-%m-%d %H:%M:%S")


_______________________________________________
time-nuts mailing list -- [email protected]
To unsubscribe, go to https://www.febo.com/cgi-bin/mailman/listinfo/time-nuts
and follow the instructions there.

Reply via email to