Friday, January 28, 2011

Display test

In the midst of some breadboard work I began to get worried about cycles.   Specifically, I wasn't sure the ATMega328 + arduino bootloader would have enough processing power to do everything I have in mind.    As I see it, the two critical factors are a snappy display and responsive controls.   The LEDs have to be updated at least every 4ms to avoid a strobe effect, and preferably more like 3 or 2ms.  I thought this would be easy with a 16mhz CPU, but some quick tests I ran (with my terrible, terrible code) had me worried;  I was running into strobe territory with a very small number of additional instructions.

So I wired up the whole display section on a breadboard to see if I'm on the right track.   Here's video of an early test.   4 10-segment LED arrays.   Each time through the main loop:
* An analog pin is read 5 times
* The values are mapped from 0-8
* The mapped values are shifted out to the Row and Column registers.
I put a pot on the analog pin so I could wiggle it around and see the results.   I'm relieved to see that there seems to be quite a bit of headroom.   (The flickering LEDs in the upper right are due to me selecting poor cutoff values)



Heartened, I next wired up all 5 LED arrays, and added the extra shift register needed for LEDs 9 and 10.  Additionally, I added the multiplexer I plan to use to switch between each audio input and wired 4 pots to the MUX (didn't have 5 on hand).   In this video, each loop has the following steps:
* The three MUX control pins are set 5 times to select input channel
* The analog pin is read 5 times
* The values are mapped from 0-8
* The mapped values are used to lookup the appropriate LEDs to light
* The looked-up values are shifted out to the two Row and one Column registers 



It appears my concerns were unwarranted.  I know that many of the Arduino functions (like shiftOut) translate to quite a few steps in actual AVR code, so I'm glad to see that I've still got a good amount of headroom after doing so many shifts and reads.  I was able to add up to a 4ms delay on the whole program and it was still quite acceptable.   Hooray.

There's some issues with using the MUX.  When the signal approaches +5v, things get flickery and glitchy. I should probably read the datasheet.  Also, since the MUX needs 3 control pins plus the one output pin AND I'm only reading 5 inputs, I'm only saving 1 pin...   I need to revisit my audio board design once I have a better grasp of the amping and biasing process.  If the signal is already in a happily-readable state before it hits the mux, I'll just remove the mux and run them all right back to analog pins on the arduino.   I just happen to have a single pin free, and this would remove a good number of steps from the main loop. 

I'm still struggling with audio signal manipulation and interpretation.  A couple of halfassed attempts at biasing and amping a linelevel signal produced bupkis.   Perhaps I should read up on what I'm doing instead of taking more shots in the dark.

No comments:

Post a Comment