Author Topic: open source GPIB adapter  (Read 28632 times)

0 Members and 1 Guest are viewing this topic.

Offline dazz1

  • Frequent Contributor
  • **
  • Posts: 693
  • Country: nz
Re: open source GPIB adapter
« Reply #125 on: December 01, 2023, 09:38:18 am »

Maybe, but the fact that your LED never blinks whenever the bootloader is in flash makes me suspect at least part of your problem lies elsewhere. I'm suspicious you have a short or a bad solder connection on at least one of the AVR pins. In particular, I'm wondering if you could have a short or intermittent connection to ground from pin 10 of the AVR since the bootloader is invoked by grounding that pin.

For QFN parts, I've had good luck clearing solder issues by heating the chip until the solder reflows, then giving the chip a few gentle but firm taps right in the center with handle of my tweezers.

I found a solder bridge on the MCU pins 36/37.  I cleared that and now the LED flashes/stays on when it should.  That is a step forward.
The USB is not enumerating so possibly a bad solder joint there.  I have already re-checked my design and it seems to be OK. 
Dazz

Over Engineering: Why make something simple when you can make it really complicated AND get it to work?
 

Offline dazz1

  • Frequent Contributor
  • **
  • Posts: 693
  • Country: nz
Re: open source GPIB adapter
« Reply #126 on: December 03, 2023, 10:23:11 am »
I soldered two wire-wrap wires to the USB D- and D+ lines on the connector side of the 22R series resistors.  I wanted to see what data was reaching the connector.
Many techs start fault finding from one end of the signal path.  It is a lot faster to start in the middle of the signal path and just repeat the halving process until the fault is found.  If (say) there are 16 test points in a signal path, and one is faulty, halving the signal path will find the fault in no more than 4 tests.

In all cases, with the adapter plugged into an operating GPIB bus, the LED would flash once, then remain on, indicating a valid connection to a live GPIB bus.  If the GPIB bus was made inactive, (turning off the test equipment), the LED started flashing.  No evidence of any issue with the GPIB bus, MCU or software.

I did see usb renumeration, but only if the USB-C cable was plugged in one way.  If the plug was rotated 180 degrees, there was no USB traffic. 
I swapped cables.  Same symptoms.
Static testing of the USB-C connector showed no solder bridges.
Checked all the resistors in-circuit with the USB connector. 
I (re)checked the connector data sheet and compared against the circuit diagram and foot print.  All good.  No problem found.
Close inspection indicated some of the solder joints might be suspect.  I resoldered the connector joints and tried again.

I have gone from renumeration one-way back to renumeration no-way.  I see no data on the USB lines.
The only thing I have touched is the USB connector, so I suspect the connector is faulty.  Swapping that out is going to be a challenge. 

Images show initial USB signal followed by streaming data and an overview of the setup.   
The computer is an old Asus eeePC running Linux.  I just wanted to see a valid USB connection (command:  lsusb )
Dazz

Over Engineering: Why make something simple when you can make it really complicated AND get it to work?
 

Offline tautech

  • Super Contributor
  • ***
  • Posts: 28382
  • Country: nz
  • Taupaki Technologies Ltd. Siglent Distributor NZ.
    • Taupaki Technologies Ltd.
Re: open source GPIB adapter
« Reply #127 on: December 03, 2023, 10:31:33 am »
Isn't USB C polarised ?
Avid Rabid Hobbyist
Siglent Youtube channel: https://www.youtube.com/@SiglentVideo/videos
 

Offline coromonadalix

  • Super Contributor
  • ***
  • Posts: 5906
  • Country: ca
Re: open source GPIB adapter
« Reply #128 on: December 03, 2023, 03:27:09 pm »
not supposed to  if the design is verified,   that's the advantage of usb-c,   no up / down nightmares

but have to deal with more pins on the connector
 

Offline dazz1

  • Frequent Contributor
  • **
  • Posts: 693
  • Country: nz
Re: open source GPIB adapter
« Reply #129 on: December 04, 2023, 07:59:14 am »
Isn't USB C polarised ?

