A simple tool to aid in reverse engineering a PCB - Page 1
Forum section: electronics / projects

author: intabits
author_rank: Frequent Contributor
timestamp: November 30, 2018, 05:11:48 am
content: Top ImageBottom ImageMerged for tracing

author: DaJMasta
author_rank: Super Contributor
timestamp: November 30, 2018, 06:21:57 am
content: Works great until it's double sided or more

author: 001
author_rank: Super Contributor
timestamp: November 30, 2018, 06:24:22 am
content: Do You use X-ray machine?

author: Archangel1235
author_rank: Newbie
timestamp: November 30, 2018, 06:30:00 am
content: Quote from: 001 on November 30, 2018, 06:24:22 amHe's just keeping two images one on top of the other with some transperency

author: BBBbbb
author_rank: Unknown
timestamp: November 30, 2018, 09:37:21 am
content: Adding some cropping and centering would make it useful. You cannot rely on having two perfectly superimposed images.If you have to open some more powerful image editor to adjust the images for your SW, you might as well finish the job there playing with transparency.

author: intabits
author_rank: Frequent Contributor
timestamp: November 30, 2018, 11:41:03 am
content: Quote from: DaJMasta on November 30, 2018, 06:21:57 amIt is just a simple thing, for simple jobs. Exploring an idea.But with double sided PCBs, it would still be of value I think. Traces under components would be a problem, but it apart from that, it would allow a trace to be followed around the PCB from top to bottom through vias and pads.If you find yourself tracing out a (simple-ish) PCB, even double sided, it's got to be a help.Quote from: BBBbbb on November 30, 2018, 09:37:21 amAs to alignment, I envision just having a corner jig to position the PCB with stability, and a camera on a small tripod looking down on it.Take a snap, flip the PCB, position into the corner, take another snap.Use dumb old MS-paint to crop the images, using the corner jig edges as one reference, and just make sure that the X-Y pixels counts are similar on both images. Done.Or just select the PCB area, also easy.But yes, cropping, scaling, rotation and alignment facilities could be added.I'm just presenting an idea here, not a finished, all singing, all dancing product.This could be taken a lot further, with a facility to add overlaid component designators, marking pad and via positions, and maybe even component outlines.Then a facility to click all the pads in a net, resulting in a netlist for input to some other EDA system.

author: rhb
author_rank: Super Contributor
timestamp: November 30, 2018, 12:09:18 pm
content: That looks like an undamaged IBM mainframe card. Do you have any more? If so send me a PM. I'd like to buy one.I have one I bought in the 60's for the transistors, but the connectors were broken off before they were scrapped.

author: Simon
author_rank: Unknown
timestamp: November 30, 2018, 02:36:02 pm
content: I have done this in the past. Scanners make very good work of taking a picture of a PCB that will be easy to line up with another picture of the same PCB.

author: StillTrying
author_rank: Super Contributor
timestamp: November 30, 2018, 03:14:40 pm
content: All that's needed now is the software to read the image and draw the schematic.

author: Simon
author_rank: Unknown
timestamp: November 30, 2018, 03:25:09 pm
content: Quote from: StillTrying on November 30, 2018, 03:14:40 pmKilljoy

author: intabits
author_rank: Frequent Contributor
timestamp: November 30, 2018, 04:56:46 pm
content: Quote from: rhb on November 30, 2018, 12:09:18 pmIndeed it is. This particular one is the error amplifier for a power supply (full PS schematic in the ZIP). I too bought them without the fingers back in the '60's.But in the late 70's it was ME breaking them off for the gold. I had about 7000 of them.I still have quite a few, but being in the US, it would probably be cheaper for you to buy them on eBay.People do want a lot for them, but I don't think they sell many, so I reckon they'd take a lower offer.Look for "IBM SMS card" (which stands for Standard Modular System)If you can't get one at a reasonable price, you can PM me.

author: DaJMasta
author_rank: Super Contributor
timestamp: November 30, 2018, 04:57:54 pm
content: Quote from: intabits on November 30, 2018, 11:41:03 amCould be an interesting exercise to try, I would think traces under traces would be the biggest problem visually. That said, I wonder if you could adjust the colors for each layer, like CAD software does, and then overlay them. Maybe the contrast of colors could be enough to distinguish them with some practice.

