Jump to content

RockyBoy

Senior Reefer
  • Posts

    6,351
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by RockyBoy

  1. Qute fun DIYing... Also thanks to bro GP2700 for some programming tips.
  2. My crappy arduino sketch: #include <avr/io.h> #include <stdlib.h> #include <Wire.h> /*LCD CONTROL CONTROL CHARACTER DECIDED BY INTERNAL OPERATION OF ATTINY2313 SPI LCD / RS232 CONTROLLER T0 SEND CONTROL CHARACTERS. Serial.write(CR); Serial.write(CD); OR Comm (CD,0) (0 for SPI and 1 for RS232) SEND ASCII 250 AND THEN ANY CONTROL CHARACTER */ #define CR 250 //TO ACCESS CONTROL REGISTER /*SEE PAGE 191,192,193 OF HITACHI LCD CONTROLLER HD44780 DATSHEET 0 0 0 0 0 0 0 1 */ #define CD 1 //CLEAR DISPLAY //1 ADD ADD ADD ADD ADD ADD ADD #define L1 0X80 //ROW 0 COL 0 #define L2 0XC0 //ROW 1 COL 0 #define L3 0x94 //ROW 2 COL 0 #define L4 0xD4 //ROW 3 COL 0 // 0 0 0 0 1 D C B #define CBY 0X0F //CURSOR ON BLINK ON 00001DCB #define CBN 0X0C //CURSOR 0FF BLINK 0FF #define SCK 13 #define MISO 12 #define MOSI 11 #define RESET 10 //#define START_H 8 // Clock start of PWM light int START_H=11; //#define STOP_H 14 // Clock stop PWM light int STOP_H=23; int value = 0; // variable to keep the actual value int White = 9; // White LEDs int Blue = 3; // Blue LEDs int Moon = 5; //Moonlight int fans = 8; // Fan int moonVals[31] = {5, 5, 5, 5, 10, 20, 60, 70, 80, 90, 110, 130, 180, 250, 180, 130, 110, 90, 80, 70, 60, 50, 40, 30, 20, 20, 10, 10, 10, 10, 10}; int stepper1; int stepper2; int lights_fade_time = 1; int buttonwhite; int buttonblue; int temp1 = 0; // temperature variables int temp2 = 0; int temp3 = 0; int sample1[20]; int sample2[20]; int range; //temp range int i; int alarm1a=0; int alarm1val=0; int aval1; int aval2; int RCByte; int TCByte = 0xff; int mv = 0; int tog = 0; char c[30]; char *MONTH[]={"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; char *DAYS[]={"Sun","Mon","Tue","Wed","Thu","Fri","Sat"}; //clock setup #define clockAddress 0x68 // This is the I2C address // RTC variables byte second, rtcMins, oldMins, rtcHrs, oldHrs, dayOfWeek, dayOfMonth, month, year, psecond; /***** 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. //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(); //} // Gets the date and time from the ds1307 void getDateDs1307(byte *second, byte *minute, byte *hour, byte *dayOfWeek, byte *dayOfMonth, byte *month, byte *year) { Wire.beginTransmission(clockAddress); Wire.send(0); Wire.endTransmission(); Wire.requestFrom(clockAddress, 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() { Wire.begin(); Serial.begin(57600); pinMode(6,OUTPUT); pinMode(7,OUTPUT); // following delays may not work on all targets... pinMode(RESET, OUTPUT); digitalWrite(RESET, LOW); delay(50); digitalWrite(RESET, HIGH); delay(50); pinMode(SCK, OUTPUT); //digitalWrite(SCK, LOW); pinMode(MISO, INPUT); pinMode(MOSI, OUTPUT); spi_init(); //pinMode(9,OUTPUT); //digitalWrite(9,LOW); //digitalWrite(10,LOW); //delay(50); //pinMode(10,INPUT); //digitalWrite(10,HIGH); // myspi.init(); digitalWrite(6,LOW); LCD_Reset(0); digitalWrite(6,HIGH); digitalWrite(7,LOW); LCD_Reset(0); digitalWrite(7,HIGH); LCD_Reset(1); pinMode(2,INPUT); //button for white pinMode(4,INPUT); //button for blue digitalWrite(2,LOW); digitalWrite(4,LOW); pinMode(Blue,OUTPUT); pinMode(White,OUTPUT); pinMode(Moon,OUTPUT); pinMode(fans,OUTPUT); } void loop() // run over and over again { if(tog==0){ digitalWrite(7,HIGH); digitalWrite(6,LOW); tog = 1; } else{ digitalWrite(7,LOW); digitalWrite(6,HIGH); tog = 0; } spi_send(CR); // | Alternate | spi_send(L1); // | Comm(CD) | Serial.write(CR); Serial.write(L1); // Getting clock data getDateDs1307(&second, &rtcMins, &rtcHrs, &dayOfWeek, &dayOfMonth, &month, &year); sprintf(c,"%2.2u:%2.2u %s %2.2u,%s'%2.2u",rtcHrs,rtcMins,DAYS[dayOfWeek-1 ],dayOfMonth,MONTH[month-1],year); Serial.print(c); spi_trans(c); spi_send(CR); spi_send(L2); Serial.write(CR); Serial.write(L2); for(i = 0;i<=19;i++){ // gets 20 samples of temperature sample1[i] = ( 5.0 * analogRead(2) * 100.0) / 1023.0;// to change to analogRead(0 temp1 = temp1 + sample1[i]; sample2[i] = ( 5.0 * analogRead(2) * 100.0) / 1023.0; temp2 = temp2 + sample2[i]; delay(50); } temp1 = temp1/20.0; // better precision temp2 = temp2/20.0; // better precision sprintf(c,"HS1=%u%cC HS2=%u%cC ",temp1,0xdf,temp2,0xdf); Serial.print(c); spi_trans(c); //White PWM starts here if (temp1 < 69){ //check LED temperature if (rtcHrs == START_H && rtcHrs < (START_H + lights_fade_time)){ if (rtcMins >= 0 && rtcMins <= 30) {stepper1 = map(rtcMins,0,30,0,255);} analogWrite(White,stepper1); digitalWrite(fans,HIGH); analogWrite(Moon,0); }else if(rtcHrs>= (START_H + lights_fade_time) && rtcHrs < (STOP_H - lights_fade_time)){ digitalWrite(fans,HIGH); analogWrite(Moon,0); stepper1 = 255; analogWrite(White,stepper1); }else if(rtcHrs == (STOP_H - lights_fade_time)&& rtcHrs < STOP_H){ if (rtcMins >= 0 && rtcMins <= 30) {stepper1 = map(rtcMins,0,30,255,0);} digitalWrite(fans,HIGH); analogWrite(White,stepper1); analogWrite(Moon, moonVals[dayOfMonth-1]); }else if(rtcHrs <START_H || rtcHrs >= STOP_H && rtcHrs <=23){ digitalWrite(fans,LOW); stepper1 = 0; analogWrite(White,stepper1); analogWrite(Moon, moonVals[dayOfMonth-1]); } spi_send(CR); spi_send(L3); Serial.write(CR); Serial.write(L3); sprintf(c,"Whites = %3u%%",100*stepper1/255); Serial.print(c); spi_trans(c); }else if (temp1 > 70){ stepper1 = 150; analogWrite(White,stepper1); digitalWrite(fans,HIGH); spi_send(CR); spi_send(L1); Serial.write(CR); Serial.write(L1); sprintf(c,"**High Temperature**"); Serial.print(c); spi_trans(c); spi_send(CR); spi_send(L3); Serial.write(CR); Serial.write(L3); sprintf(c,"Whites = %3u%%",100*stepper1/255); Serial.print(c); spi_trans(c); delay(200000); } //Blue PWM starts here if (temp2 < 69){ //check LED temperatures if (rtcHrs == START_H && rtcHrs < (START_H + lights_fade_time)){ if( rtcMins >= 30 && rtcMins <= 60) {stepper2 = map(rtcMins/2,15,30,0,255);} analogWrite(Blue,stepper2); digitalWrite(fans,HIGH); }else if(rtcHrs>= (START_H + lights_fade_time) && rtcHrs < (STOP_H - lights_fade_time)){ digitalWrite(fans,HIGH); stepper2 = 255; analogWrite(Blue,stepper2); }else if(rtcHrs == (STOP_H - lights_fade_time)&& rtcHrs < STOP_H){ if (rtcMins >=30 && rtcMins <=60) {stepper2 = map(rtcMins/2,15,30,255,0);} digitalWrite(fans,HIGH); analogWrite(Blue,stepper2); }else if(rtcHrs <START_H || rtcHrs >= STOP_H && rtcHrs <=23){ digitalWrite(fans,LOW); stepper2 = 0; analogWrite(Blue,stepper2); } spi_send(CR); spi_send(L4); Serial.write(CR); Serial.write(L4); sprintf(c,"Blues = %3u%%",100*stepper2/255); Serial.print(c); spi_trans(c); }else if (temp2 > 70){ stepper2 = 150; analogWrite(Blue,stepper2); digitalWrite(fans,HIGH); spi_send(CR); spi_send(L1); Serial.write(CR); Serial.write(L1); sprintf(c,"**High Temperature**"); Serial.print(c); spi_trans(c); spi_send(CR); spi_send(L4); Serial.write(CR); Serial.write(L4); sprintf(c,"Blues = %3u%%",100*stepper2/255); Serial.print(c); spi_trans(c); delay(200000); } delay(500); spi_send(CR); spi_send(CBN); buttonwhite = digitalRead(2); buttonblue = digitalRead(4); if(buttonwhite == HIGH){ analogWrite(fans,255); analogWrite(Blue,0); analogWrite(White,255); spi_send(CR); spi_send(L3); Serial.write(CR); Serial.write(L3); sprintf(c,"Whites = %3u%%",100); Serial.print(c); spi_trans(c); spi_send(CR); spi_send(L4); Serial.write(CR); Serial.write(L4); sprintf(c,"Blues = %3u%%",0); Serial.print(c); spi_trans(c); delay(20000);} else if (buttonblue == HIGH){ analogWrite(fans,255); analogWrite(White,0); analogWrite(Blue,255); spi_send(CR); spi_send(L3); Serial.write(CR); Serial.write(L3); sprintf(c,"Whites = %3u%%",0); Serial.print(c); spi_trans(c); spi_send(CR); spi_send(L4); Serial.write(CR); Serial.write(L4); sprintf(c,"Blues = %3u%%",100); Serial.print(c); spi_trans(c); delay(20000);} /* */ //digitalWrite(6,HIGH); //digitalWrite(7,LOW); ////BLINK LED CONNECTED TO ATTINY2313 SPI OPTOISOLATED I/O BOARD //for (int i=0; i <= 5; i++){ //TCByte = 0; //RCByte = myspi.Transmit(TCByte); //delay(500); //TCByte = 0XFF; //RCByte = myspi.Transmit(TCByte); //delay(500); //} } void LCD_Reset(uint8_t inter) //inter is for interface: 0 for SPI: 1 for RS232 { Comm(0b00110000,inter); delay(5); Comm(0b00110000,inter); delayMicroseconds(100); Comm(0b00110000,inter); Comm(0b00111000,inter); Comm(0b00001100,inter); Comm(0b00000001,inter); Comm(0b00000110,inter); } void Comm(uint8_t mval, uint8_t inter){ if (inter == 0){ spi_send(CR); spi_send(mval); } if (inter == 1){ Serial.write(CR); Serial.write(mval); } } void spi_init() { uint8_t x; SPCR = 0x53; x=SPSR; x=SPDR; } void spi_wait() { do { } while (!(SPSR & (1 << SPIF))); } uint8_t spi_send(uint8_t { uint8_t reply; SPDR=b; spi_wait(); reply = SPDR; delay(2);//very importent for the LCD board to process return reply; } uint8_t spi_trans(const char *str) { while (*str) spi_send(*str++); } [/code]
  3. I used this circuit to boost up the output of the arduino to 10V for the meanwell PWM dimming input.
  4. From the top. 20x4 LCD display using serial connection to the arduino. The on/off button is to switched on/off the LCD backlight. The 2 buttons below is to manual on the blue lights or the white lights.
  5. Fan is controlled using arduino to this solid state relay which can be triggered at 5V to 24V.
  6. Internal wirings... very messy...
  7. After a few weeks of coding, hardwiring, finally made my controller from scratch. My DIY controller is for 1) dimming the blues and the whites based on timinngs 2) moonlight based on days, towards the mid-month, would be the brightest 3) measure temperatures for my 2 LED heatsinks, if hit certain temperature that I think is too high, the LEDs intensity will be powered down less than 40% for abt 20 minutes to cool down. The overheat condition is to anticipate if the heatsink fans are not working, or ambient temperature is too high. 4)switching on/off the heatsink fans when the LED is siwtched on/off. 5)Added 2 buttons, white and blue, if pressed any one of them, let say blue button, will shut down the white LEDs and switch on the blues. Just for demo purposes.
  8. I think its about time for me to spray with the coating to keep them nice and dry. So far no issues with my LED lights without the coating, probably because they are well sealed.
  9. If leave more than a week, the dirt trap in the filter socks will cause the nitrate level to rise. Do change regularly. I have 4, and I rotate them every 2 to 3 weeks. At least 2 weeks to dry in the sun to let the chlorine bleach disappear.
  10. no need chiller also can. Just put fan and the tank temp not exceeding more than 31degC
  11. I'm selling this H&S skimmer due to upgrading. Skimmer & aquabee needlewheel pump are in good quality as always maintained. This skimmer is good up to 850 liters. More info on this skimmer Selling the whole set as you see in the pictures below. 1) H&S skimmer used as external or internal 2) Eheim feeder pump 3) Outlet tubes Selling the above between $350 to $380. I will not entertain lower than $350. New skimmer is more than $1k. After 4 days of skimming .... Consistant bubble size ... Quite a tall skimmer as compared to my son. Pls PM me for yuor interest. Self collect at Hougang.
  12. Bro, Any plans for auto dimming?
  13. been using for a few months and my sump getting cleaner.
  14. Just to check, for the driver ELN-60-48, how many 3W LED can you connect in series?
  15. This would be my next DIY project.
  16. Henry of Marine life is also selling. Good price as well.. Not sure if there is stock coz I saw 1 piece only.
×
×
  • Create New...