Not long ago, I would have said I don't know the answer.   ???
Now I know just enough to be certain I suffer from the Dunning-Kruger effect.  Therefore I can say with some confidence that the usb-C is polarised in a way that you can tell if the plug is in one way, or the other.  CC1 and CC2.

The attached image compares the connector datasheet pinout with my PCB layout.  The pin-out is asymmetric.  I was checking to see if I had made a mistake with the pcb layout. I hadn't.  :phew:

All of the diagnostics I have done point to a faulty connector.  I don't remember why I chose this connector, but I sourced it from Aliexpress, and that was probably a mistake.   :palm: Things like that happen under the effect of Dunning-Kruger. 
Dazz

Over Engineering: Why make something simple when you can make it really complicated AND get it to work?
 
The following users thanked this post: tautech

Offline dazz1

  • Frequent Contributor
  • **
  • Posts: 693
  • Country: nz
Re: open source GPIB adapter
« Reply #130 on: December 06, 2023, 01:56:28 am »
I removed suspect usb connector and found the problem.  :-+ The visible side of the connector pins were nicely tinned.  The lower side was not. I also found lots of flux residue under the connector in a hard to clean out location.

I am replacing the usb-c connector and starting by tinning the lower side of the connectors.  There is no evidence the first connector was faulty.  Just bad soldering.  A little embarrassing  https://www.eevblog.com/forum/Smileys/default/facepalm.gif   because a few decades ago, I used to manage a school to train technician apprentices.  I introduced a High Reliability Hand Soldering course.  I never took the course myself so that is my excuse for making a mess of soldering the usb-c connector.

When I was young, my eyesight was good and I used large parts.  Now I am old, my eyesight is not so good, and I use really small parts.   :-//
Dazz

Over Engineering: Why make something simple when you can make it really complicated AND get it to work?
 

Offline tautech

  • Super Contributor
  • ***
  • Posts: 28382
  • Country: nz
  • Taupaki Technologies Ltd. Siglent Distributor NZ.
    • Taupaki Technologies Ltd.
Re: open source GPIB adapter
« Reply #131 on: December 06, 2023, 04:09:23 am »
It does help to select extended/low density footprint when laying out the PCB which provide for a solder fillet to be formed rather than a footprint that's the perfect size for a component.
We all live and learn....
Avid Rabid Hobbyist
Siglent Youtube channel: https://www.youtube.com/@SiglentVideo/videos
 

Offline dazz1

  • Frequent Contributor
  • **
  • Posts: 693
  • Country: nz
Re: open source GPIB adapter
« Reply #132 on: December 06, 2023, 09:02:55 am »
I replaced the connector. 
Removed the solder bridges. 
Beeped out all the connector pins.

Connected everything up and ....  nothing.
The red led is doing what it should be doing, so the MCU is doing its thing. 

One of the usb data lines is floating so I could have 2x faulty usb cables or I have a bad batch of usb-c connectors. 

Since I stopped buying things of Aliexpress for the cheapest price, I haven't had an issue with quality.  I find the more you pay for an item on Aliexpress, the better the quality.  Definitely not true for western sellers.

Apart from the usb connector, there is no evidence that the fault is with the adapter, software etc. 


Dazz

Over Engineering: Why make something simple when you can make it really complicated AND get it to work?
 

Offline dazz1

  • Frequent Contributor
  • **
  • Posts: 693
  • Country: nz
Re: open source GPIB adapter
« Reply #133 on: December 10, 2023, 07:49:44 am »
I found the fault with my adapter today.
One of the 22R resistors in each USB data line between the MCU and the USB connector had an intermittent fault to open circuit.
I found the fault by rescuing a USB socket from an old motherboard.  This broke out all of the signal lines.
I was then able to do continuity checks through the cable, connector and to the various points on the pcb.  This test showed the connector is all good.
Probably should have found this fault earlier.

The adapter now reliable renumerates with both a Linux and Windows machines.

Now I am just tying to get a version of visa running following some pointers way back at post 102.
« Last Edit: December 12, 2023, 10:06:33 am by dazz1 »
Dazz

