Journals

DiscoStu13 years ago2010-08-12 14:53:00 UTC 14 comments
The girl I nearly had something with just emailed me. She wanted me to know she "officially" has a girlfriend now.

Life just likes to tease me.
DiscoStu13 years ago2010-08-04 15:55:41 UTC 4 comments
Today I finally took the time to hit the drums hard. After about a year of barely having time to play at all, I actually made some loud noise for the first time since I moved in.

Besides recalling I truly need new ear plugs (I'm sure I lost some hearing today :P) I have found out that I also need headphones (rather than using the speakers across the room) as I could barely hear the music I was playing along with.

Before you judge, I'm a rather quiet player - hence I forced myself to play louder than usual, simplistic '60s-ish rocky music with room for a lot of fills and such adornations.

I had a pair of foam ear plugs but one day I took them off and they were all covered in ear wax so I washed them with warm water. But the foam never compressed again, and I have to go out and get me new ones.
DiscoStu13 years ago2010-07-05 16:24:08 UTC 6 comments
I had a dream last night in which I was Kevin Costner and I was sent back in time to 1997 with a time machine put together by a sound engineer. I was supposed to figure out why was I specifically thrown into 1997 and then find a way to return "home". I found myself bouncing between different years, solving ancient riddles (or even creating them in prehistoric ages for me to find and solve in a future year) and hiding my own instructions from the Nazis. But I couldn't figure it out because I woke up.

It's a shame, because it was very cinematic and I was thinking it would be an awesome movie.
DiscoStu13 years ago2010-07-04 21:00:09 UTC 8 comments
I made a tiny scratch on the (now almost) perfect body surface of my new camera, right on the card door. I can't stand it. I die a little inside every time things like this happen. I want to apologise to my beloved camera but its wound will be there forever, an eternal reminder that I'm never careful enough.

Why do these things happen to me? :(
DiscoStu13 years ago2010-06-15 02:23:57 UTC 13 comments
Screw it, I'll keep shooting cats - with this:
User posted image
User posted image
User posted image
Yep, it's about time I got me a decent camera. Now bad photos will be entirely my fault. Ironically, this would be the very first time my finger slips into the frame (see 1st pic).

Unfortunately I suspect it has a hot pixel. I'll test it some more, I'd hate to have to return it.
DiscoStu13 years ago2010-06-01 02:22:01 UTC 2 comments
I have to admit that, sometimes, I'm glad sites like this (and photographers like this) exist. They do an excellent job at making me look so very professional - both as a photographer and as web designer. And as proofreader.

I bet your eyes bleed by now. I don't even expect you to bother navigating to other areas of the site. Not even in a Peugeot factory you'll find this many 404s.

I can't bring myself to even call this a startup business. This is straight up a plain useless cheapskate trying to... do whatever. I can't even figure out what the fuck are the services provided by this "company". Bonus points to whoever finds out.
DiscoStu13 years ago2010-05-24 01:53:11 UTC 12 comments
GOD FUCK IT! LET THE DEVIL TAKE MY FUCKING MISERABLE LUCK TO HELL!

It's the 3rd confession of lesbianism I get in the past 12 months. Is this a joke or what? It's not like I'm a regular in those lesbian bars with no emergency exit Homer wound up in in one episode. Why me?

And this last one was a DECENT one. One that would have been well worth her weight in gold (looks aside :P). There are truly few like this one. But of course, I can't tell her that. Not even being bestfriends. It just makes me feel weird... :(

Oh well.

sigh
DiscoStu13 years ago2010-05-13 16:05:03 UTC 4 comments
The Perfect Clock: The code behind it

A few days ago, I posted the theoretical point of view of a perfect PIC clock. Today, I'll present you with a few code snippets. TWHL could really, really use [code] or [ pre ] tags, and I don't mean just for this.

*Remember to define variable names - i.e seconds equ 0x25

I'll start easy. This is the interrupt routine. There's nothing special in it.
;*******************
Interrupt:

	call	Clock_step
	bcf	INTCON, T0IF	;Clear interrupt flag to be able to return
	retfie
The above code is called on each timed interrupt - every 8.192ms. Now you need to make something useful of that. The following is only a 122-interrupt second, just to show context.

;*******************
Clock_step:
	incf	tick
	movfw	tick
	sublw	D'122'		;Count 122 cycles, add 1 second
	btfss	STATUS,Z
	goto	Clock_end

	clrf	tick		;I have 1 second, reset int counter.
	call	Seconds_inc	;Increment seconds counter
	movfw	seconds
	btfss	STATUS,Z	;On seconds=0, increment minutes
	goto	Clock_end

	call	Minutes_inc	;Increment minutes counter
	movfw	minutes
	btfss	STATUS,Z	;On minutes=0, increment hours
	goto	Clock_end

	call	Hours_inc	;Increment hours counter
	;--snip-- you get the idea.

Clock_end:
	return

;*******************
Seconds_inc:
	incf	seconds
	movfw	seconds
	sublw	D'60'
	btfsc	STATUS,Z
	clrf	seconds		;Reset on 60 seconds
	return

Minutes_inc:
	;--snip-- again, you get the idea.
Remember, this is only the imprecise clock, only to show the concept. Now you'll need to adjust for 122 and 123 cycles and all that shizzle I mentioned in the other journal.

To do this, I have allocated a tick_wait variable, to store whether my next cycle should be 122 or 123 interrupts long. I have also allocated adj_s to count 14-second cycles, and adj_c, to count 64 14-second cycles.

We must make a few changes to the code above.

;*******************
Clock_step:
	incf	tick
	movfw	tick
	[b]subwf	tick_wait,w[/b]	;Instead of 122, check against tick_wait
	btfss	STATUS,Z
	goto	Clock_end

	clrf	tick		;I have 1 second, reset int counter.
	[b]call	Tick_adj[/b]	;Check if next cycle counts 122 o 123

	call	Seconds_inc	;Increment seconds counter
	;--snip-- same as previous sample.

Clock_end:
	return
;*******************
Seconds_inc:
	;--snip-- same as previous sample.

;*******************
; NEW CODE BELOW
;*******************
Tick_adj:
	incf	adj_s
	movfw	adj_s
	sublw	D'14'
	btfss	STATUS,Z	;If 14, I'm done with 14s cycle
	goto	tick_adj2	;Otherwise, check if it's 13
	clrf	adj_s		;reset 14s cycle
	movlw	D'122'
	movwf	tick_wait
	goto	tick_adj_end

tick_adj2
	movfw	adj_s
	sublw	D'13'
	btfss	STATUS,Z	;If 13, it's adjust time
	goto	tick_adj_end	;if not 13 either, nothing to do

	incf	adj_c
	movfw	adj_c
	sublw	D'64'
	btfsc	STATUS,Z
	goto	tick_adj_end	;if this is the 64th adj cycle, ignore it

	incf	tick_wait	;14th second is next, lasts 123
	movfw	adj_c
	sublw	D'65'		;Check if 65
	btfsc	STATUS,Z
	clrf	adj_c		;If 65, reset count

tick_adj_end:
	return
As you can see, the code has grown quite a bit. But here we have our (theoretically) perfect clock.

I had to revise this code before posting, as the code I've written has functions to decrement seconds, minutes, and hours (so there's no need to wrap around incrementing if you missed 1 minute) as well as date keeping and alarm. What I posted here is only a fraction of it, but feel free to use this code in any clocks you intend to make.

By the way, since I still haven't built it, I'm not sure how to store years. Therefore I risk being subject to either the year 2256 bug (returns to 2000) or the year 2999 (returns to 2000 too). It could also be in 9999, but it'd be wishful thinking to expect it not to break before that :P

I hope you have found this an educational experience :)

