Light control / Sterownik Światła


R2=7kΩ when light is ON / gdy światło jest włączone

VCC=5V

Vain1=R2/(R1+R2)
Vain0=1,2V internal source / źródło wewnętrzne








R1____R2: 3kΩ____7kΩ____15kΩ
43kΩ ____0,3V____0,7V____2V
20kΩ ____0,6V____1,4V____2,2V

for /dla R2=43kΩ Uain1=(0,3V-2V) trip point below 7kΩ / przełączenie poniżej 7kΩ



/*
file:Attiny_wyl.c
MCU: Attiny2313
Date: 05.III.2010
rev: 00
Author: Przemysław Sitek

Used ports:
PORTB 1 AIN1
PORTD 6 RELAY

CHANGES:
05.III.2010 project start */

#include "avr\io.h"
#include "avr\interrupt.h"
#define F_CPU 8000000UL // 8 MHz
#include "util\delay.h"



//delay 30min
void delay30min(void) {
uint8_t i;
uint8_t j;
for(j=0;j<240;j++) { // x/4 min 120/4=30min
for(i=0;i<100;i++) { //15s
_delay_ms(10);
}
}
}

//delay 4s
void delay4s(void) {
uint8_t i;
for(i=0;i<33;i++) { //4s
_delay_ms(10);
}

}


// INTERRUPT for analog comparator vector
ISR(ANA_COMP_vect) {
if bit_is_clear(ACSR, ACO){
delay4s();
if bit_is_clear(ACSR, ACO){
PORTD|=(0x01<<6); // relay is OFF
delay4s();
}
}
else {
delay4s();
if bit_is_set(ACSR, ACO){
PORTD&=~(0x01<<6); // relay is ON
delay30min();
PORTD|=(0x01<<6); // relay is OFF
ACSR&=~(0x01<<5); // AC output 0
delay4s();
}
}
}

int main(void) {

DDRD|=(0x01<<6); // relay as OUTPUT
PORTD|=(0x01<<6); // relay is OFF
DDRB&=~(0x01); // AIN0 as INPUT
DDRB&=~(0x01<<1); // AIN1 as INPUT
PORTB&=~(0x01); // AIN0 no pull-up
PORTB&=~(0x01<<1); // AIN1 no pull-up

// ANALOG COMPARATOR settings
ACSR|=(0x01<<6)|(0x01<<3)|(0x01<<1); // raising egde
ACSR&=~(0x01<<7)&~(0x01<<2)&~(0x01);
// ENABLE INTERRUPTS
sei();


while(1) { // Infinite loop

}

}

CPU overheats / CPU się przegrzewa

First of all load kernel modules:
AMD Sempron/Athlon/MP ( K7 )
Socket Types: A, Slot A

sudo modprobe powernow-k7


AMD Duron/Sempron/Athlon/Opteron 64 ( K8 )
Socket Types: 754, 939, 940, S1 ( 638 ), AM2 ( 940 ), F ( 1207 )
sudo modprobe powernow-k8

Intel Core Duo
sudo modprobe speedstep-centrino

Intel Pentium M
sudo modprobe speedstep-centrino

Others (Unknown)
I'm not entirely sure which cpus are supported using this module. If your cpu doesn't work with one of the above methods try this one.
sudo modprobe acpi-cpufreq

Step 4: Scaling Modules
sudo modprobe cpufreq_conservative
sudo modprobe cpufreq_ondemand
sudo modprobe cpufreq_powersave
sudo modprobe cpufreq_stats
sudo modprobe cpufreq_userspace

And put them in /etc/modules
then install cpufreqd

apt-get install cpufreqd

Now check te output of
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
should bo like this:
powersave conservative ondemand performance

now edit /etc/cpufreqd.conf and restart cpufreqd ( /etc/init.d/cpufreqd reload )


For my single core Pentium M i looks like this:
# this is a comment
# see CPUFREQD.CONF(5) manpage for a complete reference
#
# Note: ondemand/conservative Profiles are disabled because
# they are not available on many platforms.
# In my case TZ1 is a CPU core temperature, if you use dual core
# you must change this file. I keeps temperature between 85-90oC
# when CPU usage is about 100%. test your configuration using
# stress --cpu 8 --vm 2 --vm-bytes 128M --timeout 600s
# to install stres use "apt-get install stress"
# and watch how temperature changes using "acpi -V"
# don't forget to reload cpufreqd

[General]
pidfile=/var/run/cpufreqd.pid
poll_interval=2
verbosity=4
#enable_remote=1
#remote_group=root
[/General]

[acpi]
acpid_socket=/var/run/acpid.socket
[/acpi]

[Profile]
name=Ondemand
minfreq=0%
maxfreq=100%
policy=ondemand
#exec_post=echo 8 > /proc/acpi/sony/brightness
[/Profile]

[Profile]
name=Performance High
minfreq=100%
maxfreq=100%
policy=performance
#exec_post=echo 8 > /proc/acpi/sony/brightness
[/Profile]

