element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Test & Tools
  • Technologies
  • More
Test & Tools
Blog New Functionality for Older Equipment: Adding USB and SCPI Programmability
  • Blog
  • Forum
  • Documents
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Test & Tools to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: shabaz
  • Date Created: 10 May 2024 1:28 AM Date Created
  • Views 2368 views
  • Likes 10 likes
  • Comments 8 comments
  • rpiintermediate
  • psu
  • Pico SCPI labTool
  • labview
  • scpi
  • PST
  • pyvisa
  • pi pico
  • power supplies
Related
Recommended

New Functionality for Older Equipment: Adding USB and SCPI Programmability

shabaz
shabaz
10 May 2024
New Functionality for Older Equipment: Adding USB and SCPI Programmability

Table of Contents

  • Introduction
  • What’s the Problem being Solved?
  • What’s Inside?
  • Solution Overview
  • Circuit Diagram
  • Building It
  • Software
  • Testing It
  • Summary


Introduction

This blog post shows how I went about adding programmability to an old power supply! More generally, there is plenty of old equipment out there, some with no control/monitoring interfaces, and some with ancient or proprietary protocols running over (say) RS-232 or perhaps RS-485 connections.

In the test equipment world, there is a popular (and fairly easy-to-understand) protocol called SCPI, and it can be run over a USB protocol called USBTMC. If you’re intending to use equipment in a lab, then SCPI is a great protocol to use (whether it is over USB, or Ethernet, or RS-232), because of the compatibility with various test orchestration software. You can then control/operate and monitor the equipment with (say) NI LabView, or MATLAB, or Python.

If legacy equipment does not support SCPI or USBTMC, then it may still be possible to add USB to it and create the functionality. This blog post discusses the steps involved.

image

What’s the Problem being Solved?

I purchased an old manually-adjustable power supply from ebay. Unfortunately, it came with no computer interface for setting and monitoring the voltage and current. Without such an interface, it would be very tedious to run tests that required the voltage to be adjusted in steps repeatedly for instance.

An RS-232 interface was an optional extra that could have been purchased back in the early 1990’s! However, Jan Cumps managed to locate the PDF service manual for the power supply, and it was discovered that it would be very straightforward to retrofit it, simply by adding a couple of optocouplers and a serial DB-9 connector. The power supply firmware can be made aware that the interface exists, by holding down some buttons at power-up. This was all great, however the protocol was proprietary, running over a 2.4 kbps connection. Furthermore, I don’t have a PC with an RS-232 interface. It would be far better if the power supply could be modified to incorporate a USB socket supporting SCPI!

What’s Inside?

The photo below shows the legacy power supply internals. The design looks very early 1990’s : ) I was impressed that quite a lot of attention has been paid by the designers, to reduce noise. It’s a linear supply, with two adjustable channels, and a third fixed 5V channel. As well as the input mains filter and really nice low-capacitance (between primary and secondary windings) transformer, the outputs have an LC filter attached (not visible).

The optional RS232 interface fits in the gap visible near to the power entry/fuse area, if the partially-punched metal is knocked out.

image

The photo below shows the PROM chip (I dumped out the firmware, if anyone wants to disassemble it!), and to the left of it, is a 3-pin socket where the optional RS232 interface board would connect.

image

It’s a pretty ancient power supply; it has a very basic user interface, quite confusing to read since everything needs to fit the 16x2 LCD screen. SCPI capability would be highly desirable to simplify usage of this supply!

image

Solution Overview

About a year ago, Jan Cumps Jan Cumps  developed software called the Pico SCPI labTool, or PST for short. The software, which runs on a tiny Pi Pico microcontroller board, implements USBTMC SCPI functionality. By default, it accepts commands to turn on/off some spare GPIO pins on the Pi Pico. It can also be used to take analog measurements from the ADC pins on the Pi Pico. 

image

The PST software can be easily added to, to create new SCPI functionality. What I would need to do, is to implement a software adapter to convert between SCPI commands and the legacy commands that the power supply unit supports.

In terms of hardware, I would need to connect up the Pi Pico to the legacy power supply, using a similar optocoupler scheme as the RS-232 adapter board would have used, if it had been installed. In other words, as far as the legacy power supply is concerned, the new hardware looks just like if the RS232 interface were fitted.

image

The legacy power supply accepts RS232 commands such as VSET and ISET in order to set the voltage or current. However modern SCPI-capable power supplies accept commands such as SOURCE:VOLTAGE:LEVEL or SOURCE:CURRENT:LEVEL. The firmware running on the Pi Pico will interwork between the SCPI world and the commands that the legacy power supply supports.

That’s it! This project is nice and simple.

Circuit Diagram

The service manual was examined to see how the RS232 interface worked. As can be seen, the UART signals, called RXD and TXD originate at the 8051-compatible microcontroller, and, through inverter buffers (more on that later!) become signals called RXDD and TXDD, and they attach via optocouplers to the DB-9 connector that would ordinarily connect to a PC with RS232 interface. The signal flow is shown in orange for the transmit, and green for receive (from the legacy equipment perspective).

The optocoupler circuitry and the DB-9 connector were not present. A partially-punched hole at the rear of the equipment is where the DB-9 connector and (presumably) a small circuit board would connect if the RS232 interface was purchased and installed.

image

For the new module, similar optocoupler circuitry was used and was attached to the Pi Pico. The USB connector on the Pi Pico is quite small, so a larger Type B USB socket was soldered.