Over Engineering: Why make something simple when you can make it really complicated AND get it to work?
 

Offline coromonadalix

  • Super Contributor
  • ***
  • Posts: 5906
  • Country: ca
Re: open source GPIB adapter
« Reply #134 on: December 10, 2023, 04:12:01 pm »
Rhode Schwartz visa package is small and efficient, you have rs tools in it to send and read commands ...
 

Offline dazz1

  • Frequent Contributor
  • **
  • Posts: 693
  • Country: nz
Re: open source GPIB adapter
« Reply #135 on: December 12, 2023, 10:16:57 am »
Rhode Schwartz visa package is small and efficient, you have rs tools in it to send and read commands ...

I have installed R&S visa, now I am just started reading through the manual to get it to work.  I have not used GPIB, visa or Python before.
Dazz

Over Engineering: Why make something simple when you can make it really complicated AND get it to work?
 

Offline dazz1

  • Frequent Contributor
  • **
  • Posts: 693
  • Country: nz
Re: open source GPIB adapter
« Reply #136 on: December 13, 2023, 10:25:20 am »
Finally, if you're familiar with Python, here is a simple script that can be used to read from the HP 3478A you mentioned in your earlier post. Please note: Your VISA resource string will be different because your adapter will have a different serial number to mine.

Code: [Select]
# HP 3478A Multimeter simple read test

import pyvisa

rm = pyvisa.ResourceManager()

multimeter = rm.open_resource('USB0::0x03EB::0x2065::GPIB_23_3423331363435161F191::INSTR')

# Set function to DC volts
multimeter.write('F1')

try:
    while True:
        print(float(multimeter.read().strip()))
except KeyboardInterrupt:
    multimeter.clear()
    multimeter.close()
    rm.close()

Hi
where do I find the VISA resource string ?
Dazz

Over Engineering: Why make something simple when you can make it really complicated AND get it to work?
 

Offline coromonadalix

  • Super Contributor
  • ***
  • Posts: 5906
  • Country: ca
Re: open source GPIB adapter
« Reply #137 on: December 13, 2023, 11:32:08 am »

import pyvisa

rm = pyvisa.ResourceManager()

multimeter = rm.open_resource('USB0::0x03EB::0x2065::GPIB_23_3423331363435161F191::INSTR')
 

Offline caiser01

  • Regular Contributor
  • *
  • Posts: 61
  • Country: us
Re: open source GPIB adapter
« Reply #138 on: December 14, 2023, 11:21:55 pm »
Hi
where do I find the VISA resource string ?

There's a couple ways to find it. Since you say you haven't used Python before, let's stick to R&S VISA for a start to keep things simple.

With your instrument connected to the PC with the USB->GPIB adapter, open the R&S Tester app (just called Tester on Windows, RsVisaTester on Mac/Linux). On the menu bar, click Find Resource. In the window that opens, click the big refresh button in the upper left corner. The available VISA resources will show up in the list on the right of that window. In the list, find the resource for your connected instrument ('USB0::0x03EB::0x2065::nnnnn::INSTR') and double click it. This will take you back the main window of the Tester app. From there, you can click the Connect button and try sending your instrument some commands. For the HP3478A, try writing F1, F2, F3, etc and observe whether the meter function is changing.

If everything looks good, just copy the VISA resource string from the Tester app window and paste it over the resource string in my example Python script. Close the Tester app and try running the Python script.
 

Offline dazz1

  • Frequent Contributor
  • **
  • Posts: 693
  • Country: nz
Re: open source GPIB adapter
« Reply #139 on: December 15, 2023, 11:00:40 pm »

There's a couple ways to find it. Since you say you haven't used Python before, let's stick to R&S VISA for a start to keep things simple.
...
I found the resource string using pyvisa on the command line.  I haven't tried R&S visa or your script yet.  Getting there.
I have been programming unprofessionally for around 45 years so I am reasonably relaxed about learning python.

