Sencore USB Interface Project - Page 1
Forum section: electronics / projects

author: pigrew
author_rank: Frequent Contributor
timestamp: August 21, 2019, 04:56:51 pm
content: I'm developing a USB interface for various Sencore test equipment (such as their LC102 meter). Their used I/O interfaces (like the IB78) are getting pretty rare and expensive, so I figured I should make something a bit more modern.STATUS: PCB and components have been ordered. FPGA logic development is in progress.The prototype PCB is posted atGitHub.If you're interested in buying one (either assembled or as a kit), send me a PM.Original Post:Another reason I want one is that a LC102 asks you to use a special stick to hold down a front-panel button to do burn-in tests of capacitors, but with an I/O interface, one can just ask it to do burn in and also log data.I'd greatly appreciate any comments on the schematic (or even layout) before I order boards. Also if any others are interested in the product, let me know. I can easily sell/distribute (bare PCB+8243) to folks in the USA (I'm not sure what shipping costs to foreign countries). If there is a huge interest, I may even look into having JLCPCB do assembly for me.The genuine interface boxes are based on an 8243 I/O expander and a microcontroller. I've reimplemented it using a 8243 (discontinued but available on eBay) and a STM32 microcontroller. The genuine boxes are not isolated which leads me to have some safety concerns due to the LC102's ability to output a floating 1000 V, with the I/O interface ground connected to the instrument's negative output. Therefore, I've added isolation to the design. Though, I use a 0.1" pin header between GND and EARTH which isn't enough separation, but at least it will be an arc to earth (I also have a shorting terminal for connecting the USB shield to the Sencore's earthed shield).In order to support hot-plug, I've also added a bus switch IC with "I-off" support. The genuine box could crash the meter's MCU bus if plugged in with the box unpowered.The PCB is designed to fit into a Bud HP-3652-B enclosure. I'm planning to have the I/O cable just running through the back panel, though I could switch it to being connectorized. Adding a 0.150"mm pitch Phoenix Contact 1803332 header on the back, but it's a bit large for the enclosure. Other suggestions?There always seems to be conflicting advice on if the USB shield should be shorted to its GND on the downstream side. I'm leaning towards yes, though I've marked it as a capacitor to couple them on the schematic.

author: HighVoltage
author_rank: Super Contributor
timestamp: August 21, 2019, 05:13:38 pm
content: Very interesting.So, this will plug in to the RS232 connector on the back?Will also work on the LC103?You will also provide windows software to control the instrument?Can you also implement it in such a way that it can be used to calibrate the LC103?

author: coromonadalix
author_rank: Super Contributor
timestamp: August 21, 2019, 05:18:21 pm
content: @pigrew super job you did, no pun intended, i would do a single sheet schematic for clarity purposes.

author: pigrew
author_rank: Frequent Contributor
timestamp: August 21, 2019, 08:41:25 pm
content: Hmm, just noticed there is a IB78 on eBay for $140, but that's what I'm aiming to recreate, but with isolation and USB instead of RS232.Quote from: HighVoltage on August 21, 2019, 05:13:38 pmNo, this is designed to go interface with a circular DIN-8 connector on the back of the LC102, which is a 8239 MCU expansion interface, not RS232. My design will act as a USB CDC device (virtual COM port). It replaces the need for an IB78/IB72.Quote from: HighVoltage on August 21, 2019, 05:13:38 pmI don't have a LC103, so cannot test it with one. It looks like the LC103 has a DE-09 connector. I don't know the pinout or even what sort of interface the LC103 uses. I except it will not be compatible.EDIT: Most certainly will not work. I found the schematics of the LC103 and it is RS-232. You could just get a normal USB->RS232 cable and use it to talk to the meter (if you can figure out the command syntax). Be careful with the high voltages, an isolated RS-232 adapter is a good idea.Quote from: HighVoltage on August 21, 2019, 05:13:38 pmNo, I'm planning to only make the hardware to provide a serial port for the meter.Quote from: HighVoltage on August 21, 2019, 05:13:38 pmDoubtful. My suggestion would be to make a ROM dump and try to disassemble the microcode to figure out the calibration commands. The LC102 has published commands for its control, as do their older products. LC102 calibration is by adjusting pots/capacitors.

