Question about PYUPDI Style programming for mega tiny core parts

I was just reading the GitHub project page about how to wire up a UPDI programmer, by @DrAzzy, and noticed a curious omission about types of available USB/Serial interfaces. (I believe that FTDI and CH340G based interfaces were the ones that were mentioned. EDIT: There were a couple more types mentioned in a comparison chart, farther down the page.)

My "go to" method for a USB-to-digital serial interface is as follows:

  • take a spare UNO or NANO (I have a few of each);
  • upload "The Empty Sketch" (i.e. startup() and loop() methods are defined, but empty);
  • take a couple of small pieces of adhesive 3M Post-It (or similar) labels and label one as Tx and the other as Rx;
  • paste the "Rx" adhesive label over the Arduino (UNO or NANO) board's "Tx" pin label and the "Tx" adhesive label over the Arduino "Rx" pin label;
  • connect the external device to the newly re-labelled Rx and Tx pins (with appropriate level-shifting resistors and/or diodes, if the external device is 3.3V);
  • connect the UNO/NANO USB connector to a PC running a terminal emulator (or even the Arduino IDE serial monitor). EDIT: Or running the "PYUPDI Style" programmer software. :wink:

(Note that this should theoretically work with any spare Arduino board that does NOT have a USB interface integrated into the main Arduino processor - so this would not work (AFAIK) for boards like Leonardo or Due.)

This effectively allows the UNO/NANO on-board USB serial interface to communicate with external devices connected to the (newly re-labelled) Tx and Rx pins.

Loading "The Empty Sketch" leaves all of the main Arduino processor's I/O pins (including the serial interface Arduino pins 0 and 1) in high-impedance state. Note that the "normal" Arduino "Tx" pin is actually connected to the on-board USB interface's "Rx" pin (and vice versa), hence the re-labelling of the two pins.

And, yes, dedicated serial interface boards are available "dirt-cheap" from vendors like Ali-express and, other Asian vendors on Ebay, but I really do not want to wait a month or more to receive shipments.

Questions for @DrAzzy (or anyone who might know the answers).

EDIT: I looked up the schematic of the UNO R3 board and found that there are 1K resistors in both the Rx and Tx lines. As well, the LEDs are NOT on the signal lines as I had thought, but are controlled by separate digital I/O pins on the 'mega16U2 (the chip being used as the USB interface).

  • Would the above scheme work for the "PYUPDI Style" programmer?
  • If so, what would be the best value(s) and placement(s) of resistor(s) (for programming time) between the UNO/NANO serial interface, and the UPDI pin of the target "bare" chip (like the ATtiny412)? EDIT: from the GitHub page and the 1K resistors on the UNO schematic, I infer that there only needs to be the one 470R resistor, and the diode between Rx and Tx.
  • In the Windows Device Manager, would the comport latency timer need to be updated (as discussed under " Serial adapter requirements" on the GitHub project page)?
  • Would the Arduino's on-board Tx and Rx LEDs (and their resistors) negatively affect programming? (I believe these are just a resistor-diode pair between each Tx/Rx signal line and ground.) EDIT: No, they would not, because my belief was wrong. The LEDs are controlled by separate I/O pins on the 'mega16U2; they are not on the Tx and Rx lines.
  • Under "Required Components," list item 2, the GitHub project page indicates that a 1N4148 is a Schottky diode(??). I know it is a "fast-switching" and "small-signal" diode, but I do not think it is a Schottky diode. So is the smaller forward voltage drop of a Schottky diode not required for this application? (I am assuming that, being a "fast-switching diode", the 1N4148 recovery time is similar to a Schottky diode recovery time, so the only other relevant difference that I know of would be the forward voltage of each type.)

Instead of specially wiring up a USB interface (like a FTDI or CH340G board) to make a "permanent" dedicated UPDI programmer, I could just add the diode and resistor to a small UNO shield prototype board, make the three-wire "cable" as described in the GitHub article, load the UNO with "The Empty Sketch," et Voila! Instant UPDI programmer. :grinning:

So would that work?

EDIT: So here is my proposal for a UPDI Programmer "mini-shield" for Arduino UNO R3:

As mentioned above, the UNO would be loaded with "The Empty Sketch" (both setup() and loop() are empty). The top-right and bottom-left headers are meant to represent the pins UNDER the board that would engage with the UNO's header sockets. (Note the reversal of the Tx and Rx labels at the top-right.) The extra two pins for each of these two headers are included to help make the shield more stable when connected to the UNO. The three-pin header in the middle is meant to represent the connector pins for the 3-wire UPDI "cable", with ground in the middle, as suggested by the GitHub page.

From the UNO R3 schematic, and from my understanding of @DrAzzy's GitHub page, I believe the above should work.

Thanks and best regards,
DuinoSoar