author: jmelson
author_rank: Super Contributor
timestamp: November 30, 2018, 08:55:56 pm
content: Quote from: rhb on November 30, 2018, 12:09:18 pmYes, that is an SMS card, used in 1401, 1620, 707x and 709x machines by the zillions. (7094 had 11,000 SMS circuit cards!Totally blows my mind how they even kept such a machine running.)These are certainly collector's items today.Jon

author: cdev
author_rank: Super Contributor
timestamp: November 30, 2018, 09:07:57 pm
content: Use a scanner with a transparency adapter and cut a mask that puts the PCB in the middle of a piece of opaque paper so the light from the transparency adapter doesn't wash out the image by shining around the sides. Take both reflective and transmissive images. Bracket your transmissive exposures.Shining a light through often is the key to figuring out where inner traces go.Also photos taken like that often make neat 'electronics' images artistically.

author: Simon
author_rank: Unknown
timestamp: November 30, 2018, 10:14:39 pm
content: Yes if you need a "photo" of a PCB and it needs to be in the flat a scanner is the best way, and way more resolution than a camera.

author: CatalinaWOW
author_rank: Super Contributor
timestamp: November 30, 2018, 10:20:37 pm
content: Some work with an image editor (changing hues etc) prior to superposing the images can help on double sided boards. If you are really familiar with image editing you can do even more to separate traces, hardware, components and solder mask.

author: Macbeth
author_rank: Super Contributor
timestamp: November 30, 2018, 10:41:47 pm
content: I use Photoshop especially with boards that have been photographed at different angles. You identify or make your own fiducials and then apply the warp/transform filters with the mirror and of course transparency tools. CS2 is free since they abandoned their servers. Somehow I have CS6 for free too, I don't know what happened there.. But GIMP should do too.

author: ogden
author_rank: Super Contributor
timestamp: November 30, 2018, 10:45:19 pm
content: Only tool you need after such a photos is brain. You shall consider it as an compliment because photos are pristine

author: janoc
author_rank: Super Contributor
timestamp: December 01, 2018, 12:36:33 am
content: Quote from: intabits on November 30, 2018, 11:41:03 amA better solution is to get rid of the tripod (so that you can use a phone instead of a camera/scanner that may not be on hand, find a good angle where you don't have glare, etc.) and instead find 4 points that you know the position on the board (e.g. 4 corners). Then you can warp the image to get rid of any trapezoidal distortion due to the camera not being exactly perpendicular with the board. In theory this could be done with any 4 points (they don't have to be right angle corners but those are the simplest) automatically - it is called finding a homography transform.https://docs.opencv.org/3.4/d9/dab/tutorial_homography.html(see the part on perspective removal)https://www.learnopencv.com/homography-examples-using-opencv-python-c/That's basically what the Photoshop/Gimp do when you ask them to do perspective correction.The layer alignment can be done in a similar way - first rectify the images up as above and then you can find a transform between matching points that will scale and align one layer over the other one. All that this needs is solving a system of linear equations.It can be done semi-automatically - e.g. have the user mark the points with a mouse.A few other features I have found useful or wished to have:- filling the traces with color so that you can easily see the individual nets- marking of the components and their pins- have a way to generate a netlist/rough schematic out of the above - e.g. this could be perfectly doable with KiCAD where the schematic is just a large text file.

author: T3sl4co1l
author_rank: Super Contributor
timestamp: December 01, 2018, 06:41:20 am
content: Yeah, I do this. Usually I color the layers so they're easier to follow; which is more effective here with silver traces, than with modern green boards (so one layer stays normal and the other is rotated to red or whatever).Tim

author: Simon
author_rank: Unknown
timestamp: December 01, 2018, 08:14:24 am
content: I curse the man that put a camera in a phone. they hidiously distort the image, hence why i still paid hundreds of pounds for an SLR.