image

Building It

I didn’t create a printed circuit board for this project. You can see the optocouplers and the Pi Pico in the photo below. The three wires at the top-left go to the 3-pin connector that was mentioned earlier, on the legacy equipment.

I didn’t want to have to keep opening up the equipment each time there is a firmware change on the Pi Pico, so I added a BOOTSEL (boot select) button next to the USB socket. It is flush, and not easy to accidentally press, but can be pushed in with fingernails when connecting the USB socket to the PC, in order to get the Pico into the boot mode.

image

This project was easy to assemble with point-to-point wiring on perfboard:

image

I took a gamble and installed it without testing it first! Anyway, it worked out.

image

It looks weird seeing a modern QFN-package microcontroller inside the ancient equipment.

image

Software

There is a ton of documentation on the Pico SCPI labTool, and many code examples.

I mostly followed the example described at the following link, skipping immediately to the section titled Implementing the ADC Functionality, changing the code as I went, to implement a 2400 baud UART instead of an ADC:  Creating a Pi Pico based High-Resolution Measurement Instrument 

I’m happy to explain any of my work if required, but it’s very self-explanatory; the code is almost entirely in a single file called psu_utils.c (and associated psu_utils.h header file). Everything else relies on Jan’s code. By looking at the psu_utils source and header files, it is easy to see how the SCPI commands invoke UART messages to perform the interworking between the SCPI world and the legacy power supply.

Testing It

Initially, it didn't work! After some thinking, the root cause was easily spotted (maybe you've already seen the issue if you saw the circuit diagrams!). I often forget that RS232 voltage levels are not only different, but are inverted, i.e. logic '1' is not a positive voltage and logic '0' is not a negative voltage. That was why the inverters were present in the original circuit. By inserting my module where the RS232 board went, the logic levels were inverted for me. I didn't want to now modify the module and add inverters! Fortunately, the solution was extremely simple. The Pi Pico C SDK offers the capability to automatically invert signals! Once I added that bit of configuration into the pin setup code, and re-uploaded the firmware into the Pico, all was well and I could begin testing the SCPI commands.

If you have NI VISA installed, then there is a simple tool called NI-VISA Interactive Control, where you can directly type SCPI commands and see the results. I used a very similar tool called Tektronix OpenChoice Talker Listener, since that was already installed on the PC.

I was able to issue voltage and current setting commands such as the ones shown below, and see the power supply update it’s LCD screen! I measured the voltage using a multimeter. The explanation of these SCPI commands would be in any typical modern power supply programming manual (I copied them from a BK Precision PSU programming manual).

SOUR1:VOLT:LEV:IMM:AMP 1.4
SOUR1:CURR:LEV:IMM:AMP 0.3

The full expansion for setting the voltage on channel 1 to (say) 2.34V is:

SOURCE1:VOLTAGE:LEVEL:IMMEDIATE:AMPLITUDE 2.34

The power supply can also report the current measured voltage and current values, and the SCPI commands implemented to do that are shown here:

SOUR1:VOLT:LEV:IMM:AMP?
SOUR1:CURR:LEV:IMM:AMP?

The power supply channels can be switched on/off with the following SCPI command (the value 1 or 0 at the end sets the channel on or off respectively:

SOUR1:OUTP:STAT 1

Summary

The Pi Pico, running the Pico SCPI labTool software, can extend the life of equipment, and also save costs! I saved quite a bit of money by buying a cheaper power supply and then adding the interface.

If you're interested in converting equipment to incorporate the SCPI functionality with PST, there are plenty of code examples out there, and it’s very easy to modify the code to incorporate the desired SCPI functionality.

Thanks for reading.

  • Sign in to reply
  • DAB
    DAB over 1 year ago

    Very cool way to update an old power supply.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 1 year ago in reply to Jan Cumps

    I made one. I think for the BBC micro bit. It's been so long that I start doubting.

    Found it back!  micro:bit as Pass / Fail indicator in an automated test setup 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 1 year ago in reply to shabaz

    But also hope someone makes a really simple SCPI-controlled traffic-light, for indicating test execution status!

    I made one. I think for the BBC micro bit. It's been so long that I start doubting. It's used for a production line bucketing control.
    To push components that are outside of specs off the line. It included a traffic light for operator awareness. 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz over 1 year ago in reply to Jan Cumps

    Completely, I couldn't convey the peace of mind of having the power supply now functioning just like a top-end PSU, to run tests and log measurements, and all within a couple of evenings work.

    I have other non-SCPI equipment that would be good to upgrade one day. But also hope someone makes a really simple SCPI-controlled traffic-light, for indicating test execution status! I reckon a Pico, running PST, with some LEDs (could be neopixel or similar, if not simply a toy traffic light), would be a product people might even purchase.

    image

    • Cancel
    • Vote Up -1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 1 year ago in reply to genebren

    It is! When we made the Pico SCPI/USB library, the dream was that it 'd result in projects like this.
    The only requirement for the "device that wants to be programmed" is that there is a way to control it. Nothing more.

    In this case, shabaz ' instrument has a serial interface (it's using an 8051). It does not comply with Pico's logic levels, and it doesn't comply with the SCPI standards. But just a few component (less than 10 I think) and a few lines of code (possibly also close to 10 - all of them template) turns it into an IEEE compliant programmable supply.
    You can plug it straight away into a LabVIEW, PyVisa or MathLab design. And it 'll behave "like a bought one".

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube