Showing posts with label ATTiny. Show all posts
Showing posts with label ATTiny. Show all posts

Monday, 17 November 2014

ATTiny85 – Tutorial 11 – Light Input Controlling Sound Output

This is the final Freetronics 11 – Experimenters Kit tutorial. The other 10 tutorials have been covered and, I’m please to say, I have now completed all 11 tutorials with the ATTiny85.

This tutorial makes use of the Freetronics Light module (a light detecting resistor or LDR) with the Freetronics Sound module (a piezo electric module). The light level is read by the analog LDR and the light level value is passed as a tone to the piezo.

Once again, we are using a web sourced tone function that makes use of the ATTiny85 timers to produce an output tone value. This time, however, we are not using predefined wave cycle values, but using analog light level values to drive the tone.

ATTiny85 Pin - Lesson 11

The Piezo is connected on pin 1 (ATTiny85 pin 6), while the LDR is connected on A2 (ATTiny85 pin 3).

Tutorial11

The LDR also connects VCC to the positive rail and GND to the negative rail.

The modified sketch:

/* Tutorial 11: Light Input Controlling Sound Output */

int piezo = 1;
int lightLevel = 0;
int duration = 300;

void setup()
{
  pinMode(piezo, OUTPUT);
}

void loop()
{
  lightLevel = analogRead(A2);
  TinyTone(lightLevel, 4, duration);
}

void TinyTone(unsigned char divisor, unsigned char octave, unsigned long duration)
{
  TCCR1 = 0x90 | (8-octave); // for 1MHz clock
  OCR1C = divisor-1;         // set the OCR
  delay(duration);
  TCCR1 = 0x90;              // stop the counter

}

I believe that TCCR1 and OCR1C both point to pin 1 (but I’d have to research that a little to make sure). Reason tells me that this is so … reason and I are not always particularly good friends.

It would be nice to reduce the delay so that the tones are more smooth, it would be kinda like a light driven theramin.

Check out the rest of the tutorials here.

Friday, 14 November 2014

AVRDUDE – Pagel and BS2 error

