Showing posts with label PROJECTS. Show all posts
Showing posts with label PROJECTS. Show all posts

Monday, March 5, 2012

Well into the new year - & my puter is better, along with my house..

Well i'm still around - my computer has a brain augmentation: another 2 GB of RAM.

& my roof leaks have been fixed - now i can get on with making my back room into my 'lab' room with puter bits, electronic stuff, & various tools & projects.

would like to re-build that 'hakeri' bloody shed out the back - it's falling down & being pushed sideways by a large, mostly non-fruiting plum tree!  somewhere to store garden tools cluttering up the house @ present.

bought myself a couple of tech-presents; one of those non-reciprocating saw thingies with a box of attachments of various kinds.  cutting aluminium sheet won't be the wretched business it used to be (& that's just the start - my house's previous occupants were real bush carpenters who did some amazingly silly things!).

Thursday, January 12, 2012

FINAL -- duh!! -- so far..

Well, a final mark of 57 (C) was a bit underwhelming, but at least it's better than a poke in the eye with a burnt stick!

i wish i knew how to make Georgia Bold my default font on this blog but..

& i'm not going to stop playing around with these things, but i've got rather a lot on at the moment, & i need to get thees out of my hair: 

the leaks in my hall roof; 

dealing to the undergrowth that is my yard (majorly chopped with a grunty weed-whacker, but still in need of further 'treatment') - i have an abiding hatred of grass - the agricultural kind, not friend Mary Jane - which i regard as suitable only for football & other sports to be played on & livestock to shit on; as a domestic ground cover it sucks enormously;

my feeble-minded computer - the poor wee thing does its best, but with the equivalent these days of a pre-frontal lobotomy (half-a-Gig), it desperately needs me to take pity on it & beef up its RAM (to at least 2 Gig);

there's a thing out the back masquerading as a shed; needs replacing or turned into a workshop-type thingy..;

a giant, non-producing, plum tree out the back needs topping ( i know it's a plum because it actually has delivered one or two plums occasionally (i'm not joking!), one of which has grown into a smaller, equally non-producing, tree - i need some arborist's/orchardist's advice maybe;

the inside of my house is a f*****g tip - it really needs sorting!

& NO i haven't made any poxy New Year's resolutions either!

(except maybe to bow to the inevitable & sign up to Facebook - not because i've any wish to dump myself online, but various friends keep asking me, & i'd like to be able to access their stuff.)

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}..

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.

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.

Sunday, September 25, 2011

Project 3 -- Minor Project: schematic

this is the best i could do - i don't know how to make circuit jumper in Fritzing but it should be obvious that that's what they are, not connections..

The 3 'wriggly' things are Peltier elements (Thermistors)

Project 3 -- Minor Project: software

/*
 * Project:    Minor_Project_621
 * Author:     Jane-Maree Howard
 * Date:       Wednesday 21/09/2011
 * Platform:   Arduino 22
 * Purpose:    To demonstate a fridge-control robot
 * Operation:  Several thermistors are mounted inside the fridge.
 *              Their values are read in sequence at 1-minute intervals,
 *              their average is calculated, & the values & their average stored in EEPROM
 *              A LDR is also mounted inside the fridge, to detect when the door is opened.
 *              Change in the LDR resistance trigers an interrupt, & this is also recorded.
               Declare: 
               Setup():             
               Loop():                   
 */
#include                   // EEPROM library

int  iAnalogPin[]    = {0,1,2,3};    // analog pin numbers
int  iLEDpin         = 13;           // door-open LED
int  iDarkLevel      = 100;          // pre-set photocell reading triggering interrupt

int  iGetData        = 0;            // get signal to retrieve data

int  iHeading        = 0;            // signal to print heading
int  iSecond         = 1000;         // 1 second delay &..
int  iMinute         = 60000;        // ..1 minute delay

int  iTemperature[3];                // temperature readings from A0 - A2
int  iAvgTemp;                       // Average of the 3 temperatures

volatile byte iAddressCount   = 0;   // EEPROM address counter
volatile byte bLEDstate       = 0;   // LED pin ON or OFF
 