author: coromonadalix
author_rank: Super Contributor
timestamp: August 21, 2019, 09:38:25 pm
content: Would it be feasible with an bluepill STM32F103C8T6 (128 KB flash, 20 KB RAM) for a 2$ usd boardBuild a daughter board with the other components and the upd8342 ...https://alselectro.wordpress.com/2018/11/18/stm32f103-bluepill-getting-started-with-arduino-core/The yellow underlined are 5v tolerant ports ??thksEDITFound this puppy :https://medium.com/swlh/super-blue-pill-like-stm32-blue-pill-but-better-6d341d9347daat around 6$ usd ??

author: Renate
author_rank: Super Contributor
timestamp: August 21, 2019, 10:14:56 pm
content: That looks pretty through and complete.Still, could we lose that pig of a chip, 8243?It doesn't seem that difficult to make a modern processor just interface with the 4 bit interface directly.The USB isolator is pretty fancy, by why not just optoisolate UART data out of the uP and use an FTDI232 on the cold side?You'd reduce the bandwidth requirement of the isolator a few decades!

author: coromonadalix
author_rank: Super Contributor
timestamp: August 21, 2019, 10:30:48 pm
content: @Renate MaybeI can't catch the logic behind this for an "going to rs232 port".The 8243 has been ported to vhd / vhdl file, some fpga / cpld can take the 8243 task. Tried on an old Xilinx xc9572, it use 52% of its ressources lollNo schematics of the 2 interfaces exists, just pictures of the ib78 and an eeprom dump attached hereI'll try to make a schematic of mine when i'll get it from the usa, bought 1 week ago.Aside note:Just got an usb to rs232 cable sp-880 ---- Ftdi based with an unknown ic in it, who provide some isolation / buffering ... with this cable i can use an equipment still connected to a computer, others adapters dont work unless i use an industrial DIN isolated rs232 interface from polland.I do understand @pigrew concerns,the lc102 can output 1kv in some tests... danger danger will robinson lollStill i would love to build a newer version of this Pigrew IB78 project and hide it directly in the LC102and maybe convert the LC102 back round din plug to a usb input port loll

author: Renate
author_rank: Super Contributor
timestamp: August 21, 2019, 10:46:50 pm
content: Quote from: coromonadalix on August 21, 2019, 10:30:48 pmI'm just saying, have the STM decode the 4 bit data that would come into the 8243.This stuff is pretty slow and with a bit of hopping you can catch it all.Your current design uses a USB port with a CDC interface as a virtual Com Port.My suggestion is having the STM output 3.3V serial data at 115200 (or whatever), push it through a cheap 6N135 optoisolator.On the other side you have an FTDI232 or CP~~~~ that turns into USB and a virtual Com Port on your desktop.I've used this for floating voltage/current measurements.Isolating USB at 12 or 480 Mbs is a bigger deal.