Edit 17 Dec 2023:
A real resource string looks like this:
Code: [Select]
('USB0::0x03EB::0x2065::GPIB_02_24238323232351C01171::INSTR', 'ASRL1::INSTR')
                             ^^
It appears to be a constant that is unique to each adapter except for the GPIB instrument address.  In this case "02" marked with ^^.
If you have a list of instruments with their GPIB addresses, it should be possible to read the GPIB address from the resource string to figure out which code should run for that instrument.
This would avoid the need to identify specific adapters.  You would be able to plug in any adapter to any instrument. 
« Last Edit: December 17, 2023, 09:12:25 am by dazz1 »
Dazz

Over Engineering: Why make something simple when you can make it really complicated AND get it to work?
 

Offline caiser01

  • Regular Contributor
  • *
  • Posts: 61
  • Country: us
Re: open source GPIB adapter
« Reply #140 on: December 16, 2023, 01:42:38 am »
It appears that the resource string is unique to each adapter (I have only assembled one so far).  If so, then the string should be physically readable on the adapter.
I haven't design the enclosure yet, but it would be easy to include a slot for a light card label with the printed resource string. 
It seems sensible to make the label big enough to include space for the ID of the test equipment that the associated software is written for.

The resource string will be different for each different instrument you use the adapter with.

If you have the adapter's Auto ID feature enabled (it is by default), the resource string will contain the instrument's response to a *IDN? query. For example, when connected to my HP 53131A universal counter, the resource string is: USB0::0x03EB::0x2065::HEWLETT-PACKARD_53131A_0_3703::INSTR

If you're connected to an instrument that does not support the *IDN? query or if you disable the adapter's Auto ID feature, the resource string will look like this:

USB0::0x03EB::0x2065::GPIB_23_3423331363435161F191::INSTR

The part in bold is a serial number that should be unique to each adapter. The GPIB_nn part represents the GPIB address of the connected instrument. This will change for different instruments with different addresses.
 

Offline dazz1

  • Frequent Contributor
  • **
  • Posts: 693
  • Country: nz
Re: open source GPIB adapter
« Reply #141 on: December 16, 2023, 02:41:09 am »
Hi
I have been playing around with the code but it isn't working.  I don't appear to have comms with the meter. 

Code: [Select]
# HP 3478A Multimeter simple read test

import pyvisa

print("Simple GPIB test for HP3478A multimeter")
print("Show the list of Resources")
rm = pyvisa.ResourceManager()
print(rm.list_resources())
# ID string for adapter 0:  'USB0::0x03EB::0x2065::GPIB_23_24238323232351C01171::INSTR'

print("Opening the Meter")
# Resource = GPIB-usb adapter 0.  Different for each adapter.
multimeter = rm.open_resource('USB0::0x03EB::0x2065::GPIB_23_24238323232351C01171::INSTR')

# Write some text to display
multimeter.write('D2OK GPIB USB')

# Set function to DC volts (F1), auto-range (RA), trigger hold (T4), 4.5 digit (N4), auto-zero (Z1), internal trigger (T1)
multimeter.write('H1T1')
print("Reading the DC volts")
try:
    while True:
        print(float(multimeter.read().strip()))
except KeyboardInterrupt:
    multimeter.clear()
    multimeter.close()
    rm.close()

I usually add a lot of print statements to see what is working, and what isn't.
It isn't.
I get the following error messages:

Code: [Select]
>python gpib_test.py                                                                                     
Simple GPIB test for HP3478A multimeter                                                                                                                         
Show the list of Resources                                                                                                                                       
('USB0::0x03EB::0x2065::GPIB_23_24238323232351C01171::INSTR', 'ASRL1::INSTR')                                                                                   
Opening the Meter                                                                                                                                               
Traceback (most recent call last):                                                                                                                                 
File "D:\gpib_test.py", line 19, in <module>                                                                 
multimeter.write('H1T1')
...

If the resource string is from the instrument and not the adapter, then the adapter must have comms with the instrument.

