Author Topic: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI  (Read 1568 times)

0 Members and 2 Guests are viewing this topic.

Offline FensterguckerTopic starter

  • Contributor
  • Posts: 22
  • Country: at
    • Private Website
Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« on: March 07, 2024, 09:39:10 am »
I recently bought a second Brymen BM869s multimeter with USB adapter.
The adapter is labeled BC-86P and has a Microchip PIC18F4550 built in. There is a programming plug on the board and the code in the PIC is not protected.

Unfortunately, the adapter does not work properly with the new BM869s. The IR-LED of the BM869s seems to transmit too strongly and the adapter has read errors. According to Brymen, you can change a resistor in the BM869s, but an adhesive tape over the phototransistor on the adapter also works as a temporary solution.

For this reason, I took a closer look at the adapter and reactivated an old project of mine. I wrote a firmware for the adapter that uses the USBTMC protocol and SCPI commands. The basis was the book by Henry Bruhns "USB in der Messtechnik" from 2008.

The code was originally written in assembler, then translated to mikroC, and now I have converted it to an MPLAB X project with XC8. Enclosed is the firmware as HEX file. I still have to revise the code, which will unfortunately take some time.

You can change VID/PID and string descriptors via SCPI command and read in the data from the BM869s.

I have tested the firmware with R&S VISA. I myself use the WinUSB driver and self-written software.

One more comment on the serial number. Brymen stores the serial number affixed to the adapter as binary data in the string descriptor. This is why the serial number cannot be read out normally. With the new BC-86P adapter, the serial number does not match the sticker either, and is apparently used for all adapters (233380011).

Peter

Edit: New Hex file

Code: [Select]
SCPI command for reading in:

:READ? <1|2|3|11|22|33|9>

:READ? -> Main value with unit.
:READ? 1 -> Main value.
:READ? 11 -> Main value with unit.
:READ? 2 -> Secondary value.
:READ? 22 -> Secondary value with unit.
:READ? 3 -> Main value and second value separated by a tab.
:READ? 33 -> Main value and secondary value with units separated by a tab.
:READ? 9 -> The 20 bytes read in by the BM869s as binary data, not text.
Code: [Select]
SCPI commands with the default values:

:SETUP:MANUfacturer "NEMYRB"
:SETUP:PRODuct "BC86P"
:SETUP:FIRMware "20240223"
:SETUP:SERIal "123456789"
:SETUP:VID 26214 // Hex 0x6666
:SETUP:PID 14081 // Hex 0x3701

The values are saved in the EEPROM.
Code: [Select]
SCPI commands:

*IDN?
:ECHO? text

Available, but do not always give correct values:

*RST
*CLS
*ESR?
*ESE / *ESE?
*OPC / *OPC?
*STB?
*SRE / *SRE?
*WAI

:SYSTem:ERRor?
:SYSTem:ERRor:NEXT?
:SYSTem:VERsion?

And a few others that make no sense here.
Code: [Select]
Example values:

1.5591
1.5593 V DC
-1.5594 V DC
1.5599 V DC 0.027 V AC
1.5596 V DC AVG -.--- V AC
1.5598 V DC MAX 0.027 V AC
0020.9C °C 020.7 °C
00.014 mA DC+AC 00.02 mA AC
00.000 mA DC -25.00 %4-20mA
-000.09 ^ mV DC 001.0 mV AC
.0L V diod
013.78 Ohm
-000.052 mV DC
-999999 (read error)
« Last Edit: March 08, 2024, 03:36:18 pm by Fenstergucker »
 

Offline FensterguckerTopic starter

  • Contributor
  • Posts: 22
  • Country: at
    • Private Website
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #1 on: March 08, 2024, 04:11:55 pm »
Attached is the source code for MPLAB X v5.35 and XC8 v2.46 (C99). The warnings are only my seven '#warning ToDo: ...' remarks, and two functions are not used. I am not a C programmer, and the origin of the code from assembler cannot be overlooked. The comments in the code are all in German.

The functions for the BM869s are in the file 'Bm869.c'. They are called by the function 'ScpiReadQ' in the file 'UsbBC86P488Device.c'. In the file 'Define.h' you can set some defaults for the compilation.

Code: [Select]
Memory Summary:
    Program space        used  4774h ( 18292) of  8000h bytes   ( 55.8%)
    Data space           used   4B4h (  1204) of   800h bytes   ( 58.8%)
    Configuration bits   used     7h (     7) of     7h words   (100.0%)
    EEPROM space         used    88h (   136) of   100h bytes   ( 53.1%)
    ID Location space    used     8h (     8) of     8h bytes   (100.0%)
BUILD SUCCESSFUL (total time: 28s)

Attached is also a sketch of the connections for the PIC18F4550 that I found.

Peter
 

