Sunday, September 23, 2018

Getting started with AudioDIY and the Atmel ATTINY85: What to do with these tiny things?

I can't help but be seduced by an Arduino that, from about a foot away, looks like an op amp. And costs only a bit more!!!

I'm talking about the ATTINY, which in its "85" form looks like this:



Can we really pack an Arduino punch into an 8 PIN chip?

Time to find out!

I bought a few of the ATTINY85's ($2-3 for DIP, good for prototyping; under a dollar US for surface mount) and a Sparkfun programmer for about $15 from Amazon:
From my reading, programming ATTINY using the Sparkfun is pretty straightforward--I figured I'd have the LED blink app up and running in 10 minutes?

But it didn't work!  10 minutes became a couple of hours....

Hello?

I have 2 computers I use for Arduino programming on my bench and the Sparkfun programmer didn't work on either: an older MacBookPro running OS-X Mountain Lion and a Lenovo T430 running CentOS 7.  I have used both many times for programming Nanos such as the one used for the SynthDMV.

After following the Sparkfun instructions (which are very clearly written--good work Sparkfun) several times, no go; it's like the system couldn't find the ATTINY85 chip I had put into the programmer.

Driver issues?

Many documents on the web say for Linux and Mac you don't need drivers for this Sparkfun Programmer--only for Windows and thankfully I don't do Windows in my electronics lab....too much Windows at work, don't need that here as well!

But still it felt like a driver issue.


Lots of head scratching....odd that I saw this "hide the ATTINY" issue for both laptops (different OS's right?  different hardware)?

To make a long story short, I found other poor sorry fellow dumb SOB's who had the same problem, and one of them suggested "try a different USB cable".  Well, I wasn't using a USB cable at all; I was just plugging the programmer into an open USB port of either laptop.  Seemed at best like a long shot but after 2 hours of messing around with this I was ready to try anything.

I dug around in my USB cable crapola box and found a M/F USB 2.0 extender--a standard M/M USB cable wouldn't work--I plugged the Male into the Mac, the Sparkfun programmer into the female side, and of course after that the programmer worked!

Now that makes no sense at all....i could see the programmer being unhappy with the USB port on one laptop, but not two, and running different OS's at that--and it didn't work on any USB port anywhere, but with the USB extender cable it worked everywhere.  Makes no sense!!! 

I posted this on an Arduino Forum and got zerohttp://forum.arduino.cc/index.php?topic=388043.0 responses, so maybe of the 7.7 billion people on the planet I'm the only one to have ever have had this problem?  Whatever.

UPDATE!! FIGURED It OUT! It had nothing to do with cabling, drivers, or anything else. both the mac and linux machines are linux based and both weren't giving the programmer permission to program. I still don't know why the system worked after I changed out the cable, I must have done something else (run arduino IDE as root?) total mystery until I found this. Here is how to fix this issue:

From your linux box, open terminal

issue the command

lsusb

note in the list which one is TINYUSBISP: for me it is this:

Bus 003 Device 030: ID 1781:0c9f Multiple Vendors USBtiny

now issue this sudo command where the last 2 numbers match bus and device numbers spat out by the lsusb program.

[clamm@localhost ~]$ sudo chmod 666 /dev/bus/usb/003/030

fixed!

Onward!! Anyway: now that the BLINK proof of concept is working--a few things to think about:

  • There is no "official" I2C library for the ATTINY.  I see folks using this "BroHogan" i2c library; I have yet to test it.  So my favorite I2C goodies like the MCP4725 D/A are not supported using the more familiar wire.h library, but that's probably OK.
  • SPI is the same deal--but you can apparently use this guy's software to do SPI with this chip.
  • There is a LED on the programmer--D0--that does help a bit I guess.
  • There is no built in serial I/O in this system, which makes debugging harder.
  • You have to supply your own 5V power supply--to power the chip as well as any peripherals--there is no 5V regulator on board, as there is on the nano.
  • Tinkercad Circuits, which I use all the time to bang out virtual Arduino code to then use in the real world, supports ATTINY. And from messing around with it so far: at least some of the slightly more arcane features, like Pin Change Interrupts, appear to be supported.  yeh!!!
  • The Programmer you see above has breakouts for the pins on the ATTINY--so you aren't schlepping the chip in and out all the time--very useful.


OK time to put this on the bench:


Yes, blink works, analog in works, basic interrupts work, and so on.

After an afternoon of messing around, two designs came to mind that might be good candidates for projects based on this chip:


CMOS 4051 based CV selector based on incoming control voltage:
The CV is read by an analog pin (need to condition the CV to be 0V < x <5V, but that's not too hard) and then used to switch between CV fed to 4 or 5 of the 4051's inputs.  Any audio would have to exist between 0 < x <5V as well, but if you can massage the audio to that range, that should work as well.  That's all simple op amp stuff right?

Or, a low parts count (I think) trapazoid generator:

Hope I am not using too many IO pins here!

Overall though I keep going back to this nagging throught--why not just pay an extra $4 or whatever and use a nano clone?  You get more pins, more options, serial for debug, etc.  Of course the NANO is bigger, but not too big for projects that involve 1u Fracraks which is the smallest thing for which I'd probably use Arduino.

So I am left wondering what if anything AudioDIWHY I will use ATTINY for--I am not making drones or robots where space is at an absolute premium.

Oh, you can supposedly use ATTINYs as an I2C slaves but the use for that still eludes me as well.

BTW I think these guys are burning audio stuff onto ATTINYs and selling them as finished audio DIY chips.  So the tenement version of a VLSI chip making operation. Just a guess? Makes sense--and if that's what they are doing: clever.

Regardless it's cool that someone can make an Arduino that's this small.

OK that's it.....Until next time....as always, don't breathe the fumes.

ReverselandFill "Aconitum" Noise Board--Augmented with C1406HA VC Attenuation--Finished!

Hello again fellow readers and audio nerds.  This post: Time to finish off the Reverselandfill "Aconitum" board for my DIY modul...