Edit: Wow, [ pre ] works! Although only sometimes. WTF?
Edit2: I just found out why. Dude, at least let it respect tabs.
Edit3: No, I was wrong. It appears to be random. TWHL BACKEND NO WORKIE!
DiscoStu13 years ago2010-05-13 14:26:59 UTC 6 comments
I'm downloading Portal right now (thanks Huntey for the shoutbox post) Now, I have incoherent information displayed to me. The main window says "Downloading: 76%, 208.2 KB/s", but the taskbar icon tooltip says "Steam - downloading at 121.2 KB/s / Portal (77%)"

This would be the first time I'm using Steam for anything. Which one am I supposed to believe?
User posted image
DiscoStu13 years ago2010-05-10 10:52:02 UTC 5 comments
Just a general question to other Electronics fans (I asked Tetsu0 but I thought there might be someone else interested too)

What is your preferred method to make PCBs? I mean, after the breadboard phase, when you want the definitive PCB. I learned several methods while in school but they were inconvenient in one way or another.

The easy one is to draw the circuit straight on the board with a permanent marker, but this isn't so neat for complicated designs.

Then there was another method which required some expensive blue paper, then convincing someone at a press to print the circuit on it, then stick it to the blank board (copper side) and iron it. I hated this one.

The last one was to trace the design on vinyl with a cutting plotter, then sticking it to the board. I preferred this one, but I don't have a cutting plotter.

So anyway, what's your preference?
DiscoStu14 years ago2010-04-25 05:06:58 UTC 9 comments
The perfect clock: A theoretical approach

For those that showed interest in my previous journal.
Warning: Long post ahoy!

