Brymen BC-86P USB-Adapter - Firmware with USBTMC & SCPI - Page 1
Forum section: electronics / projects

author: Fenstergucker
author_rank: Regular Contributor
timestamp: March 07, 2024, 09:39:10 am
content: 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).PeterEdit: New Hex fileCode: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: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 0x3701The values are saved in the EEPROM.Code:SCPI commands:*IDN?:ECHO? textAvailable, 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:Example values:1.55911.5593 V DC-1.5594 V DC1.5599 V DC0.027 V AC1.5596 V DC AVG-.--- V AC1.5598 V DC MAX0.027 V AC0020.9C °C020.7 °C00.014 mA DC+AC00.02 mA AC00.000 mA DC-25.00 %4-20mA-000.09 ^ mV DC001.0 mV AC.0L Vdiod013.78 Ohm-000.052 mV DC-999999 (read error)

author: Fenstergucker
author_rank: Regular Contributor
timestamp: March 08, 2024, 04:11:55 pm
content: 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: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

author: Fenstergucker
author_rank: Regular Contributor
timestamp: March 09, 2024, 07:21:50 am
content: 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

author: Fenstergucker
author_rank: Regular Contributor
timestamp: March 10, 2024, 08:27:48 am
content: 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.pngThe signal changes when it should be stable.BC-86P-Signal-TX-RX-Phototr-4.pngAdapter with adhesive tape, the signal arrives earlier.BC-86X-Signal-TX-RX-5.pngThe old BC-86X adapter has a much more stable signal. I have not measured the phototransistor.BC-86P-Signal-TX-RX-Phototr-6.pngThe 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 PIC18F4550BC-86X from 2014 with Cypress ChipEnclosed is the current hex file and code. The empty battery symbol is now also displayed when the units are read in.Peter

author: Fenstergucker
author_rank: Regular Contributor
timestamp: March 10, 2024, 06:16:46 pm
content: 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".PeterCode:Address Opcode DisAssy26B4 5C10 SUBWF 0x10, W, ACCESS26B6 0E00 MOVLW 0x026B8 5811 SUBWFB 0x11, W, ACCESS26BA E20A BC 0x26D026BC 0E01 MOVLW 0x1 <<==>> change to MOVLW 0x2 (0E02)26BE 6EE6 MOVWF POSTINC1, ACCESS26C0 ECDA CALL 0x2BB4, 026C2 F015 NOP26C4 52E5 MOVF POSTDEC1, F, ACCESSCode:; Serial number.; Address 0x2A19 String Descriptordb 0x0A; bLength - Descriptor size in bytes (variable)db 0x03; dDescriptorType - The constant String (03h)db 0x11; Brymen Serial number 233380011db 0x00; 0x0000000233380011db 0x38db 0x33db 0x02db 0x00db 0x00db 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

author: Furna
author_rank: Frequent Contributor
timestamp: March 13, 2024, 08:58:27 pm
content: 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 advanceLuca

author: Fenstergucker
author_rank: Regular Contributor
timestamp: March 16, 2024, 07:39:11 am
content: 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.0Peter

author: Furna
author_rank: Frequent Contributor
timestamp: March 16, 2024, 09:46:03 am
content: 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".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.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

author: Fenstergucker
author_rank: Regular Contributor
timestamp: March 16, 2024, 10:12:41 am
content: 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

author: Furna
author_rank: Frequent Contributor
timestamp: March 17, 2024, 09:26:02 am
content: Quote from: Fenstergucker on March 16, 2024, 10:12:41 amHello Peter,Understood; I hope at one pont in my life I will have all the tools and the *expertise* you have ;-)QuoteNote 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.QuoteThank 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 PIC18F4550I guess these are the steps; am I right?QuoteLuca

author: Fenstergucker
author_rank: Regular Contributor
timestamp: March 17, 2024, 10:05:23 am
content: 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

author: Fenstergucker
author_rank: Regular Contributor
timestamp: March 18, 2024, 12:45:34 pm
content: 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.pngI 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.pngPeter

author: Furna
author_rank: Frequent Contributor
timestamp: March 21, 2024, 05:46:19 pm
content: Quote from: Fenstergucker on March 17, 2024, 10:05:23 amI 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.

author: Fenstergucker
author_rank: Regular Contributor
timestamp: March 22, 2024, 08:24:47 am
content: 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

author: Furna
author_rank: Frequent Contributor
timestamp: March 22, 2024, 12:14:40 pm
content: Does the BC-86P adapter with the modified R9 resistance works with the old BM869s?Thank you.

author: Fenstergucker
author_rank: Regular Contributor
timestamp: March 22, 2024, 12:31:22 pm
content: 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

author: marrob
author_rank: Contributor
timestamp: March 29, 2024, 04:14:59 pm
content: 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

author: HubertGlaubke
author_rank: Newbie
timestamp: April 27, 2024, 08:55:01 am
content: 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.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: September 20, 2024, 01:15:34 pm
content: First, a big thank you for the code. I have not gotten IR fully working yet on my BM869s but I'm close. Before I fix the firmware library and get it working on a good old ATmega8I want to add a screenshot I made just now.At the moment an output pin of my uC is connected with a 270 Ohm series resistor and an IR LED to GND, resulting in 1.5V pulses on yellow when the LED is on. Purple is read back from the Brymen. It is a 24kOhm pullup resistor on a photo diode. No transistor amplification. It's also built on a breadboard right now and it's still a work in progress.Both IR LED and photodiode are random parts from my junk bin and had been laying in a drawer for 15+ years.I am also fiddling a bit with timing. When I send IR pulses shorter then 5us, then the Brymen does not see them. to leave room for aging and "randomness" I settled on a pulse width of 20us. (Software delay is a bit off).This delay is also comparable with the reaction time of the BM869s, so instead of sampling the data on the negative going flank, I first do the second delay, and sample just before I send the next IR pulse. With this timing communication is twice as fast as the "original". I could probably make it twice as fast again, but there is absolutely no need for this. If I am going to optimize further, then it would be by putting the software timing into an ISR thing, but I'm not sure that is worth it.// Send 8 light pulses, and read back the byte from the BM869s.uint8_t ReadByte(void) {uint8_t iResult;uint8_t iMask;iResult = 0;for (iMask = 1; iMask != 0; iMask <<= 1) {IrLedOn( );_delay_us(20);IrLedOff();_delay_us(30);if ( IrFotoIn( )) { // pinFoto == eOff) { // Todo: Invert data?iResult |= iMask;}// _delay_us(1);}return iResult;}Edit / Addition: Dazed 'n confused by my silliness.The functions provided by Fenstergucker work quite nicely. Only missing thing was that I forgot to invert the data, which is needed because I made the hardware interface different.