Show Posts
Pages: 1 [2] 3
16  Topics / Product Design / Re: Itead, Members with Experience... on: December 11, 2012, 01:08:58 pm
I too worry about the iMall transition. Not sure why it was needed, what it fixed. I have an order in production now, let's see what happens.

They've been going through that "transition" since I started ordering PCBs from them many, many months ago and there's never been any issue on my end. I wouldn't worry.
17  Using Arduino / Microcontrollers / Re: attiny 85, any pointers?/ on: December 06, 2012, 07:11:30 pm
That's fine if there isn't documentation, I'm sure I can decipher it. I'd just like to get an example working. Pin mappings might be nice too... I'm sure I've got everything wired correctly but you never know.
18  Using Arduino / Microcontrollers / Re: attiny 85, any pointers?/ on: December 05, 2012, 09:38:15 pm
I wasn't using the RF24 examples, I was using the MIRF examples which don't use the role pin.

Also, it appears I spoke too soon. The UNO was reporting that it was getting packets even though none were being sent. I'll take another crack at it tomorrow when I'm more rested, but if you've got any example that you know works, that'd be helpful.
19  Using Arduino / Microcontrollers / Re: attiny 85, any pointers?/ on: December 05, 2012, 06:42:58 pm
I double checked my connections and it turns out that I didn't have the MISO and MOSI reversed on the UNO. I had them reversed on the ATtiny, but not the UNO.

Of course, I shouldn't have had them reversed on the ATtiny because the library reverses the mappings already. Whoops.

What did you mean by the role pin though?
20  Using Arduino / Microcontrollers / Re: attiny 85, any pointers?/ on: December 04, 2012, 09:06:51 pm
Just wanted to thank you again, your modified library worked like a charm with the 84, And everything is working beautifully!
Could you post some sample code?

I'm trying to use the ping_client and ping_server examples. I've got an ATtiny84 running the ping_client (modified to use the libraries provided by winner10920) and I've got an Arduino Uno using the ping_server example but just the stock example, not modified at all.

The ATtiny sends the packets, but the Uno doesn't receive them.
21  Topics / Product Design / Re: Arduino ISP Programmer Shield on: November 26, 2012, 07:21:59 pm
The 6 pins involved in programing are being connected and disconnected with the dip switches. One row of switches for each chip style. One row are all "on" and the other 2 rows of switches are all "off". You can see what I mean by the picture on this page. http://jeffmurchison.com/blog/arduinoisp-deluxe-shield-updated/
Yep, that's exactly how it works (that's my shield design).

OP, if you only want your shield to program ATtiny25/45/85 and ATmega328 then you don't need DIP switches like mine, at the very minimum, you can get away with using only two jumpers (or a small 2-position DIP switch). Here's a reference sheet for the microcontrollers:



Note that the ATtiny*5 pins on the right side (pins 8-5) are:

VCC
SCK
MISO
MOSI