As I have commented in a previous journal, for several years already I wanted to make a digital clock with a PIC microcontroller and I never really got around to actually build it. Not because I didn't know how, just because I was lazy or didn't have the time. Last year at uni, while not paying attention to maths class (should have, but instead I did this) I spent my afternoons trying to at least think how the assembly code would be. I will later look up the code I've already written and include it here. This is what I have observed, and I hope others will find it useful.

Ever since I had to program one in school, one of the most elemental flaws in a simple clock design is error propagation - which might not matter when the clock is only a decorative item in projects that don't live more than a couple of minutes inside the lab, but is kind of an important issue if what you're making is a clock that will (hopefully) stay for years on that shelf in plain sight. And dammit you want it decently accurate.

Here I shall describe a simple setup that should run (at least) on either a PIC 16F84 or a PIC 16F877 (tested on those, should run on other 16F- models as well).

This microprocessor should be running on a 4MHz crystal oscillator, to achieve the simple number of 1MIPS (1Million instructions in 1 second). That's just mine, do your own calculations for other oscillator frequencies.

The basic design can't be simpler. First we need to enable timer-based hardware interrupts, by setting INTCON to 1X1XX000. Then the Prescaler has to be set to 1:128 by setting OPTION_REG to 00000110, to scale down those interrupts to a longer, more practical interval. This should leave us with an interrupt every 8192 oscillator cycles. Which at 1MHz last 1 microsecond each, so 8192 cycles should last us 8.192 milliseconds between interrupts.

Hardware-based timer interrupts are obviously periodical. If they are fired every 8.192ms, you count enough interrupts and you should be close enough to a full second, right? Not quite, because 8.192ms x 122 = 999.424ms. That's almost one second. Almost. If you just increment the seconds-count register after 122 interrupts, your clock will be 1 second ahead for every about 14 minutes. Doesn't sound so good now, eh?

Well, you could find out how many seconds does it take to be one full second ahead, and substract one second at that point. Fine, that would WORK. It's EASY. And it's the only solution I've ever found on the internet. But it's a horrible hack and it will look HORRIBLE if you happen to be looking at it at that time. But go ahead if you like, do that and stop reading here.

I'll keep going for those that want their seconds more uniformly spaced. What if we count 123 interrupts? Well, no. It turns out that we'd be off the other way: That's 1007.616ms. A larger error, with longer seconds - leading to the clock being 1 second behind every about 5 minutes of running. That's even worse.

So if we want our seconds more uniformly timed (and our clock not looking like it has a bug), we'll have to use a combination of 122 and 123 cycles. Now, counting 122 interrupts gets us 0.999424 seconds. If we add up enough of these "short" seconds, the leftover time should someday be enough that a "long" second (123 cycles) wouldn't be too noticed. It turns out that magic number is 13:

13 "short" seconds = 8.192ms x 122 interrupts x 13 = 12992.512ms = 12.992512 actual seconds

If at this point we make the next second a "long" second (of 1.007616 actual seconds), our 14 seconds will last exactly 14.000128 actual seconds. That's much better, we have actually trimmed the error to about a four-millionth. But it is still not good enough for me.

