initial push
This commit is contained in:
commit
7a65017460
1
eeprom_010618.hex
Normal file
1
eeprom_010618.hex
Normal file
@ -0,0 +1 @@
|
||||
<01><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
BIN
rgb led attiny13_label_reflow_Schaltplan.pdf
Executable file
BIN
rgb led attiny13_label_reflow_Schaltplan.pdf
Executable file
Binary file not shown.
246
rgb_led_vdo_attiny13_row_optimisation2.ino
Normal file
246
rgb_led_vdo_attiny13_row_optimisation2.ino
Normal file
@ -0,0 +1,246 @@
|
||||
#define EEPROM_DEBUG
|
||||
/*
|
||||
bug fix where Blinking RED would not change led_color back --> global/local definiton
|
||||
ToDo: Different PCB-Layout, sodass RGB LED beim Flashen nicht leuchten.
|
||||
Changelog:
|
||||
18.02.17:
|
||||
CHANGE: Add EEPROM_DEBUG defined block. Need to be compiled with -O3 Flag
|
||||
INFO: ledcolor==3 block is obsolete. Could be removed to save space
|
||||
23.06.17:
|
||||
CHANGE: comment out ledcolor==3 block
|
||||
reduce brighness to 100 for green and red
|
||||
INFO: MicroCore 1.0.2 creates very small binary, suspious
|
||||
25.05.18:
|
||||
CHANGE: reduce the used flash
|
||||
ADDED: max red temp per session
|
||||
FIXED: lowered red, green led intensity
|
||||
*/
|
||||
|
||||
// ATMEL ATTINY13_20 / ARDUINO
|
||||
//
|
||||
//Clock frequency: Default internal clock (9.6MHz / 8 = 1.2MHz)
|
||||
//BOD 4.3V
|
||||
//GCC -Os LTO enabled --> 746 Bytes
|
||||
//Global variables: 7 Bytes
|
||||
// avrdude -c usbasp -p attiny13
|
||||
// Fuse 0x6A 0xF9
|
||||
// Fuse 0x3F
|
||||
//
|
||||
//
|
||||
// +--------+
|
||||
// [ RST (PB5) |1* 8| (VCC) Power ]
|
||||
// [ Temp (PB3) |2 7| (PB2) RED ]
|
||||
// [ NC (PB4) |3 6| (PB1) GREEN ]
|
||||
// [ Ground (GND) |4 5| (PB0) BLUE ]
|
||||
// +--------+
|
||||
//
|
||||
//Fuse Settings
|
||||
//CKSEL1..0: 11 - 128kHz --> HVSP!!
|
||||
//SUT1..0 : 10 - 14CK+64ms
|
||||
//CKDIV8 : 0 - CLK divided by 8 -> 16kHz --> HVSP!!
|
||||
|
||||
|
||||
//PIN assignment
|
||||
const byte tempPin = 3; //this sets the temp pin
|
||||
const byte red = 2; //this sets the red led pin
|
||||
const byte green = 1; //this sets the green led pin
|
||||
const byte blue = 0; //this sets the blue led pin
|
||||
|
||||
/* NTC table and info
|
||||
5 volts / 1024 units or, .0049 volts (4.9 mV) per unit
|
||||
measurement takes place at the engine oil tank drain bolt
|
||||
|
||||
VDO Werte ***DEPRECATED**
|
||||
55 °C @ 2k Ohm == 0,587V (120EA)
|
||||
65 °C @ 2k Ohm == 0,423V (87EA)
|
||||
70 °C @ 2k Ohm == 0,361V (74EA)
|
||||
75 °C @ 2k Ohm == 0,309V (63EA)
|
||||
80 °C @ 2k Ohm == 0,265V (55EA)
|
||||
90 °C @ 2k Ohm == 0,195V (40EA)
|
||||
100 °C @ 2k Ohm == 0,150V (30EA)
|
||||
120 °C @ 2k Ohm == 0,089V (18EA)
|
||||
|
||||
|
||||
Koso linear NTC 10k @ 25 °C (guess)
|
||||
50 °C @ 2k Ohm == 3,41 V (696EA)
|
||||
55 °C @ 2k Ohm == 3,24 V (662EA)
|
||||
65 °C @ 2k Ohm == 2,88 V (589EA)
|
||||
70 °C @ 2k Ohm == 2,72 V (556EA)
|
||||
75 °C @ 2k Ohm == 2,54 V (518EA)
|
||||
80 °C @ 2k Ohm == 2,36 V (482EA)
|
||||
90 °C @ 2k Ohm == 2,06 V (420EA)
|
||||
100 °C @ 2k Ohm == 1,75 V (359EA)
|
||||
---------------------------------
|
||||
110 °C @ 2k Ohm == (300EA) (guess)
|
||||
Handbuch definiert Oeltemperatur zwischen 55 - 65 ° C.
|
||||
Hier wird der Bereich zwischen 50 und 90 °C als GRUEN definiert
|
||||
zwischen 100 und 110 °C als ROT definiert
|
||||
Ab 110 °C beginnt der Notfallmodus
|
||||
|
||||
http://www.xt-660.de/forum/viewtopic.php?p=173806#p173806 weitere XT660Z Werte
|
||||
Messwerte
|
||||
Bei rund 6-9 ° Aussentemperatur bleibt Die Anzeige auf blau
|
||||
Bei rund 10-15° Aussentemperatur springt die Anzeige zwischen kalt und warm. Lediglich Stadtverkehr bzw. Stand zeigt warm an. Ggf. untere Grenze herabsetzen
|
||||
bei rund 15-25° Aussentemperatur stabil. Hoechstwert 504EA ~ 78° ggf. obere Grenze nach unten verschieben.
|
||||
bei rund 27° Aussentemperatur im Stau rote Anzeige. Hoechstwert 379EA ~ 95°. vmtl kein Lüfter an
|
||||
|
||||
1.6.18: maximaler Wert bisher: 0x019D = 413EA
|
||||
*/
|
||||
|
||||
|
||||
#ifdef EEPROM_DEBUG
|
||||
//use EEPROM to sav maximum temperature
|
||||
#include <EEPROM.h>
|
||||
#endif
|
||||
|
||||
const unsigned int threshold_cold = 690; //threshold for color change from blue to green
|
||||
const unsigned int threshold_hot = 360; //threshold for color change from green to red
|
||||
const unsigned int threshold_emerg = 300; //threshold for color change from red to red blink
|
||||
|
||||
static byte ledcolor; //Memory for the current LED Color. TODO: Change assignment to something other
|
||||
static unsigned int temp_set; //Memory for the used temperature value
|
||||
|
||||
/*
|
||||
function to update and read unsigned integer into EEPROM
|
||||
*/
|
||||
#ifdef EEPROM_DEBUG
|
||||
unsigned int eepromReadInt(byte address) {
|
||||
unsigned int value = 0x0000;
|
||||
value = value | (EEPROM.read(address) << 8);
|
||||
value = value | EEPROM.read(address + 1);
|
||||
return value;
|
||||
}
|
||||
|
||||
void eepromUpdateInt(byte address, unsigned int value) {
|
||||
EEPROM.update(address, (value >> 8) & 0xFF );
|
||||
EEPROM.update(address + 1, value & 0xFF);
|
||||
}
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
//this sets the I/O pins
|
||||
pinMode(red, OUTPUT);
|
||||
pinMode(green, OUTPUT);
|
||||
pinMode(blue, OUTPUT);
|
||||
pinMode(tempPin, INPUT);
|
||||
|
||||
//LED initialize
|
||||
digitalWrite(blue, HIGH); delay(500);
|
||||
digitalWrite(blue, LOW); delay(100);
|
||||
digitalWrite(green, HIGH); delay(500);
|
||||
digitalWrite(green, LOW); delay(100);
|
||||
digitalWrite(red, HIGH); delay(500);
|
||||
digitalWrite(red, LOW); delay(100);
|
||||
|
||||
ledcolor = 0;
|
||||
//temp_set = 0;
|
||||
//temperature reference
|
||||
temp_set = analogRead(tempPin);
|
||||
//clean current red max value
|
||||
eepromUpdateInt(4, 0);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
unsigned int temp_curr; //Memory for the measured temperature value
|
||||
unsigned int diff; //Memory for the difference between measured and used temperature value
|
||||
unsigned int diff_sum; //Memory for aggregated difference
|
||||
|
||||
//clean for a new measurement row
|
||||
diff = 0;
|
||||
diff_sum = 0;
|
||||
|
||||
//logic part
|
||||
|
||||
//while the meaesured difference in a row is smaller than 5 (<1°C) units, do nothing. Avoids massive flickering
|
||||
//Change it to 10 units, if the steadyness is too low
|
||||
while (diff_sum <= 10) {
|
||||
//read current temperature
|
||||
temp_curr = analogRead(tempPin);
|
||||
//avoid abs() function. Get a positive difference
|
||||
if (temp_curr <= temp_set) {
|
||||
diff = temp_set - temp_curr;
|
||||
} else {
|
||||
diff = temp_curr - temp_set;
|
||||
}
|
||||
|
||||
//if emergency_mode is active and
|
||||
//otherwise it is not blinking
|
||||
if (ledcolor == 4) {
|
||||
digitalWrite(red, HIGH);
|
||||
/* Not needed
|
||||
digitalWrite(green, LOW);
|
||||
digitalWrite(blue, LOW);
|
||||
*/
|
||||
delay(500);
|
||||
digitalWrite(red, LOW);
|
||||
|
||||
}
|
||||
//Sum up the positive difference but use small steps
|
||||
diff_sum = (diff_sum + diff) >> 1;
|
||||
delay(500);
|
||||
}
|
||||
//overwrite the used temperature value with the measured value
|
||||
temp_set = temp_curr;
|
||||
|
||||
|
||||
#ifdef EEPROM_DEBUG
|
||||
//save max temp into first four bytes of EEPROM
|
||||
unsigned int val = eepromReadInt( 0 );
|
||||
if (temp_set < val) {
|
||||
eepromUpdateInt(0, temp_set);
|
||||
}
|
||||
#endif
|
||||
|
||||
//LED Color decicion.
|
||||
if (temp_curr >= threshold_cold ) {
|
||||
ledcolor = 2; //BLUE
|
||||
} else if (temp_curr < threshold_cold and temp_curr >= threshold_hot ) {
|
||||
ledcolor = 1; //GREEN
|
||||
} else if (temp_curr < threshold_hot and temp_curr >= threshold_emerg ) {
|
||||
ledcolor = 0; //RED
|
||||
} else if (temp_curr < threshold_emerg) {
|
||||
ledcolor = 4; //RED_BLINK
|
||||
} else {
|
||||
ledcolor = 3; //ERROR - Should not be reached
|
||||
}
|
||||
//LED power off to change state
|
||||
digitalWrite(red, LOW);
|
||||
digitalWrite(blue, LOW);
|
||||
digitalWrite(green, LOW);
|
||||
//set the output as ledcolor says
|
||||
switch (ledcolor) {
|
||||
case 0: //if ledcolor equals 0 then the led will turn RED
|
||||
analogWrite(red, 100);
|
||||
#ifdef EEPROM_DEBUG
|
||||
//save red temp into EEPROM
|
||||
val = eepromReadInt( 4 );
|
||||
if (temp_set < val) {
|
||||
eepromUpdateInt(4, temp_set);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case 1: //if ledcolor equals 1 then the led will turn GREEN
|
||||
analogWrite(green, 100);
|
||||
break;
|
||||
case 2: //if ledcolor equals 2 then the led will turn BLUE
|
||||
//digitalWrite(blue, HIGH);
|
||||
//keep blue less bright
|
||||
analogWrite(blue, 100);
|
||||
break;
|
||||
// case 3: //if ledcolor equals 3 then the led will turn WHITE (COMMENT -> OFF)
|
||||
// /*digitalWrite(red, LOW);
|
||||
// digitalWrite(green, LOW);
|
||||
// digitalWrite(blue, LOW);*/
|
||||
// analogWrite(red, 100);
|
||||
// analogWrite(green, 100);
|
||||
// analogWrite(blue, 100);
|
||||
// break;
|
||||
case 4: //if ledcolor equals 4 then the led will BLINK RED
|
||||
digitalWrite(red, HIGH);
|
||||
delay(500);
|
||||
digitalWrite(red, LOW);
|
||||
break;
|
||||
}
|
||||
delay(500);
|
||||
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
:1000000009C016C015C014C013C012C011C010C062
|
||||
:1000100065C00EC011241FBECFE9CDBF20E0A0E611
|
||||
:10002000B0E001C01D92A736B207E1F77CD05BC1FA
|
||||
:10003000E7CF87B18074836087B9369A3699FECF4F
|
||||
:1000400084B125B190E0922B0895EBE2F1E0319775
|
||||
:10005000F1F700C000000197C1F70895EF92FF92F9
|
||||
:100060001F93CF93DF931F92CDB7DD27162FE82E76
|
||||
:10007000F12CC701798323D16981681711F0C70179
|
||||
:1000800025D18FEFE81AF80AC70119D1181749F0DE
|
||||
:10009000612FC7010F90DF91CF911F91FF90EF90DB
|
||||
:1000A00015C10F90DF91CF911F91FF90EF900895B0
|
||||
:1000B0000F931F93CF93082F10E0C80100D1C82FD2
|
||||
:1000C000C8010196FCD02C2F30E0322F2227A90145
|
||||
:1000D000482BCA01CF911F910F9108951F920F9243
|
||||
:1000E0000FB60F9211248F939F93AF93BF9380917C
|
||||
:1000F000600090916100A0916200B0916300019650
|
||||
:10010000A11DB11D8093600090936100A0936200D7
|
||||
:10011000B0936300BF91AF919F918F910F900FBEED
|
||||
:100120000F901F90189583B7826083BF8FB583604F
|
||||
:100130008FBDF894A89580E481BD789417B886B1F6
|
||||
:10014000826886B9BA9AB99AB89ABB988FB58F77F0
|
||||
:100150008FBDC09A84EF91E078DF8FB58F778FBD28
|
||||
:10016000C09884E690E071DF8FB58F7D8FBDC19A16
|
||||
:1001700084EF91E06ADF8FB58F7D8FBDC19884E6F3
|
||||
:1001800090E063DFC29A84EF91E05FDFC29884E67B
|
||||
:1001900090E05BDF109264004CDF909366008093E8
|
||||
:1001A000650060E070E084E059DF94E0E92EBB2454
|
||||
:1001B000B39422E0A22E34E6F32EC12CD12C39DFE9
|
||||
:1001C000EC0180916500909166008C179D0720F0EE
|
||||
:1001D0008C010C1B1D0B03C08E01081B190B809199
|
||||
:1001E0006400843029F4C29A84EF91E02EDFC29833
|
||||
:1001F000C601800F911F6C01D694C79484EF91E0E3
|
||||
:1002000024DF2BE0C216D104D0F2D0936600C09355
|
||||
:10021000650080E04DDFC817D90718F4BE0180E003
|
||||
:100220001DDFC23B82E0D80718F0A092640012C024
|
||||
:10023000CE01885691408A34914018F4B0926400FF
|
||||
:1002400009C0CC52D140EC9718F41092640002C05F
|
||||
:10025000E0926400C2988FB58F778FBDC0988FB53C
|
||||
:100260008F7D8FBDC198809164008130D9F050F0AE
|
||||
:100270008230E9F08430F9F4C29A84EF91E0E5DE4F
|
||||
:10028000C29819C08FB580688FBDF6BE84E010DFBC
|
||||
:1002900060916500709166006817790760F484E0EA
|
||||
:1002A000DDDE09C08FB580628FBDF9BC04C08FB59B
|
||||
:1002B00080688FBDF6BE84EF91E0C7DE7ECFE19906
|
||||
:1002C000FECF8EBBE09A99278DB30895262FE19932
|
||||
:1002D000FECF1CBA8EBB2DBB0FB6F894E29AE19A02
|
||||
:0A02E0000FBE01960895F894FFCFB9
|
||||
:00000001FF
|
Loading…
Reference in New Issue
Block a user