author: Dubbie
author_rank: Unknown
timestamp: December 01, 2018, 08:20:19 am
content: The lens in your average phone camera doesn’t have particularly bad distortion. I know because it have measured it on my phone many times.

author: Simon
author_rank: Unknown
timestamp: December 01, 2018, 08:23:49 am
content: Quote from: Dubbie on December 01, 2018, 08:20:19 amUntil you realize how many people are having facial surgery because they beleive their phones

author: Dubbie
author_rank: Unknown
timestamp: December 01, 2018, 08:27:14 am
content: I think that is just the reality of rectilinear projection on a wide angle lens closeup.

author: Simon
author_rank: Unknown
timestamp: December 01, 2018, 09:12:10 am
content: Quote from: Dubbie on December 01, 2018, 08:27:14 amdefine wide angle lens..... most camera's that are not SLR's are sold on their equivalent to 35mm frame lons length. This is because the field of view depends on the lens length and the frame size. Once the world had defined standards the last being the 35mm frame format. with this format a 50mm lens gave the closest match to a human eye's field of view and sense of pespective. Anything less was wide angle or fisheye in extreme cases and anything more was telephoto. Wide angle having potential distortion and fisheye - well they called that an artform. Then digital came along and sensors got smaller, this meant that the lens for the same field of view had to be shorter. My first bridge camera had a 6mm sensor and my lens was marketed as a 18-300mm, in reality it was 6.2-66mm. I used to find zommed shots more pleasing and eventually worked out this was because at 50-66mm i was getting a truer prospective. Zoom lenses themselves are a compromise and introduce distortion. I have kept my 50mm prime lens that came with my camera because it is very useful for any people shots. Having recently compared two photos with the same people taken with that lens and a phone I can assure you that there is a difference. You won't see it in buildings etc but in faces that we humans are particularly attentive to and all the more so when it is our own there is a difference. Distortion is not constant and worse at the edges of a lens.

author: janoc
author_rank: Super Contributor
timestamp: December 01, 2018, 05:35:05 pm
content: Simon I have done a lot of camera calibrations on phones (it is necessary for doing any kind of computer vision/augmented reality) and they really don't distort that much, even at full wide setting. We aren't talking early 2000 camera phones anymore. For example iPhone/iPad cameras gave me a calibration that was pretty much dead on match to an ideal pinhole camera. Square pixels, distortion coefficients down in the noise. I am sure the physical camera isn't so great and Apple's firmware does some undistortion/pre-processing before delivering the image to the userland APIs (I am not talking about the camera app but images grabbed from the camera using my own code) but the user doesn't really care about that.SLR lenses often distort much more than tiny smartphone lenses, especially barrel distortion at the wide end can be really pronounced. The smartphone lenses with their microscopic focal length don't really have where to pick that kind of distortion up at the distances the lens is usually being used (and is even able to focus). It is extremely difficult to build anything resembling a fisheye in such small form factor. That doesn't mean it is impossible to build a crappy lens but given the smartphone prices today the customers would lynch such company.Of course there is no comparison with an SLR when it comes to sharpness, color aberrations and minimal aperture/low light capabilities but you really don't care about any of that when shooting pictures of PCBs for analysis. For this kind of job an SLR is an enormous overkill, even a crappy handheld phone shot is going to be usable just fine. The idea is to enable reverse engineering boards, not to win a photography contest! (and yes, I do own a Canon 80D with a few lenses too)Also often when you are fixing boards you don't have an SLR at hand but almost everyone has a phone - then the whole point is moot.Anyway, if you happen to have a phone that produces images so distorted that it would cause problems with the reverse engineering, it is pretty simple to calibrate the camera and remove the distortion in software after the fact. Definitely simpler than having to monkey around with a large camera, tripod and what not - and have to undistort the image anyway ...

author: intabits
author_rank: Frequent Contributor
timestamp: December 01, 2018, 06:19:33 pm
content: Quote from: janoc on December 01, 2018, 12:36:33 amYes, you could complicate a simple program with fancy algorithms and maths, to avoid using a tripod. Or, use a tripod. Or any arrangement of blocks of wood, rubber bands and blu-tack that will enable you to take two photos without moving the camera.Sure, you'd have all that fancy stuff in a full-featured program, but it's not an essential feature. There's other higher value core functionality that I would be adding long before that.QuoteI mentioned earlier that the component/pin marking and netlist generation was a desirable future direction.That's where I would be adding complexity...