Offline FensterguckerTopic starter

  • Contributor
  • Posts: 22
  • Country: at
    • Private Website
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #2 on: March 09, 2024, 07:21:50 am »
I have changed the BC-86P adapter a bit and now it works without any problems with the new BM869s and with an older BM869s from 2014.

I bent the phototransistor slightly so that it is completely inside the housing and does not protrude. Then I glued the hole with hot glue. But that wasn't quite enough, there were still reading errors. With an additional piece of 3M Scotch Magic tape, the adapter works.

A BC-86X adapter from 2014, on the other hand, works without any problems on both BM869S without errors.

Peter
 

Offline FensterguckerTopic starter

  • Contributor
  • Posts: 22
  • Country: at
    • Private Website
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #3 on: March 10, 2024, 08:27:48 am »
I have now been able to fix the read error in the firmware. The signal from the new BM869s is irregular, and varies by ~ 16 µs. It sometimes changes when the adapter is possibly reading the signal. I have now inserted a delay of 20 µs and the adapter now works without hot glue and tape.

BC-86P-Signal-TX-RX-Phototr-1.png
The signal changes when it should be stable.

BC-86P-Signal-TX-RX-Phototr-4.png
Adapter with adhesive tape, the signal arrives earlier.

BC-86X-Signal-TX-RX-5.png
The old BC-86X adapter has a much more stable signal. I have not measured the phototransistor.

BC-86P-Signal-TX-RX-Phototr-6.png
The BC-86P adapter also works with the old BM869s from 2014, as the signal also never changes too late.

The error should therefore also be present in the original firmware.

Here is the list of devices again:
BM869s from 2024, Firmware 'b'
BM869s from 2014, Firmware '869-P9'
BC-86P from 2024 with PIC18F4550
BC-86X from 2014 with Cypress Chip

Enclosed is the current hex file and code. The empty battery symbol is now also displayed when the units are read in.

Peter



« Last Edit: March 10, 2024, 08:30:50 am by Fenstergucker »
 

Offline FensterguckerTopic starter

  • Contributor
  • Posts: 22
  • Country: at
    • Private Website
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #4 on: March 10, 2024, 06:16:46 pm »
I have disassembled the original firmware (rev. 86.07) and can compile it in MPLAB X. By changing the waiting time for a stable signal, the original firmware also works without read errors.

I was able to extend the original pulse duration from ~ 68 µs to ~ 88 µs. It was a coincidence that the time fits so well.
I only changed a 'MOVLW 0x1' to 'MOVLW 0x2' at one point, and the adapter works.
With the original firmware, I get a question mark instead of a digit every 2 to 3 seconds in the Brymen software, for example.

Edit: It is also possible to change the serial number. You can also use a correct UNICODE string, but then only with four characters, e.g. "1234".

Peter

Code: [Select]
Address       Opcode            DisAssy
26B4          5C10        SUBWF 0x10, W, ACCESS
26B6          0E00        MOVLW 0x0
26B8          5811        SUBWFB 0x11, W, ACCESS
26BA          E20A        BC 0x26D0
26BC          0E01        MOVLW 0x1  <<==>>  change to MOVLW 0x2 (0E02)
26BE          6EE6        MOVWF POSTINC1, ACCESS
26C0          ECDA        CALL 0x2BB4, 0
26C2          F015        NOP
26C4          52E5        MOVF POSTDEC1, F, ACCESS
Code: [Select]
; Serial number.
; Address 0x2A19 String Descriptor
db 0x0A ; bLength - Descriptor size in bytes (variable)
db 0x03 ; dDescriptorType - The constant String (03h)
db 0x11 ; Brymen Serial number 233380011
db 0x00 ; 0x0000000233380011
db 0x38
db 0x33
db 0x02
db 0x00
db 0x00
db 0x00

; Serial number.
; Address 0x2A19 String Descriptor
; db 0x0A ; bLength - Descriptor size in bytes (variable)
; db 0x03 ; dDescriptorType - The constant String (03h)
; db '1' ; Serial number 1234
; db 0x00
; db '2'
; db 0x00
; db '3'
; db 0x00
; db '4'
; db 0x00
« Last Edit: March 16, 2024, 06:24:06 am by Fenstergucker »
 

Offline Furna

  • Contributor
  • Posts: 15
  • Country: de
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #5 on: March 13, 2024, 08:58:27 pm »
Hi Peter,

I ordered my first Brymen BM869s and I ordered also the USB adapter BU-86X; the idea was exactly to avoid losing time/effort and start logging data straight away.
Indeed I received the BC-86P in the BU-86X box ... I am emailing the vendor right now; still I didn't read thoroughly your post anyway it seems I must learn some new skills.
Meanwhile, thank you in advance  ;)
Luca
2069978-0
The sky above the port was the color of television, tuned to a dead channel.
 