And pins 20-17 on the ATmega328 are the same. So those can be directly connected to VCC, Arduino pin 13, pin 12, and pin 11 (double check that those pins are right, that's off the top of my head and might be wrong).

The only jumpers you would need would be for pins 1 and 4 on the ATtiny*5.
22  Using Arduino / Programming Questions / Re: Code works on ATtiny84, but not ATtiny44A on: November 19, 2012, 01:40:54 am
Thanks for the quick replies, everyone. I don't know how I missed that. I temporarily brought the arrays down to 50 instead of 100 and sure enough, it works fine now that it's not using as much memory.

Code:
const int maxTurns = 100; // The maximum number of random numbers that will be generated.
int randomArray[maxTurns]; // Array that will store the random numbers for the game
int inputArray[maxTurns];  // Array that will store user input

...alone is 400 bytes of memory.  How much SRAM does the ATtiny44 have?

Can the arrays be changed to an eight bit data type?

Well, I'm not sure to be honest. My technical knowledge of the different data types and their memory footprints is fairly basic. Would it be as simple as changing the 'int' to 'byte', or is it more complicated than that?

Like it has been said, not enough RAM available...Most of your variables can be changed to byte instead of int. Also I noticed, that you constantly write to eeprom in loop(), considering the eeprom have a life of only 100.000 write/erase operations, I think it's a bad idea!

You can use the Arduino Enhanced IDE and it will report a warning if you use too much memory smiley
Yeah, I started using the EEPROM to get a better random seed. I guess my analog pins were grounded too well on my PCB, because I wasn't getting anything by using them. Basically it just keeps track of how far into the sequence the user gets, then adds that to the value already in the EEPROM. This creates a somewhat random number that I can use for a seed. Another user suggested an even better way using a timer, so I may try that out as well. I was aware of the 100,000 operations limit, but I don't think most people would actually hit that limit. People might get, max, 15-20 turns in before failing, so it'd take 5000-6500 games played to exhaust the limit. Still, I might go with the timer solution just in case.
23  Using Arduino / Programming Questions / Code works on ATtiny84, but not ATtiny44A on: November 19, 2012, 12:21:54 am
The ATtiny44 and 84 are both pin-compatible, and as far as I know, just the same microcontroller but with different EEPROM and flash memory sizes.

However, for some reason, my code here for this Simon Says game (see bottom of post) only works on an ATtiny84, not an ATtiny44A. At first I thought it was a voltage issue. I'm only using 2 AA batteries, and I was using an ATtiny84V, which requires less voltage according to the datasheet. However, I tried it on a regular ATtiny84 (which should require the same amount of voltage an ATtiny44A does) and it worked just fine.

I'm kind of stumped on this one. Can anyone think of why the code won't work? I'm running them at 8MHz, internal oscillators. When I use the ATtiny84, everything works right - the startup sound plays, and then the light sequence flashes. When I use the ATtiny44A, no startup sound plays, no light sequence flashes. Here's a video of how it works with the ATtiny84:




My code is here:

Code:
/*
 Application Name: Simon Says Game Kit
 Description: A simple game of Simon Says.
 Author: Jeff Murchison
 Contact: jeff@jeffmurchison.com
 Date: November 15, 2012
 Version: 1.0
 License:
 
 This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
 http://creativecommons.org/licenses/by-nc-sa/3.0/
 
 To purchase a kit, please visit:
 http://jeffmurchison.com/blog/simon-says-game-kit/
 
 Notes:
 
 This code uses cores from the arduino-tiny project, and is designed for use on an ATtiny84.
 For more information and to download the cores, visit the arduino-tiny Google Code page:
 http://code.google.com/p/arduino-tiny/
 
 */


#include <EEPROM.h>   // We're going to be writing some stuff to the microcontroller's EEPROM

int buzzerPin = 2;  // The buzzer pin
int buttonPin[] = {
  0, 7, 8, 9, 10}; // The four button input pins
int ledPin[] = {
  0, 3, 4, 5, 6};  // LED pins
int buzzerTone[] = {
  50, 200, 400, 600, 800};  // Buzzer Tones for the different buttons (fail, 1, 2, 3, 4)

int turnCount = 1;  // Turn counter
int buttonState = 0;  // Button state checker

const int maxTurns = 100; // The maximum number of random numbers that will be generated.
int randomArray[maxTurns]; // Array that will store the random numbers for the game
int inputArray[maxTurns];  // Array that will store user input

int eepromValue = 0;

boolean playedThisTurn = false;  // Boolean variable for if the sequence has been played already
boolean buttonPressed = false; // Boolean variable for f a button has been pressed



void setup()
{
  //Serial.begin(9600);  // Serial is commented out as the ATtiny doesn't support it. Useful for debugging on an ATmega328.

  pinMode(buzzerPin, OUTPUT);  // Set the buzzer to output

  for(int x=1; x <= 4; x++) {  // Set pinmodes for button, LED pins, set LEDs HIGH (off)
    pinMode(ledPin[x], OUTPUT);
    digitalWrite(ledPin[x], HIGH);
    pinMode(buttonPin[x], INPUT);
  }
  //Serial.print("---------");
  //Serial.println("");
  randomArrayGen();
  //Serial.print("Random Array Generated.");
}


void loop()
{
  eepromValue = EEPROM.read(0);
  if ((eepromValue + turnCount) >= 255) {   // EEPROM bytes can only hold a value from 0 to 255. This ensures we don't overflow.
    EEPROM.write(0, turnCount);
  }
  else {
    EEPROM.write(0, (turnCount + eepromValue)); // Add the turncount to EEPROM value 0. We use this for random seed.
  }
  if (playedThisTurn == false) {  // If the player hasn't pushed a button this turn yet, then..
    //Serial.println("");
    //Serial.println("");
    //Serial.print("Turn:");
    //Serial.print(turnCount);
    //Serial.println("");
    //Serial.println("Playing Array");
    //Serial.println("---------");
    playedThisTurn = true;  

    for (int x=1; x <= turnCount; x++) {  // Play all of the moves in the random array at the beginning of each turn
      LEDandTone(ledPin[randomArray[x]], buzzerTone[randomArray[x]]);
      //Serial.println(randomArray[x]);
    }
    //Serial.println("---------");
  }

  for (int z=1; z <= turnCount; z++){
    //Serial.println("");
    //Serial.println("");
    //Serial.print("inputNumber: ");
    //Serial.print(z);
    buttonCheck(z);
    buttonPressed = false;
  }
  turnCount++;
  delay(500);
}


void randomArrayGen ()  // Function for generating the random array
{
  randomSeed(EEPROM.read(0));
  for (int x=1; x < maxTurns; x++) {
    randomArray[x] = random(1, 5);
    //Serial.println(randomArray[x]);
  }
  for (int t=600; t <= 1000; t=t+7){
    tone(buzzerPin, t);
    delay(20);
    noTone(buzzerPin);
    delay(10);
  }
  delay(500);
}

void LEDandTone(int ledPin2, int buzzerTone2)
{
  tone(buzzerPin, buzzerTone2);  
  digitalWrite(ledPin2, LOW);
  delay(400);
  digitalWrite(ledPin2, HIGH);
  noTone(buzzerPin);
  delay(100);
}


void buttonCheck(int inputNumber)  //Function for allowing user input and checking input against the generated array
{
  while (buttonPressed == false){  // As long as a button has not been pressed this turn, keep checking button inputs
    for(int y=1; y <= 4; y++) {
      buttonState = digitalRead(buttonPin[y]);
      if (buttonState == HIGH) { //Checking for button push

        //Serial.println("");
        //Serial.print("Button Pressed: ");
        //Serial.print(y);
        //Serial.println("");

        LEDandTone(ledPin[y], buzzerTone[y]);
        inputArray[inputNumber] = y;

        playedThisTurn = false;
        buttonPressed = true;
        y = 5;

        if (inputArray[inputNumber] == randomArray[inputNumber]) { //Checks value input by user and checks it against
          //Serial.print("CORRECT!");
          //Serial.println("");                
        }                                    
        else {
          //Serial.print("INCORRECT");
          //Serial.println("");
          //Serial.println("");
          //Serial.println("------- DEBUG INFO -------");
          //Serial.println("");
          //Serial.print("inputArray[inputNumber]: ");
          //Serial.print(inputArray[inputNumber]);
          //Serial.println("");
          //Serial.print("randomArray[inputNumber]: ");
          //Serial.print(randomArray[inputNumber]);
          //Serial.println("");
          //Serial.print("[inputNumber]: ");
          //Serial.print(inputNumber);
          //Serial.println("");
          //Serial.print("turnCount: ");
          //Serial.print(turnCount);
          //Serial.println("");
          fail();  
        }
      }
      /*if (buttonPressed == true){
       Serial.println("Exiting buttonState loop.");
       }*/
    }
    /*if (buttonPressed == true){
     //Serial.println("Exiting for loop.");
     }*/
  }
  //Serial.print("Exiting while loop, inputNumber should increment after this");
  delay(200);
}


void fail()  //Function used if the player fails to match the sequence
{
  tone(buzzerPin, 50);
  for (int x=1; x <= 4; x++){
    digitalWrite(ledPin[x], LOW);
  }
  delay(2000);
  //EEPROM.write(0, turnCount+(EEPROM.read(0)));
  turnCount = 1; //Resets turn value so the game starts over without need for a reset button
  for (int x=1; x <= 4; x++){
    digitalWrite(ledPin[x], HIGH);
  }
  noTone(buzzerPin);
  delay(1500);
  randomArrayGen();
}
24  Topics / Product Design / Re: Extra long headers for shields? on: November 13, 2012, 04:33:10 pm
Those ones are still only 10.5mm long. Actually, this is where I get the majority of my components, they're cheaper than almost everywhere else.

I ended up revising my design to not go over the USB or power jacks on the board, so I have no problem with using the shorter headers now.
25  Topics / Product Design / Re: Itead, Members with Experience... on: November 13, 2012, 04:24:14 pm
I've ordered a lot of boards from iTead, and the turnaround is typically a week. Shipping to me (Toronto) is about 2 weeks using the regular shipping option, or 3 days using DHL expedited.

The quality has always been pretty great, and their customer service is very nice. Also, sometimes you get extra of your own boards if someone else decided to open-source their project and your boards were grouped together. At least, that's what I think is the reason I sometimes get 11 or 12 boards instead of 10.
26  Community / Products and Services / Re: Great PCB House for Prototyping on: November 05, 2012, 11:54:14 am
So if I ordered from itead a 25mm x 50mm design, but under the 50mm x 50mm ordering code, would I received just 10 pcb's and effectively waste half the order, or would they supply twice as much, ie 20 pcbs?
No, you would get 10 PCBs. If you want to get 20, you would either double-up or add another 10 PCBs to your order. If you want to cut them, invest in a scroll saw or a dremel. I just cut some of mine this past weekend and had no problem with the scroll saw.
27  Community / Products and Services / ArduinoISP Deluxe Shield - easily program attiny + atmega microcontrollers on: October 27, 2012, 05:59:36 pm
(Edit: I decided to rename the shield to avoid any trademark issue with the Arduino folks. It is now known as the TinyLoadr Shield)

I just got in the latest version of my ArduinoISP Deluxe Shield. I designed this shield to easily program microcontrollers using the ArduinoISP sketch and an Arduino. The latest version supports the following microcontrollers:

- ATtiny13
- ATtiny24/44/84
- ATtiny25/45/85
- ATtiny2313/4313
- ATmega168/328

And it should also work with any other microcontroller that is pin-compatible with one of those listed (like the ATtiny13, and ATmega8/48/88).

It's very easy to use and is really helpful if you like using bare AVR microcontrollers in your projects like I do. If you'd like to learn more about it, you can check out this blog post. If you'd like a shield for yourself, then I'm selling them over at Tindie.

Here are some pics of it (click for full res):







28  Using Arduino / Project Guidance / Re: MAX7219 and resistors for 7-segment displays on: September 26, 2012, 10:04:18 pm
Actually I've got one more question for someone. The datasheet recommends a 0.1uF ceramic and 10uF electrolytic decoupling capacitors between GND and V+. If I'm using two MAX7219s, can I use one set of capacitors, or should I use two sets?
29  Using Arduino / Project Guidance / Re: MAX7219 and resistors for 7-segment displays on: September 25, 2012, 10:17:01 pm
The 30mA is max continuous current and 90mA is a peak current when the display is multiplexed, note the "1/10 duty cycle, 0.1ms pulse width" meaning it would be on for 0.1ms then off for 0.9ms in a multiplexed setup.

That's what I thought, just wanted to make sure! Thanks for your help.
30  Using Arduino / Project Guidance / Re: MAX7219 and resistors for 7-segment displays on: September 25, 2012, 06:14:15 pm
BTW, absolute maximum ratings are to be avoided. The rated typical segment drive current is 40mA, but the minimum is 30mA, so that is what should be designed for.

I was checking out the LEDcontrol library last night and it seems like a good library to use. Also, I'm aware that I'd probably burn it out at the absolute max rating. I just listed those ratings because they were what jumped out at me.

I was unaware, however, of the 30mA minimum. I was planning on using these 7-segment displays, however I'm not sure about something from the datasheet:



(I want to use the green ones).

Will this display be ok to use? I believe the 90mA peak forward current means that I can safely put 40mA to it for a very short period of time, like the MAX7219 would as it cycles the digits on/off.
Pages: 1 [2] 3