/* all operations are performed in the setup() section of the program */
void setup()  
{
  delay(iSecond*5);                 // up to 10 minute delay
  pinMode(iLEDpin, OUTPUT);         // LED-pin is an output..
  digitalWrite(iLEDpin,LOW);        // ..initially turned off
  Serial.begin(9600);               // SM @ 9600baud
  // attach interrupt 0, to digital pin 2
  attachInterrupt(0, DoorOpen, CHANGE); // ..on CHANGE
                     
  iGetData  = KeypressInput();      // check for receiving data
  while (iGetData == 0)             // if no signal,start reading..
  {
    // stop interrupts while reading
    noInterrupts();                 // stop interrupts while reading
    iAvgTemp   = 0;                 // zero average Temperature vble               
    /* First read the 3 values into iTemperature[] .. */
    for (byte j=0; j<3; j++)
    { 
      // read value on 3 thermistor pins i.e. iAnalogPin[j]
      iTemperature[j]  = analogRead(iAnalogPin[j]); 
      // now we have to map 0-1023 to 0-255..
      // ..since we want to store the values as bytes..
      iTemperature[j]  = map(iTemperature[j], 0, 1023, 0, 255);
      // ..& write them to EEPROM
      EEPROM.write(iAddressCount, iTemperature[j]);
      // increment the address count..
      iAddressCount++ ;
      iAvgTemp        += iTemperature[j];  // add to average total         
      // delay 10 milliseconds
      delay(10);  
    }//for(j)
    iAvgTemp  = (int)(iAvgTemp/3);
    // write Average to EEPROM also..
    EEPROM.write(iAddressCount, iAvgTemp);
    // ..& increment the address count.
    iAddressCount++ ;
    interrupts();                   // re-enable interrupts
   
    // debugging
    Serial.print("\nrecorded data\t");
    for (int j=0;j<3;j++)
      Serial.print(iTemperature[j]);
    Serial.print(iAvgTemp);
   
    delay(iMinute);                 // delay 1 minute..
    iGetData  = KeypressInput();    // ..then check for receiving data
  }// while(==0) */


 
  while (iGetData != 0)             // ..otherwise, retrieve stored data & send to SM
  {
    if (iHeading%20 == 0)
      Heading();
    iHeading++;
   
    //diagnostic stuff & logic testing
    if (iHeading > 100)
    {
      iGetData  = 0;    // check for receiving data
      iHeading = 0;
    }//if()
   
  }// while(!=0)
}// end setup()

void loop()
{/*nothing done in here*/}//end loop()

/* prints heading to Serial Monitor at pre-set intervals */
void Heading()
{
  Serial.println("\nTemperatures\tT0\tT1\tT2\tT3\tAverage\tDoor\n");
}//Heading()

//END


LIBRARY FUNCTIONS:

/*
 * Project:    LIB04_KeypressInput
 * Author:     Jane-Maree Howard
 * Date:       Saturday 08/10/2011
 * Platform:   Arduino 22
 * Purpose:    To make a library function for inputting a key-press via Serial comm link
 * Operation:  Description: inputs a key-press & returns an Integer
 -             Declare:     NONE - MUST BE DECLARED IN CONJOINING SKETCH(ES)
 -             Setup():     NONE - MUST BE USED ONLY IN CONJOINING SKETCH(ES)
 -                          (used  only in testing)
 -             Procedure(): int KeypressInput();  no parameters   
 -             Loop():      NONE - MUST BE USED ONLY IN CONJOINING SKETCH(ES)
 -                          (used  only in testing)            
 */
int KeypressInput()
{
  /*  inputs a keypress via the Serial comms link
      & returns a non-zero Integer only if there is an input
      CALLED IN MAIN SKETCH  */
  int iKey = 0;
  // send data only when you receive data
  if (Serial.available() > 0)
    iKey = Serial.read();
  return iKey;
}//KeypressInput()
//END