I do not recommend using a whole arduino board, with all that stuff dangling off the serial adapter, when all you want is a serial adapter. Maybe if serial adapters cost $30 each orr something this would be something worth considering. But they're $1/each for basic serial adapters. Trolling aliexperience for 5-10 minutes. I was able to find somewhere I could get 7 before the total price (including shipping) went over $5, Why are people using $20 official boards, or $5-6 clones, which have all these things dangling off the serial line Some of the nanos I have seen that are based on CH34G's have both TX and RX light. That means that their RX light is just LED + resistor. That'd kill UPDI for sure.

If this all was something you'd only ever have to do once, and then you;d be set for many months, I would consider that an acceptable approach, or if you are up against the wall and that's all you have and you need to program via UPDI now. But a UPDI programmer is something you will be reaching for and using constantly.. and actual serial adapters are cheaaaap. Oh, and the serial adapter chip on official unos seems to be incredibly fragile electrically (if you plugged it into something powered externally, when it wasn't plugged in, it would not surprise me if it trashed an uno being used as a serial adapter. The CH340G standalone adapters can take a lot of abuse....

So I did not include that method because I think it is a bad idea and recommend against it every chance I get!

Oh goddamnit, You are correct that that is not a schottky diode, I will remove that part number from my documentation and find a schottky part number. The voltage drop directly shrinks your window. You want as little as possible. I've been using the BAT5-something's in the SOT23 package myself. I did actually try it a while back with a plain diode, and, like the resistor, it was on the edge of working

Com port latency timer is extremely relevant to anything with an FTDI chip or fake FTDI chip. That option does not exist for other manufacturers adapters.

Thank you for your replies, Spence. I appreciate it. I will see what I can find for adapters shipped from the U.S. or Canada at low cost, then.

According to the "official" UNO R3 schematic at arduino.cc, the only "stuff dangling off" the Rx/Tx lines is the 'mega328p, which has those two pins at high impedance (with the "empty sketch" running). The Rx/Tx LED/Resistor pairs are actually controlled by two other digital I/O pins on the 'mega16U2 being used as the serial adapter, and are not connected to the Rx/Tx lines at all. The schematic shows a 1K Ohm resistor on each of the Rx/Tx lines between the 16U2 Rx/Tx pins and the Arduino board pins, but that is all.

I have three or four UNO R3 clones and they all have the '16U2 as the on-board serial adapter, so I am assuming (perhaps rashly) that the schematics of my clones are the same as the "official" schematic. But I have also seen clone schematics using the CH340, and they do have the LED/Resistor pairs directly "dangling off" the Arduino board pins for Rx/Tx. BTW, my three NANOs are CH340 clones with the LEDs directly on the Rx/Tx lines.

And I do see your point about possible damage to the Arduino board if the external target circuit is mis-configured, or the Arduino board is unpowered while the target is powered, etc. (although that could be true of almost any Arduino-based project wiring).

Concerning the diode, if a through-hole diode is being used, am I correct to assume that a 1N5817 or 1N5819 would do the trick?

BTW, I do not yet have the ATtiny412 chips in my "parts bin" yet, but I do plan to order some soon. (So I am, as yet, unable to test the UPDI programming.)

Much thanks and very best regards,
DuinoSoar.

I'm so sorry to hear that. Order fast - if you go with digikey, https://www.digikey.com/product-detail/en/ATTINY412-SSFR/ATTINY412-SSFRCT-ND/9554994?itemSeq=365713851 that one is expected to ship in june. The other versions of the chip, digikey is getting some in late august, while mouser's got only about 1600 more of ANY type coming to them before next year that are still uncommitted. We're in the midst of a historic shortage of microcontrollers, and sadly microchip is hardest hit. Maybe they should have spent more money on fab capacuity anbd less buying every rival on the block.

Those diodes are a bit excessive in size -= I'd try to use a small signal schottky diode instead of something that beefy.

Rats! Just as you wrote, they are out of stock at both Mouser.ca and digikey.ca. How do you know about the expected availabilities in June and August from DigiKey? Have you been in communication with them, or does it show up on the web pages somewhere? (I did not see it on the web site; just that the "lead time" is 38 weeks!) Mouser.ca are saying some parts available in September.

Add to your cart then click "check lead time" from the cart. Be sure to check all 4 versions of the part because the expected ship dates vary by almost a year sometimes. I thought I saw some shipping in july on digikey. I have a cart filled with stuff I'm not actually going to buy just to check leadtimes in this bullshit shortage,

Ahhh. Tricky! Thanks.

This is just an FYI update.

I put in my order at DigiKey. I back-ordered 10 each of ATtiny412's and ATtiny10's. I am also receiving (tomorrow!) 10 each of PIC12LF1840's and ATtiny85V's (the low-voltage version of the ATtiny85). I want to experiment with power consumption of a few different uC's, for battery operated projects; so these are the four processors that I am going to pick on (or, in the case of the '12LF1840, "pic" on. :grinning: ) Oh, and I am also getting that MPLAB Snap programmer/debugger that I asked about in another forum section. And a bunch (100) of BAT46 small-signal Schottky's. (I have another application in mind that will use a bunch of those.)

