Author Archives: Goran

Opet zima

Juče pao sneg. Nula stepeni. Danas tmurno, oblačno, sneg pomalo promiče, minus dva. Gledam zeku u rupi prekoputa, šćućurio se i ne mrda. Samo mu krzno svakog dana sve više beli.

New WP site

This is my temporary web site, intended to serve as a sand box for learning more about WordPress. It will evolve, grow, change, and very often – be broken.

I’ve been using / playing with WP since Mingus (v1.2). It was residing on different web servers that I was building and killing in my basement. Each of those servers had an installation or two of the WP. Although I can be considered as an experienced WP user, I was only that – just an user. Trying different plugins, themes, little bit adjusting some of the themes … Nothing seriously. No consistent posting, no big traffic, no big deal.

Now, although I don’t work in the web industry as a professional anymore (been there from the end of the ’90s – ’till around 2003), I can confidently say that I have necessary skills for more serious meddling with the WP. HTML, CSS, JavaScript, PHP, … everything is here, it’s just little bit rusty. Engine needs some oiling and TLC. That’s going to be purpose of this site.

PICAXE LCD Thermometer

Code and schematic for the LCD thermometer built with PICAXE 28X1.

Click on the schematic to get big picture, or click here for the pdf.

To copy the code, hover over the code and you’ll see four icons on top right. First icon opens new window with the code only, second icon copies the code to the clipboard, third icon prints the code (be careful with that, prints more than 5 pages, so don’t kill the trees).

; =================================================================
; author: Goran Poprzen
; filename: lcd-temp-0.7.bas
; target: picaxe28x1
; date: Jan 5, 2009
; version: 0.7
; description: Measures the temperature with DS18B20 temp. sensor
; and shows on the 2x16 char LCD display,
; also sends to the serial terminal, and
; checks against the limits and sets the output accordingly:
; high if temp. is lower then higher limit,
; low if temp. is higher then lower limit.
; Confusing, eh? Not really!
; =================================================================

; picaxe28x1 variables
; bit0-31, b0-27, w0-13

; variables used here:

symbol lcdchar = b4
symbol lcdtmp = b5
symbol counter = b6

symbol position = b7
symbol tenths = b8
symbol ones = b9

; 16-bit measured temperature
symbol temp12 = w5
symbol temp12lo = b10
symbol temp12hi = b11

; 16-bit lower temp. limit
symbol TL = w6
symbol TLlo = b12
symbol TLhi = b13

; 16-bit higher temp. limit
symbol TH = w7
symbol THlo = b14
symbol THhi = b15

; status of the output pin
symbol LED = bit0

; greetings message
eeprom 0,("GPtronics 2010Thermometer")

#rem
here is the table for
decimal part of the temp reading

0 / 16 = 0.0000 ==> 00
1 / 16 = 0.0625 ==> 06
2 / 16 = 0.1250 ==> 12
3 / 16 = 0.1875 ==> 19
4 / 16 = 0.2500 ==> 25
5 / 16 = 0.3125 ==> 31
6 / 16 = 0.3750 ==> 37
7 / 16 = 0.4375 ==> 44
8 / 16 = 0.5000 ==> 50
9 / 16 = 0.5625 ==> 56
10 / 16 = 0.6250 ==> 62
11 / 16 = 0.6875 ==> 69
12 / 16 = 0.7500 ==> 75
13 / 16 = 0.8125 ==> 81
14 / 16 = 0.8750 ==> 87
15 / 16 = 0.9375 ==> 94

#endrem
; two decimal digits rounding
; eeprom 32,("00061219253137445056626975818794")

; four decimal digits - not rounded
eeprom 32,("0000062512501875250031253750437550005625625068757500812587509375")

; =================================================================

main: ; executed at the beginning
gosub taketemp ; first measuring to determine initial status of the output relay
gosub init
gosub lcdinit ; initialization of the lcd display
gosub hello ; greeting message - just for fun :)

main2: ; loop
gosub taketemp ; temperature measuring
gosub checklimits ; checks measured temp. against limits and sets output accordingly
gosub sendtemp ; sends data to rs-232
gosub showtemp ; converts numbers and shows them on lcd

goto main2 ; loop again

; =================================================================

init:
counter = 0

TLhi = 22 ; lower temperature limit
TLlo = 0
THhi = 24 ; higher temperature limit
THlo = 0

if temp12 <= TH then : gosub ledon : else : gosub ledoff : endif

return

; =================================================================

lcdinit:
pins = 0
pause 200

pins = 48
gosub pulsing
gosub pulsing
gosub pulsing

pins = 32
gosub pulsing
gosub pulsing

pins = 128
gosub pulsing

lcdchar = 14
gosub wrins

lcdchar = 12
gosub wrins

return

pulsing:
pulsout 3,3
pause 10
return

; =================================================================

wrchr:
pins = lcdchar & 240
high 2
pulsout 3,1
lcdtmp = lcdchar * 16
pins = lcdtmp & 240
high 2
pulsout 3,1
return

wrins:
pins = lcdchar & 240
pulsout 3,1
lcdtmp = lcdchar *16
pins = lcdtmp & 240
pulsout 3,1
high 2
return

; =================================================================

hello:
lcdchar = 1
gosub wrins

lcdchar = 12
gosub wrins

for counter = 0 to 13
read counter, lcdchar
gosub wrchr
next counter

lcdchar = 192
gosub wrins

