Win10 USB to Old HP Instruments RS232 Comunication - HP16500B Serial Programming
by frenzi3793 in Circuits > Electronics
1235 Views, 6 Favorites, 0 Comments
Win10 USB to Old HP Instruments RS232 Comunication - HP16500B Serial Programming
This tutorial is about comunicating over serial protocol (RS232) from python scripts running on windows 10 to HP16500B Logic Analyzer. These beasts are great debugging tools that comes really cheap nowaday (i've paid mine 150€), and programming them over serial can greatly expand their functionalities.
In this tutorial i'm focusing on the hardware side that can be a little bit tricky. This is not a fully documented tutorial, but a list to things to watch out when working with serial interface on 'modern' OS not equipped with native serial port.
Probabily, what i'm about to explain is also suitable for other instruments with serial comunication capability (HP or not) but that's not tested.
Supplies
USB to RS232 interface (DB9 male connector)
Female DB9 to Male DB25 cable (THREE WIRE) - To build
USB to RS232 Interface - Win10 Setup
Any USB to serial interface is ok. I'm using a very old one, but you can easily found it on amazon for few bucks.
The Logic Analyzer (LA) need a DB25 male (M) connector , but i reccomend you to buy an USB to DB9 Male (M) adapter and build yourself the DB9F to DB25M cable (see next step).
Obviouslyou have to install your USB to RS232 interface drivers; after that, on device manager > Port (COM and LPT) > your_adpater_COM_port > port setup set:
baud rate = 9600, bit = 8, parity = none, stop bit = 1, flow control = Xon / Xoff
Three Wire DB9F - DB25M RS232 Cable
This cable is the most important step. Have this wrong and nothing will work.
With RS232 protocol it's possible to comunicate with only three wire and software flow control (xon/xoff) or with more wires (null modem cable) and hardware flow control (rts/cts) (page 45 to 52 of the programmer's guide).
Hardware flow control is better but most usb to serial adapter don't control rts and cts pins in the right way. RTS, CTS, DSR, DCD, DTR has to remain high over all the comunication process. So if we use a null modem cable with a usb to rs232 interface that's not gonna work.
So we need to go with three wire method, connecting RX, TX, signal GND (and cables shield GND) only; it's a better choice to diy the cable in order to be sure that only these 3 signals are connected.
For this you need: male db25 and female db9 connectors, 2 meters or of shielded cable (it's ok to use a LAN cable).
P.S. I have ricycled the connectors from old unused boards and made by myself the casings with a 3d printer, but you can find them easily on amazon.
LA Setup
Setup the LA to match the PC settings.
Python Software
For sending serial commands you can use whatever you want. I prefer Python, using pySerial library.
I'm assuming that you've alredy have python and pySerial installed (cmd > pip install pySerial).
This is a simple example script:
import serial ser = serial.Serial( 'COM8', 9600, xonxoff = True, rtscts = False, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, timeout=0.5) ser.write(b':SELECT?\r\n') #Ask what menu we are in print("Response: "+ser.readline().decode()) #Print the response ser.write(b':MENU 5\r\n') #Visualize menu 5 ser.write(b':SELECT 5\r\n') #Select module 5 (LA in my case) ser.write(b':START\r\n') #Start selected module ser.close()
It's really important to send \r\n (CR + LF , used as a new line character in Windows) at the end of each command, otherwise commands are not executed.
Not all the commands listed in the programmer's guide are working. I think that's because the guide is about an older software revision than the one that i've installed and maybe some commands are deprecated.
Here's a python implementation of most common commands but is quite old and need to be revised to work under python3.
HP INSTRUMENT BASIC for Windows 95
All the examples in programmer's guide assuming that you are using Hp basic and they're adding this language syntax to the commands; the real command is the one between the quotes "". However, if you like retrocomputing and you have access to a windows 95 pc with serial port you can also install HP INSTRUMENT BASIC and have some fun. Device settings are the same of step 1; for setup the in-software port settings look at the examples in the help file. With 'real' serial port you can also use hardware flow control with null modem type cables.
Others Manuals and OS Update
Here some other manual for the HP16500 family that i've collected over time.
For updating the system software you only need to download the last OS, extract the exe file and copy each folder on a floppy drive. Insert DISK1 and turn on the LA. The boot take from 5 to 10 minutes; after the LA booted, start copying all the files in DISK1 in system folder with file manager, overwriting the existing ones. When done, without turn off the LA copy also DISK2,3,4 and PVTEST disks. Done. Take your time, it's a slow process (each file has to be manually overwrited).