Print

Frog Logger Program

Explanation of Use



How to Customize the Program


Logging Parameters

These are the most important variables for general use. The frequency and duration of recording may be set by changing these values to suit your study.

"RecM" - Used to set times when recorder is active Recorder will start when the current minute equals one of these values {0, 30}

"RecTime" - Sets the recording period in seconds. Default value is 60. Not yet implemented.

"XtimeB" & "XtimeE" - Sets the beginning and ending of the recording blackout period in 24h format. Used to prevent recording during the daytime. If XtimeB = 9 & XtimeE = 18, the recorder will not record from 9AM to 6PM. Not yet implemented.

Sensor Calibrations

"thermK" - Thermistor constant used for calibration. Found by setting thermK to 0, measuring the temperature reported by the logger and subtracting the actual temperature (thermK = reported temp - actual temp).

Audio Recorder Control Settings


"BegDelay" - Delay between when the recorder power is turned on and the signal to start recordings. Default value is 1000.

"RecPulse" - Pulse length for activating the audio recorder controls for starting and stopping recording. Default value is 500.

"RecDelay" - Delay to begin time stamp after recording has begun. Default value is 1000.

"EndDelay" - Delay between when the recorder stops recording and the power is turned off. Default value is 1000.


Time code pulse parameters

These values generally do not need to be changed, If you have difficulty reading the time, want to reduce overall duration on the recording, or the audio recorder has difficulty fully capturing the sounds, you may wish to change different aspects of the time stamp by altering these values.

"Vfreq" - Frequency of the 5 pulses. Default value is 2500.

"Vdur" - Duration of the 5 pulses. Default value is 300.

"Vpause" - pause between the 5 pulses. Default value is 300.

"Ifreq" - Frequency of the 1 pulses. Default value is 956.

"Idur" - Duration of the 1 pulses. Default value is 100.

"Ipause" - Pause between the 1 pulses. Default value is 300.

"VIpause" - Pause between the 5 and the 1 pulses. Default value is 300.

"BEfreq" - Frequency of pulses that mark beginning and end of data transmission. Default value is 500.

"Mdur" - Duration of pulses that mark beginning and end of data transmission. Default value is 50.

"Upause" - Pause between units. Default value is 600.


Debugging Feature

To assist with finding errors in your setup and to visually check how the device is running, the logger reports its status via the serial connection to the Arduino computer program. During the initial start up, the logger displays which program is running and then reports that the logger has successfully started. When a logging event begins, a report is posted that the recorder is active followed by the start time and date. Next, the current temperature is reported both in its raw voltage form and as a conversion to Celsius. The Analog to digital converter (ADC) of the microprocessor reports the temperature from the thermistor as a relative number from 0 to 1023, where 0 = 0 volts and 1023 = 5 volts. At the end of a logging event, the logger reports the time that the recorder stopped and the time.


Messages sent from the logger to the Arduino computer program via the serial connection:
Open Frog Logger
Kelly Lasater 2009
www.openlogger.org

Logger is Running

Rec ON
16:0:3  6/19/2009
Temperature raw ADC = 449
Temperature C = 28

Rec OFF
16:1:31

Rec ON
16:30:23  6/19/2009
Temperature raw ADC = 449
Temperature C = 28

Rec OFF
16:31:25



Program Code


Program for Arduino:
/*
Open Frog Logger 2009
Kelly Lasater

Conservation Genome Resource Bank for Korean Wildlife
Seoul National University, College of Veterinary Medicine 
85-802, San 56-1,Sillim-Dong, Gwanak-Gu, 
Seoul 151-742, South Korea

Please see <http://www.openlogger.org> for additional information

Activates a audio recorder to record at specific time for a designated time period. 
Time, date, and temperature are recorded on the audio file as long and short pulses 
to mark units of five and 1, respectively. Board can be run on 12v supplied from a 
lead acid battery for extended lengths of time. On board power supply can supply 
power to the audio recorder and can be turned on and off by the recorder or set to 
be on continuously. Time is tracked by a DS1307 real time clock with battery backup. 
An optoisolator is used to control a digital audio recorder. An LED indicator is 
available to signal the current status of the unit. The LED will blink once every 
five seconds while in standby and will be on continuously when recording. A 
thermistor on the board records ambient air temperature and can be calibrated by 
adjusting a thermal constant. Three digital and three analog inputs are available 
for additional sensors. An SD card will be added at a later date to record the time 
and all sensor data to a text for each recording event. The logger will send text 
reporting recorder status and sensor data through the serial line to the Arduino 
software for debugging.

DS1307 real time clock access by Maurice Ribble, 4-17-2008, http://www.glacialwanderer.com/hobbyrobotics 

This work is licensed under the Creative Commons Attribution-Noncommercial-
Share Alike 3.0 License. To view a copy of this license, visit 
http://creativecommons.org/licenses/by-nc-sa/3.0/us/ or send a letter to 
Creative Commons
171 Second Street, Suite 300
San Francisco, California, 94105, USA.
*/

	// Adds communication protocols and Identification for DS1307 real time clock