/*
 * Project:    LIB09_photocell_interrupt
 * Author:     Jane-Maree Howard
 * Date:       Thursday 24/11/2011
 * Platform:   Arduino 22
 * Purpose:    To make a Photocell Switch for an interrupt pin (digital 2 or 3).
 * Operation:  The circuit arrangement is the same as the ladyada
 *             LED dimmer, but here the software has a trigger threshold 
 *             for turning the interrupt pin on.
 *             The output of the Analog pin is measured as before,
 *              but instead of analogWrite() to the interrupt pin,
 *              digitalWrite is used to switch the pin on or off.
 *             We don't need to map the Analog pin output,
 *              since it's merely a trigger.
 *             Original description:
 *               "Connect one end of the photocell to 5V, the other end to Analog 0.
 *                Then connect one end of a 4.7K resistor from Analog 0 to ground
 *                Connect LED from pin 9 through a resistor to ground"
 *             Declare, Setup(), Loop(): 
 *              NONE - MUST BE USED ONLY IN CONJOINING SKETCH(ES)
 -             Procedure(): void PhotocellTrigger(int,int,int); 
 -                          void DoorOpen();
 */

/* the photocell pin value is tracked by the interrupt */
void PhotocellTrigger(int iInterruptPin, int iPhotoPin, int iDark)
{
  int iPhotoReading = analogRead(iPhotoPin);     //i.e. analog 0
    //we now use our  'darkLevel' variable to trigger the LED ON.
  if (iPhotoReading > iDark)
    digitalWrite(iInterruptPin, HIGH);          // turn InterruptPin on, else..
  else
    digitalWrite(iInterruptPin, LOW);           // ..turn InterruptPin off 
}//PhotocellTrigger()

/* called when the Interrupt is triggered - records door state */
void DoorOpen()
{
  digitalWrite(iLEDpin, bLEDstate);      // Turn door-open LED ON or OFF..
  EEPROM.write(iAddressCount, bLEDstate);// ..record the incident..
  iAddressCount++;                       // .. increment address count..
  bLEDstate  = !bLEDstate;               // ..& change LED-state ON to OFF or vice versa
}//DoorOpen()
//END

Project 3 -- Minor Project: Design

My MINOR PROJECT has the following hardware design features:

** 3 thermistors on a wiring loom able to be set up inside my fridge.

** 1 photocell on the same wiring loom.

