« October 2004 | Main | January 2005 »
November 14, 2004
DC Motor Lab: A Solar-Sensitive Window Blind Operator
At first, all I could think to create with DC motors was wheel driven robots. However, after I spent a long time building an H-Bridge, the idea occurred to build a system to control the blinds in my room.
In my room, I want the window opened during the day to let the sunlight in, and closed at night for privacy. The idea is, when the sun shines on a photocell outside the window, the PIC tells a DC motor to open the blinds. When becomes is dark outside, the contraption closes the blinds.
I did not get to far with the implementation--I still have no idea how the mechanics of opening/closeing the blinds would work. However, I built a working H-bridge and hooked it up to a motor. The motor comes from what I think is an old tape deck. I had a button that would reverse the current (taking the place of the photocell) and make the motor change direction.
H-Bridge and Motor w/ Gears:

Posted by rus200 at 08:21 PM
November 03, 2004
Midi Lab
I got the midi-out up and working. I overcame a problem with the code from the lab web-site, and I modified the picBasic random number generation to work with my application--a sequence generator.
------
I got the midi-out up and working. I ran into a problem in that the code from the lab did not work with my setup. This code:
DEFINE OSC 20
DEFINE HSER_RCSTA 90h ' enable the receive register
DEFINE HSER_TXSTA 20h ' enable the transmit register
DEFINE SER_BAUD 31250 ' set the baud rate
needed to be changed to:
'setup hardware serial port:
define HSER_RXSTA 90h
define HSER_TXSTA 20h
define HSER_BAUD 31250 'midi data rate
Once I got that working I thought of an application. In 20th-century music theory a la Schoenberg, a sequence of unique pitches can be used to create serial music. I thought I would create a device that could generate a 7-note sequence and, at the push of some buttons, play it in retrograde, inversion, and transpose it. However, due to time constraints I only got as far as generating a random 7-note sequence.
Overcoming lousy random number generation:
For my application, I had a button that triggered a function that put random numbers in a 7-element array. This array was then converted to pitch so a 7-note sequence would play. Pressing the button would produce a new sequence. However, the RANDOM function produces the same random number ever time the chip is turned on. Every time I turned on the chip I would get the same sequence. To overcome this, I enabled a counter that would increment with each iteration of main. I then added this counter to the newly generated random number. To convert this to a pitch I did modulo 12 on the random number. There is the possibility that the random variable with the addition of the counter could exceed the memory allocation of its data type. Does anyone know what happens when that occurs?
Here's the code.
Posted by rus200 at 01:00 PM