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
 

Wednesday, October 26, 2011

Task 40 - Timer0 Polling routine - toggle LED on/off

/*
 * Project:      Timer_0_Polling_Experiment
 * Author:      Peter Brook tidied by Jane-Maree Howard on..
 * Date:          ..Wednesday 26/10/2011
 * Platform:    Arduino 22
 * Purpose:     To visually demonstrate Timer0 polling
 * Operation:  Polls Timer0 prescaled by 1024; toggles LED on/off every second
 *      Declare: toggle variable; counter vble; ToggleLED() routine 
 *      Setup():  Serial port @9600baud; Prints opening statement; delays 5 seconds
 *                      set TImerMaSK0 to zero - turn of Timer0 interrupt;
 *                      set Timer/CounterControlRegister0B to DEC5; prescaler /s by 1024;
 *      Loop():    idle until TimerInterruptFlagRegister0 == 1;
 *                      reset TIFR0; count 1 'tick'(from 0 to 60, 61 'ticks');
 *                      @ 60'ticks', reset 'ticks' & toggle LED on/off
 */
int     state = 1;        // LED toggle vble - init. OFF!      
byte  ticks = 0;        // counts up towards 60, the LED toggle value

void setup()
{
  Serial.begin(9600);  // Serial port @ 9600 baud
  Serial.println("\n\tInitial state is OFF\n\t");
  delay(5000);            // wait 5 seconds 
  // initialize digital pin 13 as an output.
  // Pin 13 has an LED connected on most Arduino boards:

  pinMode(13, OUTPUT);
  //after this, can't use 'delay() any more
  TIMSK0 = 0;          // turn off Interrupt for Timer0
  TCCR0B = 5;         // Prescaler divides by 1024;  BIN101 = DEC5
}//setup()

void loop()
{
   while(byte(TIFR0 &0x01) ==0) // loop till flag goes up
   {/* do nothing */}                       
   TIFR0 = 1;                // clear flag
   ticks++;                     // count a tick
 
   if (ticks == 60)          // preset value
   {
      ticks=0;                  // reset 'ticks'
      Serial.print("\tTT ");
      ToggleLED();        // toggle LED
   }//if()
}// loop()

void ToggleLED()
{
  if (state==1)
  {
    digitalWrite(13,LOW);                    // LED turns OFF
    state = 0;                                          // toggle 'state' vble
    Serial.print("I've toggled OFF");   // Serial Monitor o/p
  }//if()
  else
  {
    digitalWrite(13,HIGH);                    // LED turns ON
    state=1;                                             // toggle 'state' vble
    Serial.println("I've toggled ON "); // Serial Monitor o/p
  }//else()
}//ToggleLED() 



In the code, the initial state of the on-board LED (pin 13) is OFF.


The SM output records the first toggle ("TT") & the LED
(of course ) stays OFF.

From then on, the LED's recorded toggled state matches that of the on-board LED (pin 13)

Tasks 40-41 -- Automation&Robotics: schedule 8

  • 40.. Copy the Timer0 Polling routine
             given to you in a previous post,
    and run it with some tidying up.
    Show your tidy code.
    ~
  • 41.. Repeat the program in 40,
             but this time make it work a one second LED flash
    using an Interrupt Service Routine.
    ~


Thursday, October 20, 2011

Task 38a - using the I2C bus with an EEPROM 24LC64 addressed differently

I've added a line to the earlier code coz i want to make it easier to change the device address.


 In this particular case:
  A0 is LOW;
  A1 is HIGH;
  A2 is LOW.


This device needs to be addressed as 0x52
(see code changes below)


#include {Wire.h}           // I2C library - usual brackets warning

byte  LCaddress  = 0x52;    // 24LC64 device address
:
:
// now write the char-string to the EEPROM - NOTE 0x52:address pin A1 is HIGH
i2c_eeprom_write_page(LCaddress, 0, (byte *)somedata, sizeof(somedata));
:
:
// now access the first address (0) from the memory
 byte b = i2c_eeprom_read_byte(LCaddress, 0);   //NOTE 0x52:address pin A1 is HIGH