According to Wiki, the Pagel BS2 signals error that happens when you are programming an ATTiny85 (and apparently the 84 too) is a consequence of some missing configuration in the avrdude.conf file that comes with the Arduino.
Apparently, you need to correct the configuration problems and then everything will be fine. It is.
  1. Go to your Arduino IDE installation folder (something like C:\Program Files (x86)\arduino-1.0.4\hardware\tools\avr\etc.
  2. Before you do anything … make a backup of the file avrdude.conf
  3. Open the avrdude.conf file in a text editor
  4. locate the ATTiny85 section in the file
  5. locate the chip_erase_delay = 4500; line
  6. add the following two lines below this:
      pagel = 0xB3;
      bs2 = 0xB4;
  7. locate the memory=”lock” keyword in the ATTiny85 section
  8. replace this section with the following (copy and paste)
memory "lock"
   size  = 1;
   write = "1 0 1 0  1 1 0 0  1 1 1 x  x x x x",
           "x x x x  x x x x  1 1 i i  i i i i";
   read  = "0 1 0 1  1 0 0 0  0 0 0 0  0 0 0 0",
           "0 0 0 0  0 0 0 0  o o o o  o o o o";
   min_write_delay = 9000;
   max_write_delay = 9000;
;


Do the same for the ATTiny84 section.
You will need to restart the IDE for this to be affected.
After this, you need to
  1. Connect the ATTiny85 to the Arduino using your favourite ICSP
  2. load the sketch into the IDE
  3. Select the ATTiny85 board in the IDE
  4. Select Arduino as ISP in the IDE
  5. Upload your sketch to the ATTiny85.
That should fix the problem.
I have now tested the abovementioned fix and the error message has now gone away. To test this, I loaded the sketch from Tutorial 10, compiled and then uploaded it to the ATTiny85 with the following, successful, result.
image
As you can see, the Pagel and BS2 error messages have gone … YAY! Thank you Wiki Page!
After uploading the sketch to the ATTiny85, I dropped the ATTiny85 chip into the circuit and powered it up, again, success. The circuit does what it’s supposed to do.
All in all, happy camper time.

Thursday, 13 November 2014

ATTiny85 – Tutorial 10 – Detecting Knocks and Vibration

This tutorial in it’s original form sends the detection of knocks and vibrations from the Freetronics ”Sound” module to the serial monitor. As we don’t have access to a serial monitor from the ATTiny85, instead we are going straight to the extended tutorial, monitoring our knocks and vibrations with an LED.

ATTiny85 Pin Project 10

For this tutorial, the Piezo (Sound module) is connected on A1 (ATTiny85 pin 7) and an LED is connected to 0 (ATTiny85 pin 5).

The Piezo is read using the analogRead Arduino function and, when the analog value read from the Piezo is > 5, it will light up our LED (with a pull down resistor).

/* Project 10: Detecting Vibrations and Knocks */

int knock = 0;

void setup()
{
  pinMode(0, OUTPUT);
}

void loop()
{
  knock = analogRead(A1);
  if(knock>5)
  {
    digitalWrite(0, HIGH);
    delay(300);
    digitalWrite(0, LOW);
  }
}

The sketch is pretty straight forward … the variable knock is assigned the value of analogRead and, if it’s value is > 5 the ATTiny85 turns the LED on with digitalWrite, then waits 300 milliseconds, and then turns the LED off again with digitalWrite.

Tutorial10

You can see from the above image that the wiring is pretty straight forward. Top right of the breadboard is  the 5V regulator. The ATTiny85 was programmed using the ATTiny85 ICSP.

ATTiny85–Detecting Knocks and Vibrations with Freetronics “Sound” module

This is the 10th Freetronics Experimenters Kit tutorial that I’ve converted to the ATTiny85.

Check out the rest of the tutorials here.

Thursday, 6 November 2014

ATTiny85 – Tutorial 9 – Making Sounds

While this looked like a fairly simple tutorial on the face of it, it was actually a bit more difficult.

The main problem that I encountered was that the tone() function is not supported by the ATTiny85 core, so I had to do a bit of hunting around to find an equivalent method for the ATTiny85. As I expected, others had come across this same problem and had already developed a solution for it.

Two of the solutions that I tried (arduino-tiny library and a beep function) were both unsuccessful. Both produced cricket sounds (probably because the timing was wrong). However, I found Simple Tones for ATtiny that produces a nice scale and didn’t cause me too many other problems.

ATTiny85 - Tutorial 09

The connection from the ATTiny85 to the Piezo is very simple. Connect Pin 1 of the ATTiny85 to either pin of the piezo (it isn’t polarised). Connect GND to the other pin of the piezo.

Here is the sketch from the Technoblogy article referred to above (Simple Tones for ATTiny).

/* TinyTone for ATtiny85 */

// Notes
const int Note_C  = 239;
const int Note_CS = 225;
const int Note_D  = 213;
const int Note_DS = 201;
const int Note_E  = 190;
const int Note_F  = 179;
const int Note_FS = 169;
const int Note_G  = 159;
const int Note_GS = 150;
const int Note_A  = 142;
const int Note_AS = 134;
const int Note_B  = 127;

int Speaker = 1;

void setup()
{
  pinMode(Speaker, OUTPUT);
}

void loop()
{
  playTune();
  delay(300);
}

void TinyTone(unsigned char divisor, unsigned char octave, unsigned long duration)
{
  TCCR1 = 0x90 | (8-octave); // for 1MHz clock
  // TCCR1 = 0x90 | (11-octave); // for 8MHz clock
  OCR1C = divisor-1;         // set the OCR
  delay(duration);
  TCCR1 = 0x90;              // stop the counter
}

// Play a scale
void playTune(void)
{
TinyTone(Note_C, 4, 500);
TinyTone(Note_D, 4, 500);
TinyTone(Note_E, 4, 500);
TinyTone(Note_F, 4, 500);
TinyTone(Note_G, 4, 500);
TinyTone(Note_A, 4, 500);
TinyTone(Note_B, 4, 500);
TinyTone(Note_C, 5, 500);
}

This sketch works just dandy, straight out of the box. Nice work Technoblogy, nice work indeed.

I need to do some more research to find out how I can get the tone() function from the arduino-tiny library to work satisfactorily, but for now, the above sketch serves my purpose.

Making Sounds with Piezo and the ATTiny85

Well, that concludes Tutorial 9. Enjoy. Once again, 9V to 5V Regulator and ATTiny85 ICSP were used to make this tutorial circuit.

Check out the rest of the tutorials here.

Tuesday, 4 November 2014

ATTiny85 – Tutorial 6 – Making Things Move With Servos

The Freetronics Tutorial 6 replaces the LED and Resistor connection on pin 11 of the Freetronics 11 with the data connection to a simple servo.

The ATTiny85 version does the same thing … not really much sense reinventing the wheel, huh?

ATTiny85 - Lesson 6 - Making Things Move With Servos

As we learn with Tutorial 7, there are three PWM pins on the ATTiny85 to choose from. I went with the easiest and most convenient … our old friend, pin 0.

If you use the sketch from Tutorial 5 in the Freetronics Tutorial with a servo instead of an LED, then this sketch works admirably.

// Tutorial 6: Making things move with servos
int led = 0;
int brightness = 0;
int delayTime = 10;

void setup()
{
  pinMode(led, OUTPUT);
}

void loop()
{
  while(brightness < 255)
  {
    analogWrite(led, brightness);
    delay(delayTime);
    brightness++;
  }
  while(brightness > 0)
  {
    analogWrite(led, brightness);
    delay(delayTime);
    brightness--;
  }
}
 

Of course, I’m using the ++ and – incrementing function rather than brightness = brightness + 1; and brightness = brightness –1; because I think that it looks better, but that’s just me. Let the spirit guide you in your decision …

Lesson 6 - Running

The green jumper connects from ATTiny85 pin 0 to the yellow connector on the servo, Red connects to Orange on the Servo from the 5V rail and the black jumper connects the brown servo connection to GND.

Here’s a short video of the action.

ATTiny85 Controlling a servo with PWM

Check out the rest of the tutorials here.

Monday, 3 November 2014

ATTiny85 – Tutorial 7 – RGB LED

I was playing around looking at the information at hand on the ATTiny85 PWM and I thought that there were only 2 PWM capable pins on the chip … apparently, I was wrong, there are three. PB0, PB1 and PB2 are all PWM. Until I realised that, I was toying with the idea of software based PWM. There are some pretty good articles, tutorials and pages relating to software PWM, so I’ll probably get around to playing with it, some other time.

In the meantime. I had another look over the Freetronics Tutorial #7 – RGB LED and I decided that the code was a little clunky. The RGB values all jump to their random values and there is a lot of blinking … that’s OK if that’s what you want. Anyway, I had a quick play and decided to make the values rise from 0 to their random value and then back down to 0 so that they fade in and out. It’s still a little inelegant, but for the sake of a decent tutorial, I thought that this would be fairly useful.

ATTiny85 - Lesson 7 - RGB LED

My code is as follows

//Tutorial 7: RGB LED *** EXTENDED

int rPin = 0;
int gPin = 1;
int bPin = 2;

void setup()
{
  pinMode(rPin, OUTPUT);
  pinMode(gPin, OUTPUT);
  pinMode(bPin, OUTPUT);
  analogWrite(bPin, random(0, 255));
  analogWrite(gPin, random(0, 255));
  analogWrite(rPin, random(0, 255));
  delay(500);
}

void loop()
{
  upDown(random(0,255), random(0,255), random(0,255));
  delay(500);
}

void upDown(int r, int g, int b)
{
  //bring the colours up
  int rVal, gVal, bVal = 0;
  for(int rVal = 0; rVal < r; rVal++)
  {
    analogWrite(rPin, rVal);
    delay(10);
  }
  for(int gVal = 0; gVal < g; gVal++)
  {
    analogWrite(gPin, gVal);
    delay(10);
  }
  for(int bVal = 0; bVal < b; bVal++)
  {
    analogWrite(bPin, bVal);
    delay(10);
  } 
 
//  return to 0
  while(rVal>0)
  {
    rVal--;
    analogWrite(rPin, rVal);
  }
 
    while(gVal>0)
  {
    gVal--;
    analogWrite(gPin, gVal);
  }
 
    while(bVal>0)
  {
    bVal--;
    analogWrite(bPin, bVal);
  }
 
}

This is still fairly close to the original, with an upDown function that fades each colour in and then all of them out again.

I used my ATTiny85 ICSP to program the ATTiny85 and the 9V to 5V power regulator to supply the solderless bread board.

Lesson 7 - Board

As you can see, there isn’t anything outside of the Arduino core being used in the code, and the wiring is very straight forward. The layout is as per the Freetronics tutorial (more or less … I’ve added a jumper from the top to bottom rails).

Here is how it looks when it’s running. Bear in mind that the cycle uses a random RGB value and splits it up, so it *should* be different for every cycle.

RGB LED Controlled by PWM on the ATTiny85

Well … it’s now well past my bed-time, so I’m calling it a night.

Have fun ATTiny85ers!

Check out the rest of the tutorials here.

ATTiny85 – Tutorial 5 – Dimming LED using PWM

This tutorial is a very simple conversion from ATMEGA328P to ATTiny85, there is only one pin involved in producing output, so we only need to change from pin 11 to pin 0. On the ATTiny85, there are three hardware PWM pins … pin 0, pin 1 and pin2 , so it’s simply a matter of switching over to Pin 0 and away we go.

ATTiny85 - Lesson 5 - Dimming LED with PWM

I’ve changed the sketch for personal taste (and I think, efficiency), you’re free to use the Freetronics version of the code if you like … it’s no great shakes on something this small.

/* project 5: Controlling LED brightness with PWM */

int led = 0;
int brightness = 0;
int delayTime = 10;

void setup()
{
  pinMode(led, OUTPUT);
}

void loop()
{
  while (brightness < 255)
  {
    analogWrite(led, brightness);
    delay(delayTime);
    brightness++;
  }
  while (brightness > 0)
  {
    analogWrite(led, brightness);
    delay(delayTime);
    brightness--;
  }
}

As you will see from the following image, there isn’t much to the wiring for this project.

Tutorial5

And here’s the circuit running through it’s light/dim wizardry.

Tutorial 5 – ATTiny85 - Dimming LED with PWM

Once again, I’m using my ATTiny85 ICSP to program the ATTiny85 using the Arduino UNO and my 9V to 5V power regulator to supply 5V to the circuit.

Check out the rest of the tutorials here.

Friday, 31 October 2014

ATTiny85 Tutorials

I thought that it may be easier for everyone if I put together a single page that lists all of the ATTiny85 tutorials on this blog so that you can come here and launch off to the tutorial that you want to see.

Once again, these are based on the Freetronics Eleven tutorials that you get when you buy the Experimenters Kit.

My goal is to produce an ATTiny85 equivalent for each of the tutorials in that guide, so that you can take advantage of both the Freetronics basic tutorials and my experimentations with the ATTiny85.

I am a hobbyist, not an expert!

Tutorials

Freetronics Tutorial Comments
01 – Controlling an LED  
02 – Controlling 8 LED 4 LED
03 – Reading Digital (On/Off) Input 4 LED
04 – Reading Analog (Variable) Input  
05 – Dimming LED Using PWM  
06 – Making Things Move With Servos  
07 – RGB LED  
08 – Drive More Outputs With A Shift Register 8 LED using 75HC595
09 – Making Sounds Using alternative tone() function
10 – Detecting Vibrations and Knocks  
11 – Light Input Controlling Sound Output  

I’m going to come back to this article and fill in the blanks as I complete the tutorials, so check in from time to time to see how we get along.

I will include the Arduino sketch along with the article so that you can see how the code differs between the chips. I am still planning on doing the same with the ATTiny84 and I’m likely to use the same format.

Typically, the tutorials will include a pin assignment section, an image or video of the completed circuit, the Arduino code and some commentary on the differences that I’ve encountered and the approach that I’ve taken.

Thursday, 30 October 2014

ATTiny85 Tutorial 4 – Reading Analog (Variable) Input

This is the 4th tutorial in the Freetronics Experimenters Kit converted to ATTiny85.

With this tutorial, the main changes from the original tutorial is again the pin assignments. But, also, the ATTiny85 is not connected to the PC via the USB cable, so Serial.begin, Serial.print and Serial.println are redundant. I have removed them from the sketch.

ATTiny85 Pins - Project 4

In this tutorial, the light sensor is connected to first Analog Digital Comparator pin (physical pin 7 ADC1). In your sketch, the analog pins are A1, A2 and A3 … so for the purpose of this tutorial, we’re using A1. The LED is connected on pin 0 … got that, A1 and 0 … right, let’s move on.

The modified sketch is as follows.

int led = 0;
int lightLevel;

void setup()
{
  pinMode(led, OUTPUT);
}

void loop()
{
  lightLevel = analogRead(A1);
  digitalWrite(led, HIGH);
  delay(lightLevel);
  digitalWrite(led, LOW);
  delay(lightLevel);
}

Within the loop function, the ATTiny85 reads the value of the light sensor, this gives a value of 0 – 5V. The value is read as an integer value from 0 – 1023. This value is assigned to the lightLevel variable that is used to set the blink rate of the LED. The more light there is, the slower the blink rate.

breadboard - Project 4

The yellow wire connects the light sensor to A1 on the ATTiny85 and the LED is connected to 0 on the ATTiny85.

To test this circuit, I powered it up and then turned on my LED lamp above the sensor … as you would expect, the blink rate slowed down, then I swung the lamp away from the sensor to give an analog light variation and the blink rate sped up as less light was hitting the sensor … all working as you would expect.

Tutorial 4 circuit running.

Again, I programmed the ATTiny85 using my ATTiny85 ICSP and powered the breadboard using my 5V power regulator.

That’ll do for now, I’ll come back to these tutorials next week.

Check out the rest of the tutorials here.

ATTiny85 Tutorial 8 – Drive More Outputs With A Shift Register

So, I thought that I’d skip ahead a bit and get straight into the control of LED via a shift register. As the ATTiny85 has few pin outs, the main thing to be able to go beyond the simple binary pin to pin scheme is to get a shift register working for you.

For this tutorial, I have tried to fit all of the components onto a half+ board. Of course, I’m using my 5V regulator, so I am cheating slightly. However, the ATTiny85 and the 74HC595 both fit on the board along with the required 8 LED.

The original Arduino sketch includes the instantiation of Serial communication, that hasn’t been enabled on my ATTiny85, so I’m just commenting it out in the sketch. I am also omitting the smoothing capacitor between data and GND, if you want to include it, by all means, knock yourself out.

The shift register tutorial uses only digital pins in the original, so I am substituting like for like in the ATTiny85 platform.

The wiring is a little confusing (probably because I crammed it all into a half+ board), but there really isn’t much to it.

Lesson 08 - Drive More With A Shift Register_bb

So long as you get the connections between the ATTiny85 and the 74HC595, then it’s really just a matter of poke and play (of course, you’ll need to be careful with the Vcc and GND connections!).

ATTiny85 - Connections to Shift Register

I’ve taken the liberty of changing the sketch to something closer to what I’ll actually be using, so beware that there are some functional changes (although very few).

Onto the sketch:

/*
  Shift Register Example
  Turning on the outputs of a 74HC595 using an array.
  Modified for ATTiny85

Hardware:
* 74HC595 shift register
* ATTiny85
* LEDs attached to each of the outputs of the shift register

*/
//Pin connected to ST_CP (12) of 74HC595
int latchPin = 2;
//Pin connected to SH_CP (11) of 74HC595
int clockPin = 3;
////Pin connected to DS (14) of 74HC595
int dataPin = 0;

//holders for information you're going to pass to shifting function
byte data;
byte chaseArray[8];

void setup() {
  //set pins to output because they are addressed in the main loop
  pinMode(latchPin, OUTPUT);
//  Serial.begin(9600);

  chaseArray[0] = 1;   //00000001
  chaseArray[1] = 2;   //00000010
  chaseArray[2] = 4;   //00000100
  chaseArray[3] = 8;   //00001000
  chaseArray[4] = 16;  //00010000
  chaseArray[5] = 32;  //00100000
  chaseArray[6] = 64;  //01000000
  chaseArray[7] = 128; //10000000
 
  //function that blinks all the LEDs
  //gets passed the number of blinks and the pause time
  blinkAll_2Bytes(2, 500);
}

void loop() {

  for (int j = 0; j < 8; j++) {
    //load the light sequence you want from array
    data = chaseArray[j];
    //ground latchPin and hold low for as long as you are transmitting
    digitalWrite(latchPin, 0);
    //move 'em out
    shiftOut(dataPin, clockPin, data);
    //return the latch pin high to signal chip that it
    //no longer needs to listen for information
    digitalWrite(latchPin, 1);
    delay(60);
  }
}

 

// the heart of the program
void shiftOut(int myDataPin, int myClockPin, byte myDataOut) {
  // This shifts 8 bits out MSB first,
  //on the rising edge of the clock,
  //clock idles low

  //internal function setup
  int i=0;
  int pinState;
  pinMode(myClockPin, OUTPUT);
  pinMode(myDataPin, OUTPUT);

  //clear everything out just in case to
  //prepare shift register for bit shifting
  digitalWrite(myDataPin, 0);
  digitalWrite(myClockPin, 0);

  //for each bit in the byte myDataOut
  //NOTICE THAT WE ARE COUNTING DOWN in our for loop
  //This means that 000001 or "1" will go through such
  //that it will be pin Q0 that lights.
  for (i=7; i>=0; i--)  {
    digitalWrite(myClockPin, 0);

    //if the value passed to myDataOut and a bitmask result
    // true then... so if we are at i=6 and our value is
    // %11010100 it would the code compares it to %01000000
    // and proceeds to set pinState to 1.
    if ( myDataOut & (1<<i) ) {
      pinState= 1;
    }
    else { 
      pinState= 0;
    }

    //Sets the pin to HIGH or LOW depending on pinState
    digitalWrite(myDataPin, pinState);
    //register shifts bits on upstroke of clock pin 
    digitalWrite(myClockPin, 1);
    //zero the data pin after shift to prevent bleed through
    digitalWrite(myDataPin, 0);
  }

  //stop shifting
  digitalWrite(myClockPin, 0);
}


//blinks the whole register based on the number of times you want to
//blink "n" and the pause between them "d"
//starts with a moment of darkness to make sure the first blink
//has its full visual effect.
void blinkAll_2Bytes(int n, int d) {
  digitalWrite(latchPin, 0);
  shiftOut(dataPin, clockPin, 0);
  shiftOut(dataPin, clockPin, 0);
  digitalWrite(latchPin, 1);
  delay(200);
  for (int x = 0; x < n; x++) {
    digitalWrite(latchPin, 0);
    shiftOut(dataPin, clockPin, 255);
    shiftOut(dataPin, clockPin, 255);
    digitalWrite(latchPin, 1);
    delay(d);
    digitalWrite(latchPin, 0);
    shiftOut(dataPin, clockPin, 0);
    shiftOut(dataPin, clockPin, 0);
    digitalWrite(latchPin, 1);
    delay(d);
  }
}

Running

I thoroughly recommend that you do this tutorial on the Arduino first before attempting the ATTiny85 version, so that you know what to expect and how the connections work. Other than that, this makes a nice and tiny board project, now I need to play with laying this out on a board so that I can etch it … that should be fun.

5V Reg - Powered

Testing the ATTiny85 Shift Register Sub Board

The above video is the ATTiny85 and 75HC595 sub board connected to breadboarded LED. This is the next step on from the breadboard version in this article, but uses the same sketch and is functionally identical.

Check out the rest of the tutorials here.

Tuesday, 14 October 2014

Prototype Embedded Electronics – Together

Now that I have completed the three circuits that I had planned to embed in the Steam Punk prop (Torch, Pulsing/Fading LED, LED Chaser) it’s time to put them together in a single main/sub configuration as they would be in the prop. I had to cheat a little here … I couldn’t find one of my male to male DuPont connectors and, rather than make a new one, I opted for the easier option of replacing the 2x2 SMD circuit with the 4 x 5 LED “Desk Light” circuit. In terms of testing the components together, this should really have no practical impact on the outcome. Sure, they are through hole components … and a lot more of them, so the only real difference from the perspective of testing the overall concept is that it will draw more power from the battery. In the embedded scenario, I need to rebuild ALL of the component circuits, so there really isn’t anything lost there.

I have connected a 9V battery to my trusty solderless breadboard and then connected each of the components to the power rails. The Torch and Pulsing/Fading circuits are connected to the 9V directly, whereas the LED Chaser is connected to 9V via a 5V Regulator (I opted for an early version of this as I didn’t need the optional LED power indicator).

The result is as expected … it all works just dandy. I should probably go ahead and work out power consumption so that I have an idea of how long the battery will last in the prop. I’m still toying with the idea of also embedding a battery charger circuit … but it is easy and cheap enough to use a commercial – “off the shelf” charger so I’m not going to bother with that … yet.

There are still more tweaks and optimisations that I am planning, but that’s for later.

I present to you the prototype embedded electronics of the Steam Punk prop …

Fiat Lux

Combined embedded electronic circuits for a planned Steam Punk Cosplay prop

Monday, 13 October 2014

ATTiny85 Shift Register – Sub Board Populated

This weekend I completed the preparation work on the LED Sub Board for the ATTiny85 Shift Register board.

The preparation work was simply cutting the board to shape and filing it down to make it round.

Tonight, I populated the board with the resistors (SMD 0805 120Ω), the pin headers and the 3mm blue LED. There really wasn’t much involved in this other than getting down and doing it. I could have made my live a little easier by spacing the pin headers more … but, you live and learn.

LED Sub-board 01

The trickiest part was soldering the SMD resistors. I did this by first clipping the resistor onto the board with a spring clip and soldering one side (the inside edge) and then going around and soldering the outside. After that, I soldered the pin headers and finally, the LED. I gave the board, LED and pins a test using the multimeter and found that the pin header for LED 2 was dry soldered, so I went over it again until I had a decent solder filet.

LED Sub-board 02

The top of the board looks pretty straight forward, nothing much to see.

This is still a prototype board, so I’m not terribly fussed. I’m happy with the shaping of the board, but, again, I could make my life easier by making this slightly larger. In the final version, I plan to have sockets instead of LED soldered to the board as the LED will be mounted on the inside of a Steam Punk prop … not held flat to a disc.

ATTiny85 Shift Register – Chasing LED Sub Board

Well, as far as a prototype goes, I think I’m happy with the outcome. I’ve learned some useful stuff about this type of circuit and I can use what I’ve learned when I’m making the version that will mount inside the prop, such as the spacing of the pin headers and the spacing and size of the screw mounting holes.

This project will probably end up as wearable electronics, I plan to mount the sub-board in opaque resin and make a badge out of it. I’ll also decrease the delay interval in the Arduino sketch to run roughly double the speed.

Wednesday, 8 October 2014

ATTiny85 Shift Register – Main Board Populated

Tonight, I populated the main board for this project and made the necessary connecting wires. You can see the previous post at ATTiny85 Shift Register – Etched.

I started out by making the 9 DuPont Female to Female 1 Pin wires, 8 yellow and 1 black. The yellow wires connect Q1 – Q8 on the shift register to (ultimately) LED 1 – LED 8 on the sub-board. This was mostly a process that took time. I cut the wires to 100mm, stripped 5mm from both ends of the wire, tinned the wires, tinned the DuPont connectors, soldered the wire to the DuPont connectors, slipped the pin housing onto the connector … job done. Although, 9 wires with a little finessing ended up taking me about 45 minutes to complete, I’m glad that job is done.

ATTiny85 and 74HC595 - Populated 02

The next task was to populate the Main Board with the 8 and 16 pin DIP and the pin headers … there aren’t any heat sensitive components here, so it was, again, just a process.

ATTiny85 and 74HC595 - Populated 01

Tested the board and connections with the multimeter, all happy.

ATTiny85 and 74HC595 - Populated 03

After that, dropped in the ATTiny85 and 74HC595

I still have to pull the ATTiny85 and upload the modified Shift Register sketch onto it. I plan to test the main board by connecting it to 8 LED and resistors on a solderless breadboard. But … I’m too lazy and I think that I’ve done enough tinkering today.

huh … what do you know … I’m not that lazy!

Testing the ATTiny85 Shift Register board

Putting the Electronics together – Planning

The main reason that I’ve been tinkering with electronics is my longer term goal of embedding some interesting lighting effects into a Steam Punk prop. That was where all of this started.

Now I have some decisions to make about which lighting effect circuits I want to include.

I want:

  • A pulsing/fading light acting as a power indicator and with a cool translucent – through hole cover (i.e. the Mac power indicator);
  • Chasing lights to come on when the trigger is pulled; and
  • A torch-light at the front of the prop

I’ve done a couple of pulse fade circuits, all with varying degrees of success (well … appearance). My two favourites are the 9V PUT transistor pulse fade that I found in the Make! book and the ATTiny85 pulsing LED that I modified from the Arduino as ISP sketch. The PUT version is neat and quite cheap, it doesn’t require any expensive parts (relatively), the most costly part is the PUT transistor (2N6027), but, at around $0.27AUD per transistor, I can live with that, this pushes the PUT version to around $0.73 per board. The ATTiny85 version has far fewer parts, but the ATTiny85 is much more expensive than a PUT transistor so it ends up costing around $2.48AUD.

The Chasing Lights is a bit of a no brainer, I’m going to go with the ATTiny85 + LED Sub-board option. The total cost of the board and sub-board comes to $4.37AUD.

Finally, I’m going to rebuild the 2x2 SMD LED Matrix project and change the layout a little. This was a great learning circuit for a couple of reasons and at a cost of around $0.49 it’s nice a cheap too!

There are a couple of additional costs, such as switches. For the chasing lights, I’ll either use a momentary switch or a lever switch, which way I go is going to depend on the way that I design the trigger for the prop. Apart from that, there’s about $1.00 worth of wire.

So, the embedded electronics come in at (PUT) $6.59 or (ATTiny84) $8.34 … plus the switches.

Electronics Block Diagram

The above block diagram shows the overall design using the ATTiny85 Pulse/Fade component while the one below shows the overall design using the PUT Pulse/Fade component.

Electronics Block Diagram - Alternative Pulse

With the PUT Pulse/Fade, I’ve dropped a switch and put the SMD LED onto the 9V power source, rather than the 5V regulated power source.

My next step from here is to put these circuit boards together on a prototype “board” to test the overall concept.

Tuesday, 7 October 2014

ATTiny85 Shift Register – With Sub Board

Breaking the design of the circuit into a controller board and LED sub-board arrangement seems to be a bit … inefficient. Of course, this could be just because of my design.

Fritzing - ATTiny85 - Shift Register - 3_pcb

On this board there are just the ATTiny85, 74HC595 (Shift Register) and the necessary pin blocks for connecting it to the round LED sub board. There’re probably more efficient designs for this, but I’ve simply removed the LED and resistors and then re-routed the traces.

Fritzing - LED Sub Board - Round_pcb

The LED sub-board is probably more like what I wanted. At the moment, the 9 pin headers are aligned for main and sub-board simply connecting using a straight forward pin block pairing. However, I’m likely to connect the main and sub-board with jumper wires rather than male pin block to female pin block, so the arrangement of the pin headers on the main board are kinda irrelevant and I could make the design more efficient on the main board, for instance, I could have the pin header right up against the 74HC595, meaning that the routing would be much less of a dogs breakfast. That would also mean that I could re-orient the ATTiny85 and have the traces from that to the 74HC595 more straight forward too.

With that in mind … the arrangement of the main board should probably be more like the following.

Fritzing - ATTiny85 - Shift Register - 4_pcb

This is a much more straight forward design and doesn’t waste any space. The new design (above) is 40mm x 40mm, so I can save a bit of space using this layout rather than the one above. 1 wire to carry the GND and 8 for the Q0 – Q7 pins on the 74HC595 chip.

That should probably cover the design side fairly well. OK, so this is the design that I’m going to go with.

I guess the other thing that I like more about this design is that I can have a couple of LED sub-boards with different coloured and sized LED and play with the visual design of the board more.

ATTiny85 Shift Register – Plan

I’ve been struggling for a while to work out a design for an ATTiny85 circuit with a shift register and 8 LED laid out on a single sided copper clad PCB. My main issue has been with the overlapping of traces.

Well, today I think that I’ve created a design that will work.

Fritzing - ATTiny85 - Shift Register - 2_pcb

I’m going to start making this board tonight and see if my design is right and then I’ll start tinkering with the design. I want to make a circular chasing light on a @40mm diameter board. So far, my designs for this circuit have left a lot to be desired so I’ll see how I get along.

The main questions to be answered in this design are:

  • Can I re-arrange the LED and resistors around a circular PCB; and
  • Is the design sufficiently optimised.

Ultimately, the chasing LED circuit will be embedded in another device, so I need the PCB to be of an optimal size. Once the board design is proven, then I can jigger around with it some more.

Honestly, I don’t mind if the circuit doesn’t live up to my expectations, it’s all learning.

Of course, the alternative is a sub-board with the LED and resistors on it.

Thursday, 2 October 2014

Arduino ATTiny84 ISP Shield – PCB – Part 2

Here is the completed Arduino UNO ATTiny84 ICSP (ISP) Shield that I have just completed.

ATTiny84 ICSP Shield 02

While soldering the board, I went through and tested each trace with the multimeter so that I wouldn’t have to go back later and find any dud connectivity. It turns out that there weren’t any shorted or broken traces this time, so it may have been a vein effort, however, I know that when I plug it in and run the circuit, that at least there aren’t any hardware failures.

The Arduino IDE test (using the UNO as an ISP) went without a hitch too, so it seems that all of my errors were caught early on and I ran out of problems … yay!

I am quite pleased with the two ICSP, they work well, have minimum components and an elegant design.

To recap on some of the design elements, below is the connections from the ATTiny84 to the Arduino UNO.

ATTiny84_To_Arduino

You can see that the connections for the ATTiny84 are essentially the same as  theATTiny85, just arranged differently.

I have been thinking about using a tri-coloured LED (common cathode) to replace the three 3mm Red, Green and Blue LED … but that can wait for now, I really don’t need the extra ICSP.

Arduino as ISP for ATTiny84

Following on in the same vein as my previous articles on Arduino as ISP for ATTiny85 IC, this article addresses the ATTin84. I refer you to the previous posts in the thread ATTiny85 thread for more information on plans, designs and etcetera, particularly Arduino as ISP for ATTiny85.

As I have mentioned in previous articles, there are very few differences between the 84 and the 85 in terms of pinouts. The arrangement and number of the pins are probably the most significant differences. The components required are virtually the same (you need a 14 pin DIP rather than an 8 pin … and obviously, you need an ATTiny84 IC).

ATTiny85_To_Arduino

Above is the pinout for the ATTiny85 IC and how it connects to the Arduino UNO. Below is the pinout for the ATTiny84 and how it connects to the Arduino UNO.

ATTiny84_To_Arduino

The differences between the two chips mean that there is some significant difference in the arrangement of the PCB that I designed for the ATTiny85 but the footprint is nearly identical and the ArduinoISP sketch that comes with the Arduino IDE needs no modification at all.

The Blink sketch also does not need modification from the already modified ATTiny85 version of the sketch, however, instead of connecting the LED to pin 5 (PB0), we are now connecting to pin 2 (PB0). Well … I still need to verify that once I’ve finished building the ISP and then breadboarded the ATTiny84 IC in the same test configuration as the previous article. But from my current reading, that should be just Jim Dandy.

Tuesday, 30 September 2014

Arduino ATTiny84 ISP Shield – PCB – Part 1

Following on from my ATTiny84 ICSP Arduino Shield Plan article and in the same vein as the Arduino ATTiny85 ISP Shield articles, I am now in the process of making an Arduino shield for programming the ATTiny84. This is the 16 pin miniature Atmel microprocessor.

ATTiny84_Pinout_thumb1

The above shows the pin configuration of the ATTiny84 that the shield will interface to the Arduino. The relevant pins for ICSP control are Vcc, GND, PB3 (RESET), PA4 (USCK), PA5 (MOSI), and PA6 (MISO).

Once again, the design makes use of the Arduino Pins 7, 8 and 9 for PRG, ERR and HB indicator LED, so while the arrangement of pins is different, the function and interface to the Arduino UNO is the same.

Fritzing-ATTiny84-ICSP_etch_copper_b

The above image is the mirror reverse copper bottom layer converted to a jpeg file. And below is the toner transferred PCB that was created using the above (although, I’ve used the raster PDF version rather than the converted bitmap). Last night I discovered that I got this wrong. The copper trace on the bottom of the PCB should not be reversed. Make sure you print it out correctly. I still get this wrong from time to time.

ATTiny84-ISP-Shield-01_thumb1

I’ve since given the PCB a bit of a scrub with a wet thumb to remove the remaining paper residue and gone over the traces with a medium Staedtler Lumocolor marker to improve the resolution of the traces and pads.

Now all that remains is to etch the board and start populating it in the same manner as the ATTiny85 version.

I also made another 9V to 5V regulated power supply. The only difference that I am making to the new 5V reg is to orient the output +/- on the bottom of the PCB so that I can plug it directly into a solderless breadboard (meaning that I don’t have to chase wires from the reg to the board … more elegant, I think).

9V---5V-Regulator_thumb

Again, scrubbed with wet thumb and then retraced with the marker to give a better resist for the acid bath.

In case you are interested … here is the bitmap copper bottom mirror for transfer toner.

Fritzing-9V-to-5V-Regulator_etch_cop

Well … that’s it for me, tonight.

Dual Sided PCB – A first foray – Part 1

Now that I am fairly confident in my ability to produce a single sided printed circuit board, it’s time to move on to the more complex issue of producing a 2 sided printed circuit board.

The plan is to make a circular PCB with a shift register and 8 LED. The circuit will be driven by an ATTiny85 that attaches via 3 jumpers to the board (so that I can free up some space on the board) and to power via another 2 jumpers.

Shift Register - Round PCB - Copper Both Layers

Above is the circuit design showing both the top and bottom layer.

I started out by using a hole saw to cut the double sided copper clad board to the right shape. The main downside to this method is that you end up with a pilot hole in the middle of the board. Fortunately, the pilot hole ends up underneath the 16 pin DIP and not much routing needs to be considered.

Normally, when transfer printing a single layer PCB, the bottom layer is printed out as a mirror image so that when it is transferred to the board, it’s around the right way. For dual layer, it seems that the top layer is printed out in positive and transferred to the PCB so that it will match up with the bottom layer. I printed out both top (positive) and bottom (mirror) onto an A4 sheet of paper, held the sheets with the toner side facing each other and held it up to the light and it looked like the above image … so I think that this is the right way to go.

I also included three “register” points on the design so that I could align the two faces. I plan to cut the A4 sheet down to the design and then hold both top and bottom layer to the copper clad board using the register points for aligning them.

The other three holes in the design are for mounting screws.

Shift Register - Round PCB - Copper Top

The top layer includes the ATTiny85 connections (4 o’clock on the design), most of the shift register connections and the anode connections for the LED.

Shift Register - Round PCB - Copper Bottom Mirror

The bottom layer includes the resistors (I’m using 0805 SMD), the cathode connections for the LED, and the power connections (note that the bottom layer as shown above is NOT mirrored … if you are going to use this design, you will need to mirror the image first).

One of the things that I haven’t quite worked out yet is the connection of the DIP on two layers. I may have to do some rearranging of traces, bending of DIP legs so that they can be surface mounted on the top layer.

This design requires:

  • 8 x 0805 SMD resistors (appropriate for your LED) I’m using 100Ω;
  • 8 x LED;
  • 1 x 16 pin DIP;
  • 1 x 3 pin header (connects to the ATTiny85);
  • 1 x 2 pin header (connects Vcc and GND);
  • 1 x 74HC595 Shift Register IC;

To run the circuit, I’m going to have the ATTiny85 on a solderless bread board running my modified Shift Register sketch.

Well … that’s the plan. I’ll do the toner transfer and etch tonight and see how far I get along with the build.

Paypal Donations

Donations to help me to keep up the lunacy are greatly appreciated, but NOT mandatory.