Saturday, March 25, 2006

Butterfly windmill

As is so often the case, the butterfly nature of my mind has led to me completely forgetting to continue work on any of my past projects, and I have, instead, been working on something completely different today - a power distribution system. Clearly if one needs to have such large items as a lighthouse lamp working, one needs a power source, and as of the current moment, it is powered by a windmill.

Windmill close-up

The windmill itself generates electrical power which is then transmitted to, and stored in, a battery of my own design. (All power connections are safely buried underground or otherwise well insulated, do not be concerned.) The lighthouse then takes energy from the battery whilst it is lit.

Windmills do not actually generate an awful lot of power, but I take advantage of the peculiar cycle of day and night in Second Life here. Astronomers have calculated that a day lasts for three hours, whereas night lasts for only one - thus the windmill has three times the length of the nighttime when it is not required to power the lamp, and can therefore charge the battery.

For any parties interested in how this particular arrangement is scripted, it is a fairly simple three-part arrangement of shouts and listens. Only one permanent active listen is required, in the battery itself, on channel -70809.

Generator objects such as the windmill send energy to the battery by shouting a positive number on this channel. The battery then adds a number of OEUs (Ordinal Energy Units) to its store. At the moment, it is limited in capacity to 100,000 OEUs - more than this is released as a harmless shower of particles, though I would not expect it to ever get there.

Battery in lighthouse

The windmill's script is more complicated as it also alters the speed of the rotation according to the current wind velocity, and produces different amounts of power depending again on wind velocity, but a simple example of this sort of object would be the Etheric Generator, a fairly simple device producing energy through ambient ether flow (unfortunately, not powerful enough to light the lamp).

Consumer objects such as the lamp request energy from the battery by shouting both a negative number and a randomised channel for a response, for example "-300,-2379845". They then start to listen on their randomised channel for the battery's reply, because the battery might not actually have enough energy to fulfil their request. The battery removes either the given number of OEUs from its store, or all of the remaining ones, whichever is less, and shouts back the number of OEUs provided.

Flare Bulb and Etheric Generator

Again, the lighthouse lamp itself is rather more complicated than is necessary to illustrate this point, seeing as how it must also rotate and check for sunset and sunrise, but I have constructed a simple and inefficient Flare Bulb which takes power and wastes it by merely spitting out particles.

At this point, you, the reader may or may not be curious as to the scripting of these things, and in case of the latter I here present:

- The Battery script
- The Etheric Generator script
- The Flare Bulb script

So relatively simple, but more interesting things could perhaps be done with these basic principles. Note how the Flare Bulb only requests power once per minute usually, for efficiency, but if it does not receive its maximum, it will request more power once that has run out. On the matter of efficiency, as long as we do not have dozens of these devices or ones running at high timers, there is only one open listen, and the system should have relatively little impact on sim performance I would judge.

- - -

What is the purpose of this, I hear the gentleman at the back ask? Yes, you, sir. You look to me like some sort of clerk or other man of business, possibly even an accountant. Where is your soul, sir? Do you have no appreciation of the joys of simple creative activity? Begone with you, and run through the park with no shoes on until you have re-united yourself with the pleasures of experience rather than commerce, or until you tread on a squirrel, at which point you may stop so as not to cause further harm.

10 Comments:

Anonymous Anonymous said...

Very nice article. I like the idea of 'real' power management in SL. It's always a good excercise of your programming skills to code something like you were in real world. :-)

I'm looking forward to your next articles!

3/25/2006 04:08:00 PM  
Anonymous Anonymous said...

What happens if you have 2 batteries? Do they get the same amount of charge and consumption at the same time?

3/26/2006 10:20:00 AM  
Blogger Ordinal Malaprop said...

Tsutomu: Thanks! I hope to develop this idea a bit. I'm sure we can do solar panels as well, to start with.

Dedric: At the moment, both batteries would receive charge given to them at the same time. They would also both provide power simultaneously to anything that asked, though because the response listen by a power consumer is cancelled after the first response is received, each consumer would only get one set of power. So they'd just mirror each other, a bit uselessly.

You can have entirely separate circuits as long as you use different channels for basic requests (not just -70809). One thing I was interested in would be a main circuit with a battery that, when it was exhausted, could ask for power from a backup battery on a different circuit.

Different circuits would also be used for long-distance power transmission I think, with one circuit shouting to another connected one. That would be a new "pylon" object, a bit like a battery but just relaying messages from one circuit to another rather than storing and providing energy.

Oh, one other thing I was thinking of was maximum power transmitted, or even better a resistance function of some sort, perhaps based on distance.

3/26/2006 11:14:00 AM  
Anonymous Anonymous said...

That's pretty cool. Be careful of code like this though:

llShout(-70809, "-" + (string)amount + "," + (string)channel);
gLId = llListen(channel, "", NULL_KEY, "");

Maybe it's not an issue with LSL, I don't know, but it looks like there is a race condition here. If the script is interrupted after the shout but before the listen then the battery might shout the response before the flare bulb gets a chance to establish the listen. That sort of thing can cause occasional random failures for no clear reason. If it's possible, maybe try reversing those two lines?

3/27/2006 04:32:00 PM  
Blogger Ordinal Malaprop said...

Good point, always better to listen first before asking for a response. I'll change that.

3/27/2006 04:44:00 PM  
Anonymous Anonymous said...

This is beautiful. It makes me want to post some of the scripts in my random creations.

Also, I have a very close friend who's been toying with the idea of electricity in Second Life. I'll be sure to point him this way.

3/28/2006 03:30:00 AM  
Anonymous Anonymous said...

I would be interested in working with someone willing to create a series of batteries that could be charged by the appropriate generators to power landing beacons atop my house.

3/28/2006 08:47:00 PM  
Anonymous Anonymous said...

I <3 this blog. :)

3/30/2006 09:03:00 PM  
Anonymous Anonymous said...

Oops, it switched to anonymous after I previewed.

I still <3 this blog tho. :)

3/30/2006 09:04:00 PM  
Anonymous Anonymous said...

My brain sparked off an idea. We can tell where the sun is in the sky. And we can determine what the cloud density is at any given point in the sky. Perhaps combine the two with some crazy maths to generate power with solar panels?

4/02/2006 09:22:00 PM  

Post a Comment

<< Home