Re: the "become" instruction in orb language

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: the "become" instruction in orb language

Kohsuke Kawaguchi
Administrator
I hope you don't mind my posting this to [hidden email]. I'm
hoping to hook more people into electronics and I suspect posting like
this would help.


Arnaud Lacour wrote:
> kohsuke, I must admit I am not an electronics guru at all but I can't
> understand how you manage to gradually change the color of the LED when
> the PIC pins only output 0 or 1 ... that completely baffles me. would
> you mind shedding some light on this ?

This is a technique called pulse-width modulation [1].

The basic idea is simple. If you turn LED on and off fast enough, it
will look like partially lit to human eyes. Let's say, your on/off cycle
(AKA "duty cycle") is 100Hz --- so one cycle is 10ms. (That UBW runs in
20MHz or so, so 10ms is about 10000 clock cylces. You can very easily do
this)

If your LED is on 1ms and off 9ms, it will look fairly dim, but not
completely off. If it's on 2ms and off 8ms, it will look little more
bright. Now you get the idea. In my orb, I split the duty cycle in 256.

Note that human eyes generally react to logarithmic scale of luminosity,
  and AFAIK the way LEDs work often also make the luminosity curb
non-linear, so when you look at the LED, you don't really see a smooth
gradient in this scheme (IOW, going from 1/256->2/256 you see
significant difference, but not with 254/256->255/256)

With the way Hudson uses orb, this is not a problem, but in other
applications you'd have to design things to accommodate this.


> I can't get your agent working on my ubw so I'm painfully debugging
> stuff with some liberty basic programs I wrote and I'll move on to java
> when I'm confident with the rest. I already shorted the UBW twice on my
> breadboard and feared I had fried the chip but that little thing is
> quite fool proof.

Yes. It's better to build it piece by piece. And yes, UBW seems to be
fairly fool proof with all kinds of protection circuits built-in. You
can find more about that in the datasheet.

[1] http://en.wikipedia.org/wiki/Pulse_width_modulation
--
Kohsuke Kawaguchi
Sun Microsystems                   [hidden email]

smime.p7s (4K) Download Attachment