:
:
 addr++;                //..next address &..
//..access next address from the memory.
b = i2c_eeprom_read_byte(LCaddress, addr);      //NOTE 0x52:address pin A1 is HIGH
:
:
etcetera..

& i've changed the input data just to make sure the program's doing what it should be doing..
 
char somedata[] = "Jane-Maree's EEPROM data";  // - 24 characters..



And this is what it does..










..& when i've written..

byte  LCaddress  = 0x51;    // 24LC64 device address


 ..it's because.. 

  A0 is HIGH;
  A1 is LOW;
  A2 is LOW.


..& this device needs to be addressed as 0x51..



..producing this  ==} 




i've got pikkies of the breadboard arrangement clearly (i hope) showing the connections to A0, A1, & A2.


Everything else is unchanged..







Wednesday, October 19, 2011

Task 38.1 - using the I2C bus with an EEPROM 24LC64: software edit

/*
 * Project:      eeprom_fromWeb
 * Author:      hkhijhe - tidied even more by Jane-Maree Howard
 * Date:         01/10/2010
 * Platform:   Arduino 22
 * Purpose:    To demonstrate use of the I2C bus with an EEPROM 24LC64
 -             "You were issued with an eeprom 24LC64 IC.
 -              This is a TWI memory that you connect to SCL and SDA on the Arduino.
 -              Run the program from the blog.
 -              Show your code changes and the serial monitor output in your blog".
 * Operation:  Because this chip is I2C,
 -               it only uses Arduino analog pins 4 & 5 (SDA and SCL),
 -               and of course the power (5V) and GND.
 -             Connect as follows:
 -                Arduino pin 4 to EEPROM pin 5
 -                Arduino pin 5 to EEPROM pin 6
 -                Arduino 5V to EEPROM pin 8
 -                Arduino GND to EEPROM pin 1,2,3,4
 -             Be sure to leave pin 7 of the EEPROM open or tie it to GND,
 -               otherwise the EEPROM will be write protected.
 -             Include: Wire.h - the I2C library
 -             Declare: various i2c_eeprom_read.. i2c_eeprom_write.. procedures
 -             Setup(): Opens the Wire connection, the Serial connection,
 -                      writes a char-string to the EEPROM, & prints heading
 -                      NOTE: the char-string has length = 28
 -             Loop():  Reads from the EEPROM, & prints, one byte at a time, & repeats                
 */