The "D2" command just writes a string to  the display, but that is not happening.
The "H1T1" puts the meter into DC mode, continuous internal trigger, but it isn't. 
That indicates I may have a hardware fault either in the instrument, or in the adapter. 

R&S Tester does not find the usb-gpib adapter resource.  I am not sure if installing NI-visa or py-visa has over-written something that R&S needs.

« Last Edit: December 16, 2023, 02:54:32 am by dazz1 »
Dazz

Over Engineering: Why make something simple when you can make it really complicated AND get it to work?
 

Offline caiser01

  • Regular Contributor
  • *
  • Posts: 61
  • Country: us
Re: open source GPIB adapter
« Reply #142 on: December 16, 2023, 03:22:29 pm »
R&S Tester does not find the usb-gpib adapter resource.  I am not sure if installing NI-visa or py-visa has over-written something that R&S needs.

If you have multiple VISA implementations installed, we need to figure out which one pyvisa is grabbing.

What is the output when you run pyvisa-info from the command prompt?
 

Offline dazz1

  • Frequent Contributor
  • **
  • Posts: 693
  • Country: nz
Re: open source GPIB adapter
« Reply #143 on: December 16, 2023, 08:52:34 pm »
...
What is the output when you run pyvisa-info from the command prompt?

Code: [Select]
Machine Details:                                                                                                                                                   
Platform ID:    Windows-10-10.0.19045-SP0                                                                                                                       
Processor:      Intel64 Family 6 Model 94 Stepping 3, GenuineIntel                                                                                                                                                                                                                                                             Python:                                                                                                                                                             
Implementation: CPython                                                                                                                                         
Executable:     G:\Programs\Python310\python.exe                                                                                                                 
Version:        3.12.1                                                                                                                                           
Compiler:       MSC v.1937 64 bit (AMD64)                                                                                                                       
Architecture:   AMD64                                                                                                                                           
Build:          Dec  7 2023 22:03:25 (#tags/v3.12.1:2305ca5)                                                                                                     
Unicode:        UCS4                                                                                                                                                                                                                                                                                                           
PyVISA Version: 1.14.1                                                                                                                                                                                                                                                                                                            Backends:                                                                                                                                                           
ivi:                                                                                                                                                               
Version: 1.14.1 (bundled with PyVISA)                                                                                                                           
#1: C:\WINDOWS\system32\visa32.dll:                                                                                                                                 
found by: auto                                                                                                                                                   
architecture:                                                                                                                                                       
('x86', 64)                                                                                                                                                   
Vendor: Rohde & Schwarz GmbH                                                                                                                                     
Impl. Version: 7340546                                                                                                                                           
Spec. Version: 7340544                                                                                                                                       
#2: C:\WINDOWS\system32\visa64.dll:                                                                                                                                 
found by: auto                                                                                                                                                   
architecture:                                                                                                                                                       
('x86', 64)                                                                                                                                                   
Vendor: Rohde & Schwarz GmbH                                                                                                                                     
Impl. Version: 7340546                                                                                                                                           
Spec. Version: 7340544                                                                                                                                                                         

I can see it is grabbing the R&S visa (I have NI visa installed as well) but when I run R&S directly, it does not detect the usb-gpib adapter. 
So I still don't know if I have a HW or SW fault.

I am writing a test program in C++ (another new language to me, although I have programmed in C-like languages eg.Java) that will sequentially pulse each port pin.  It will help identify solder bridges or open circuits on the port pins.
It will be a separate stand-alone program usable on, or adaptable to, any AVR MCU.
Dazz

Over Engineering: Why make something simple when you can make it really complicated AND get it to work?
 

Offline caiser01

  • Regular Contributor
  • *
  • Posts: 61
  • Country: us
Re: open source GPIB adapter
« Reply #144 on: December 16, 2023, 09:51:10 pm »
I can see it is grabbing the R&S visa (I have NI visa installed as well) but when I run R&S directly, it does not detect the usb-gpib adapter.

That's weird given that when you run the Python script, it does detect the adapter.

Just for giggles, try adding this line after the open_resource line:

Code: [Select]
multimeter.write_termination = '\n'
If that doesn't work, try making it '\r\n'.
 

Offline dazz1

  • Frequent Contributor
  • **
  • Posts: 693
  • Country: nz
Re: open source GPIB adapter
« Reply #145 on: December 16, 2023, 10:22:42 pm »

Just for giggles, try adding this line after the open_resource line:

Code: [Select]
multimeter.write_termination = '\n'

That worked. Thanks.

The code displayed:
Code: [Select]
>python gpib_test_HP3478A.py                                                                             
Simple GPIB test for HP3478A multimeter                                                                                                                         
Show the list of Resources                                                                                                                                       
('USB0::0x03EB::0x2065::GPIB_23_24238323232351C01171::INSTR', 'ASRL1::INSTR')                                                                                   
Opening the Meter                                                                                                                                               
Reading the DC volts                                                                                                                                             
-1.6431                                                                                                                                                         
-1.6427                                                                                                                                                         
-1.6425                                                                                                                                                         
...

So that confirms the adapter is 100% working. 
Dazz

Over Engineering: Why make something simple when you can make it really complicated AND get it to work?
 

Offline caiser01

  • Regular Contributor
  • *
  • Posts: 61
  • Country: us
Re: open source GPIB adapter
« Reply #146 on: December 16, 2023, 11:32:23 pm »
So that confirms the adapter is 100% working. 

Took a while to get here but that's great!

Just had a look at xyphro's GitHub and it sounds as if he's been busy optimizing the firmware. Should be a nice update when he does his next release.
 

Offline dazz1

  • Frequent Contributor
  • **
  • Posts: 693
  • Country: nz
Re: open source GPIB adapter
« Reply #147 on: December 17, 2023, 12:17:45 am »
Just had a look at xyphro's GitHub and it sounds as if he's been busy optimizing the firmware. Should be a nice update when he does his next release.

This adapter is a software project with some hardware attached.  The quality of this type of project is largely defined by the software.  Optimizing the software can only be a good thing.
There might be an improvement to be gained by simply altering the compiler settings.  By default, the MAKE file compiler settings are set to create the smallest firmware file size.  Also the slowest to execute.  Changing compiler setting to increase the file size should be a zero effort action to make a small increase in speed. 

When the compiler is set to build a large file, it replaces call to functions with the code of the function.  Code is repeated.  It is very inefficient on code size, but also fast.  There is no reason to keep the file size any smaller than 32k on the ATmega32U. 
« Last Edit: December 17, 2023, 09:17:27 am by dazz1 »
Dazz

Over Engineering: Why make something simple when you can make it really complicated AND get it to work?
 

Offline dazz1

  • Frequent Contributor
  • **
  • Posts: 693
  • Country: nz
Re: open source GPIB adapter
« Reply #148 on: December 17, 2023, 09:52:45 am »
So that confirms the adapter is 100% working. 
Took a while to get here but that's great!

Now I am working on using the GPIB for my WaveTek 2520 RF Signal Generator.  I have GPIB comms so the instrument is OK but I need to figure things out to get all the commands working. 
At present, I am using my deck top PC, which is no where near my workshop.

I would like to get my little old Linux Asus eeePC running pyvisa.  What do you suggest, and in what order should I install?  NI, R&S ?
Dazz

Over Engineering: Why make something simple when you can make it really complicated AND get it to work?
 

Offline alm

  • Super Contributor
  • ***
  • Posts: 2881
  • Country: 00
Re: open source GPIB adapter
« Reply #149 on: December 17, 2023, 10:09:16 am »
I would like to get my little old Linux Asus eeePC running pyvisa.  What do you suggest, and in what order should I install?  NI, R&S ?
I found installing a commercial VISA stack a pain on Linux. Especially maintaining it through OS upgrades. I'd also research what hardware they support. I know NI-VISA doesn't support NI GPIB-USB devices on Linux kernel versions from the last 15 years or so. I don't know about USBTMC.

I would use PyVISA-py as backend. This integrates much better with Linux and doesn't require any kernel modules or daemons to run.


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf