Noob question isolating homemade programmer - Page 1
Forum section: electronics / projects

author: Fixed_Until_Broken
author_rank: Regular Contributor
timestamp: March 07, 2020, 01:00:09 am
content: Hello I have no real background designing stuff but I made a in circuit EEprom programmer for instrument clusters I work on a lot. Its currently a breadboard project but I want to take it to the next step and make a shield with easyeda.Before I can move on to that next step I want to Isolate the Micro controller and its power supply from the EEprom that is going to be programmed while it is not reading/writing. reason for this is so that way I don't risk damaging the circuit board I am flashing while attaching the connector and so I don't have to unplug the connector every time I turn the boards I am programming to test the results. my current work around is that I just unplug the 5v/ground pin off the Arduino.What would be the best way to do that? I feel like a relay is overkill. Use transistors as switches?maybe y'all could look over the project and let me know if you think I overlooked anything. I want it be open for anyone else to make the same thing.Here is a video I did on it:https://youtu.be/JH3pLX_XkbkGithub on it:https://github.com/garnerm91/st95020

author: Nominal Animal
author_rank: Super Contributor
timestamp: March 07, 2020, 03:06:10 am
content: Get yourself an Arduino Pro Micro clone off eBay, and treat it as if it was an Arduino Leonardo. Also get a cheap ADuM3160 USB isolator. All told this will cost you about ten, twelve bucks or so. The isolator has a small DIP switch; make sure it is in the position that lights up the blue led (full speed, 12 Mbit/s) and not in the other position (low speed, 1 Mbit/s).Change the pins in your Arduino sketch to match the ArduinoPro Micro pinout. For everything other than the pinout, treat the clones as Arduino Leonardos in the Arduino environment. (This is because the Pro Micro clones donothave the SparkFun bootloader, just the standard Arduino Leonardo bootloader. So, the clones are essentially Arduino Leonardos [which has the same ATmega32u4 microcontrollers], but with the same pinout as SparkFun Pro Micros.)The ADuM3160 isolates the USB bus from the microcontroller up to one kilovolt. The isolated DC-DC converter on them provides about 200mA, which should be plenty enough for your use case.

author: Fixed_Until_Broken
author_rank: Regular Contributor
timestamp: March 07, 2020, 03:18:56 am
content: What I am trying to isolate is the 5volt and ground feed going to my SOP8 clip I am using to program the eeprom. Maybe I am using the wrong word I want to turn off of power to the clip when it is not reading/writing. If that makes sense? Its mostly to protect the circuit board that is being programmed just in case someone does something stupid like clip it on the wrong IC or clip it backwards.

author: angrybird
author_rank: Regular Contributor
timestamp: March 07, 2020, 05:32:58 am
content: Quote from: Fixed_Until_Broken on March 07, 2020, 01:00:09 amSo, umm, you rewriting odometers there, buddy?

author: Fixed_Until_Broken
author_rank: Regular Contributor
timestamp: March 07, 2020, 03:04:38 pm
content: Quote from: angrybird on March 07, 2020, 05:32:58 amI mean you can and I do a lot of odometer corrections if you buy a used cluster you have 2 options install it as is and now you have report in writing that the odometer is inaccurate or you are committing felony here in the US and that doesn't matter if it is high or low. Your other option is to program to the correct amount. I didn't really make the tool for odometer correction though the digiprog is a cheap ass tool that does that just fine the same way the arduino is doing and Xstar makes a cheap obd2 tools that do it better and easier you don't have take the board apart.What I am doing with it for the most part is going in and enabling trans temp, turning km clusters into miles, fix odometer error and yes odometer correction. the tools mentioned before can't do that.

author: angrybird
author_rank: Regular Contributor
timestamp: March 07, 2020, 03:06:22 pm
content: Quote from: blueskull on March 07, 2020, 08:05:44 amHi mr. communist, I'm sorry that I made you angry in the other thread, please don't derail this one.

author: angrybird
author_rank: Regular Contributor
timestamp: March 07, 2020, 03:12:57 pm
content: Quote from: Fixed_Until_Broken on March 07, 2020, 03:04:38 pmHehe, thought so. I have used various tools in the past for cluster changes but I very careful with odometer corrections - With these, trust no one and keep records on all customers to protect yourself! Some time ago I took a guy to court for something related to this, about a year after buying a car from him. He sent the cluster in to an internet vendor for the odometer change, and sold it to me with 50k less miles than it actually had. He did a pretty good job keeping mileage records off of carfax and the like but I found some records at an independent repair shop and that was what started it. It ended up costing him more than $30k for a $7k car in the end, and I got my money and damages and he got the car back with a bad transmission

author: Fixed_Until_Broken
author_rank: Regular Contributor
timestamp: March 07, 2020, 04:11:11 pm
content: Back on topic though. How would y'all switch the 5volts and ground on and off to the the sop8 clip? I feel like relays might be overkill. I have optocoupler laying around so they would work but doesn't really seem like the right tool for the job. so transistors? I am a total noob when it comes to making stuff... I just fix broken stuff haha. I am probably over thinking this.

author: Fixed_Until_Broken
author_rank: Regular Contributor
timestamp: March 07, 2020, 04:43:44 pm
content: Thanks.PN2222 do the job just fine? that is what I normally use when I am playing with my arduino...Edit never mind checked the data sheet that is a NPN not PNP

author: Ian.M
author_rank: Super Contributor
timestamp: March 07, 2020, 05:13:09 pm
content: Data lines should be protected with Schottky diode clamps between target Vcc and ground, and 50mA polyfuses between the clamps and the target. Output lines from the Arduino should be buffered with line drivers capable of more current than the 50mA polyfuse rating. Input lines should have 1K series resistors to ensure that the Arduino's MCU's internal ESD clamping diodes don't pass significant current during any event that causes the clamp diodes to pass current.You probably don't need to switch the ground. You can switch target power (Vcc) by using a low Vgs threshold*P-MOSFET driven by an Arduino pin, but protecting it is harder. Use a beefy MOSFET and a polyfuse of no more than 5% of the MOSFET's current rating and it will probably survive being shorted.You *NEED* the ADuM3160 USB isolator that Nominal Animal suggested so any mistake or idiocy#that takes out the Arduino doesn't damage the PC.* a MOSFET with a gate threshold voltage in the 1V to 2.5V range is suitable for direct drive from a 5V logic signal.# e.g. trying to use it on a cluster that's still connected to the car battery!

author: Fixed_Until_Broken
author_rank: Regular Contributor
timestamp: March 07, 2020, 05:43:20 pm
content: Makes sense on the USB Isolation will be updating the design to include that. What rating should I be looking at for the diodes?None of this for while it is connected to a car battery its all done on a work bench with a dc power supply.(dc power supply is off while programming but I want to to be able to leave it plugged in while test boot some of the eeproms I am still working out different parts of the bins on them so I make lots of changes) I just want to put some protection into the design in case someone else tries to make this and does something stupid I dont want them to damage their computer, Arduino or instrument cluster.

author: Ian.M
author_rank: Super Contributor
timestamp: March 07, 2020, 06:42:07 pm
content: The clamping diodes are a compromise - too high a current rating means a large junction area and too much capacitance for fast data signals. Therefore, worst case, if the user connects one of the data lines to +14V from the bench PSU, the clamping diode may not survive, but as long as the energy the polyfuse lets through isn't enough to blow the failed diode open, there should be no damage other than to the diode. I'd start by looking at BAT54S series Schottky diode pairs, which can withstand 600mA non repetitive peak If for no more than 10ms and see if that's enough for a reliable trip of a 50mA polyfuse. If not, that should at least give you some idea how beefy a diode you actually need.The line drivers should be powered from the switched supply at the drain of the P-MOSFET, and that supply should be protected against overvoltage by a crowbar circuit with a 5.5V trip point that turns off the P-MOSFET and grounds the switched supply via a beefy N-MOSFET, leaving the polyfuses in the switched Vcc lines and the data lines to hopefully isolate them before damage occurs to the programmer or the target.If your programmer had a higher voltage power source than the 5V USB Vbus supply, you'd have better options as the switched Vcc supply could come from a LDO with a current limit, an external Adj pin and an enable pin, eliminating the need for a P-MOSFET and permitting target power to be current limited at source, and allowing a Schottky diode to protect it against being back-fed from a powered target without excessive voltage drop. You'd still need the crowbar circuit and polyfuses to provide protection against misconnection to a powered target.

author: rstofer
author_rank: Super Contributor
timestamp: March 07, 2020, 07:13:38 pm
content: How about jumper headers on the various pins? If you have to modify the PCB, jumpers take less design effort than MOSFETs and such. It probably isn't sufficient to just isolate the power and ground, I would expect that the signals need to be isolated as well.

