- (MOSI/DI/SDA/!OC1A/PCINT8) PB0 MOSI,LED1 SENSE1+ PA0 (ADC0/DI/SDA/PCINT0)
+ATTiny 861A pin assignment
+==========================
+ (MOSI/DI/SDA/!OC1A/PCINT8) PB0 MOSI,LED4 SENSE1+ PA0 (ADC0/DI/SDA/PCINT0)
(MISO/DO/OC1A/PCINT9) PB1 MISO,PWM1 SENSE12- PA1 (ADC1/DO/PCINT1)
- (SCK/USCK/SCL/!OC1B/PCINT10) PB2 SCK,LED2 SENSE2+ PA2 (ADC2/INT1/USCK/SCL/PCINT2)
- (OC1B/PCINT11) PB3 PWM2 SW2 PA3 (AREF/PCINT3)
+ (SCK/USCK/SCL/!OC1B/PCINT10) PB2 SCK,LED5 SENSE2+ PA2 (ADC2/INT1/USCK/SCL/PCINT2)
+ (OC1B/PCINT11) PB3 PWM2 LED6 PA3 (AREF/PCINT3)
VCC AGND
GND AVCC
-(ADC7/!OC1D/CLKI/XTAL1/PCINT12) PB4 LED3 SENSE5 PA4 (ADC3/ICP0/PCINT4)
- (ADC8/OC1D/CLKO/XTAL2/PCINT13) PB5 PWM3 SENSE3+ PA5 (ADC4/AIN2/PCINT5)
- (ADC9/INT0/T0/PCINT14) PB6 SW1 SENSE34- PA6 (ADC5/AIN0/PCINT6)
- (ADC10/RESET/PCINT15) PB7 RST SENSE4+ PA7 (ADC6/AIN1/PCINT7)
-
-
-Lights:
-1 - front light
-2 - rear spotlight
-3 - rear LED strip
-
-PWM1
-PWM2
-PWM3
-SENSE1 - light 1
-SENSE2 - light 2
-SENSE3 - light 3
-SENSE4 - ambient light sensor
-SENSE5 - battery voltage sense
-SW1 - mode switch
+(ADC7/!OC1D/CLKI/XTAL1/PCINT12) PB4 SW2 LED7 PA4 (ADC3/ICP0/PCINT4)
+ (ADC8/OC1D/CLKO/XTAL2/PCINT13) PB5 PWM3 SENSE3 PA5 (ADC4/AIN2/PCINT5)
+ (ADC9/INT0/T0/PCINT14) PB6 SW1 SENSE4 PA6 (ADC5/AIN0/PCINT6)
+ (ADC10/RESET/PCINT15) PB7 RST SENSE5 PA7 (ADC6/AIN1/PCINT7)
+
+
+Components
+==========
+PWM1 LED1 rear spotlight: step-down, differential SENSE1
+PWM2 LED2 rear LED strip: step-up, differential SENSE2
+PWM3 LED3 front light: step-down, single-ended SENSE3, inverted stride
+
+SENSE4 - ambient light sensor, single-ended
+SENSE5 - battery voltage sensor, single-ended
+
+LED4 - status LED (green)
+LED5 - error LED (red)
+
+LED6 - speedometer illumination LED
+LED7 - front UV LED
+
+SW1 - on/off; mode switch
SW2 - temporary light boost or whatever
-LED1 - speedometer illumination LED
-LED2 - status LED
-
-
-ADC
-single-ended resolution:
-0.00107 V .. 1.1 V
-differential resolution 8x gain:
-0.00013 V .. 0.1375 V
-differential resolution 20 gain:
-0.000054 .. 0.055 V
-differential resolution 32x gain:
-0.000036 .. 0.03438 V
+
+
+ADC Gain
+========
+single-ended resolution: 0.001074 V .. 1.1000 V
+differential resolution 8x gain: 0.000134 V .. 0.1375 V
+differential resolution 20x gain: 0.000054 V .. 0.0550 V
+differential resolution 32x gain: 0.000036 V .. 0.0344 V
+
analog input resistance 100 MOhm
-LED current sense, 0.033R sensing resistor:
- min gain max gain
- 20 mA => 0.00066 V 8x
+
+PWM LED current sense
+=====================
+0.033R sensing resistor:
+ max gain min gain
+ 20 mA => 0.00066 V 8x
100 mA => 0.0033 V
150 mA => 0.0050 V
- 300 mA => 0.0099 V
- 350 mA => 0.0116 V
- 700 mA => 0.0231 V
- 1000 mA => 0.0330 V 32x
- 1500 mA => 0.0495 V 20x 0.0495 W
- 2000 mA => 0.0660 V 8x 0.066 W
- 3000 mA => 0.0990 V 8x 0.1 W
+ 300 mA => 0.0099 V Power burned at sensing resistor:
+ 350 mA => 0.0116 V 0.004 W
+ 700 mA => 0.0231 V 0.016 W
+ 1000 mA => 0.0330 V 32x 0.033 W
+ 1500 mA => 0.0495 V 20x 0.074 W
+ 2000 mA => 0.0660 V 8x 0.132 W
+ 3000 mA => 0.0990 V 8x 0.297 W
Battery sense
+=============
range 5-15 V
-1.5M..15k
-cca 10 uA @15V
- 3.3 uA @5V
-
-Ambient light sense
-20 lx -- cca 333 kOhm
-200 lx -- cca 35 kOhm
+1.5M..100k
-lx:
-1lx == full moon
-400 lx == sunset/sunrise
-10 klx == full daylight
+voltage current sense voltage
+15V: 9.3 uA 0.94 V
+12V: 7.5 uA 0.75 V
+ 5V: 3.1 uA 0.31 V
-need probably 1-1k lux scale
-
-Photodiode:
+Ambient light sensor
+====================
5 V, 1M5 resistor + photodiode: voltage at the photodiode
darkness: 3.71 V => 4.31 MOhm
bathroom without lights, only outside lights: 3.68 V => 4.18 MOhm
kitchen light: 3.29 V => 2.89 MOhm
bathroom halogen lights 0.02 V => 6 KOhm
battery light: 0.01 V => 3 KOhm
+
+Use 1M5 main resistor + 300K sensing resistor, 1.1V single-ended sense
+
+Expected voltage ADC readings
+darkness: 0.244 V 226.8
+bathroom: 0.249 V 231.8
+kitchen light: 0.318 V 296.2
+halogen light: 0.831 V 773.1
+battery light: 0.832 V 774.5
+
+Plain LEDs
+==========
+@5 V source
+20 mA/3V: 100 R resistor
+20 mA/2V: 150 R resistor
+ 2 mA/2V: 1K5 resistor
+
+Battery idle current
+====================
+2000 mAh: 1.0 mA -> 83 days capacity
+2000 mAh: 0.1 mA -> 833 days capacity
+