author: pigrew
author_rank: Frequent Contributor
timestamp: August 21, 2019, 11:14:47 pm
content: Great questions.Quote from: coromonadalix on August 21, 2019, 09:38:25 pmMy prototype used a bluepill. It was a heck of a lot of manual wiring, and the bluepill comes misconfigured with the wrong USB pull-up resistor value, and not much ESD protection. Once taking time to do a PCB, one might as well put the micro on the PCB in the first case. So, yep, it would be slightly cheaper to use a blue pill since I can't get parts as cheaply here as in China, but not easier design-wise. Also note that I'm using a STM32F0 which seems to be newer than the STM32F1 series (I don't understand the numbering scheme...)Quote from: Renate on August 21, 2019, 10:14:56 pmCan we get rid of the 8243? Yes, I had assumed not easily with a microcontroller. The slave needs to respond to the bus signal within about 650ns of a falling edge. Assuming 20ns clocks, that's 30 cycles total. With very careful programming (nested interrupts, etc), it may be possible even though I had initially dismissed it. I had imagined implementing it with a FPGA. Another factor is that the bus is 5V logic, so one would need to add a set of transceivers (5 inputs and four tri-state outputs, so 10 MCU IO pins).On a bus read, the MCU would need to quickly latch the data on a the falling edge of nPROG (60ns hold time), decode the instruction, read the appropriate data from RAM, and write the data back to the bus. Perhaps DMA would work to latch the bus data? Oh, and bus reads can happen every 5 or 10us, so the MCU would spend nearly all of its time handling bus I/O.My proposed FPGA solution would have used UART isolators (2 IO and 2 flow control lines), but wouldn't support USBTMC if I ever wanted to implement that. The USB solution has more flexibility (even DFU modes) and the user doesn't have to pay attention to the baud rate or flow control settings. I'd probably use a purpose-built isolation IC (like from Silicon Labs). In terms of board space, the USB isolator is about equal to the UART isolation, and the USB isolator isn't that much more expensive than the digital isolator+FT230X.I was looking at QFP package FPGAs, which would require a bunch of board area and decoupling capacitors.... In particular, I like the MachXO2. A TinyFPGA would be great, but it looks like they are mostly out of stock. However if I do accept QFN soldering, the LCMXO2-256HC-4SG32I may actually work out well. Maybe I'll look back at that solution. A note is that the FPGA needs its own external oscillator, as its internal RC isn't precise enough for use in a UART, so an oscillator needs to be added to drive the FPGA (unless I pass the FT230X's clock output through the digital isolator.).

author: pigrew
author_rank: Frequent Contributor
timestamp: August 22, 2019, 12:32:24 am
content: Another thing that worries me about the 8243 is it seems like the MCU and the 8243 may simultaneously write to the bus during a "read" operation. At the start of a read, the MCU outputs its "read command" on the bus and pulls nPROG low. Then, the 8243 will respond to a read command by putting the data on the bus.Based on the attached diagram, I see no maximum t_B and no maximum t_C, so these could overlap. Based on recording bus traffic, t_A was ~730ns which is very close to the maximum allowed access time (with a 10 MHz clock). How do the chips not fry each other? Is it that the drivers are just really weak and are able to tolerate the contention?

author: coromonadalix
author_rank: Super Contributor
timestamp: August 22, 2019, 02:12:03 am
content: The 8243 was made to work with these cpu in a bidirectional fashion ... thats why we dont see any substitue for it, not sure the ported vhdl equivalent chip would work well in this case ??And the 8250 who act as a fifo / buffer must help.At 19200 bauds around year 1990, must have been a accomplishment lol ??My test board would be an bluepill with the 8243 like i saw on his prototype, add a small 5vdc to 5vdc isolated dc-dc converter, do some tests at 9600 bauds and / or 19200 bauds, no protection added for now (cheap and dirt mode loll) and later just add an usb isolator on the usb line.The 4 poles relay we see, must be activated by the rs232 line, or maybe by the LC102 dtr dsr rqs cts not sur if its work in dte dce ... dce dte mode etc ...Willing to be a guinea pig, i just need a code to compile or dump, i have an st programmer ready loll

author: Renate
author_rank: Super Contributor
timestamp: August 22, 2019, 02:19:52 am
content: The middle trace in that diagram is when the MCU is writing, so of course there is no conflict.The bottom trace is MCU writing, then 8243 writing, i.e. a read.The 8243 responds as quickly as it can to the falling PROG, tACC=650ns maxSince the data hold on the MCU has a minimum of 20nS there should be plenty of elbow room.I just hate the waste of expanding a nibble to 16 bits that you have to stick back into a uP.Silly idea:You could get a little uP, run it in a tight, no interrupts loop and have it spit out the data on SPI to its big brother.

author: pigrew
author_rank: Frequent Contributor
timestamp: August 23, 2019, 04:17:41 pm
content: Ok... Design attempt number 4?I got rid of the 8243, replacing it with a FPGA. I added an earthed STM32f042 MCU to do the USB->UART interfacing. I'm a little bit unsure of all of the bus drivers, or how much extra capacitance I'm adding to the bus (though shouldn't be much more than the IB78 itself). I'm using a bus driver which has two enables, one for nPROG and the other for the signal from the FPGA, which should help avoid any spurious writes to the bus.I'm somewhat worried that I chose the wrong logic families for the bus I/O? (bus is 5V, CMOS levels). The MCU and FPGA are both 3.3V. I'll probably end up running the UART at 100 or 250 kHz.I also found out that I've been doing micro-USB ports the wrong way. Standard micro-USB connectors are "bottom-mount", but based on the enclosure I really need a "reverse" top-mount connector. I guess people are supposed to put the USB transceiver on the bottom of the board, so the USB tracks don't need to via up or down. I also would have rathered an integrated USB line filter+ESD package, but I couldn't find any without an internal pullup, so I'm using a 5-pin TVS package, and external series termination resistors.

author: coromonadalix
author_rank: Super Contributor
timestamp: August 23, 2019, 05:50:49 pm
content: I would ditch all esd protection, an direct dc supply line from the dc-dc, no USB Soft-start, OVP, OCP circuit, just an good reset line.Maybe i would add an 9600 baud and the 19200 baud selector, many serial to usb port are at 9600 bauds "default" until you crank it up to 115200. Unless there is some baud detection implementedNot for a low parts count, but i do think its a little too much, your protection is added with the small dc-dc converter and an usb isolator.We use SMS05C protection ic's around our ATF1504 cpld design, no speed or capacitances issues.https://www.onsemi.com/pub/Collateral/SMS05C-D.PDFAnd we use TXB0108 voltage translation ic's in our embedded boards.https://cdn-shop.adafruit.com/datasheets/txb0108.pdfJust received my IB78, same eeprom version than yours, and i got an usb rs232 optoisolated db25 adapter who go nicely on the box, it has an micro dc-dc converter in it.Jus battling with the IB78 dc plug, too deep for my taste, will connect it to the lc102 and see ... with an window terminal how it goes.An idea would be to add a suplemental pin in the din plug for the IB78 supply power ... i put an 18v 3.46 amp laptop adapter on my lc102, enough power to do, and it does 100-250 vac line

author: pigrew
author_rank: Frequent Contributor
timestamp: August 23, 2019, 08:17:58 pm
content: Anther question is the FPGA to bus transceivers. I noticed that there are bidirectional bus I/O chips like TXS0108E (5.5 pF) or like SN74LVC8T245 (8.5 pF). It would save four pins on the FPGA to use them, but there the FPGA has enough pins already.... These are about equal capacitance to the existing solution of a receiver and a transmitter IC (4 pF + 2 pF), though there would be less parasitic capacitance. My plan would be to continue as I've posted.ADDITION: The TXS0108E and TXB0108 are bad ideas due to the high bus capacitance of the meter+IB cable.Quote from: coromonadalix on August 23, 2019, 05:50:49 pmRegarding ESD, I'd like to at least keep the pads on the PCB, but feel free to not populate them if you prefer living dangerously.ANOTHER ADDITION: Maybe we the FPGA is low power enough that we can parasitically draw power from the I/O lines? (I'm mostly joking)EDIT #3: Apparently the STM32 has built-in series termination resistors, so the 22 ohm ones need to go away (or be populated with shunts). STM32L0x2 would be another good choice of STM32, but no huge benefit in this application (that I know of).

author: pigrew
author_rank: Frequent Contributor
timestamp: August 24, 2019, 05:58:51 pm
content: Another round of updates, though only minor tweaks. I changed to a full size USB jack and added a jumper to go between (Sencore Earth + USB_SH) instead of (Sencore Earth + GND) nets. I've also adjusted the USB series resistors to be 0-ohm instead of 22 (STM32 has internal 40 ohm drivers). I also changed the STM32 programming header pins to suit the layout better (It's not a standard pinout).(To view the 3D PDF, usually I have to use Acrobat and click at button at the top of the window to "trust" the document.... Is there a better way to transmit 3D models for mass consumption?)

author: coromonadalix
author_rank: Super Contributor
timestamp: August 25, 2019, 12:04:12 am
content: Hi im back soonerIs it possible to use tqfp packages for the machx02 chip, thoses qfn packages are a pain to work, will you assemble the pcbs ? normally you need stencils and a very fine solder paste for them, i work with the same 32 pins package, if you need to rework them or unsolder them, you absolutely need an hot air station, the under center pad dissipate lots of the needed heat into the pcb.For J1 pcb output to the LC102, i would use the same mta100 connector, or any 0.1" pitch connector, it would be easier to make a bridge connector between your interface and the lc102, i have thoses tools at my job, i could make many cables for you or even use already made dupont male to male wires, or maybe an idc10 connector, or a 2x5 pins 0.1" header ?my 2 centsI would have put your 4 holes at the corners, not in the center, but you had an enclosure in mind if i recall, that way U10 would be pushed more in the center of the pcb, shorter pcb traces ??

author: pigrew
author_rank: Frequent Contributor
timestamp: August 25, 2019, 03:01:57 pm
content: Quote from: coromonadalix on August 25, 2019, 12:04:12 amThe smallest TQFP has 100 pins, so much more board space. I decided to use the QFN32 since it comes in two convenient sizes (256 and 1200 LE) and has enough pins.If JLCPCB doesn't remove the solder mask between pins, they are not too difficult to solder.Quote from: coromonadalix on August 25, 2019, 12:04:12 amIt's a hard choice. I want some sort plug with strain relief. The Phoenix Contact ones are certainly not ideal, but I'm having trouble convincing myself that some other connector is appropriate. DIN-7 is too large for the enclosure I selected, mini-din8 might be too low voltage? (Even though I'm focusing on isolation, there shouldn't be much of a voltage differential in practice. I just really don't want to fry the computer). But, now I'm leaning towards DE-9 (a.k.a DB-9). It's shielded, has higher voltage ratings, cheap, and somewhat easy to assembly.Quote from: coromonadalix on August 25, 2019, 12:04:12 amYeah, I'm designing the PCB around the Hammond 1593J enclosure. I don't really like the locations of the mounting holes, but they are where they are...

author: coromonadalix
author_rank: Super Contributor
timestamp: August 25, 2019, 04:47:12 pm
content: The db9 may add confusion, people may think its an serial portOr an idc10 angled connector with latches ??https://www.futurlec.com/Connectors/IDCMHL10RApr.shtml

author: pigrew
author_rank: Frequent Contributor
timestamp: August 27, 2019, 10:21:27 pm
content: I've ordered a set of 5 PCBs with a final design. I realized the microcontroller is TTL-level (not CMOS level), so I am able to use a simpler bus level translator IC, instead of a separate input and output IC. This frees up a few FPGA I/O pins, allowing the layout to be more compact and the addition of a debug LED. I did use the DE-9 connector, and am planning to plug one pin to prevent RS-232-level signals from being connected, although the ESD TVS Zeners (and series resistors) may prevent damage to the components. The USB-UART bridge will uses a STM32F052 MCU. My current plan is for it to be a CDC device, but I may eventually implement USBTMC so that it interacts with instrument control software more nicely.Schematics and PCB data filesare posted.I missed tweaking the locations of a few designators, but have not found any serious mistakes (yet).Seems I used an unregulated isolated DCDC converter; I'll need to regulate its output, switch converters, or add a resistive load (~150 mW)...(If anyone wants a build (or a kit), I should be able to sell you one once I test the software/design, though I won't offer any sort of warranty. Send me a PM and we'll work something out. Software will put put on github once the hardware is built.)

author: coromonadalix
author_rank: Super Contributor
timestamp: August 28, 2019, 12:35:17 am
content: Pm'ed you thks for your great work.

author: pigrew
author_rank: Frequent Contributor
timestamp: September 03, 2019, 11:04:18 pm
content: PCBs have arrived... they're tiny. I'm surprised that I didn't get hit by Trump's tariffs... Logistically I don't know who I would pay, or how.I've found a few minor issues with the schematics, but nothing insurmountable. Parts should arrive in the next few days. Next time I should look more carefully at the the amount of RAM the micro has, 6 kB is about the minimum for a STM32 USB device, it seems. I used the TSSOP-20 package, which is only shipping with minimal RAM. The QFP packages have more options.USBTMC or CDC? I'm tempted to sit down and write a simple USBTMC driver...Photo below, with a RMB, 10 HK$ and 25 cents, for scale.

author: coromonadalix
author_rank: Super Contributor
timestamp: September 04, 2019, 02:04:46 am
content: damn tiny they are loll

author: ebclr
author_rank: Super Contributor
timestamp: September 04, 2019, 11:53:58 am
content: Take a look on this little board, your work can be quite easier and cheaperhttps://www.electrodragon.com/product/ch552-ch554-mini-dev-board-ch55x-series/

author: pigrew
author_rank: Frequent Contributor
timestamp: September 04, 2019, 01:10:59 pm
content: Quote from: ebclr on September 04, 2019, 11:53:58 amIf only it were that easy. Those CH55x might be easier to use than the STM32 (though probably not for me as the English documentation is lacking), but it wouldn't remove most of the PCB components from this project. The issue is that the circuit must speak as a MCS-48 IO expander on the bus, which requires somewhat fast timing. The CH55x doesn't look like it has that capability. Also, the Sencore bus uses TTL-drivers with 5V pull-ups, so voltage translation is still needed.(The CH552 board also doesn't provide any isolation or ESD protection, which I also wanted...)The FT2232H almost worked, but it's expander mode is for the MCS-51 bus, not MCS-48. The MCS-48 8243 has special op-codes to AND and OR memory locations which were dropped in the MCS-51.ADDED LATER: Unless I'm missing some feature about the CH55x? I could have strung together a bluepill or USB-UART, isolator, another blue pill, 8243.. Would have been less design effort.

author: coromonadalix
author_rank: Super Contributor
timestamp: September 04, 2019, 01:16:13 pm
content: for the ft2232, i use at my job a kanda atf1504 programmer .. around 50$ usdit is an ft2232d inside

author: pigrew
author_rank: Frequent Contributor
timestamp: September 09, 2019, 01:31:26 pm
content: I finally have a PCB that doesn't fry itself when plugged in.Unfortunately I had to make a few modifications to the board due to my swapping pins and grounding things when making the schematic. Adding a bunch of 0402 pull-down resistors works, but isn't too fun. At least now I can make blinking LEDs from the FPGA and get the micro to connect to a USB host (even in DFU mode). The micro can be programmed via USB or JTAG... whichever. The FPGA still needs a JTAG programmer. If I used a larger isolator and had pins to spare, I could have programmed it from the micro over SPI... (CS, data_in, data_out, clock, interrupt?)Speaking of USB, I really dig the red color of the selected USB port, but not so much the high retention. I feel like I'm going to rip the board apart when plugging in a USB cable.I got distracted by writing a USB driver for the STM32F0. The one ST provides uses a bit too much RAM and is just generally too bulky for such a small micro. I've been working on porting TinyUSB to it, though are were a few other choices, such as libopencm3 and Keil.

author: pigrew
author_rank: Frequent Contributor
timestamp: October 02, 2019, 12:39:10 am
content: Argh, signal integrity!The USB interface is now mostly working, which is great. However, I'm getting errors when transmitting certain commands, and I believe it is due to signal integrity issues.The modern driver ICs have much too high of a drive strength, creating fast edges, inducing large amounts of crosstalk.The interface uses one unidirectional nPROG line and a bidirectional 4-bit bus. I assembled a 50cm long shielded cable, and when probing nPROG (~4cm probe wires to a 1.5 GHz active probe), see nPROG bouncing about 1.9 V when my driver outputs to the 4-bit bus. This crosstalk is sometimes causing the FPGA to trigger a second time on the nPROG line (it's edge triggered). The bus driver outputs to the bus a few internal clock cycles after the falling edge of the clock (in order to decrease the chance of bus contention) which causes the observed jitter.At the moment, earth is isolated from circuit common on my interface board. Common is connected to earth inside the Sencore chassis by ~10kohm. Perhaps I'll end up putting a small cap (47pF?) from the shield to common, and connect the shield continuously to the USB shield.Since everything is so slow (data access time is supposed to be <750 ns), I think the solution is to just increase the series resistance on the 4-bit bus. I'm presently using 33 ohm, but will boost it to 220 ohm or so. Guestimating 150 pF of load capacitance, this will give a 76 ns rise time (plenty fast).I really like Okawa's RC calculator page for computations like this.On the USBTMC front, I got my most of my USB class driver changes merged into the TinyUSB project, so I'm communicating over USBTMC and not CDC, which is pretty nice. (I just ordered a rough looking HP 432A power meter from eBay, I think I'll retrofit a USB SCPI interface into it, and maybe a digital display).FOLLOWUP: It was inductive coupling (not capacitive like I had guessed). My circuit was driving the bus too soon and there was contention on the bus for about 300 ns, creating pretty severe current spikes (hopefully made less damaging by the 33 ohm resistors I had). I was driving the bus 125 ns after the clock edge, but the MCU goes tri-state after about 600ns. Replacing the resistors with 300 ohm and also delaying driving the bus ~700ns after the clock edge helps, and sending commands is more reliable. However, it may not be data-sheet compliant for the bus because the access time is supposed to be <650ns. With the required timing, bus contention seems guaranteed.