At this point we can repeat the above process. We have a cycle of 14.000128 seconds. We could check how many of these are needed to be able to easily substract the leftover error. Notice it happens to end in 128, which is a power of 2 and thus easier to add up. So if we count 64 of these 14000.128ms cycles, it adds up to 896008.192ms (that's a lot of seconds). If only we could trim those 8.192ms off the 64th cycle...

Wait a minute, don't the timer interrupts last 8.192ms? And remember that for every 13 "short" seconds, the 14th happened to be 8.192ms longer? I think we're lucky. Here, we make the first 63 14-second cycles "normal", and the 64th has to be purely 14 122-interrupt seconds. What does this mean? Well, this:

(8.192ms x 122i x 13 + 8.192ms x 123i) x 63 + 8.192ms x 122i x 14 = 896000ms
(Green="short" second, Red="Long" second)

Cue the sunshine, because what we have here, gentlemen, is 896 perfectly rounded seconds - or 14 minutes and 56 seconds.

Now we can rejoice watching others' sub-perfect, sloppy, whole-second-substracting clocks while enjoying our beautifully smooth clocks with perfect cycles of 14:56.

With this, we have successfully removed the software error in the time calculations, leaving only the time shift caused by (possible) manufactural imperfections in the oscillator crystal.

Now you take care of date-keeping and Daylight Savings Time.
DiscoStu14 years ago2010-04-17 18:12:56 UTC 9 comments
For years now I wanted to make a hand-made digital clock with a PIC microcontroller. I haven't even thought a design for the circuit board, and I only have half the software done (the non-hardware-specific part). I wrote most of that program (should I call it Operating System?) while in math class last year, when I was bored of all that crap. I even took the time to figure out how to compensate for the time offset created by a power of 2 oscillator - which, if left unattended, would add up to 1 second every 14 minutes (with a 4MHz crystal oscillator)... and that would make a pretty shitty clock.

I never even drawn a line representing hardware design yet. I know how I want most of it, but I'm thinking I'm too lazy to actually finish the job.

And I don't even know why I'm posting this. Does anyone care? :P
DiscoStu14 years ago2010-04-02 00:08:33 UTC 2 comments
No journals in 2 days? Alright, my turn.

My camera has been having the occasional malfunction lately so I've been looking into the acquisition of a new camera. Naturally, before simply going into a shopping spree and buy something stupid I'll regret later (it did happen before), I'm asking around for advise.

Now, the plan so far includes this camera, this lens, and possibly one of these flash units.

Anyone around here know enough to support or suggest against it? (yeah... I know it's a Half Life site and not a professional photography one, but you never know)
DiscoStu14 years ago2010-03-29 15:54:59 UTC 2 comments
Need help with PHP!

I have a page that displays images from a directory passed through GET. I use this code to find out if the requested directory has images:

$eventcode = trim($_GET['event'])

(snip)

$content = glob(strtolower($eventcode) . '/*.{jpg, JPG, jpeg, JPEG, png, PNG}', GLOB_BRACE);


However, I just found out that the glob instruction above returns false when all images have uppercase extension. Am I overlooking something?

Any insight will be greatly appreciated.
DiscoStu14 years ago2010-03-15 15:52:41 UTC 14 comments
The neverending curse

Don't you just love silence? Especially when it's time to sleep?

I've been deprived of good ole silence for years. In about 2002, the old bitch next door got herself a new dog. An apparently prize-winning German Shepherd. She got up every day at 6.30 in the morning and let the fucker go outside. Of course, since she never allowed it to have any contact with the outside world, the SOB would bark at absolutely anything from behind the fence: people passing by, cars, birds, garbage, hearing my voice from the other side of the dividing wall, or just because. This usually went on until lunch, and then let it back out until dinner. The only period of acceptable, continuous silence I could get was 22:00-6:45. And since my school had classes late, after having dinner and shit I could only go to bed after midnight. Then of course I wouldn't plan to get up before noon. This fucker ruined my sleep patterns.

And of course, if you tell the owner of such a dog anything, they just don't give a shit.

We moved to a new house last year. At last I would forget those fuckers. How wrong I was.

At the new house, it wasn't just one. It was two fucking barkers with no time restrictions. Area diagram below. The first one, labeled 1, is a large dog which I've never seen- it's outside my field of view. As soon as they let it out to the back yard, it started barking nonstop with its very loud voice. This could be at any time of the day, or any time of the night. After some time, we discovered this was especially bad at about 4 in the morning when certain cat passed by on a wall. Luckily, this one has been pretty silent the past month or two (knock on wood).

Then was the second one, labeled 3 (yeah wrong order). There was an old ancient, peaceful and silent balding yellow dog, until one day (not long after we moved in) they got him company: A young, small brown Boxer with a not too loud, worn out high voice -yet still terribly annoying. This one is random. We don't know its reasons, but it also barks continuously at... anything. Just because. It can bark for days without rest. Right now it's been yelling since yesterday, with only a pause between 2am and 6am. You can guess how I slept.

And finally, 3 or 4 months ago they finished a small housing building with 4 balconies facing back. People started moving in. Right there, at the last balcony, lives number 2: A German Shepherd. Sometimes it's not there, but when it is, it barks. Loudly. Very. Like the others, just because. Any time of the day or night. This morning this one teamed up with number 3 to fuck up my sleep once again. Both shut up at about noon.

Then also, this morning there was one replying to 2 and 3. Luckily, it's not a regular customer. But still joined them this morning to piss me off even more. It's somewhere in the orange area. I've never seen it. But I don't care about it, I believe I'll forget about it if the others shut up.
User posted image
Note: Not to scale. My bedroom is at the red spot. It's about 20 metres to number 3, and 25 or less to number 2.

I've already given up. Not even the police gives a shit, they don't come when I call them about this. Does anyone here know how to... ahem... "take care" of this issue? I'd have already shot them all but my father has a strict no-shooting policy (and this isn't Texas). I don't know what to do.

Edit: Wow, long post. Gotta stop doing that.

Update
An air rifle is the solution to subjects #2 and #3. No actual harm done. I should bill the owners for educating their stupid animals (something they should have done, just like I did with my own dog). It's like they want them to be annoyances.

I still don't know what to do with subject #1, although (knock on wood) it's been quieter lately. And whatever there is in the orange area, I think it's just replying to #2. Also since this morning I hear puppies from about that area. I think it's time to get grenades.