author: intabits
author_rank: Frequent Contributor
timestamp: December 02, 2018, 06:55:44 am
content: Quote from: janoc on December 01, 2018, 12:36:33 amI've just played with a much more demanding example: a 275mm x 290mm double sided PCB with 100 chips on it.And with that, the distortion was too great, even with careful use of a tripod.I added pan and zoom, and then X/Y shift adjustments, but any given adjustment setting was good for only a small area, maybe 50mm square.So I accept that homography would be absolutely necessary for images like that. But I maintain that the other functions for marking pads and connections are still much more important. You'd want those facilities for all but the simplest PCBs, whereas you could probably get onto fairly complex PCBs without needing homography.Of course, trying to reverse engineer a large PCB like the one I mentioned above would be a massive task, no matter how sophisticated the tools being used.And might still be nigh on impossible...

author: Simon
author_rank: Unknown
timestamp: December 02, 2018, 08:57:16 am
content: Quote from: janoc on December 01, 2018, 05:35:05 pmI just examined pictures taken of mysely and some friends, one on my SLR one on a camera phone. The people to the edge of the phone picture start to distort. Not enough for you to notice unless you make a comparison. Fortunately PCB's don't care if they look fat

author: janoc
author_rank: Super Contributor
timestamp: December 02, 2018, 10:30:06 am
content: Quote from: intabits on December 01, 2018, 06:19:33 pmIf you call a set of linear equations "fancy math", I don't know what to say.The issue is usability of the program. If I can click 4 corners and have the image fixed up vs. having to set up a tripod, prop up the board so that it sits level even if there are components on the bottom and still will have a distortion because the board isn't on the axis of the lens and isn't perfectly perpendicular, the former is a big win for me.But you are free to do as you wish, of course.

author: cdev
author_rank: Super Contributor
timestamp: December 03, 2018, 02:51:23 am
content: This free program is really two programs, enblend and enfuse that can turn multiple images into one and hide the seams for you. It does a really good job of it. They work great with images taken with the intention of emulating a scanner - for example, large photos of books or maps or PCBs. And of course you can use it to stitch several small scans with your small a4 or letter or legal size size scanner together to make big scans.http://enblend.sourceforge.net/Combine it with "hugin" (and at least one flavor of "sift" which I am sure at least you janoc are already familiar with) and you'll have a complete panorama workbench which can be used to do all sorts of things with multiple images including all sorts of perspective transformations and mappings.http://hugin.sourceforge.net/Its ideal for stitching images of any kind and coming out of the process with a square image with accurate sizes, with a little tweaking.A flatbed scanner's scans sizes are based on the math of the x-y scanning process with its two stepper motors so usually are very close to being pixel accurate/ verifiably right.

author: orbanp
author_rank: Regular Contributor
timestamp: December 07, 2018, 12:46:01 pm
content: This program is very useful as it is!It would be great if you could save the combined image, and if it would handle png files as well.Thanks for making this available!Regards, Peter

author: cdev
author_rank: Super Contributor
timestamp: December 07, 2018, 03:21:08 pm
content: Quote from: orbanp on December 07, 2018, 12:46:01 pmI am not the author! Just a photographer who has been using enblend/enfuse for a long time for photos of stuff.Hugin is great too!You know,image recognitionhas come so very far in the last few years, we really are not very far away from aautomated programthat could literally suck in two good quality photos of both sides (of a two sided PCB) and/or perhaps some backlit trans-illuminated images to reveal its internal trace structure - that would be needed if it was a multi layer board-A program that could take your hi-res photos of a PCB and generate a schematic from that automatically, labeling any questionable areas and perhaps suggesting measurements - taken at specific points - which it could also suggest - that could resolve ambiguities.It might even be able to guess as to unknown values and suggest what the device's function might be.