[Profile]
name=Performance Low
minfreq=80%
maxfreq=80%
policy=performance
[/Profile]

[Profile]
name=Powersave High
minfreq=60%
maxfreq=60%
policy=powersave
[/Profile]

[Profile]
name=Powersave Low
minfreq=40%
maxfreq=40%
policy=powersave
[/Profile]

[Rule]
name=AC Low temp
ac=on
cpu_interval=0-95 # (on/off)
acpi_temperature=TZ1:0-85
profile=Ondemand
[/Rule]

[Rule]
name=AC High temp
ac=on
cpu_interval=90-99 # (on/off)
acpi_temperature=TZ1:85-95
profile=Performance Low
[/Rule]

[Rule]
name=AC Extreme temp
ac=on
cpu_interval=99-100 # (on/off)
acpi_temperature=TZ1:95-103
profile=Powersave Low
[/Rule]

[Rule]
name=AC off
ac=off
cpu_interval=70-90 # (on/off)
profile=Powersave Low
[/Rule]




In this post I used informations from http://ubuntuforums.org/showthread.php?t=248867


CPU frequency scaling / Skalowanie częstotliwości procesora

The script below uses gnome-applets (to install them on debian/ubuntu use apt-get install gnome-applets). You also need to prepare your computer to use frequency scaling, if you use ubuntu follow instructions on http://ubuntuforums.org/showthread.php?t=248867 . Changing the script to suit your computer is a piece of cake :)
usage:
bash$ scaling 3

Poniższy skrypt używa gnome-applets (aby je zainstalować na debianie/ubuntu użyj apt-get install gnome-applets). Konieczne jest również przygotowanie systemu do skalowania częstotliwości, jeśli używasz ubuntu wykonaj instrukcje ze strony http://ubuntuforums.org/showthread.php?t=248867 . Dopasowanie skryptu do Twoich potrzeb to już kaszka z mleczkiem :)
sposób użycia:
bash$ scaling 8

#!/bin/bash
echo Possible frequences
echo Mozliwe czestotliwosci
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
echo Possible governors
echo Mozliwe tryby zarzadzajace
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors

# Part of script I use for my processor
# Values below are taken from
# /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies#
# and /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors


#
# Czesc skryptu przeznaczona dla mojego procesora
# wartosci wziete sa z
#/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies
#i /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
echo 1 1600000
echo 2 1333000
echo 3 1067000
echo 4 800000
echo 5 userspace
echo 6 powersave
echo 7 ondemand
echo 8 conservative
echo 9 performance


case $1 in
"1")command='cpufreq-selector -f 1600000' ;;
"2")command='cpufreq-selector -f 1333000' ;;
"3")command='cpufreq-selector -f 1067000' ;;
"4")command='cpufreq-selector -f 800000' ;;
"5")command='cpufreq-selector -g userspace' ;;
"6")command='cpufreq-selector -g powersave' ;;
"7")command='cpufreq-selector -g ondemand' ;;
"8")command='cpufreq-selector -g conservative' ;;
"9")command='cpufreq-selector -g performance' ;;
esac




# this command needs to be run by a superuser
# ta komenda musi byc wykonywana przez superuzytkownika
if [ ${#command} -ne 0 ] ; then
sudo $command
fi

Tvtime remote control / Pilot do Tvtime



It's a TCK/TK script I use to control tvtime on linux over ssh. As you probably know tck/tk is a script language with widget support (GUI). The script can be run using wish (simple windowing shell). You can download wish for any operating system (if you use debian/ubuntu try apt-get install tk8.4). Enjoy it DOWNLOAD :)

Przedstawiam skrypt napisany w TCK/TK, którego używam do zdalnego sterowania programu tvtime na linuxie przez ssh. Jak pewnie wiecie tck/tk jest językiem skryptowym z obsługą widgetów (GUI). Skrypt można uruchomić programem wish (simple windowing shell). Wish dostępny jest na wszystkie systemy operacyjne (jeśli używacie debiana/ubuntu możecie sciągnąć go poleceniem apt-get install tk8.4). Miłego używania ŚCIĄGNIJ :)

My first entry / Mój pierwszy wpis :)

This is my first blog and I hope it's going to last for a while. First of all I would like to say that almost everything I publish on this blog is on BSD license http://en.wikipedia.org/wiki/BSD_license, if it's not I will mention it in a title of blog entry. I know that things I write are not perfect, but they suit my needs, feel free to change them if you wish. If you like it - COMMENT IT, otherwise COMMENT IT :)
Przemo


To jest mój pierwszy blog i mam nadzieję, że przetrwa dłuższą chwilę. Na wstępnie chciałbym zaznaczyć, że prawie wszystko co jest opublikowane na tym blogu jest na licencji BSD http://pl.wikipedia.org/wiki/Licencja_BSD, jeśli nie, to zaznaczę to w tytule wpisu. Wiem, że rzeczy, które piszę nie są doskonałe, ale mi odpowiadają. Jeśli Ci się podoba - SKOMENTUJ, w przeciwnym razie SKOMENTUJ :)
Przemo