Offline FensterguckerTopic starter

  • Contributor
  • Posts: 22
  • Country: at
    • Private Website
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #6 on: March 16, 2024, 07:39:11 am »
Just found it at Kiriakos, he had posted here in the forum earlier:

"BRYMEN BM869s revision of 2023 & Communication errors with BC-86P USB"
https://www.ittsb.eu/forum/index.php?topic=1867.0

Peter
 
The following users thanked this post: Furna

Offline Furna

  • Contributor
  • Posts: 15
  • Country: de
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #7 on: March 16, 2024, 09:46:03 am »
Hi Peter,

I now read better your post.
I confirm that a simple stripe of paper between the transmitting IR-LED and the receiving fototransistor "solves the issue".
2075747-0
I consider this the best option at the moment; no sticky stuff around that get loose, no crack open the adapter.
I am setting up a test of a couple of hours (programmable power supply, reading from the multimeter) to verify the stability and reliability.

Thank you for the link to Kiriakos's post.
He is blaming Brymen for replacing the transmitting IR-LED in the multimeter; I am not 100% sure they did.
Indeed you reported that with an older USB adapter there are no issues at all; this demostrates that the IR-LED in the multimeter was not replaced.
I guess it is more Brymen was trying to cut costs getting rid of unneeded products, and someone declared the BM869s compatible with BC-86P.
This is not the case ... even during the software installation from the CD (you are requested to type in your multimeter model, so the right combination software/driver is choosen) you are alerted to be sure to have a BC-86x adapter.
2075753-1
I am in touch with the vendor and Brymen, anyway in my case Brymen still don't recognize their mistake.
At this point I am still not aware what resistor should be replaced in the multimeter and I have to admit I would prefer to work on the adapter instead.

Nevertheless, I'll wait for Brymen and live with what I have at the moment.
Luca
« Last Edit: March 16, 2024, 09:48:14 am by Furna »
The sky above the port was the color of television, tuned to a dead channel.
 

Offline FensterguckerTopic starter

  • Contributor
  • Posts: 22
  • Country: at
    • Private Website
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #8 on: March 16, 2024, 10:12:41 am »
Hello Luca,

I can measure that the IR LED sends a stronger signal than the BM869s from 2014.

The resistor 102 should be changed from 200 Ohm to 470 Ohm, see photo.

I have a second BC-86P adapter with the patched firmware, which now works without errors.
If you want we can swap the adapters, further details better by private message.

Peter
« Last Edit: March 16, 2024, 10:17:03 am by Fenstergucker »
 

Offline Furna

  • Contributor
  • Posts: 15
  • Country: de
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #9 on: March 17, 2024, 09:26:02 am »
Hello Luca,
I can measure that the IR LED sends a stronger signal than the BM869s from 2014.
Hello Peter,
Understood; I hope at one pont in my life I will have all the tools and the *expertise* you have ;-)

Quote
The resistor 102 should be changed from 200 Ohm to 470 Ohm, see photo.
Note taken and photo downloaded.
As I wrote already: even if I am able to desolder/solder that resistor (I think I also have a 470 Ohm around somewhere) I prefer to work on the adapter.

Quote
I have a second BC-86P adapter with the patched firmware, which now works without errors.
If you want we can swap the adapters, further details better by private message.
Thank you for your kind offer, anyway I will stay with what I have at the moment.
Yesterday's reliability tests were succesfull and I now have a fully "working" environment.
Nevertheless I am interested in learning new skills and I could in the future go down the rabbit hole of modifying my adapter.
- read the original firmware from PIC18F4550 (what programmer are you using with MPLAB X?)
- disassamble the original firmware (is MPLAX X able to do this?)
- change "26BC          0E01        MOVLW 0x1  <<==>>  change to MOVLW 0x2 (0E02)"
- recompile and write to PIC18F4550
I guess these are the steps; am I right?

Quote
Peter
Luca
« Last Edit: March 17, 2024, 09:28:10 am by Furna »
The sky above the port was the color of television, tuned to a dead channel.
 

Offline FensterguckerTopic starter

  • Contributor
  • Posts: 22
  • Country: at
    • Private Website
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #10 on: March 17, 2024, 10:05:23 am »
Hello Luca,

I use tools from mikroE to read out and program the PICs, e.g. PICFlash2 or development boards like EasyPIC3. I also have an ICD3 from Microchip, but I don't like using it.

After reading out the PIC, bytes can be changed directly with the programming software and then written back. Alternatively, the data can usually be saved in a HEX file in Intel HEX format.

The HEX file can be imported into a prepared empty MPLAB X project. The memory can then be displayed disassembled.

I have edited this output to obtain a compilable assembler file. You also have to correct errors in the disassembled code, e.g. replace the constants FSR0 etc. with FSR0L. Only then was it easier to read the code and I was able to quickly find the place where the signal of the phototransistor is read in, for example. The disassembled code also uses absolute addresses, which means that changes such as inserting or moving code are difficult to make. But changing and compiling an instruction is now easy.

I have not published the HEX file and the project here because I don't know how Brymen will react. But I am happy to pass on the data by e-mail, for example.

Peter
 

Offline FensterguckerTopic starter

  • Contributor
  • Posts: 22
  • Country: at
    • Private Website
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #11 on: March 18, 2024, 12:45:34 pm »
I measured again at rest and recorded the signal with a DIY adapter using only a phototransistor and resistor. The reference in white is from the new BM869s from 2024. Channel 3 is the signal from the old BM869s from 2014. The signal from the IR LED is stronger on the new BM869s.

01 Phototr-Ref-is-BM869s-2024.png

I have changed the original firmware so that pulses are output at pin RC2 when a byte is read in. This allows me to trigger more precisely with the oscilloscope.
You can see the signal measured at the BC-86P adapter via the phototransistor, with and without adhesive tape on the adapter. If I understand the code correctly, the signal is read in shortly before the edge changes. However, the signal often changes at this point, which causes the read errors. This does not happen with adhesive tape or with patched firmware.

06-BC-86P-Normal-&-Tape-BM8.png

Peter
 

Offline Furna

  • Contributor
  • Posts: 15
  • Country: de
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #12 on: March 21, 2024, 05:46:19 pm »
I have not published the HEX file and the project here because I don't know how Brymen will react.

I have the impression Brymen is reading ... I got an answer from Brymen and I was suggested to change a resistor on the adapter as I wrote I was more inclined.
Resistor to change is R9 from 6.8KΩ to somewhere between 2kΩ and 3.9kΩ with 3.9kΩ preferred. I only had a 3.3kΩ so I used that one ... success!
The adapter passed 2 sessions of 2 hours of test.

The sky above the port was the color of television, tuned to a dead channel.
 
The following users thanked this post: Fenstergucker

Offline FensterguckerTopic starter

  • Contributor
  • Posts: 22
  • Country: at
    • Private Website
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #13 on: March 22, 2024, 08:24:47 am »
Here is another measurement with 8.2 kOhm in parallel with R9. I measured 3.68 kOhm.
The references in pink show the original state. It is the worst signal I could record, i.e. closest to the sample point. I have not detected any reading errors.

Peter
 

Offline Furna

  • Contributor
  • Posts: 15
  • Country: de
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #14 on: March 22, 2024, 12:14:40 pm »
Does the BC-86P adapter with the modified R9 resistance works with the old BM869s?
Thank you.
The sky above the port was the color of television, tuned to a dead channel.
 

Offline FensterguckerTopic starter

  • Contributor
  • Posts: 22
  • Country: at
    • Private Website
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #15 on: March 22, 2024, 12:31:22 pm »
Hello Luca,

Yes, the adapter also works with the old BM869s from 2014. Here is a measurement with the old BM869s. The reference in pink is again the original signal (R9 6.8 kOhm), in white the BM869s from 2024 (R9 3.7 kOhm), so there are no reading errors.

Peter
« Last Edit: March 22, 2024, 12:54:10 pm by Fenstergucker »
 

Offline marrob

  • Contributor
  • Posts: 23
  • Country: gb
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #16 on: March 29, 2024, 04:14:59 pm »
Excellent detective work Peter and thanks for sharing all the details. I too have just bought a BM869s and BU-86X and have the same problem. I was considering returning it until I found this thread by searching for "BC-86P". Inserting a strip of paper has got it working for me in the short term.

It's very disappointing that Brymen let this through their quality control, but even worse that they haven't told their dealers to stop selling them (I bought mine on March 25th). The correct solution is for Brymen to recall the USB interface and replace it with one that works. We shouldn't have to modify brand new equipment.

I have contacted the UK dealer that sold the meter to me in the hope that they will encourage Brymen to sort this out.

Thanks again for all the info,
Martin
 
The following users thanked this post: Fenstergucker

Offline HubertGlaubke

  • Newbie
  • Posts: 1
  • Country: us
    • ousm adapter
Re: Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI
« Reply #17 on: April 27, 2024, 08:55:01 am »
It sounds like you've been quite industrious in tackling the compatibility issue with your Brymen multimeter and the USB adapter. Converting the firmware from assembler to mikroC, and then to an MPLAB X project with XC8, shows a significant effort in modernizing and maintaining your project.

Using the USBTMC protocol and SCPI commands allows for versatile communication between devices, and it's great that you've been able to implement this functionality in your firmware. Being able to modify VID/PID and string descriptors via SCPI commands adds flexibility and customization options to your setup.
OUSM Ac Adapter Manufacturer:  https://www.ousmpoweradapter.com/
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf