|
||||||||||||||||
|
||||||||||||||||
|
|
#106 |
|
Planted Tank Enthusiast
|
So, found my first issue, haha...
I'm trying to upload the sketch, and I am getting an error. I'm not sure what I'm missing here. I have the Time.h file, so I'm not sure what it means by "no such directory". Am I missing a file? It's bound to be something idiotically simple. This is my first go with any kind of coding, so I feel like I'm playing with fire a bit. Here's what it looks like: ![]() I saved it as a separate file and renamed it "B" in case I screwed something up. Which I probably did.
__________________
|
|
|
|
|
|
#107 |
|
Planted Tank Enthusiast
|
Ok, I had apparently installed the libraries incorrectly. That's fixed. Now, I'm getting a new set of errors, and I don't know what the fix is:
SmartyCat_6_channel_codeB:84: error: 'byte second' redeclared as different kind of symbol /Users/seankelly/Documents/Arduino/libraries/Time/Time.h:93: error: previous declaration of 'int second(time_t)' SmartyCat_6_channel_codeB:84: error: 'byte month' redeclared as different kind of symbol /Users/seankelly/Documents/Arduino/libraries/Time/Time.h:99: error: previous declaration of 'int month(time_t)' SmartyCat_6_channel_codeB:84: error: 'byte year' redeclared as different kind of symbol /Users/seankelly/Documents/Arduino/libraries/Time/Time.h:101: error: previous declaration of 'int year(time_t)' SmartyCat_6_channel_codeB:268: error: expected unqualified-id before '/' token SmartyCat_6_channel_codeB:268: error: expected constructor, destructor, or type conversion before '/' token SmartyCat_6_channel_codeB.cpp: In function 'void loop()': SmartyCat_6_channel_codeB:345: error: cannot resolve overloaded function 'second' based on conversion to type 'byte*' SmartyCat_6_channel_codeB:349: error: 'DS1307_HR' was not declared in this scope SmartyCat_6_channel_codeB:353: error: 'DS1307_MIN' was not declared in this scope SmartyCat_6_channel_codeB:357: error: 'DS1307_SEC' was not declared in this scope SmartyCat_6_channel_codeB:361: error: 'DS1307_MTH' was not declared in this scope SmartyCat_6_channel_codeB:365: error: 'DS1307_DATE' was not declared in this scope SmartyCat_6_channel_codeB:369: error: 'DS1307_YR' was not declared in this scope Anyone? I'm a hopeless noob, here. I have never done any coding, and I just want this thing to work, haha...
__________________
|
|
|
|
|
|
#108 |
|
Planted Tank Obsessed
|
I looks to me like you're trying to compile and load a "library" file. Library files can be identified by the ".h" at the end of the file name. Make sure to place that file and any others with the same ".h" into the Arduino 23 "Library" folder. The actual Program "Sketch" will have ".cpp" at the end of the file name. When you open and then "verify/compile" the sketch, the libraries that are called out in that sketch will be accessed and integrated into the actual binary code that is transferred to the chip.
Here's some code that "Sink" wrote. It makes setting the time a breeze. Just copy and paste this into the Arduino23 IDE and name it the "Time_set" sketch. Load this one first to set the time and then load the "Smartycat" sketch( be sure to adjust the start/stop/fade duration/max led intensity values to your liking before loading) Code:
/*
* Name: timeset.pde
* Author: User "sink" at plantedtank.net forums
* URL: http://bitbucket.org/akl/tank-control
*
* This code sets the time on a DS1307 RTC chip attached to an Arduino
* microcontroller board. The time is set to the system time when the
* sketch was compiled (using preprocessor macros), so make sure that:
*
* 1. Your system (PC) time is accurate.
* 2. You recompile the sketch and then upload immediately.
*
* The time is skewed forward some seconds to accomodate for compilation and
* upload time. If you find the time is consistently off by the same amount,
* you can modify the adjustment constant below.
*
* This code requires the following libraries: Wire, Time, DS1307RTC
*
* The latest version of this code can always be found at above url.
*/
/*
* Copyright (c) 2011, User "sink" at plantedtank.net forums
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <Time.h>
#include <Wire.h>
#include <DS1307RTC.h>
/*
* Time adjustment forward in seconds. Used to compensate for
* compilation/upload time.
*/
const int kAdjustment = 20;
/*
* Utility function for pretty digital clock time output
* From example code in Time library -- author unknown
*/
void printDigits(int digits) {
Serial.print(":");
if(digits < 10)
Serial.print('0');
Serial.print(digits);
}
/*
* Display time
* Adapted from example code in Time library -- author unknown
*/
void digitalClockDisplay() {
Serial.print(hour());
printDigits(minute());
printDigits(second());
Serial.print(" ");
Serial.print(month());
Serial.print("/");
Serial.print(day());
Serial.print("/");
Serial.print(year());
Serial.println();
}
void setup() {
// convert compilation time and set system clock
char const *date = __DATE__;
char const *time = __TIME__;
int sec, min, hour, day, month, year;
char s_month[5];
static const char month_names[] = "JanFebMarAprMayJunJulAugSepOctNovDec";
sscanf(date, "%s %d %d", s_month, &day, &year);
month = (strstr(month_names, s_month)-month_names)/3;
sscanf(time, "%d:%d:%d", &hour, &min, &sec);
setTime(hour, min, sec, day, month+1, year);
adjustTime(kAdjustment); // crude fwd correction
time_t t = now();
// set RTC
RTC.set(t);
Serial.begin(115200);
}
void loop () {
digitalClockDisplay();
Serial.println();
delay(1000);
}
__________________
|
|
|
|
|
|
#109 | |
|
Planted Tank Obsessed
|
Quote:
__________________
|
|
|
|
|
|
|
#110 |
|
Planted Tank Enthusiast
|
This may be the issue: I have a Mac. I've seen in the forums that the names for some things are different (I really have no clue about this stuff). Would this account for the errors?
__________________
|
|
|
|
|
|
#111 |
|
Planted Tank Obsessed
|
It may have something to do with it, but I'm not sure. Have you tried loading some of the more basic sketches, like "Blink", just to see what happens? The red LED is already connected to digital pin 13 on the Smartycat, just like an "off the shelf" Arduino, so there's no need for any other connections. Just run the sketch and see what happens.
__________________
|
|
|
|
|
|
#112 |
|
Planted Tank Enthusiast
|
I did - Blink functions perfectly. No errors
__________________
|
|
|
|
|
|
#113 | |
|
Planted Tank Obsessed
|
Quote:
That's weird. Try this copy. There are only two Libraries included, so if it doesn't compile properly, maybe the library you have is wrong or corrupted in some way. Code:
/*
// ATMEG328P-AU Microcontroller LED lighting controller for aquarium use.
// The programming code uses a DS1307 Real Time clock to set the LED lighting schedule. Current date and time can be accessed with the serial monitor set to 9600 baud.
// sunrise/sunset time,length of fade duration, and the length of the day are selectable via the programmed schedule.
// Circuit description
// PWM pins described below connected to dimming circuits on drivers spread among 6 seperate channels.
// DS1307 RTC ( real time clock) connected via I2C protocol.
*/
// Pins to control each channel LEDs. Change these if you're using different pins.
int oneLed = 3; // LED PWM arduino pin for channel one.
int twoLed = 5; // LED PWM arduino pin for channel two
int threeLed = 6; // LED PWM arduino pin for channel three
int fourLed = 9; // LED PWM arduino pin for channel four
int fiveLed = 10; // LED PWM arduino pin for channel five
int sixLed = 11; // LED PWM arduino pin for channel six
#include <WProgram.h>
#include <DS1307.h>
// written by mattt on the Arduino forum and modified by D. Sjunnesson
// Set up RTC
#include "Wire.h"
#define DS1307_I2C_ADDRESS 0x68
// RTC variables
byte second, rtcMins, oldMins, rtcHrs, oldHrs, dayOfWeek, dayOfMonth, month, year;
// Other variables. These control the behavior of lighting. Change these to customize behavior.
int minCounter = 0; // counter that resets at midnight. Don't change this.
int oneStartMins = 540; // minute to start channel 1. Change this to the number of minutes past midnight you want to start
int twoStartMins =420; // minute to start channel 2. Change this to the number of minutes past midnight you want to start
int threeStartMins =540; // minute to start channel 3. Change this to the number of minutes past midnight you want to start
int fourStartMins =420; // minute to start channel 4. Change this to the number of minutes past midnight you want to start
int fiveStartMins =420; // minute to start channel 5. Change this to the number of minutes past midnight you want to start
int sixStartMins =420; // minute to start channel 6. Change this to the number of minutes past midnight you want to start
int onePhotoPeriod = 720; // photoperiod in minutes, for this channel. Change this to alter the total legnth of the day
int twoPhotoPeriod = 960; // photoperiod in minutes, for this channel. Change this to alter the total legnth of the day
int threePhotoPeriod = 720; // photoperiod in minutes, for this channel. Change this to alter the total legnth of the day
int fourPhotoPeriod = 960; // photoperiod in minutes, for this channel. Change this to alter the total legnth of the day
int fivePhotoPeriod = 960; // photoperiod in minutes, for this channel. Change this to alter the total legnth of the day
int sixPhotoPeriod = 960; // photoperiod in minutes, for this channel. Change this to alter the total legnth of the day
int fadeDuration = 180; // duration of the fade on and off for sunrise and sunset. Change
// this to alter how long the fade lasts.
int oneMax = 100; // max intensity for this channel. Change if you want to limit max intensity.
int twoMax = 100; // max intensity for this channel. Change if you want to limit max intensity.
int threeMax = 100; // max intensity for this channel. Change if you want to limit max intensity.
int fourMax = 100; // max intensity for this channel. Change if you want to limit max intensity.
int fiveMax = 100; // max intensity for this channel. Change if you want to limit max intensity.
int sixMax = 100; // max intensity for this channel. Change if you want to limit max intensity.
/****** LED Functions ******/
/***************************/
//function to set LED brightness according to time of day
//function has three equal phases - ramp up, hold, and ramp down
void setLed(int mins, // current time in minutes
int ledPin, // pin for this channel of LEDs
int start, // start time for this channel of LEDs
int period, // photoperiod for this channel of LEDs
int fade, // fade duration for this channel of LEDs
int ledMax // max value for this channel
) {
if (mins <= start || mins <= mins > start + period) {
analogWrite(ledPin, 0);
}// This is when the led's are off, thus ledVal =0
if (mins > start && mins <= start + fade) {
analogWrite(ledPin, map(mins - start, 0, fade, 0, ledMax));
}// This is sunrise. Leds slowly brighten to full intensity
if (mins > start + fade && mins <= start + period - fade) {
analogWrite(ledPin, ledMax);
}//This is when the led's are at maximum intensity
if (mins > start + period - fade && mins <= start + period) {
analogWrite(ledPin, map(mins - start - period + fade, 0, fade, ledMax, 0));
}// This is sunset. LEDs slowly fade out.
}
/***** RTC Functions *******/
/***************************/
// 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.
/* //remove the forward slash and asterisk at the far left to activate the time date setting code
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));
Wire.send(decToBcd(minute));
Wire.send(decToBcd(hour));
Wire.send(decToBcd(dayOfWeek));
Wire.send(decToBcd(dayOfMonth));
Wire.send(decToBcd(month));
Wire.send(decToBcd(year));
Wire.endTransmission();
}
*/ //remove the forward slash and asterisk at the far left to activate the time date setting code
// Gets the date and time from the ds1307 via the I2C protocol.
void getDateDs1307(byte *second,
byte *minute,
byte *hour,
byte *dayOfWeek,
byte *dayOfMonth,
byte *month,
byte *year)
{
Wire.beginTransmission(DS1307_I2C_ADDRESS);
Wire.send(0);
Wire.endTransmission();
Wire.requestFrom(DS1307_I2C_ADDRESS, 7);
*second = bcdToDec(Wire.receive() & 0x7f);
*minute = bcdToDec(Wire.receive());
*hour = bcdToDec(Wire.receive() & 0x3f);
*dayOfWeek = bcdToDec(Wire.receive());
*dayOfMonth = bcdToDec(Wire.receive());
*month = bcdToDec(Wire.receive());
*year = bcdToDec(Wire.receive());
}
void setup() {
// init I2C
Serial.begin(9600);
Wire.begin();
}
// these functions only occur once.
/***** Main Loop ***********/
/***************************/
void loop() {
// get time from RTC and put in hrs and mins variables
getDateDs1307(&second, &rtcMins, &rtcHrs, &dayOfWeek, &dayOfMonth, &month, &year);
minCounter = rtcHrs * 60 + rtcMins;
Serial.print(RTC.get(DS1307_HR,true)); //read the hour and also update all the values by pushing in true
Serial.print(":");
Serial.print(RTC.get(DS1307_MIN,false));//read minutes without update (false)
Serial.print(":");
Serial.print(RTC.get(DS1307_SEC,false));//read seconds
Serial.print(" "); // some space for a more happy life
Serial.print(RTC.get(DS1307_MTH,false));//read month
Serial.print("/");
Serial.print(RTC.get(DS1307_DATE,false));//read date
Serial.print("/");
Serial.print(RTC.get(DS1307_YR,false)); //read year
Serial.println();
//set LED values
setLed(minCounter, oneLed, oneStartMins, onePhotoPeriod, fadeDuration, oneMax);
setLed(minCounter, twoLed, twoStartMins, twoPhotoPeriod, fadeDuration, twoMax);
setLed(minCounter, threeLed, threeStartMins, threePhotoPeriod, fadeDuration, threeMax);
setLed(minCounter, fourLed, fourStartMins, fourPhotoPeriod, fadeDuration, fourMax);
setLed(minCounter, fiveLed, fiveStartMins, fivePhotoPeriod, fadeDuration, fiveMax);
setLed(minCounter, sixLed, sixStartMins, sixPhotoPeriod, fadeDuration, sixMax);
// Get ready for next iteration of loop
delay(1000);
}
__________________
|
|
|
|
|
|
|
#114 |
|
Planted Tank Enthusiast
|
Ok, so here's a bit of a breakdown of what's going on.
I cut and pasted the code you posted and verified it. This is what came up: 'RTC' was not declared in this scope SmartyCat_6_channel_codeB.cpp:65:21: error: DS1307.h: No such file or directory SmartyCat_6_channel_codeB.cpp: In function 'void loop()': SmartyCat_6_channel_codeB:337: error: 'RTC' was not declared in this scope SmartyCat_6_channel_codeB:337: error: 'DS1307_HR' was not declared in this scope SmartyCat_6_channel_codeB:341: error: 'DS1307_MIN' was not declared in this scope SmartyCat_6_channel_codeB:345: error: 'DS1307_SEC' was not declared in this scope SmartyCat_6_channel_codeB:349: error: 'DS1307_MTH' was not declared in this scope SmartyCat_6_channel_codeB:353: error: 'DS1307_DATE' was not declared in this scope SmartyCat_6_channel_codeB:357: error: 'DS1307_YR' was not declared in this scope So, I add this: #include <DS1307RTC.h> and this is what I get: 'class DS1307RTC.h' has no member named 'get' In file included from SmartyCat_6_channel_codeB.cpp:1: /Users/seankelly/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.h:9:18: error: Time.h: No such file or directory SmartyCat_6_channel_codeB.cpp:67:21: error: DS1307.h: No such file or directory In file included from SmartyCat_6_channel_codeB.cpp:1: /Users/seankelly/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.h:17: error: 'time_t' does not name a type /Users/seankelly/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.h:18: error: 'time_t' has not been declared /Users/seankelly/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.h:19: error: 'tmElements_t' has not been declared /Users/seankelly/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.h:20: error: 'tmElements_t' has not been declared /Users/seankelly/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.h:23: error: 'uint8_t' does not name a type /Users/seankelly/Documents/Arduino/libraries/DS1307RTC/DS1307RTC.h:24: error: 'uint8_t' does not name a type SmartyCat_6_channel_codeB.cpp: In function 'void loop()': SmartyCat_6_channel_codeB:339: error: 'class DS1307RTC' has no member named 'get' SmartyCat_6_channel_codeB:339: error: 'DS1307_HR' was not declared in this scope SmartyCat_6_channel_codeB:343: error: 'class DS1307RTC' has no member named 'get' SmartyCat_6_channel_codeB:343: error: 'DS1307_MIN' was not declared in this scope SmartyCat_6_channel_codeB:347: error: 'class DS1307RTC' has no member named 'get' SmartyCat_6_channel_codeB:347: error: 'DS1307_SEC' was not declared in this scope SmartyCat_6_channel_codeB:351: error: 'class DS1307RTC' has no member named 'get' SmartyCat_6_channel_codeB:351: error: 'DS1307_MTH' was not declared in this scope SmartyCat_6_channel_codeB:355: error: 'class DS1307RTC' has no member named 'get' SmartyCat_6_channel_codeB:355: error: 'DS1307_DATE' was not declared in this scope SmartyCat_6_channel_codeB:359: error: 'class DS1307RTC' has no member named 'get' SmartyCat_6_channel_codeB:359: error: 'DS1307_YR' was not declared in this scope So, I add: #include <Time.h> and I end up with: SmartyCat_6_channel_codeB.cpp:69:21: error: DS1307.h: No such file or directory SmartyCat_6_channel_codeB:76: error: 'byte second' redeclared as different kind of symbol /Users/seankelly/Documents/Arduino/libraries/Time/Time.h:93: error: previous declaration of 'int second(time_t)' SmartyCat_6_channel_codeB:76: error: 'byte month' redeclared as different kind of symbol /Users/seankelly/Documents/Arduino/libraries/Time/Time.h:99: error: previous declaration of 'int month(time_t)' SmartyCat_6_channel_codeB:76: error: 'byte year' redeclared as different kind of symbol /Users/seankelly/Documents/Arduino/libraries/Time/Time.h:101: error: previous declaration of 'int year(time_t)' SmartyCat_6_channel_codeB.cpp: In function 'void loop()': SmartyCat_6_channel_codeB:337: error: cannot resolve overloaded function 'second' based on conversion to type 'byte*' SmartyCat_6_channel_codeB:341: error: 'DS1307_HR' was not declared in this scope SmartyCat_6_channel_codeB:345: error: 'DS1307_MIN' was not declared in this scope SmartyCat_6_channel_codeB:349: error: 'DS1307_SEC' was not declared in this scope SmartyCat_6_channel_codeB:353: error: 'DS1307_MTH' was not declared in this scope SmartyCat_6_channel_codeB:357: error: 'DS1307_DATE' was not declared in this scope SmartyCat_6_channel_codeB:361: error: 'DS1307_YR' was not declared in this scope My head hurts, haha... Does this help at all, or am I just making things more difficult? should I shoot Sink a message?
__________________
|
|
|
|
|
|
#115 |
|
Planted Tank Obsessed
|
Ok, I think you have the wrong version of the DS1307 RTC library version installed. Try the ones attached. You should be able to place both of these folders (unzipped of course) into your library folder and the Arduino IDE should be able to pick the correct one.
__________________
|
|
|
|
|
|
#116 |
|
Planted Tank Enthusiast
|
Win
__________________
|
|
|
|
|
|
#117 |
|
Planted Tank Obsessed
|
Cool! I's no 'Puter expert neither, but sometimes even a blind squirrel gets a nut!
__________________
|
|
|
|
|
|
#118 |
|
Planted Tank Enthusiast
|
Well now I have a bit of a wiring issue - I think. The emitters were working fine until I installed my splash guard. After that, some weird stuff was going on. I was unplugging the jumpers from the inputs, and the lead for channel one touched the heat sink - and the emitters for that channel turned on. Sure enough, I checked all of them and all four channels were doing the same thing. I'm not really sure what to think, so I left it. I don't want to hijack this thread any more than I already have so I'll leave it at that until I can get it repaired. It may be next week before I get things up again, as I have no idea where to begin.
__________________
|
|
|
|
|
|
#119 | |
|
Planted Tank Obsessed
|
Quote:
__________________
|
|
|
|
|
|
|
#120 |
|
Algae Grower
|
ok starting to wire up my build and have a few questions. firstly i have 3 meanwell power supplies that i got cheap a while ago and was wondering if i could use one to power the chip. i have a s-320-24 meanwell. i puts out 24 volts at 12.5 amps. next i see that there are 2 power inputs on the driver. do i need to supply power to one or both. my ftdi to usb adaptor is on the way so im sure i will have questions on programming when i get that going. i will be running 3 lines of 6 cree xmls at around 2 amps ea. i am a little confused about the pwm part of the driver. wont i be able to dim it based on programming the driver and if not what do i need to wire to where to get this thing to auto dim up and down. thanks for all the help, i will post pics of the build on here as well as par numbers once the unit is up and running.
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|