Showing posts with label hardware. Show all posts
Showing posts with label hardware. Show all posts

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

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.

Tuesday, October 18, 2011

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.
 

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

Task 32 -- the Triple Axis Accelerometer

"Find the post on the Triple Axis Accelerometer. 
 This is an example of a sensor we have to deal with.   
 Find out more information about this sensor 
 and compose a schematic illustrating how you would use an Arduino to (record) real acceleration in     
 three dimensions and display the outputs. 
 Your blog output should contain a schematic and code." 

Umm, here's my post on the hardware (with pikkie!).

Now we should have a schematic.. 
(Fritzing is good for drawing schematics!)

Here's the datasheet.. 

..& a circuit diagram (courtesy of Fritzing) showing how the accelerometer is connected to an Arduino board & external power source (not complicated at all, is it)


Thursday, September 22, 2011

Task 31B -- Making Use of Interrupts

..
Again the schematic is from the Code Project/Interrupts site.

(I had to use a 150Ohm resistor because i couldn't find my push-switch!
  It didn't work quite as well - i should really find that switch! - but i
  suspect my wobbly hand had a lot to do with it; i could try 'de-bouncing'
  the 'switch', but delay() won't work inside the interrupt-triggered function  

  (find the switch, stoopid!)  )


This time, however,  the code makes use of a Hardware Interrupt, as follows:


/*
 * Project:     Interrupts_part_B_621task31
 * Author:     DaveAuld, tidied (not much! :-) ) by Jane-Maree Howard
 * Date:          23 Feb 2010
 * Platform:   Arduino 22
 * Purpose:    To demonstrate a simple interrupt-triggered LED-switch
 * Operation:  Description:
 *             "Set up the Arduino as per the schematic
 *              and upload the code below to the microprocessor.
 *              We will use the same schematic diagram and
 *              modify the code to make use of hardware interrupts.
 *              Now when you upload the code, the LED changes state
 *              whenever the button is pressed
 *              even though the code is still running the same long delay
 *              in the main loop.

 *              [This is code PART B in the downloaded source file.]"
 */
int pbIn = 0;                               // Interrupt 0 is on DIGITAL PIN 2!
int ledOut = 4;                           // The output LED pin
volatile int state = LOW;      // The input state toggle

void setup()
{
  // Set up the digital pin 2 to an Interrupt and Pin 4 to an Output
  pinMode(ledOut, OUTPUT);

  //Attach the interrupt to the input pin and monitor for ANY Change
  attachInterrupt(pbIn, stateChange, CHANGE);
}//setup()

void loop()
{
  //Simulate a long running process or complex task
  for (int i = 0; i < 100; i++)
  {
    // do nothing but waste some time
    delay(50); // Jane-Maree increases delay time from 10ms to 50ms
  }//for()
}//loop()

void stateChange()
{
  state = !state;
  digitalWrite(ledOut, state);
}//stateChange()
//END