Sunday, November 27, 2011

A bit of a laugh..




















time for a giggle..

helps now that the tension's eased up - aside from results, of course..

Friday, November 25, 2011

All over bar the groaning..

Well, that's that for another year (academically speaking), but this blog will continue..

Last two projects were a bit of a frost - got most of the Minor Project posted, but i suspect hardware & programming logic problems, as i couldn't get it to do what i thought it should - it kept doing what i actually had told it to do.

As a poster i once saw says:

*                   I Know You Believe You Understood

*                 What It Was That You Though I Said,

*                          But I'm Not Sure You Realise

*                  That What You Thought You Heard

*                             Was NOT What I Meant!!

i can hear my Arduino chortling away at that thought, since it seems to me that what i thought i'd told it to do was something other than what i wanted {sigh}..

Always assuming the hardware works as expected, of course..

Monday, November 21, 2011

Projects -- Interrupts: Mark II

/*
 * Project:      Project_interrupt
 * Author:      Jane-Maree Howard
 * Date:         Monday 21/11/2011
 * Platform:    Arduino 22
 * Purpose:    To demonstrate an interrupt on Digital pin 3
 * Operation:  Description: Connect a 20kilOhm resistor from
 *                          digital pin3 to digital pin13!
 *                          Earlier problem solved as we now have a hardware feedback
 *                          from OUTPUT digi-pin13 to INPUT digi-pin3,
 *                          to which the interrupt is attached.
 *                          The digital flip-flop occurs every second, is fed to digi-pin3,
 *                          which registers the change & triggers the interrupt,
 *                          which, in turn, calls blink() where the pin state variable is flipped.
 *                          This state change is fed back via digi-pin13 to digi-pin3, triggering
 *                          the interrupt once again.                 
 */
int           iPin13   = 13;
int            iPin3   = 3;
volatile int  iState   = LOW;

void setup()
{
  // open Serial port
  Serial.begin(9600); 
  // set pin13, pin3 as OUTPUTs
  pinMode(iPin13, OUTPUT);
  pinMode(iPin3, INPUT);
  // interrupt1 calls blink() when pin13 flip-flops
  attachInterrupt(1, blink, CHANGE);
  digitalWrite(iPin3, iState);
  Serial.println("\nStart\n");
}//setup()

void loop()
{
  // delay 1 second
  delay(1000);
  // in effect, flip pin13
  Serial.println(iState);
  digitalWrite(iPin13, iState);
  digitalWrite(iPin3, iState);
}//loop()

void blink()
{
  // flip value to trigger interrupt
  iState = !iState;
}//blink()
//END



i finally cracked it!

most annoying though..
..but when i wondered about which pin the interrupt operated on, i went back to the appropriate page.. 

..where i saw that interrupt-0 can be attached to digital pin 2, & interrupt-1 to digital pin 3.

after that, it was pretty much plain sailing - the feedback resistor instead of some weird software, & as can be seen at left, it works beeootifly-thank-yew!

on to my next problem: how can i use LDR hardware to trigger an interrupt (for my "fridge door open" stuff!

{sigh of relief!}.

Projects -- Interrupts

/* example of interrupt function using Arduino 22 */

int                 iPin   = 13;
volatile int  iState = LOW;

void setup()
{
  // open Serial
  Serial.begin(9600); 
  // set pin13 as OUTPUT
  pinMode(iPin, OUTPUT);
  // interrupt1 calls blink() when pin13 flip-flops
  attachInterrupt(1, blink, CHANGE);
  digitalWrite(iPin, 1);
  Serial.println("\nStart\n");
}//setup()

void loop()
{
  // delay 1 second
  delay(1000);
  // in effect, flip pin13
  Serial.println(iState);
  digitalWrite(iPin, iState);
}//loop()

void blink()
{
  // flip value to trigger interrupt
  iState = !iState;
}//blink()
//END







i have been trying to get this interrupt program to work - it doesn't alternate the way i think/assume it should.


it just changes at random, sometimes acting like a touch or proximity switch!

i'm baffled :-?



here's where the example code came from - i've modified it to produce a serial monitor output, & inserted another digitalWrite() statement in the setup to try to get the thing triggering regularly..

..but it doesn't {sigh}..

Tuesday, November 15, 2011

Test Schedule

Well, to start with, here's some test information. Bit scary.. i had the erroneous impression it'd be next week, but it isn't!

Here's some hardware pics & the ATmega328 datasheet..
..& the pin-mapping between the ATmega328 & the Arduino..

We're getting lotsa questions on this.
Here's a schematic of the Duemilanove..
..& the Uno schematic.
 .

Sunday, November 6, 2011

Project 4 -- Major Project: initial survey..

Since this project involves THERMISTORS, i've gone to my other tech blog to see what i've done there.

And this entry has a handy data-table ^..^ .

The idea is to make a strip of about 4 or 5 thermistors to hang inside the door of my fridge; i want to see how much colder it is at the bottom compared to the top.

I know it is colder at the bottom, because meat keeps longer there, & sometimes starts to freeze, whereas it never does  that nearer the top.

I need some of that ribbon cable to 'insert' the thermistors into, & also to transmit data to the analog pins on my Arduino.  i also have a USB power supply, so i could actually do some data-logging over an extended period & save the data to EEPROM for later retrieval & display (& just by chance i've found a LED-strip with about 10 LEDs on it that i'd forgotten i had!).

I'd like to add TWI to a 24LCxx if i can, as that would allow more data to be stored.

A photo-cell (these entries) could tell me when the fridge door was opened.

Another little wrinkle would be to average all the thermistor readings at any one time, &  switch on a motor, say, if the average temperature rises above a preset value.

First things first, however: i need to set up the thermistor strip, write the basic software, & get that part working;  i can add bells & whistles later.

Wednesday, November 2, 2011

PROGMEM - some interesting stuff from Peter B

PROGMEM example

/*
 * Project:    PROGMEM_example
 * Author:     Peter Brook, tidied by Jane-Maree Howard
 * Date:       Tuesday 01/11/2011
 * Platform:   Arduino 22
 * Purpose:    To demonstrate storing data in Arduino's flash memory
 * Operation:  Description: Stores 10x10 matrix (int) in Flash memory
 *                          using the PROGMREM keywords & library
 *             Declare:     formatting buffer (char); word counter (int);
 *                          10X10 data matrix - myData[10][10] (int)
               Setup():     Serial@38400baud:TAKE CARE TO SET SM CORRECTLY         
               Loop():      Print to SM by ROWS, then by COLUMNS; 
 *                          setup() again & loop()
 */
#include {avr/pgmspace.h}      // PROGMEM library
 char chBuffer [5];            // Serial output formatting buffer
 word serialCount;             // word count (2 Bytes)
void setup(void)
{
    Serial.begin(38400);       // Serial connection @ 38400 baud!!
    Serial.println("\nPress space bar .");
//    while (Serial.read() != 32)   delay(1); // Wait for space 
}//setup()

// this is the data to be stored
const int myData[10][10] PROGMEM = {
    '0', '1', '2', '3', '4', '5', '6', '7', '8', 'A',
    '1', '1', '2', '3', '4', '5', '6', '7', '8', 'B',
    '2', '1', '2', '3', '4', '5', '6', '7', '8', 'C',
    '3', '1', '2', '3', '4', '5', '6', '7', '8', 'D',
    '4', '1', '2', '3', '4', '5', '6', '7', '8', 'E',
    '5', '1', '2', '3', '4', '5', '6', '7', '8', 'F',
    '6', '1', '2', '3', '4', '5', '6', '7', '8', 'G',
    '7', '1', '2', '3', '4', '5', '6', '7', '8', 'H',
    '8', '1', '2', '3', '4', '5', '6', '7', '8', 'I',
    '9', '1', '2', '3', '4', '5', '6', '7', '8', 'Z' };

void loop(void) 
{
    int i,j;      // loop counters
    byte n;       // Byte output vble
    
    // print heading for ROWS
    Serial.println("\nData by Rows.");
    for (i=0; i < 100;i++) 
    {
       // some formatting conditions
       if ((i %8)==0) 
          Serial.print("|");
       if ((i %16)==0) 
          Serial.println("");
       // now read a Byte from Flash memory
       n = pgm_read_byte_near(i);
       Serial.print(" ");
       // format output to Serial
       sprintf(chBuffer, "%02x", n);
       // print output 
       Serial.print(chBuffer);
       // next word (= 2 Bytes)
       serialCount++; 
     }//for (i)
    
    // print heading for COLUMNS
    Serial.println(" ");
    Serial.println("\nData by Columns.");
    for (i=0; i < 10; i++) 
    {
      Serial.println(" ");
      for (j=0; j < 10; j++) 
      {
        // print each column entry in BYTE format
        n = pgm_read_word_near(&myData[j][i]);
        Serial.print(n, BYTE);   
      }//for(j)
    }//for (i)
    
    // now set up to go round again
    Serial.println(" ");
    delay(3000);   
    setup();    
    Serial.println(" ");  //start over
}//loop()
/* END */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
See the following links to find out how some of this stuff works.. 
PROGMEM      printf