#include {Wire.h}               //I2C library-usual brackets warning

  void setup()
  {
    // a char-string of data to write to the EEPROM - 28 characters long!!
    char someData[] = "this is data from the eeprom";
   /*
    char somedata[] = "this is Jane-Maree's eeprom data"; - 32 characters..
     .. & it bombs.  Gibberish - I've tried it!  See WARNING below..
   */
    Wire.begin();                 // Wire connection initialised
    Serial.begin(9600);       // Serial connection @ 9600 baud
    // now write the char-string to the EEPROM
    i2c_eeprom_write_page(0x50, 0, (byte *)someData, sizeof(someData));
    delay(10);                     //add a small delay..
    // ..& print a heading
    Serial.println("\nMemory written");
    Serial.println("\nNow read memory & print to Serial port");
  } //setup()

  void loop()
  {
    int addr=0;               // address parameter, starts @ 0
    // now access the first address (0) from the memory
    byte b = i2c_eeprom_read_byte(0x50, 0);
    // while there are non-zero bytes..
    while (b!=0)
    {
      Serial.print((char)b); //..print content as char to serial port..
      addr++;                      //..next address &..
      //..access next address from the memory.
      b = i2c_eeprom_read_byte(0x50, addr);
    }//while ()
    Serial.println(" ");     // new line..
    delay(2000);               // ..2 second delay, & start again!
  } //loop()


   /*
    WARNING: address is a page address, 6-bit end will wrap around
    also, data can be maximum of about 30 bytes,
    because the Wire library has a buffer of 32 bytes
  */
  void i2c_eeprom_write_page( int deviceAddress, unsigned int eeAddressPage, byte* data, byte length )
  {
    Wire.beginTransmission(deviceAddress);
    Wire.send((int)(eeAddressPage >> 8));       // MSB
    Wire.send((int)(eeAddressPage & 0xFF));  // LSB
    byte c;
    for ( c = 0; c < length; c++)
      Wire.send(data[c]);
    Wire.endTransmission();
  } //i2c_eeprom_write_page()


  byte i2c_eeprom_read_byte( int deviceAddress, unsigned int eeAddress )
  {
    byte rdata = 0xFF;
  
    //ask device by address for data
    Wire.beginTransmission(deviceAddress);
    Wire.send((int)(eeAddress >> 8));             // MSB
    Wire.send((int)(eeAddress & 0xFF));           // LSB
    Wire.endTransmission();
  
    Wire.requestFrom(deviceAddress,1);
    if (Wire.available())
      rdata = Wire.receive();
    return rdata;
  } //i2c_eeprom_read_byte()

// END

Tuesday, October 18, 2011

Task 38 - using the I2C bus with an EEPROM 24LC64

(The post following this one goes into different device addresses)
The address given in the original code - below, more or less - has the 24LC64 connected as follows:

Pin A0 is LOW;
Pin A1 is LOW;
Pin A2 is LOW.

This requires the device address to be 0x50.

Later, we will see devices connected so that they are to be addressed as  0x51  &  0x52, merely by varying  the LOW/HIGH status of A0, A1, & A2.


This is how several devices can be connected to the same I2C bus - they are addressed differently.
/*
 * Project:      eeprom_fromWeb
 * Author:      hkhijhe - tidied by Jane-Maree Howard
 * Date:         01/10/2010
 * Platform:   Arduino 22
 * Purpose:    To demonstrate use of the I2C bus with an EEPROM 24LC64
 -             "You were issued with an eeprom 24LC64 IC.
 -              This is a TWI memory that you connect to SCL and SDA on the Arduino.
 -              Run the program from the blog.
 -              Show your code changes and the serial monitor output in your blog
". 
 * Operation:  Because this chip is I2C,
 -               it only uses Arduino analog pins 4 & 5 (SDA and SCL),
 -               and of course the power (5V) and GND.
 -             Connect as follows:
 -                Arduino pin 4 to EEPROM pin 5
 -                Arduino pin 5 to EEPROM pin 6
 -                Arduino 5V to EEPROM pin 8
 -                Arduino GND to EEPROM pin 1,2,3,4
 -             Be sure to leave pin 7 of the EEPROM open or tie it to GND,
 -               otherwise the EEPROM will be write protected.
 -             Include: Wire.h - the I2C library
 -             Declare: various i2c_eeprom_read.. i2c_eeprom_write.. procedures
 -             Setup(): Opens the Wire connection, the Serial connection,
 -                      writes a char-string to the EEPROM, & prints heading
 -                      NOTE: the char-string has length = 28
 -             Loop():  Reads from the EEPROM, & prints, one byte at a time, & repeats                 
 */