** A Duemilanove Arduino board, 
     to poll the 3 temperatures at around 1 minute intervals,
     with an interrupt feature involving the photocell
     (for when the door is opened - & closed again,
     & the software to save to & retrieve the data from the on-board EEPROM.


The whole project can be independently powered through the USB port - i have a USB power source, but a bit of tweaking may enable power to be supplied by a 9v battery (not sure about this).
    
The software design involves the following:

** Regular polling of the 3 thermistors connected to Analog pins A0, A1, A2.
     Their readings are saved to EEPROM

** An interrupt feature triggered by the photocell connected to Analog pin A3.
     The interrupt is attached to Digital pin 2, 
triggered by the photocell reading  rising above a pre-determined 'darkness' threshold.  
     A LED will be lit & the fact recorded on EEPROM in binary form (1 = open).


** A Serial Monitor connection enabling retrieval of the recorded data on a signal from the serial connection (via SM).


** A software delay enabling the project to be set up & connected to its power source - nothing will happen for about 5 minutes - then the program starts recording data.


** The software delay can be over-ridden by a signal from the SM, when the project is connected to a PC; data retrieval can then begin.


** Data retrieved from the EEPROM is written to the SM, appropriately formatted.
.

Saturday, September 24, 2011

Project 3 -- Minor Project: initial survey

This project is intended to be a predecessor to my Major Project.
It involves some, but not all, of the elements of the Major Project.

The Minor Project tests the temperature environment inside my fridge, to get an idea of the temperature range involved, & possibly how much scaling of output values from a thermistor will be needed.

The thermistor will need to be evaluated as regards its temperature range, & also what value of pull-down resistor (if any) will be needed.

A photocell-driven Interrupt sequence will be included, to record when the door is opened.

Tuesday, August 30, 2011

Project 2 - Arduino Motor Project - Serial input speed & direction control

Here's the Fritzing diagram, showing pins 9 & 10 used since they have the Pulse Width Modulation (PWM) option enabled on them.


/*
 * Project:      MotorSpin_621project02_1
 * Author:      Jane-Maree Howard
 * Date:         Tuesday 11/10/2011
 * Platform:   Arduino 22
 * Purpose:    To demonstrate Serial input motor control
 * Operation:  Description: The ET-MINI DC-MOTOR board has an H-bridge & a DC motor
 -                          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
 -            
Arduino Libraries: LIB04_KeypressInput; LIB06_PWMmotorSpeed_ETMINI;  
 -            
Setup(): Serial @ 9600 baud; Print heading;            
 -            
Loop():  Via Serial Monitpr, input a PAIR of characters, e.g. r7, ss, L9;
 -                      Press 'Enter' or 'Send';
 -                      Motor direction & speed range are outputted &..
 -                      ..PWMmotorControl(bRight, bLeft, bEnable, bMotor, bSpeed) operates
 -                      the motor according to instruction-pair;

 */
int  iKeyPress = 0;      // for incoming serial data
char chInput;              // for 'char' parameters
// digital control pins for ET-MINI DC-MOTOR
byte bRight    = 10;    // IN1 is pin 10 - rotate Right
byte bLeft     = 9;       // IN2 is pin 9  - rotate Left
byte bEnable   = 13;  // EN  is pin 13 - Enable rotation, must = '1'
byte bMotor    = 0;    // in LIB06_PWMmotorControl(), '0'=STOP, '1'=RIGHT, '11'=LEFT
byte bSpeed    = 0;    // in ditto, PWM duty cycle parameter - initialised to "stop"

void setup()  
{
  Serial.begin(9600);                      //SM @ 9600 baud
  pinMode(bEnable, OUTPUT);   // EN - ENable pin on motorboard
  pinMode(bRight, OUTPUT);     // IN1 - 'RIGHT' pin on motorboard
  pinMode(bLeft, OUTPUT);       // IN2 - 'LEFT' pin on motorboard
  Serial.println("\nEnter your control characters in pairs e.g.: R5, ss");
}//end setup()

void loop()                    
{
  // first input Motor Direction, STOP, RIGHT, or LEFT
  iKeyPress = KeypressInput();
  if (iKeyPress !=0)
  {
    Serial.print("\nInput direction\t");
    chInput   = (char)iKeyPress;
    Serial.println(chInput, BYTE);
    switch (chInput)
    {
      case ('s'):
        bMotor    = 0;
        break;
      case ('S'):
        bMotor    = 0;         
        break;
      case ('r'):
        bMotor    = 1;
        break;
      case ('R'):
        bMotor    = 1;
        break;
      case ('l'):
        bMotor    = 11;
        break;
      case ('L'):
        bMotor    = 11;
        break;     
      default: bMotor    = 0;    
    }//switch()

    // now input Motor Speed on a scale of 1-9
    iKeyPress = KeypressInput();
    Serial.print("Input speed\t");
    chInput   = (char)iKeyPress;
    Serial.println(chInput, BYTE);
    switch (chInput)
    {
      case ('1'):
        bSpeed    = 50;
        break;
      case ('2'):
        bSpeed    = 75;
        break;
      case ('3'):
        bSpeed    = 100;
        break;  
      case ('4'):
        bSpeed    = 125;
        break;
      case ('5'):
        bSpeed    = 150;
        break;
      case ('6'):
        bSpeed    = 175;
        break;    
      case ('7'):
        bSpeed    = 200;
        break; 
      case ('8'):
        bSpeed    = 225;
        break;        
      case ('9'):
        bSpeed    = 255;
        break;     
      default: bMotor    = 0;    
    }//switch()
  }//if()
  /* now that control characters have been entered e.g.L7,
     call PWMmotorControl with all parameters present
  */

  PWMmotorControl(bRight, bLeft, bEnable, bMotor, bSpeed);
}//end loop()
//END


The control characters must be entered as a pair,
otherwise it will not function.

The direction can be upper or lower case.

The duty cycle (input speed 1-9) can in theory range from 0-255, but in practice, anything < 50 won't fire the motor up.
255 represents 100%, or full-speed.







/*
 * Project:    LIB06_PWMmotorSpeed_ETMINI
 * Author:       Jane-Maree Howard
 * Date:          Tuesday 11/10/2011
 * Platform:     Arduino 22
 * Purpose:     To use PWM speed-control for an ET-MINI DC-MOTOR board
 * Operation:  The ET-MINI DC-MOTOR board has an H-bridge & a DC motor
 -                          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 PWMmotorControl(byte,byte,byte,byte,byte);     
 -             Loop():      NONE - MUST BE USED ONLY IN CONJOINING SKETCH(ES)
 -                          (used  only in testing)   
         
 */
//   RotateMotor - CALLED IN MAIN SKETCH
void PWMmotorControl(byte bR, byte bL, byte bEN, byte bMO, byte bSPEED)
{
  /* 
  Rotate ET-MINI DC-MOTOR: bR,bL,bEN are Pins; bMO en/dis-ables;
 
  bSPEED takes values 0-255 as part of the PWM duty cycle;
  analogWrite() is a PWM operation on a Digital pin,
  .            
& has nothing to do with Analog pins or AnalogRead()
  */
  // pause motor to allow change of direction

  delay(20);                        // delay 20 milliseconds
  digitalWrite(bEN,1);      // write '1' to motorboard pin EN - enable motor
  switch (bMO)
  {
    case 0:                          // STOP  - disable motor
      digitalWrite(bEN,0);  // write '0' to motorboard pin EN
      break;
    case 1:                          // rotate RIGHT @
      digitalWrite(bL,0);    // write '0' to motorboard pin IN2 - no rotation left
      analogWrite(bR,bSPEED);   // write to motorboard pin IN1
      break;
    case 11:                       // rotate LEFT @ 
      digitalWrite(bR,0);   // write '0' to motorboard pin IN1 - no rotation right
      analogWrite(bL,bSPEED);   // write to motorboard pin IN2   
      break;
    default:                           // STOP - disable motor
      digitalWrite(bEN,0);    // write '0' to motorboard pin EN - disable motor
  }//switch()case
}//PWMmotorControl()
//END


Go to the following link for the operating software
/*
 * Project:       LIB04_KeypressInput
 * Author:       Jane-Maree Howard
 * Date:           Saturday 08/10/2011
 * Platform:     Arduino 22
 * Purpose:     To make a library function for inputting a key-press via Serial comm link
 * Operation:  Description: inputs a key-press & returns an Integer

.

Project 1 - Arduino Software Investigation - the EEPROM library


 
EEPROM Library


The microcontroller on the Arduino boards has its own EEPROM:


Electrically Erasable Programmable Read Only Memory.


memory whose values are kept when the board is turned off (like a tiny hard drive).

The microcontrollers on the various Arduino boards have different amounts of EEPROM:


1024 bytes on the ATmega328

512 bytes on the ATmega168 and ATmega8, 

4 KB (4096 bytes) on the ATmega1280 and ATmega2560.


This library enables you to read, read(), and write, write(), those bytes.
 

byte EEPROM.read(address)

Description: Reads a byte from the EEPROM.
Locations that have never been written to have the value of 255.
Parameters: address: the location to read from, from 0 to 511 (int)
Returns: the value stored in that location (byte)

EEPROM.write(address, value)

Description: Writes a byte to the EEPROM.
Parameters:
address
: the location to write to, from 0 to 511 (int)
value
: the value to write, from 0 to 255 (byte)
Returns: none



The Atmega 168 datasheet says EEPROM memory has a specified life of 100000 write/erase cycles,
so there is a limit to how many times you can write information to that memory space.

Bear this in mind for long-lived projects or fast-moving data.
The datasheet also specifies that a write cycle takes 3.3 ms to complete.
Other EEPROM write and read requests will fail if executed in this time period.
This delay appears to be built into the EEPROM library,
as a casual test shows each cycle taking 3.33 ms to execute.
Hence, you do not specifically need to add a delay to an EEPROM write;
just be aware of the built-in time delay.

Below (pp 2,3) is some example code, demonstrating both Read & Write functions.



References
Arduino EEPROM Library. Retrieved from http://arduino.cc/en/Reference/EEPROM

Example

/*
 * Project:    EEPROM_ReadWrite_621project01
 * Author:     Jane-Maree Howard
 * Date:       Friday 0/08/2011
 * Platform:   Arduino 22
 * Purpose:    To demonstrate EEPROM Read & Write functions via the Serial Monitor (SM)
 * Operation:  Description:
               Include: EEPROM.h library
               Declare: EEPROM memory size; value read from EEPROM
               Functions: PrintSM(int,int) ReadEEPROM(int); EEPROM.write(int,int); 
               Setup(): SM @ 9600baud;  write to EEPROM            
               Loop():  read from EEPROM 
 * Comment:    an integer written to EEPROM will return its LSByte!
 */
#include  

//int  iMemSize  = 512; // ATmega168
int  iMemSize  = 1024;  // ATmega328
int iValue;             // value read from EEPROM

void setup()   
{
  Serial.begin(9600);  //SM @ 9600baud
  //now write to EEPROM
  for (int j=0; j
  {
    Serial.print("Writing to\t");
    PrintSM(j,j);
    WriteEEPROM(j,j);
  }//for   
}//end setup()

void loop()                     
{
  //now read EEPROM  
  for (int j=0; j
  {
    Serial.print("Reading from\t");
    iValue  = ReadEEPROM(j);
    PrintSM(j,iValue);
    delay(250);
  }//for
}//end loop()

/* PrintSM() - prints parameters to SM */
void PrintSM(int iAddr,int iVal)
{
  Serial.print(iAddr);
  Serial.print("\t");
  Serial.print(iVal);
  Serial.println();
}//printSM()

// below are the two feature functions, READ & WRITE

/* ReadEEPROM() - returns a byte from the parameter address */
int ReadEEPROM(int iAddr)
{
  // this is the READ function
  int iVal  = EEPROM.read(iAddr);
  // don't go beyond memory size
  if (iAddr >= iMemSize)
    iAddr  = 0;
  return iVal;
}//ReadEEPROM()


/* WriteEEPROM() - writes a parameter byte to the parameter address */
void WriteEEPROM(int iAddr,int iVal)
{
  // this is the WRITE function
  EEPROM.write(iAddr,iVal); 
  // don't go beyond memory size
  if (iAddr >= iMemSize)
    iAddr  = 0; 
}//WriteEEPROM()

//END


Tuesday, October 26, 2010

Task: Lego Robot software

Well - i've got the Lego-bot assembly to the point where i can now do something with it.

Now that i have access to the software, i've been experimenting with motion, loops, sound, the little screen that's on the Lego-bot controller, & generally i think i've got a handle on it.


Now to make it do something interesting!

.

Wednesday, October 20, 2010

Task: Start "Mr General" Assembly..

..which has turned out to be harder than i thought it'd be!

The following problems have emerged:
 1) we no longer have an electronics lab - the heavy-duty electrical engineering people
     now have that room for their stuff;

 2) i'm using a make-shift lab-spot, sharing with all the people
     in the 3rd-year project room;

 3) the lighting's bad in there & i can't see f**k-all;
 4) there's a trick to soldering components into those teeny-tiny holes in the PCBs,
     & it took me ages to work out how to do that & to fix my c**k-ups;

 5) i'm missing a little pack of 8 small nylon washers,
     which i normally wouldn't worry about except that they look as if they're for
     insulating metal spacers from the main PCB surface