author: Ian.M
author_rank: Super Contributor
timestamp: March 07, 2020, 07:33:28 pm
content: Yes. If one needs the capability to run a powered target without disconnecting the programmer, the signal output lines will need to be isolated when not actively programming or reading the target memory. As long as the line drivers (buffers) are powered by target Vcc, it should be sufficient to tristate their outputs. The extra loading of input lines to the Arduino should have negligible effect on the target unless the clamping diodes have excessive junction capacitance.I presume the O.P. wants to to avoid 'brute force'ing it with a bunch of reed relays or even a manual multipole switch!

author: TomS_
author_rank: Frequent Contributor
timestamp: March 07, 2020, 08:53:20 pm
content: If all you're doing is powering an EEPROM device, you could potentially just use tri-state buffers, something like a 74HCT245 which operates from 5V and so will output 5V, but who's inputs will work down to 3V3. The buffer should be able to supply enough power for an EEPROM, and also act to isolate the signals when not in use (I presume that by isolate you really mean to have your programmer go HiZ).But I suspect any EEPROM that is on a board is going to share a power rail with much more, and that all may exceed the current supply ability of the buffer.So perhaps as people have suggested, a P type transistor of sorts to supply power, and then you could use a tri-state buffer to isolate all of the signal lines when you don't want to be talking to the EEPROM.

author: Fixed_Until_Broken
author_rank: Regular Contributor
timestamp: March 07, 2020, 08:57:11 pm
content: LOL you are correct in that assumption Ian.m My first thought about this a couple days ago was to throw some little dip switches on but then thought no that is lame especially when the arduino has plenty of pins to drive something. Plus now I get learn something new!

author: Fixed_Until_Broken
author_rank: Regular Contributor
timestamp: March 07, 2020, 11:37:39 pm
content: I think I got the resistors right. I put a 10 ohm at collector so that way it shouldn't be able pull enough current to damage the transistor. Is the attached picture how you would do it? I don't have the parts yet to test it on the bread board.

author: David Hess
author_rank: Super Contributor
timestamp: March 08, 2020, 05:51:41 pm
content: Quote from: Ian.M on March 07, 2020, 05:13:09 pmThat will not prevent a short if the IC clip is rotated 180 degrees allowing the body diode to conduct; isolation on power and signal pins must work with both positive and negative voltages.

author: Ian.M
author_rank: Super Contributor
timestamp: March 08, 2020, 06:55:45 pm
content: Yes. That's why I was advocating 50mA polyfuses in all signal lines, with Schottky clamps on the programmer side and another appropriately rated polyfuse in the Vcc line.You CAN'T prevent idiocy, and when you attempt to prevent the resulting damage, the world invariably comes up with a better idiot, that does something so stupid no-one anticipated it. The best one can hope for is to prevent damage as often as reasonably practical, and when you can't, limit the cost of the damage.

author: Fixed_Until_Broken
author_rank: Regular Contributor
timestamp: March 08, 2020, 11:25:39 pm
content: Gotta love amazon free next day I got the transistors in I am going to play with them and do some testing. I still haven't ordered the diodes yet because not really sure what a good value to start at would be.

author: David Hess
author_rank: Super Contributor
timestamp: March 09, 2020, 02:35:38 am
content: Quote from: Ian.M on March 08, 2020, 06:55:45 pmI would not trust polyfuses to protect from catastrophic damage because they are so slow. On the other hand, I did not recommend anything better because protection circuits quickly get complicated to protect against reverse voltage which is a definite possibility in this case.Something like a ATE (automatic test equipment) pin driver with programmed current and voltage limits would be suitable for the I/O and power pins, but such circuits are not trivial. Slow ones look like linear class-AB buffers with current limits and some operational amplifiers are suitable but fast ones could use diode bridges as bidirectional current limiters. Their design is a fascinating problem.

author: Ian.M
author_rank: Super Contributor
timestamp: March 09, 2020, 03:49:51 am
content: Quote from: David Hess on March 09, 2020, 02:35:38 amYes, with polyfuses, there's a high risk of blown buffers and shorted clamping diodes. but both the programmer and the target should be repairable - i.e. no traces burnt off the board, and with luck, if the clamping diodes did their job long enough, and the idiocy didn't stuff -5V from the reversed Vcc onto a target signal line the target MCU and memory chip have a fair chance to survive.QuoteIts hard to justify spending big $$$ on protecting a $3 USD Arduino clone . . .

