Close

Why not the Tiny9/10?

A project log for J1772 Pilot Generator

A tester for J1772 pilot analysis

nick-sayerNick Sayer 08/13/2021 at 00:330 Comments

Folks who have followed me lately know that I've had a penchant for using the ATTiny9 in a lot of projects. So why the Tiny85 here?

The problem comes down to clocking. The Tiny85 can use a crystal for clocking (at the cost of a quarter of the pins). This project needs fairly accurate (I mean, not like GPSDO accurate, but better than the built-in RC oscillator) clocking so that the 1 kHz frequency of the output pilot stays within J1772 spec.

Well, the only way to clock the Tiny9/10 with a crystal with with an external oscillator input. That means that not only do you have to have a crystal, you need an oscillator for it too. So suddenly you're either adding another chip to the board or upgrading the crystal to a self-contained oscillator. <sad trombone/>

Well, set aside that for a moment. PB1 is the CLKI pin, and it's also OC0B. Can we get the PWM signal we want just using OC0A? Well, fortunately Fast PWM mode (0xe on the WGM bits) defines the TOP is ICR0, and you can use OCR0A as a compare match.

The ADC has only an 8 bit resolution, but even using that entire range would give us 1/4% resolution, which isn't different from what we can get with the Tiny85's 8 bit PWM timer. The Tiny10 can do 16 bit PWM, which would let us be much more granular (which we don't really care about).

Programming would also be interesting, because the TPICLK pin is also the CLKI pin, so you'd need to isolate or turn off the clock during programming. One answer there is to get an oscillator with an enable pin and add a jumper for that you can temporarily close during programming.

That, and all I have on hand are Tiny9s, and they don't come with an ADC. I'd have to buy some Tiny10s. Everybody and their brother is out of stock on them, but DigiKey expects a shipment of them "any day now."

So I might wind up trying it anyway, just for completeness' sake.

Discussions