Possible solutions (in no particular order):
 1) i have a $2 cyclist's 'headlight' to illuminate the work i'm doing;
 2) i have a $2 magnifying glass whose handle i can wedge into the 'headlight' strap,
     so i can see better;

 3) "Mr General" is no longer essential to my project - Peter says
      i can use the Lego-Bot for both project items;

 4) any number of hardware-y places must surely sell
      little nylon washers of some kind;

 5) I still think i can do this! 
     That must count for something (psychologically if not marks-wise)..





.

Thursday, July 29, 2010

2010 Second Semester - Automation & robotics - a design challenge

This semester is about Robotics & Automation.

We had a visit from Tania, a clothes designer, who works with kids who have Sensory Integration Dysfunction (SID) & enjoy, or feel safe & calm, in a "crush" or "squeeze" situation.
The challenge is to design 'crush clothing' that the kids can wear, which can be programmed for different 'crush' areas, e.g. shoulders, stomach, arms, back, chest etcetera, slowly releases the 'crush effect' over, say, 20 minutes, & logs the time, duration, kid's name, crush areas, & the like.

It sounds interesting.

I like the idea of:
* an elastic wind-&-pull mechanism,
* programmable tensioner selection,
* slow-release friction-brake,
* data-logging (maybe external EEPROM for each kid),
* 2-wire I2C from a USB connector.

Another idea is the use of compressed air-pockets.

Also mentioned were "air muscles', which sound good, especially if combined with elastic - one "muscle" could pull several coordinated threads..

Designing this could be fun.
.