author: Fixed_Until_Broken
author_rank: Regular Contributor
timestamp: March 09, 2020, 03:55:27 am
content: Ok well I got the transistors on and updated the sketch and it works. I decided do one on ground also just because after a test of powering the target board with the clip on, the arduino turned on or off the target couldn't read its own eeprom. Chip select/Slave select is the issue if I take the wire off the chip select pin the target can then read its own eeprom. I didn't thing this would be an issue. shouldn't the arduino not be able to pull CS high or low if ground and VCC are not hooked in.Just to be clear its still an issue even though I did both VCC and ground

author: Nominal Animal
author_rank: Super Contributor
timestamp: March 09, 2020, 04:00:28 am
content: I really like the idea of using anNPDT switch (a rotary switch maybe, or a set of small signal relays?), with the "OFF" position having a big resistor for each target chip pin to local ground, say 1MOhm or so each; andmaybeopamps for VCC and GND pins on the target chip, with each pin having a diode and a resistor to VCC and another pair to GND, to detect if the target chip is already powered.The resistors would dissipate any charges or current already flowing to the chip. The opamps would be used to detect if the target chip is already powered; the unusual resistors with the diodes would limit the current in that case, and the diodes would clamp the voltages to the rails so nothing should really break. (I would only do the opamps if the programming clamp is used in circuit; I wouldn't bother if a socket is used, where the solitary chip is dropped into for programming.)Based on how I have blown up ICs before, I believe the resistors alone would cover the majority of my goofs, and the opamps would catch almost all the rest if there is a possibility of a capacitor or battery powering the chip (without me realising it) when the programmer is connected. Yes, I would still blow up one every now and then by accident, but I don't see the need for trying to idiot-proof any further than that.

author: Ian.M
author_rank: Super Contributor
timestamp: March 09, 2020, 04:09:26 am
content: Quote from: Fixed_Until_Broken on March 09, 2020, 03:55:27 amThere's all sorts of sneak paths that could provide a ground return between the target and the Arduino. Adding a USB isolator will eliminate some of the possibilities, but the SPI signal lines can still be a major issue. Seehttps://www.eevblog.com/2015/12/18/eevblog-831-power-a-micro-with-no-power-pin/for an idea of what you are up against.Try leaving ground and the SPI signals connected, and the Arduino powered but hold the Arduino in reset by grounding its RESET pin. That should keep its I/O pins tristated so it doesn't affect the target SPI signals. If that works, modify your sketch to set all the SPI lines as inputs when it disconnects from the target. The Arduino will need to remain powered.

author: Fixed_Until_Broken
author_rank: Regular Contributor
timestamp: March 09, 2020, 04:14:52 am
content: OK just tried holding the nano in reset by setting it to ground same issue.here is a little picture of how it looks now I also went from a uno to a nano. I really appreciate the help. I have no background in this stuff I am just a dumb cop haha. I have already learned a ton from this project.

author: Ian.M
author_rank: Super Contributor
timestamp: March 09, 2020, 07:38:24 am
content: Quote from: Fixed_Until_Broken on March 09, 2020, 04:14:52 amSo, just to confirm, that was with the Nano properly powered and Nano ground connected to target ground?If not, please ignore the following, make it so and re-test.I''ve just double-checked the ATmega328P datasheet to be certain I'm not misleading you:QuoteAs all DDRx and PORTx registers are zeroed as their initial state, the I/O pins you are using for SPI *should* be tri-stated if the Nano is held in reset. If /SS (your CS) isn't then either there's something wrong with your circuit or with that pin of the Nano. Check that pin is floating with the Nano held in reset and no target connected (monitor the pin voltage with a DMM and see if it can be pulled both high and low with a 10K resistor alternately to Vcc and Gnd).There is a small possibility its an AC loading effect caused by the extra capacitance of your programming cable and programmer circuit, that appears when the target accesses the memory becauuse its either got less drive or operates at a higher transfer rate (or both) than your programmer, so is more sensitive to load capacitance, however I would expect such trouble to be associated with the SPI clock or data lines not /SS, as they have far more frequent timing critical transitions than /SS.

author: Fixed_Until_Broken
author_rank: Regular Contributor
timestamp: March 09, 2020, 01:19:11 pm
content: It was done with both powered on. I tested it again before I left for work just to make sure I did it right same issues. You are correct it's clock not chip select beer got to me on that one last night. I know chip select is pin 10. When I get home I will bust out the oscilloscope so we can see exactly what is happening to that clock signal.