No USB adapter yet, though. I could not find one (yet) that ships from NA at a low-enough price. :frowning_face: I know I won't really need it with the Snap and using the MPLAB IDE, but I did want to play with that nice, simple PYUPDI programmer from the Arduino IDE.

Anyway, I will have to wait until mid-June for the ATtiny10's and mid-July for the '412's, but at least I will have the '85V's and the '12LF1840's to play with in the mean time.

For HV programming of 'tiny85's, I am intrigued by @wholder's 12V fuse programmer using Arduino firmware to phase-clock a Dickson charge pump for the 12V to the /RESET pin. Does anyone know how much current is drawn by the ATtiny85's reset pin when the 12V programming voltage is applied? (The spec sheet does not seem to indicate anywhere that I looked.)

I really like that Wayne used a software feedback control loop by resistor-dividing the 12V charge pump output and feeding it back to the Arduino's A0 input to regulate the 12V (by simply starting/stopping the charge pump clock when the read-in voltage on A0 crosses a threshold). (Otherwise, if not regulated, the output would be 15V from the three-stage charge pump starting at 5V.) I am also wondering if there is any risk with that design where 15V might get applied to the ATtiny85 reset pin if the feedback software control loop ever goes wonky.

Yes, I know I could use a boost converter or a 12V battery, but I thought it was "way cool" that Wayne figured out a way to get the Arduino to supply the 12V with just a bunch of caps and diodes (so long as it does not over-tax the I/O pin's current and does not have the risk of supplying 15V to the '85).

That's it for now.

Best regards,
DuinoSoar.

Yah, I've got I think,.... 75 or 100 pcs backordered currently with digikey... I have 100 412's so I didn't buy more of those, and am holding 150 1614s's and like >50 1624s..... It's the 3216's and 3217's that I';l; run out of. And the 1616's in the QFN - I have a simple product I was planning to launch with those, but now reconsidering - they may be worth more as bare chips, and if there's a 3224 in the same package coming.... Lucky for me, nobody buys my 3217 boards though (and I'm cool with that because assembling them sucks) - I actually sold my stash of 3217's as bare chips for a substantial markup :stuck_out_tongue: Backordered replacements and a bunch of other stuff.

Re 12V, I'd have used the MAX662 or whatever instead of involving the Arduino at all - it's a regulated 12v 30mA charge pump IC.... they work great and are dead simple. Made for flash erase before the charge pump was internal. The name brand is insanely expensive from one mfg, and discontinued from the other (I think digikey still has thousands though), but apparently they're still used widely in china and are cheap. I looked into the Arduino method myself too (and I've demonstrated it in the past). You could rig it up so you didn't even need to feedback, though.... In fact, I'll bet it struggles to reach 12, period - Those don't actually get you double or triple the voltage... I haven't given up on the idea of HV UPDI via serial adapter with one of those... you just don't get many IO lines, and if you need glue logic, you might as well use a microcontroller (well, in these times you can't get microcontrollers, but in normal times)

Id recommend ordering a bunch of cheap serial adapters from china. If you're using Arduino you will be happier with the pyupdi (SerialUPDI) method than SNAP. I never made my snap's work.... I have 2, was never able to program a damned thing with them

Thanks, @DrAzzy.

[BTW, whenever I see your online ID, I always think of the Drazi alien race, from the old Babylon 5 TV series. ; ) ]

So, I ordered a lot of five CH340 adapters from amazon.ca for just under CDN$12.00 (or about $2.40 each). Probably a little pricier than ordering from China, but I should receive the order next week instead of next month (or, more likely, month after next).

BTW, after ordering the USB adapters, I found a schematic of what looks like the same module, and see that it has LED/resistor pairs "dangling off" of the Rx and Tx lines (between Vcc and the signal line; so the LEDs light when their corresponding signal is low). Hmmm. Should I remove those LEDs (or their resistors) off of the adapter board for the pyupdi programmer?

I see that there is a 1.5k resistor in the adapter's Tx line, but no series resistor for the Rx line.

In any case, once I have the '412s and the USB adapters, I can try out the pyupdi programming. (Got my BAT46's and 470R's ready to add in! ; )

I had not previously heard that there were any problems getting Snap to work. (I have one now, along with some ATtiny85V's and PIC12LF1840's.) I am more interested with Snap for debugging than for programming, but would have to develop with MPLAB instead of Arduino for source-code debugging (breakpoints, code stepping, etc.)

I see that @wholder developed a nice debug monitor for Arduino, using the DebugWire protocol on AVR devices like the ATtiny85. (It's not source-code debugging, but does provide some nice debug commands to use with the serial monitor or terminal emulator.) I guess it won't work on the '412 or the '10, though as I expect the UPDI debugging protocol is much different than DebugWire.

Thanks,
DuinoSoar.

You'll want (need) to remove the RX LED or it's resistor, most likely (you might not need it if there's no resistor between RX and UPDI). 1.5k on TX is what you want, you should only need the diode between TX and RX The TX led can stay.