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)
This is about robots & automation. It's a companion blog to JaneMareesTech, which is about the Arduino microcontroller system & related electronics
Showing posts with label MINOR PROJECT. Show all posts
Showing posts with label MINOR PROJECT. Show all posts
Sunday, September 25, 2011
Project 3 -- Minor Project: schematic
Labels:
EEPROM,
fritzing,
functions,
hardware,
interrupts,
LED,
MINOR PROJECT,
photocell,
PROJECTS,
schematic,
sensors,
serial monitor,
thermistor
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: 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
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
* 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
Labels:
Arduino,
EEPROM,
functions,
interrupts,
LED,
libraries,
MINOR PROJECT,
photocell,
PROJECTS,
sensors,
serial monitor,
software,
thermistor
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.
.
** 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.
.
Labels:
Arduino,
EEPROM,
hardware,
libraries,
MINOR PROJECT,
photocell,
PROJECTS,
schematic,
sensors,
software,
thermistor
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.
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.
Labels:
Arduino,
hardware,
MINOR PROJECT,
PROJECTS,
robots,
sensors,
software,
thermistor
Subscribe to:
Posts (Atom)