for counter = 14 to 24
read counter, lcdchar
gosub wrchr
next counter

pause 1000

lcdchar = 1
gosub wrins

return

; =================================================================

taketemp:
readtemp12 7, temp12
temp12 = temp12 * 16
temp12lo = temp12lo / 16
return

; =================================================================

sendtemp:
#rem
sertxd("Temp= ",#temp12hi," and ",#temp12lo,"/16 C",13,10)
sertxd("TH= ",#THhi," and ",#THlo,"/16 C",13,10)
sertxd("TL= ",#TLhi," and ",#TLlo,"/16 C",13,10)
return
#endrem
sertxd("Temp= ",#temp12,13,10)
sertxd("TH= ",#TH,13,10)
sertxd("TL= ",#TL,13,10)
return

; =================================================================

showtemp:
lcdchar = 2
gosub wrins

lcdchar = temp12hi / 100
if lcdchar = 0 then leadzero
lcdchar = lcdchar + 48
goto nonleadzero
leadzero:
lcdchar = lcdchar + 32
nonleadzero:
tenths = temp12hi // 100
gosub wrchr ; write 100s

lcdchar = tenths / 10
lcdchar = lcdchar + 48
ones = tenths // 10
gosub wrchr ; write 10s

lcdchar = ones
lcdchar = lcdchar + 48
gosub wrchr ; write 1s

lcdchar = "."
gosub wrchr

for counter = 0 to 3
position = temp12lo * 4 + 32 + counter
read position, lcdchar
gosub wrchr
next counter

lcdchar = 178
gosub wrchr

lcdchar = "C"
gosub wrchr

return

; =================================================================

checklimits:

if LED = 1 and temp12 > TH then gosub ledoff

if LED = 0 and temp12 < TL then gosub ledon

return

; =================================================================

ledoff:
low portc 1
LED = 0
return

ledon:
high portc 1
LED = 1
return

; =================================================================

[/sourcecode]

That’s it. In the next episode, I’ll break-up the code and try to explain each subroutine.

PC in a Mac’s case

As I said to my friend Andrew, we are going to end up on “The (Electronics) Antique (read: mostly junk) Road Show”. And we are proud of it. My recent find is a Mac G4, almost complete. Time for a new project. I’m not going to try and restore the Mac. No, most of the parts are going back to the same recycling bin, but case is … I’ve never seen that good PC case. Here are the pictures:

Mac in the basement

Mac in the basement

Open case

Open case

Mac with distant relatives

Mac and its distant relatives

On the last picture is the Mac with its distant relatives: Sinclair’s ZX Spectrum (anyone remembers it? 48kB RAM!!!) and Acer’s Aspire One running UNR 9.04. Anyway, as you can see from the second picture, there is PS, mobo, dvd drive, video card. There was no hard disk in it, and whoever took it out, he didn’t leave the HD mounting bracket. No worries, there is two more still left in the case.

That’s going to be my fall/winter project: PC in the Mac’s case, running Ubuntu 64bit, whatever version is going to be the most recent, probably 9.10. I wont finish it before the release date, that’s for sure.

Piece of an old PHP code

I was going through some old notes today. Found cute little piece of the php code. Here’s to try wordpress’ sourcecode tag:

$self = $_SERVER['SCRIPT_NAME'];

if (isset($_COOKIE['style'])) { 
  $stil = $_COOKIE['style']; 
} else { 
  $stil = 'default'; 
}

if (isset($_COOKIE['lang'])) { 
  $lang = $_COOKIE['lang']; 
} else { 
  $lang = 'en'; 
} 

if ($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['pazi'] == 'sad') {
  setcookie('style',$_POST['izbor'],time()+6000000,'/');
  Header("Location:$self"); 
} 

if ($_SERVER['REQUEST_METHOD'] == 'GET' && (isset($_GET['ln']))) { 
  setcookie('lang',$_GET['ln'],time()+6000000,'/'); 
  Header("Location:$self"); 
} 

Looks like it works, eh? How about some arduino code?

/*
Blink

Turns on an LED on for one second, then off for one second, repeatedly.

The circuit:
* LED connected from digital pin 13 to ground.

* Note: On most Arduino boards, there is already an LED on the board
connected to pin 13, so you don't need any extra components for this example.

Created 1 June 2005
By David Cuartielles

http://arduino.cc/en/Tutorial/Blink

based on an orginal by H. Barragan for the Wiring i/o board

*/

int ledPin = 13; // LED connected to digital pin 13

// The setup() method runs once, when the sketch starts

void setup() {
// initialize the digital pin as an output:
pinMode(ledPin, OUTPUT);
}

// the loop() method runs over and over again,
// as long as the Arduino has power

void loop()
{
digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // wait for a second
digitalWrite(ledPin, LOW); // set the LED off
delay(1000); // wait for a second
}

Drivel

Installed Drivel on my desktop – this is just a test.
Test – čćšđž ČĆŠĐŽ – test.
Тест – чћшђжљњџ ЧЋШЂЖЉЊЏ тест.

Bowness Park

Danas smo se jako lepo proveli u Bowness parku. Mama, Sanja, Jelena i ja. Pregazili smo reku na jednom mestu i bacali žabice u vodu, a na drugom mestu … e, o tome vam nećemo pričati jer je bilo jako smešno (nekom jeste, nekom nije, a na kraju nam je ipak svima bilo smešno).