#include {Wire.h}               //I2C library-usual brackets warning
 
  void setup()
  {
    // a char-string of data to write to the EEPROM - 28 characters long!!
    char somedata[] = "this is data from the eeprom";

   /*
    char somedata[] = "this is Jane-Maree's eeprom data"; - 32 characters..
     .. & it bombs.  Gibberish - I've tried it!  See WARNING below..

   */
    Wire.begin();                 // Wire connection initialised
    Serial.begin(9600);       // Serial connection @ 9600 baud
    // now write the char-string to the EEPROM
    i2c_eeprom_write_page(0x50, 0, (byte *)somedata, sizeof(somedata));
    delay(10);                     //add a small delay..
    // ..& print a heading
    Serial.println("\nMemory written");
    Serial.println("\nNow read memory & print to Serial port");
  } //setup()

  void loop()
  {
    int addr=0;               // address parameter, starts @ 0
    // now access the first address (0) from the memory
    byte b = i2c_eeprom_read_byte(0x50, 0);
    // while there are non-zero bytes..
    while (b!=0)
    {
      Serial.print((char)b); //..print content to serial port..
      addr++;                      //..next address &..
      //..access next address from the memory.
      b = i2c_eeprom_read_byte(0x50, addr);
    }//while ()
    Serial.println(" ");     // new line..
    delay(2000);               // ..2 second delay, & start again!
  } //loop()
 

  void i2c_eeprom_write_byte( int deviceaddress, unsigned int eeaddress, byte data )
  {
    int rdata = data;
    Wire.beginTransmission(deviceaddress);
    Wire.send((int)(eeaddress >> 8));             // MSB
    Wire.send((int)(eeaddress & 0xFF));        // LSB
    Wire.send(rdata);
    Wire.endTransmission();
  } //i2c_eeprom_write_byte()

  /*
    WARNING: address is a page address, 6-bit end will wrap around
    also, data can be maximum of about 30 bytes,
    because the Wire library has a buffer of 32 bytes
  */
  void i2c_eeprom_write_page( int deviceaddress, unsigned int eeaddresspage, byte* data, byte length )
  {
    Wire.beginTransmission(deviceaddress);
    Wire.send((int)(eeaddresspage >> 8));       // MSB
    Wire.send((int)(eeaddresspage & 0xFF));  // LSB
    byte c;
    for ( c = 0; c < length; c++)
      Wire.send(data[c]);
    Wire.endTransmission();
  } //i2c_eeprom_write_page()

  byte i2c_eeprom_read_byte( int deviceaddress, unsigned int eeaddress )
  {
    byte rdata = 0xFF;
   
    Wire.beginTransmission(deviceaddress);
    Wire.send((int)(eeaddress >> 8));             // MSB
    Wire.send((int)(eeaddress & 0xFF));        // LSB
    Wire.endTransmission();
   
    Wire.requestFrom(deviceaddress,1);
    if (Wire.available())
      rdata = Wire.receive();
    return rdata;
  } //i2c_eeprom_read_byte()

  // maybe let's not read more than 30 or 32 bytes at a time! See NOTE!
  void i2c_eeprom_read_buffer( int deviceaddress, unsigned int eeaddress, byte *buffer, int length )
  {
    Wire.beginTransmission(deviceaddress);
    Wire.send((int)(eeaddress >> 8));          // MSB
    Wire.send((int)(eeaddress & 0xFF));     // LSB
    Wire.endTransmission();
   
    Wire.requestFrom(deviceaddress,length);
    int c = 0;
    for ( c = 0; c < length; c++ )
      if (Wire.available())
        buffer[c] = Wire.receive();          
  } //i2c_eeprom_read_buffer()



You can see the gibberish along the top, caused by a buffer over-run.

i think this was what happened earlier, when i was 'experimenting'.

When all else fails, 
   Read The Instructions.

Now i need to figure out how to get around that buffer problem - i've not yet understood how to add a C-header file (.h) & C-file (.cpp)..

Task 38 - a diversion "..long time the manxome foe (s)he sought.."

..well it wasn't THAT long - I'm back in D208 &..

"Listen.. Listen.. It's a goal!!"
 (with apologies to the legendary Winston McCarthy).

well, yes!  Now it's working perfectly.  And so, for a diversion,
from Lewis Carroll..
-                                                                              The Jabberwock
-                                                                                         as illustrated by John Tenniel
 

Jabberwocky

'Twas brillig, and the slithy toves

Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe.

"Beware the Jabberwock, my son!

The jaws that bite, the claws that catch!
Beware the Jubjub bird, and shun
The frumious Bandersnatch!"

He took his vorpal sword in hand:

Long time the manxome foe he sought--
So rested he by the Tumtum tree,
And stood awhile in thought.

And as in uffish thought he stood,

The Jabberwock, with eyes of flame,
Came whiffling through the tulgey                              
wood,                                                                    
And burbled as it came!

One, two! One, two! and through and through

The vorpal blade went snicker-snack!
He left it dead, and with its head
He went galumphing back.

"And hast thou slain the Jabberwock?

Come to my arms, my beamish boy!
O frabjous day! Callooh! Callay!"
He chortled in his joy.

'Twas brillig, and the slithy toves

Did gyre and gimble in the wabe;
All mimsy were the borogoves,
And the mome raths outgrabe. 

                                                            "
from Through the Looking-Glass, and What Alice Found There (1872)

I've always liked this, so I'm pleased to have an excuse to include it.
And isn't Shakespeare marvellous:

"The graves stood tenantless, and the sheeted dead
  Did squeak and gibber in the Roman streets"

Hamlet: Act I, Scene i.
 

Task 37 - Integrate the new eeprom library from the link

Integrating the new eeprom library from the link here

"To use the library, make a folder in your SKETCHBOOKPATH\libaries 
  with the name I2C_EEPROM and put the .h and .cpp there. 
  Optionally make a examples subdirectory to place the sample app."

Reference: http://arduino.cc/playground/Main/LibraryForI2CEEPROM


Having tried Task 38 in room D208, I'm now wondering if my current change of room (D209) is causing a problem.  The website refers to a 'boundary problem', & I have a feeling that I don't really know what I'm doing (yet)..








Hmmm.. When in a quandary, have a laugh - "thanks" to Mike Keefe of the 'Denver Post'




















And this guy, Andrew Toos, at CartoonStock

 I like the 'robot' on the right..  these are just too good (hehe)  :-D

TASKS 37-39 -- Automation&Robotics: schedule 7


     37.  Integrate the new eeprom library from the link here.
            You should be able to #include this new library this.

38. You were issued with an eeprom 24LC64 IC.
      This is a TWI memory that you connect to SCL and SDA on the Arduino.
      Run the program from the blog.
     Show your code changes and the serial monitor output in your blog.

39.  The problem with the program above is that
       it can only handle about 30 bytes at a time.
     Overcome this problem so that any amount of data can be sent
     up to the capacity of the chip.   
    Write up your findings.

Sunday, October 16, 2011

How to look after your CMOS chips - with ordinary kitchen or garage stuff

Your CMOS chips are delicate little beasts - in particular, they're very sensitive to static electricity!  You really don't want this happening..

The trouble is, those nano-sized tracks inside them are easily damaged by even quite small currents sparking between them, & since the static from you, your clothes, the environment generally, is of the order of several thousand Volts, it doesn't take much to cause a spark between tracks, which are burnt out by the discharge & so that/those track(s) is/are useless & irreparable.

My little CMOS EEPROM chip is one of those, & the way to safeguard them is to:
   short-circuit all the pins to each other! 
That's why you see them "plugged" into tinfoil, conductive foam & the like.  I spent the princely sum of (ta-DA!)..

$2 - one spectacles case;
$2 - roll of heavy duty kitchen aluminium foil;
$2 - bath sponge;
---
..$6 at the local '2N5' shop in Great King St (near Countdown)..

..& here's a pikkie of the finished product!

Inside the lid you can see a pair of plastic tweezers for handling CMOS chips, & a little chip safe & sound in its protective CMOS-motel.

You've prob'ly got stuff like this @ home: kitchen foil (i folded it 2-3 times), old bath sponge (you can snip a lump off your existing one), & any small container  - doesn't really matter what it is..  & you have a (free!) CMOS chip-carrier. 

They'll be perfectly safe in there (unless you put your electrically grubby paws on them & kark them before they get their chance to Shine!) until it's time for them to Do Their Stuff!


On the right you can see another device for safeguarding your CMOS chips.

You can buy these things, with fancy conductive foam wristbands, but i made this one, coz i happened to have this peice of wire with a crocodile clip on it, so i stripped the other end & connected that to the EARTH terminal - the silvery BOTTOM one in the photo - don't do this unless you KNOW WHAT YOU'RE DOING!

230Volts AC up your arm won't leave you feeling on top of the world (unless that's how high you jump)!!!

The crocodile clip attaches to my (sterling silver - good conductor) bangle.  
Failing that, a stainless steel pot-scrub (another kitchen item) would make a useful 'hand-wipe';   very dry hands aren't good.

Friday, October 7, 2011

Tasks 18 & 19 - Arduino motor mini-board spinning both directions - software revised

/*
 * Project:    MotorSpin_621task18
 * Author:     Jane-Maree Howard
 * Date:       Saturday 03/09/2011; modified Friday 07/10/2011
 * Platform:   Arduino 22
 * Purpose:    To demonstrate control of a DC motor, using my ARDUINO Library function(s)
 * Operation:  Description: The motor is a ET-MINI DC-MOTOR board.
 -                                            See LIB01_MotorSpin_ETMINI for more details
 -             Declare:     Pin variables (byte), delay multiplier (int)
 -             Setup():     Serial.begin = 9600 baud; initialise digital control pins
 -             Procedure(): RotateMotor(params) takes 3 bytes (for the motor)       
 -             Loop():      Set RotateMotor() parameters; delay for 5 seconds             
 */
// digital control pins for ET-MINI DC-MOTOR
byte bRight    = 10;     // IN1 is pin 10 - rotate Right
byte bLeft     = 8;      // IN2 is pin 8  - rotate Left
byte bEnable   = 13;     // EN  is pin 13 - Enable rotation, must = '1'
// delay control in seconds
int iDelay     = 1000;   // delay variable     

void setup()  
{
  Serial.begin(9600);    //SM @ 9600baud
  //initialise digital control pins
  MotorPinMode(bRight,bLeft,bEnable);
}//end setup()

void loop()
//
{
   RotateMotor(bRight,bLeft,bEnable,10);   // rotate motor Right..
   delay(iDelay*5);                        // ..for 5 seconds, then..
   RotateMotor(bRight,bLeft,bEnable,0);    // ..stop..
   delay(iDelay*5);                        // ..for 5 seconds, then..
}//end loop()
//END
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/*
 * Project:     MotorSpin_621task19_1
 * Author:     Jane-Maree Howard
 * Date:         Saturday 03/09/2011; modified Friday 07/10/2011
 * Platform:   Arduino 22
 * Purpose:    To demonstrate control of a DC motor, using my ARDUINO Library function(s)
 * Operation:  Description: The motor is a ET-MINI DC-MOTOR board.
 -                      Declare:     Pin variables (byte), delay multiplier (int)
 -                      Setup():      Serial.begin = 9600 baud;

 -                                          initialise digital control pins as outputs
 -                      Procedure(): RotateMotor(params) takes 3 bytes (for the motor)         

 -                       Loop():      Set RotateMotor() parameters; 
 -                               delay for 5 seconds then reverse            
 */
byte bRight    = 10;     // IN1 is pin 10 - rotate Right
byte bLeft     = 8;        // IN2 is pin 8  - rotate Left
byte bEnable   = 13;   // EN  is pin 13 - Enable rotation, must = '1'
int iDelay     = 1000;   // delay variable     

void setup()  
{
   Serial.begin(9600);    //Serial connection @ 9600baud
   //initialise digital control pins as outputs
   MotorPinMode(bRight,bLeft,bEnable);      //LIB01_MotorSpin_ETMINI
}//end setup()