#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68

	// Declaration of digital pins used and purpose
	// I/O pins 0 - 1 dedicated to serial USB connection
	// Pin 2 not exposed
	// Digital pins 3 - 5 available for external sensors
int RecOn = 6;	// Optocoupler on signal for audio recorder digital pin 6
int RecOff = 7;	// Optocoupler off signal for audio recorder on digital pin 7
int RecPower = 8;	// Audio recorder power switch digital pin 8
int buzz = 9;	// Sets audio pulses to digital pin 9
	// Digital pins 10 - 13 available for external SD card
int ledPin = 13;	// LED connected to digital pin 13 (disable if using a SD card

	// Declaration of analog pins used and purpose
	// Analog pins 0 - 2 available for external sensors
int thermPin = 3;	// Thermistor connected to analog pin 3
	// Real time clock uses analog pins 4 & 5

	// User Parameters, change as needed
int thermK = 5;	// Thermistor constant used for calibration, thermK = reported temp - actual temp
int RecPulse = 500;	// Pulse length for activating the audio recorder
int BegDelay = 1000;	// Delay between when the recorder power is turned on and the signal to start recordings
int RecDelay = 1000;	// Delay to begin time stamp after recording has begun
int EndDelay = 1000;	// Delay between when the recorder stops recording and the power is turned off
int RecTime = 90;	// Sets the recording period in seconds

	// Used to set period recorder will not record i.e. during the day from 9am to 6pm
int XtimeB = 9;		// Sets the beginning of the recording blackout period in 24h format
int XtimeE = 18;	// Sets the beginning of the recording blackout period in 24h format

	// Used to set times when recorder is active
//int RecM[] = {0, 30};	// Recorder will start when the current minute equals one of these values

	// Time code pulse parameters
int Vfreq = 2500;	// Frequency of the 5 pulses, time = 1/2 * Frequency) * 1,000,000
int Vdur = 300;	// Duration of the 5 pulses
int Vpause = 300;	// pause between the 5 pulses

int Ifreq = 956;	// Frequency of 1 the pulses, time = 1/2 * Frequency) * 1,000,000
int Idur = 100;	// Duration of the 1 pulses
int Ipause = 300;	// Pause between the 1 pulses

int VIpause = 300;	// Duration between the 5 and the 1 pulses
int BEfreq = 500;	// Frequency of pulses that mark beginning and end of data transmission
int Mdur = 50;	// Duration of pulses that mark beginning and end of data transmission
int Upause = 600;	// Pause between units

	// Additional variables not to be changed
int Vhour;	// Stores number of 5 hour pulses
int Ihour;	// Stores number of 1 hour pulses
int Vminute;	// Stores number of 10 minute pulses
int Iminute;	// Stores number of 2 minute pulses
int Vday;	// Stores number of 5 day pulses
int Iday;	// Stores number of 1 day pulses
int Vmonth;	// Stores number of 5 month pulses
int Imonth;	// Stores number of 1 month pulses
int Vtherm;	// Stores number of 5 temperature pulses
int Itherm;	// Stores number of 1 temperature pulses

int Tvolt;	// Stores value of analog thermistor pin
int therm;	// Stores current temperature
int Dsecond;	// Stores second value in decimal form
int Dminute;	// Stores minute value in decimal form
int Dhour;	// Stores hour value in decimal form
int DdayOfMonth;	// Stores day value in decimal form
int Dmonth;	// Stores month value in decimal form
int StartTime;	// Stores the time in seconds that the recorder began
int CurTime;	// Used to track the current time
boolean TS = false;	// Used to play the time stamp only once while recording



	// Convert normal decimal numbers to binary coded decimal
byte decToBcd(byte val)
{
  return ( (val/10*16) + (val%10) );
}

	// Convert binary coded decimal to normal decimal numbers
byte bcdToDec(byte val)
{
  return ( (val/16*10) + (val%16) );
}

	// 1) Sets the date and time on the ds1307
	// 2) Starts the clock
	// 3) Sets hour mode to 24 hour clock
	// Assumes you're passing in valid numbers
void setDateDs1307(byte second,	// 0-59
                   byte minute,	// 0-59
                   byte hour,	// 1-23
                   byte dayOfWeek,	// 1-7
                   byte dayOfMonth,	// 1-28/29/30/31
                   byte month,	// 1-12
                   byte year)	// 0-99
{
   Wire.beginTransmission(DS1307_I2C_ADDRESS);
   Wire.send(0);
   Wire.send(decToBcd(second));	// 0 to bit 7 starts the clock
   Wire.send(decToBcd(minute));
   Wire.send(decToBcd(hour));	// If you want 12 hour am/pm you need to set
	// Bit 6 (also need to change readDateDs1307)
   Wire.send(decToBcd(dayOfWeek));
   Wire.send(decToBcd(dayOfMonth));
   Wire.send(decToBcd(month));
   Wire.send(decToBcd(year));
   Wire.endTransmission();
}

	// Gets the date and time from the ds1307
void getDateDs1307(byte *second,
          byte *minute,
          byte *hour,
          byte *dayOfWeek,
          byte *dayOfMonth,
          byte *month,
          byte *year)
{

	// Reset the register pointer
  Wire.beginTransmission(DS1307_I2C_ADDRESS);
  Wire.send(0);
  Wire.endTransmission();

  Wire.requestFrom(DS1307_I2C_ADDRESS, 7);

	// A few of these need masks because certain bits are control bits
  *second     = bcdToDec(Wire.receive() & 0x7f);
  *minute     = bcdToDec(Wire.receive());
  *hour       = bcdToDec(Wire.receive() & 0x3f);	// Need to change this if 12 hour am/pm
  *dayOfWeek  = bcdToDec(Wire.receive());
  *dayOfMonth = bcdToDec(Wire.receive());
  *month      = bcdToDec(Wire.receive());
  *year       = bcdToDec(Wire.receive());
}


void setup()
{
  pinMode(RecPower, OUTPUT);	// Sets the recorder power digital pin as output
  pinMode(RecOn, OUTPUT);	// Sets the opto on switch digital pin as output
  pinMode(RecOff, OUTPUT);	// Sets the opto off switch digital pin as output
  analogReference(EXTERNAL);	// Sets the analog reference voltage to the external power source
  pinMode(buzz, OUTPUT);	// Sets the time stamp digital pin as output
  pinMode(ledPin, OUTPUT);	// Sets the LED digital pin as output

  Serial.begin(9600);	// opens serial port, sets data rate to 9600 bps
  Serial.println("Open Frog Logger");
  Serial.println("Kelly Lasater 2009");
  Serial.println("www.openlogger.org");
  Serial.println();
  Serial.println("Logger is Running");
  Serial.println();

  Wire.begin();

	// Change these values to what you want to set your clock to.
	// You probably only want to set your clock once and then remove
	// The setDateDs1307 call.

  /*
  second = 45;
  minute = 26;
  hour = 15;
  dayOfWeek = 3;
  dayOfMonth = 11;
  month = 2;
  year = 9;
  setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year);
  */
}


void loop()
{
  byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; 
  getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year); // Gets the current time
  Dsecond = int(second);
  Dminute = int(minute);
  Dhour = int(hour);

  TS = false;	// Resets the time stamp marker to play during the next recording period  

	// Starts recorder at specific times
  while (Dminute == 10 || Dminute == 40)	// Activates recorder when minutes = 0 or 1 (i.e. 2 min.)
	// Multiple times should look like this: (Dminute == 0 || Dminute == 15 || Dminute == 30 || Dminute == 45)
  {

 // if (Dhour >= XtimeB || Dhour <= XtimeE)	// Prevents recording during day time
 // {
 // break;
 // }

 if (TS == false);	// Activates the time and temperature stamp only if TS is false
{
  	// Activates audio recorder
  Serial.println("Rec ON");	// Reports that the recorder has started

  StartTime = Dminute * 60 + Dsecond;

  digitalWrite(RecPower, HIGH);	// Turns on power to the audio recorder

  delay(BegDelay);	// Delay between turning on power of recorder and activation of recorder

  digitalWrite(RecOn, HIGH);	// Sends "on" signal to digital recorder

  delay(RecPulse); 

  digitalWrite(RecOn, LOW);

  digitalWrite(ledPin, HIGH);	// Turns indicator LED on

  

  delay(RecDelay);	// Delay to begin time stamp after recording has begun

 

	// Calculates temperature from thermistor

  Tvolt=analogRead(thermPin);

  therm=((-11*Tvolt)+8328)/100-thermK;

  

	// Creates pulses for time and temperature stamp on audio recorder

	// Gets current time and date from clock and converts binary to decimal numbers

  getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);

  Dminute = int(minute);

  Dhour = int(hour);

  DdayOfMonth = int(dayOfMonth);

  Dmonth = int(month);



  	// Short pulse marks beginning of data

  for (int i=0; i < Mdur; i++) {  

  digitalWrite(buzz,HIGH);

  delayMicroseconds(BEfreq);

  digitalWrite(buzz, LOW);

  delayMicroseconds(BEfreq);

  }

  delay(Upause);



	// Pulse code for hours

Vhour = Dhour / 5;

Ihour = Dhour - Vhour * 5;



   while(Vhour > 0)	// Pulses for 5s

   {

        for (int i=0; i < Vdur; i++) {

        digitalWrite(buzz,HIGH);

        delayMicroseconds(Vfreq);

        digitalWrite(buzz, LOW);

        delayMicroseconds(Vfreq);

        }

      delay(Vpause);

      Vhour--;

   } 

delay(VIpause);	// Delay between 5s and 1s

   while(Ihour > 0)	// Pulses for 1s

   {

        for (int i=0; i < Idur; i++) {

        digitalWrite(buzz,HIGH);

        delayMicroseconds(Ifreq);

        digitalWrite(buzz, LOW);

        delayMicroseconds(Ifreq);

        }

      delay(Ipause);

      Ihour--;

   } 

delay(Upause);	// Delay between units

   

   

	// Pulse code for minutes

Vminute = Dminute / 10;

Iminute = Dminute - Vminute * 10;

Iminute = Iminute / 2;



   while(Vminute > 0)	// Pulses for 5s

   {

        for (int i=0; i < Vdur; i++) {

        digitalWrite(buzz,HIGH);

        delayMicroseconds(Vfreq);

        digitalWrite(buzz, LOW);

        delayMicroseconds(Vfreq);

        }

      delay(Vpause);

      Vminute--;

   } 

delay(VIpause);	// Delay between 5s and 1s

   while(Iminute > 0)	// Pulses for 1s

   {

        for (int i=0; i < Idur; i++) {

        digitalWrite(buzz,HIGH);

        delayMicroseconds(Ifreq);

        digitalWrite(buzz, LOW);

        delayMicroseconds(Ifreq);

        }

      delay(Ipause);

      Iminute--;

   } 

delay(Upause);	// Delay between units





	// Pulse code for days

Vday = DdayOfMonth / 5;

Iday = DdayOfMonth - Vday * 5;



   while(Vday > 0)	// Pulses for 5s

   {

        for (int i=0; i < Vdur; i++) {

        digitalWrite(buzz,HIGH);

        delayMicroseconds(Vfreq);

        digitalWrite(buzz, LOW);

        delayMicroseconds(Vfreq);

        }

      delay(Vpause);

      Vday--;

   } 

delay(VIpause);	// Delay between 5s and 1s

   while(Iday > 0)	// Pulses for 1s

   {

        for (int i=0; i < Idur; i++) {

        digitalWrite(buzz,HIGH);

        delayMicroseconds(Ifreq);

        digitalWrite(buzz, LOW);

        delayMicroseconds(Ifreq);

        }

      delay(Ipause);

      Iday--;

   } 

delay(Upause);	// Delay between units





	// Pulse code for months

Vmonth = Dmonth / 5;

Imonth = Dmonth - Vmonth * 5;



   while(Vmonth > 0)	// Pulses for 5s

   {

        for (int i=0; i < Vdur; i++) {

        digitalWrite(buzz,HIGH);

        delayMicroseconds(Vfreq);

        digitalWrite(buzz, LOW);

        delayMicroseconds(Vfreq);

        }

      delay(Vpause);

      Vmonth--;

   } 

delay(VIpause);	// Delay between 5s and 1s

   while(Imonth > 0)	// Pulses for 1s

   {

        for (int i=0; i < Idur; i++) {

        digitalWrite(buzz,HIGH);

        delayMicroseconds(Ifreq);

        digitalWrite(buzz, LOW);

        delayMicroseconds(Ifreq);

        }

      delay(Ipause);

      Imonth--;

   } 

delay(Upause);	// Delay between units





	// Pulse code for temperature

Vtherm = therm / 5;

Itherm = therm - Vtherm * 5;



   while(Vtherm > 0)	// Pulses for 5s

   {

        for (int i=0; i < Vdur; i++) {

        digitalWrite(buzz,HIGH);

        delayMicroseconds(Vfreq);

        digitalWrite(buzz, LOW);

        delayMicroseconds(Vfreq);

        }

      delay(Vpause);

      Vtherm--;

   } 

delay(VIpause);	// Delay between 5s and 1s

   while(Itherm > 0)	// Pulses for 1s

   {

        for (int i=0; i < Idur; i++) {

        digitalWrite(buzz,HIGH);

        delayMicroseconds(Ifreq);

        digitalWrite(buzz, LOW);

        delayMicroseconds(Ifreq);

        }

      delay(Ipause);

      Itherm--;

   } 

delay(Upause);	// Delay between units





	// Short pulse marks end of data

  for (int i=0; i < Mdur; i++) {  

  digitalWrite(buzz,HIGH);

  delayMicroseconds(BEfreq);

  digitalWrite(buzz, LOW);

  delayMicroseconds(BEfreq);

  }

  delay(100);

  

  /*

	// Any additional sensor reading should go here

  */

  

	// Reports time and temperature data to the serial (can be removed)

  Serial.print(hour, DEC);

  Serial.print(":");

  Serial.print(minute, DEC);

  Serial.print(":");

  Serial.print(second, DEC);

  Serial.print("  ");

  Serial.print(month, DEC);

  Serial.print("/");

  Serial.print(dayOfMonth, DEC);

  Serial.print("/");

  Serial.print("200");	// Needs to be changed to "20" in 2010

  Serial.println(year, DEC);

 

  Serial.print("Temperature raw ADC = ");		

  Serial.println(Tvolt);

  Serial.print("temerature C = ");

  Serial.println(therm);

  Serial.println();

  

  TS = true;	// Prevents the time and temperature stamp from playing more than once during the recording

  }

 

   CurTime = StartTime;

 

  while (CurTime - StartTime <= RecTime)	// Loops until elapsed time equals set recording time

  {

  delay(1000);

  

  getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year);  // Gets the current time

  Dsecond = int(second);

  Dminute = int(minute);

  Dhour = int(hour);

  

  CurTime = Dminute * 60 + Dsecond;	// Calculates current time in seconds

  }

  

  }


	// Stop Recorder

  if (TS == true)

  {

  digitalWrite(RecOff, HIGH);	// Sends off signal to digital recorder

  delay(RecPulse); 

  digitalWrite(RecOff, LOW);

  delay(EndDelay);	// Delay between stopping of recording and turning off power to the recorder

  digitalWrite(RecPower, LOW);	// Turns off power to the audio recorder 

  digitalWrite(ledPin, LOW);	// Turns indicator LED off

  

  Serial.println("Rec OFF");	// Reports that recording has stopped

  Serial.print(hour, DEC);

  Serial.print(":");

  Serial.print(minute, DEC);

  Serial.print(":");

  Serial.println(second, DEC);

  Serial.println();

  }

 



	// Long Wait between recording

  digitalWrite(ledPin, HIGH);	// Blinks indicator LED every 5 seconds  (can be removed)

  delay(250); 

  digitalWrite(ledPin, LOW); 

  delay(9750);  

  

}



Creative Commons License
The hardware portion of this work is licensed under a Creative Commons Attribution-Noncommercial-Share? Alike 3.0 License.

GNU General Public License
The software portion of this work is licensed under a GNU General Public License V3.



Created by: System Administrator. Last Modification: Wednesday 28 of October, 2009 12:31:58 UTC by System Administrator.

Menu [toggle]

Support this Site

Please help support this site. Contribute your time and knowledge to develop new projects and improve existing ones. You can also make donations below to help cover hosting expenses.


Map of Visitor Locations