void loop()                    
{
   RotateMotor(bRight,bLeft,bEnable,10);      // LIB01_MotorSpin_ETMINI: rotate motor Right..
   delay(iDelay*5);                                            // ..for 5 seconds, then..
   RotateMotor(bRight,bLeft,bEnable,0);       // ..stop briefly..
   delay(150);
   RotateMotor(bRight,bLeft,bEnable,11);      // ..rotate motor Left..
   delay(iDelay*5);                                            // ..for 5 seconds
   RotateMotor(bRight,bLeft,bEnable,0);       // ..stop briefly..
   delay(150);
}//end loop()
//END

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

to see how the following is included with the above sketches, click on this link

/*
 * Project:    LIB01_MotorSpin_ETMINI
 * Author:     Jane-Maree Howard
 * Date:       Friday 07/10/2011
 * Platform:   Arduino 22
 * Purpose:    To make a library function for an ET-MINI DC-MOTOR board
 * Operation:  Description: The motor is an ET-MINI DC-MOTOR board.
  -                           The board's terminals are:
  -                            EN - Enable, must be set at logic "1" for operation.
  -                            IN1- With EN @ "1", IN1 @ "1" rotates the motor to the Right.
  -                            IN2- With EN @ "1", IN2 @ "1" rotates the motor to the Left  
  -                     Declare: NONE - MUST BE DECLARED IN CONJOINING SKETCH(ES)
  -                     Setup():  NONE - MUST BE USED ONLY IN CONJOINING SKETCH(ES)
  -                                    (used  only in testing)
  -                     Procedure(): void MotorPinMode(byte, byte, byte);  

 -                                            void RotateMotor(byte,byte,byte,byte);     
  -                     Loop():   NONE - MUST BE USED ONLY IN CONJOINING SKETCH(ES)
  -                                    (used  only in testing)            
 */

void MotorPinMode(byte bR, byte bL, byte bEN)
{
  /*  initialise digital control pins as outputs.
      CALLED IN MAIN SKETCH  */
  pinMode(bR, OUTPUT);        // IN1
  pinMode(bL,  OUTPUT);       // IN2
  pinMode(bEN, OUTPUT);       // EN 
}//MotorPinMode()

// RotateMotor- CALLED IN MAIN SKETCH
void RotateMotor(byte bR, byte bL, byte bEN, byte bMO)
{
  /*  Rotate ET-MINI DC-MOTOR: bR,bL,bEN are Pins; bM en/dis-ables */
  switch (bMO)
  {
    case 01:               // PAUSE
      digitalWrite(bR,0);  // write '0' to motorboard pin IN1 - no rotation right
      digitalWrite(bL,0);  // write '0' to motorboard pin IN2 - no rotation left
      digitalWrite(bEN,1); // write '1' to motorboard pin EN - enables motor
      break;
    case 10:               // rotate RIGHT
      digitalWrite(bR,1);  // write '1' to motorboard pin IN1
      digitalWrite(bL,0);  // write '0' to motorboard pin IN2 - no rotation left
      digitalWrite(bEN,1); // write '1' to motorboard pin EN - enable motor
      break;
    case 11:               // rotate LEFT 
      digitalWrite(bR,0);  // write '0' to motorboard pin IN1 - no rotation right
      digitalWrite(bL,1);  // write '1' to motorboard pin IN2
      digitalWrite(bEN,1); // write '1' to motorboard pin EN - enable motor
      break;
    default:               // STOP - disable motor
      digitalWrite(bR,0);  // write '0' to motorboard pin IN1 - no rotation right
      digitalWrite(bL,0);  // write '0' to motorboard pin IN2 - no rotation left
      digitalWrite(bEN,0); // write '0' to motorboard pin EN - disable motor
  }//switch()case
}//RotateMotor()
//END