If I only had a Brain!

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
PHP:
start timer.
while( timer < timeout )
{
    //do anything you need to keep proj running
    //ie monitor sensors etc.
    if( timer + 10mins >= timeout )
    {
        StartAlarm();
    }
    if( timer + 9.5mins >= timeout )
    {
       StopAlarm();
    }
    if( motion detected )
    {
        reset timer;
    }
}
//shut down projector/lcd/bulb
wait 2 minutes
stop fans.

Something like that should work to enable the timer control for the projector.
it would sound the alarm for 30 seconds. you could get rid of that stop alarm and just make the alarm a single beep.

This seems like a really cool idea. Once i get my projector up and running id like to have some automatic fan control and shut-off features.


Luca Brazzi said:


Yeah... thats the one LUXURY us DIYers have over the commercial projector owners!

They would NEVER fall asleep with the PJ on with THAT expensive bulb burning!

HAHAHAHAHAHAHAAAAA!!!

Oh... BTW...

I need to take my time on this one... Ive got my Development Environment in place, however, I need to take some time to think about the algorithm for the timeout. It isnt as easy as it seems to get it right.
 
mattcosturos said:
PHP:
start timer.
while( timer < timeout )
{
    //do anything you need to keep proj running
    //ie monitor sensors etc.
    if( timer + 10mins >= timeout )
    {
        StartAlarm();
    }
    if( timer + 9.5mins >= timeout )
    {
       StopAlarm();
    }
    if( motion detected )
    {
        reset timer;
    }
}
//shut down projector/lcd/bulb
wait 2 minutes
stop fans.

Something like that should work to enable the timer control for the projector.
it would sound the alarm for 30 seconds. you could get rid of that stop alarm and just make the alarm a single beep.

This seems like a really cool idea. Once i get my projector up and running id like to have some automatic fan control and shut-off features.




The thing is... its actually a little more complicated than first meets the eye, because the system needs to react to human behaviour.

For example:

When I 1st turn on my projector, its usually because Im planning to watch a movie, or surf the web, or watch TV. Lets say Im planning to watch a movie.... Well... most movies are about 2 hours long... right?

Now... As far as the projector is concerned

Lets say that I told the "brain" to wait 1 hour 50 mins before checking to see if there is any motion, and if it didnt see any motion in the last 10 mins... shut down.

I think thats a better algorithm than telling the "brain" if you see any motion reset the counter to 0 because heck... It might sense motion 1 hour into the movie, then reset the counter to 0, then... it would be another 2 hours before it would alarm!

THEN...

Youve got to think about what happens... if after the first 1:50, it detects motion... should it reset to another 2 hours? OR... should the timeout time decay so that after the initial 2 hours, the time out gets shorter?

Then there is the whole... Watching TV vs Watching movies thing... people exhibit completely different behaviours when doing these 2 activities.

I think Ive settled on a timeout algorithm though... Im just waiting on some parts so I can start building.
 
scanboy said:
Luca Brazzi,

it's off your topic in this thread, but do you mind sharing the model # and your placement, in reference to you lamp's arc, of your IKEA Napkin Ring reflector?
Thanks


All I know is that it is an IKEA SOARE Knapkin ring, and it is spherical. The distance of the lamp from the reflector is approximately the radius. I built my light engine adjustable so that I can move the bulb closer/farther away from it easily... Im still experimenting with the position to find out what works best (no hotspots)
 
Hmmmm, I didn't realize how complicated you wanted to make the logic.

The way you describe it, its almost like you just want to use a timer, to pick how long it will stay on.
I have an air conditioner with 2 knobs. One with hour markings, and a manual setting. the other knob chooses between delay on, and delay off.
So you can set the knob to 8hrs then choose delay off, and the ac will run for 8 hrs. You can use the delay on to turn the ac on at a preset time. just pick how long you want to wait, then choose delay on. And the manual setting lets you just blast the ac all the time.

A similar setup would let someone pick how long they want to run their projector, and of course you can change the time on the know any time if you need more or less time.... however using the manual setting would bring you back to the current problem.


Luca Brazzi said:



The thing is... its actually a little more complicated than first meets the eye, because the system needs to react to human behaviour.

For example:

When I 1st turn on my projector, its usually because Im planning to watch a movie, or surf the web, or watch TV. Lets say Im planning to watch a movie.... Well... most movies are about 2 hours long... right?

Now... As far as the projector is concerned

Lets say that I told the "brain" to wait 1 hour 50 mins before checking to see if there is any motion, and if it didnt see any motion in the last 10 mins... shut down.

I think thats a better algorithm than telling the "brain" if you see any motion reset the counter to 0 because heck... It might sense motion 1 hour into the movie, then reset the counter to 0, then... it would be another 2 hours before it would alarm!

THEN...

Youve got to think about what happens... if after the first 1:50, it detects motion... should it reset to another 2 hours? OR... should the timeout time decay so that after the initial 2 hours, the time out gets shorter?

Then there is the whole... Watching TV vs Watching movies thing... people exhibit completely different behaviours when doing these 2 activities.

I think Ive settled on a timeout algorithm though... Im just waiting on some parts so I can start building.
 
mattcosturos said:
Hmmmm, I didn't realize how complicated you wanted to make the logic.

The way you describe it, its almost like you just want to use a timer, to pick how long it will stay on.
I have an air conditioner with 2 knobs. One with hour markings, and a manual setting. the other knob chooses between delay on, and delay off.
So you can set the knob to 8hrs then choose delay off, and the ac will run for 8 hrs. You can use the delay on to turn the ac on at a preset time. just pick how long you want to wait, then choose delay on. And the manual setting lets you just blast the ac all the time.

A similar setup would let someone pick how long they want to run their projector, and of course you can change the time on the know any time if you need more or less time.... however using the manual setting would bring you back to the current problem.




What I want is to have projector basically ask me (the viewer) every so often "Are you still watching me?" If it doesnt get a "Yes" answer it shutsdown.

There are several different ways I could program this.

Method 1: When the projector is 1st turned on it will wait X hours before it looks for motion, no amount of motion in the room before that 1st X hours is up will cause the timer to reset. If it detects motion after X hours, the timer resets to 0 and it will wait another X hours before looking for motion again.

Method 2: When the projector is 1st turned on, it constantly looks for motion, every time it detects motion, the timer is reset, if it detects no motion in X hours it shuts down.

Method 3: Similar to Method 1 except the timeout gets shorter after the 1st timeout period has elapsed.

Method 4: Simple timer, no matter what the Projector shuts off after X hours

And there are others, each with advantages and disadvantages....

Ill probably program several different methods, and try them all out...

I think Ill end up liking Method 2 in real world usage... Methods (1&3) only look for motion in a specific "Window" of time, and only during that "Window" can the timer be reset. What if Im on the can during that window? Or popping popcorn? Ill be upset if I return 5 minutes later to a shutdown projector :mad: . Using method 2, when I got up to go to the bathroom/etc, my motion would have reset the timer no matter where the brain was in the count down. I wont have any problems unless I spend X hours in the bathroom. :D Method 4 doesnt take into consideration the fact that people dont always know how long they will be watching TV... I may watch a movie, then turn on the TV and watch a game, I wouldnt want to have to try to calculate beforehand how long I estimate my viewing time to be so I can tell the projector how long to stay on...
 
First of all, reading this thread, I’ve got the impression that you all forgot that the heart of most of our pj’s is an LCD PC monitor or TV. And when the video signal is cut off a modern display shuts itself down. It’ just a matter of (for lack of better words) linking the display, witch will act as a controller, to the bulb and the cooler. The PIC based circuit will only act as an interface between them.
I’m only saying this because I find the motion sensor solution unreliable and unpractical because of different human behaviors.
The basic idea is that I fall asleep, the sensor doesn’t detect motion and shuts off the pj. But let’s say that I have a very agitated sleep or even worst, I’m sleep walking :) – what then? I’m not even considering the eventual pets; I have 2 cats (and they sleep 20 hours / day) so no worries, but a German-shepherd will keep the pj running for weeks :).

Enough criticism. First I would like to split the common setups in 2 categories:
A) video input source – PC/Mac (highly customizable source) vs. external TV tuner/ game console/ stand alone DVD player (little or no customizable).
B) display construction – internal power source vs. external transformer.
OK, bear with me, even it’s not clear now, I do have a point :).

IMO, the microcontroller shod do the following:
- keep the fan running for an amount of time (or until a desired internal temperature is reached) after the projector is turned off
- keep the light source on for a very short period of time after the pj’s LCD is turned off. This will force the pj to stay on in case the computer restarts (applicable only if a PC/Mac is used as a video input signal)
- monitor the LCD temperature and adjust the fan speed accordingly. In case a critical temperature is reached and the fan is at max speed, turn off the pj.
- monitor the temperature close to the light source (see first point)
- have a basic diagnostic tool – 3 led, yellow –stand by, green – power on, red – cooling off/ bulb re-strike time. I don’t see the need of an LCD, as will further complicate the design.

So, for the lucky ones with a PC as video source and a pj build around a display with internal PS things couldn’t be easier. A PC ‘knows’ how to turn on and off the display on demand, at a certain hour, after a period of inactivity and much more, all of this by just pressing a few predefined keys. This makes a remote for the pj useless.
OK, the computer can control the display. The display’s internal power source is similar to a computer one. When the monitor is off the ps supplies only a 5V stand-by current, but when the display is switched on, the 12V (and other rails) kick in powering the LCD. This rail could power a relay or a couple of them for the pj’s light source and fan. The microcontroller’s main jobs (other then monitoring the temperature) will be to keep the fan spinning for an amount of time after the projector is turned off and to keep the light source on in case the pc restarts (at restart the pc turns off the display for a couple of seconds and this can shot down the projector).

If the display has an external transformer things can become a bit complicated. If the inverter is separated from the controller board, the relay can be powered from there (there are 2 12V rails). With an all on board design (typical for small displays) there's the need to find a point on the board that has 12V when on and 0V when off. A bit hard but doable.

Now for DVD players as video source. A DVD unit can’t turn off a display, actually it has no idea that is connected to one. But DVD players have an “auto power off” function. When the DVD cuts the video signal, the monitor, after displaying the “no signal” warning will enter in stand-by mode and through the PIC will shot down the projector.
Same thing applies for external TV tuners, as far as the game console I can’t figure a way to fall asleep while playing a video game :).

So in the end there is no need even for a timer because it's already integrated in the signal source.
 
Hmmm, you have some good ideas there.
I think we could even get away without using a PIC at all, (if you dont mind wiring up some relays and a timer).

First off, use the +12v rail to control a relay.
This relay will turn the bulb on and off.
If we want to run the bulb for a preset time after the display turns off a timer could be added. This makes the circuit a little more complicated but not that much.
Second, we could use a thermostat to control the fans. Provide the fans with +12v all the time from a dedicated AC/DC converter, and turn them on when a certian temp is reached.
Ill mull this over at work tomorrow and post some more ideas.
 
mattcosturos said:
Hmmm, you have some good ideas there.
I think we could even get away without using a PIC at all, (if you dont mind wiring up some relays and a timer).

First off, use the +12v rail to control a relay.
This relay will turn the bulb on and off.
If we want to run the bulb for a preset time after the display turns off a timer could be added. This makes the circuit a little more complicated but not that much.
Second, we could use a thermostat to control the fans. Provide the fans with +12v all the time from a dedicated AC/DC converter, and turn them on when a certian temp is reached.
Ill mull this over at work tomorrow and post some more ideas.

True... many functions can be done without the use of a Microcontroller (a stand alone timer here, a thermostat there) However once you start down the path of using individual circuits to perform control functions, you 1) Complicate the required circuitry enormously, and 2) May be headed for a dead end (a situation that cant be handled with your current individual circuits design) at this point you WILL say, "Maybe I should use a Microcontroller to do all of this". Its very hard to reprogram hardwired behaviours.

With a Microcontroller based design, as you think of new functionality to implement, it becomes a matter of reprogramming the Controller, and adding a few external interface components.

The other thing that a microcontroller based design will allow is it can provide "Flexible" logic... What do I mean? Well... Currently I have a 15" Projector using a 250 watt HQI bulb and 4 fans... there are many factors which govern the dynamics of my system which can change on the next projector. Lets say my next projector is a 15.4" Proview with a 400 watt bulb and 6 fans? I want the control system to be able to "Flex" easily to accomodate the new projector design (Heat dynamics/etc) If I design a system that uses stricly dedicated circuits, when I build the next projector I may have to start at square one again instead of just changing a few input parameters to the controller.


The basic idea is that I fall asleep, the sensor doesn’t detect motion and shuts off the pj. But let’s say that I have a very agitated sleep or even worst, I’m sleep walking – what then? I’m not even considering the eventual pets

Unless you either A) Flail your arms/legs wildly while you sleep, or B) Sleep walk in the same spot/room back and forth in front of the motion detector, you shouldnt have a problem. As far as the pets go... there are Pet Sensitive Motion detectors on the market.

The other thing your comments bring up is yet another feature that should be implemented which is: A Maximum Projector On Time no matter what motion is detected. This way even if you DO sleepwalk back and forth (or your pets move around) in front of the motion detector all night... the Brain will shut down the projector after X hours no matter if you dont at some point physcially interact with the control system (pushing a button/etc). For example if you dont push the Max On Time Reset Button within 6 hours of turning on the projector, the brain will shut the projector down no matter what the motion detector detects. With this feature, the Motion detector system just becomes a way to shut the projector down SOONER than the Max On Time.

An example would be what happened to me today... I had my PJ on, and decided to go to the store. I completely forgot I left the projector on. What would have happened if something would have happened to me while I was out and I couldnt get back to shut the thing off? With the motion system it would shut down after lets say 3 hours with no motion. If my dogs were wandering around in front of the motion detector while I was gone... the projector would shut down after 6 hours no matter what (unless the dogs figure out a way to push the Max Time Out reset button on the projector) :D

I like your idea about using the PC video signal as a Power controller though... :D pretty slick... Write some code on the PC to remove the Video signal, then attach some logic to the LCD to detect when the Video signal is gone, attach a timer for the fans and...Voila.

IMHO though... the only issue with your design is that sometimes computers need to be rebooted, and sometimes they crash/blue screen/etc and some computers boot slower/faster than others. PC's in general are not really good at being reliable controllers because of their complexity. Microcontrollers on the other hand are very simple internally.

Implementing the Max Time On timeout plus the Motion Timeout means I would need several different indicators. Maybe I could just use a beep... and if the Motion timeout is getting ready to expire, it beeps one way, and if the Max Timeout is getting ready to expire it beeps another way. This would alert you as to what you needed to do (Wave an arm to trigger the motion sensor vs push the Max Time On reset button)
 
As usual, things start off simple and get more complicated as you hash out the details...

To allow the controller to control the AC power to the Ballast, I am planning to put a solid state relay in line with the ballast AC power.

This means that the controller will have to be responsible for turning the lamp on as well as turning it off. The problem is... how will the controller determine if the lamp has properly started? Im planning to get around this by using a photo resistor or some other light sensor to see if any light is coming from the lamp. So basically the way things will work is: When the projector is plugged in, the controller is energized and starts running, when the power button (controller input) is pressed, the controller enters "Projector Boot Mode" where it will attempt to start the lamp by energizing the ballast, and checking to see if it sees any light. If it sees light then it enters "Projector Running" mode... if it doesnt see any light it waits for a few seconds then tries again. It will stay in "Projector Boot Mode" until it can either start the lamp, or 10 minutes elapse when it will give up trying to start the PJ, and shutdown.

Then there is the fan issue... If the controller is controlling the lamp power, I may as well add the fan power control as well.... I was planning on doing this later...sigh...
 
Time for an update...

I got some time to work on the P-Brain...

Almost everything is in place to build this thing...

I decided to use a PIC16F876 as the controller because it has lots of IO pins.

So far this is the configuration...

PIC16F876 running at 20Mhz
120v Solid State Relay for ballast power control
Photoresistor for light detection
On/Off pushbutton
On/Off LED indicator
DS1302 realtime clock
DS1620 temp sensor
Alarm buzzer
Wired Motion detector (I took this off of my home alarm system)
IRF510 Mosfets for Fan speed control (Im going to use PWM to control the fan speed). Im planning to have 4 independently controllable fan circuits

I still need to incorporate a serial EEPROM for data storage.
I still need to incorporate a way to detect fan failure.

:smash:
 
Ok... looks like Im only going to be able to do 2 independent fan control circuits with 1 controller... the PIC16F876 only has 2 hardware PWM generators that run independently in the background without need for software generated PWM signals.... Oh well... I guess I could add another controller to generate the PWM signals for the other 2 fan circuits then send the duty cycle for each fan to it serially....

Maybe next version.
 
Ok Time for an update.

I had quite a bit of time to work on this project this past weekend, and I now have a working prototype in my development environment. I need to assemble everything onto a circuit board, and try it out in the projector.

I decided not to use the Hardware PWM on the controller for fan speed at this time, I may use it later on (in the next release)

The software was pretty easy to write, although a bit more complex than just waiting for a timer to expire/etc.


Basically in the 1st release the P-Brain has 5 states:

Unpowered - No power applied to the controller (unplugged)
Shutdown - Power applied, but in an off state
Booting - Powered on, and booting the projector
Running - Normal running mode
Shutting Down - Powering down the projector

The software moves through these various states depending upon inputs like the power button/motion detector/etc.


From the unpowered state, the only possibility is to transition to the shutdown state. In this state the brain waits for the power button to be pressed. If it detects a power button press, it transitions to the Booting state where it attempts to boot the projector. If the boot is successful, the controller enters the running state, where it begins to look for motion/etc. If the power button is pressed while in the running state, the controller enters the shuttingdown state, and shutsdown the projector, then enters the shutdown state.

Im setting the initial motion detection timeout to be 3 hours, so if the controller doesnt see any motion for 3 hours, it will shutdown. A warning beep sounds for 2 minutes before the shutdown will occur.

Im setting the initial Max Projector On Time to 6 hours... this means that no matter what, the projector will shutdown after 6 hours, unless someone physically hits the power button to make it stay alive... (Im thinking of incorporating a keep alive button instead of multiplexing this functionality on the power button)

During projector boot, the controller will start the fans, then waits for motion to be seen from the motion detector (motion detector test), once it detects that the motiondetector is working... it then energizes the lamp ballast using a 120v solidstate relay. It then uses a photoresistor to look for light coming from the projector lamp. If it sees light, it enters the running mode, if it doesnt see light, it goes Idle for a while, then tries to spark the lamp again. If it cant get the lamp lit within a specified timeout period (Lamp still too hot to spark/etc), it gives up, and shutsdown.

During shuttingdown mode, the controller turns off the lamp, and lets the fans continue to run for 40 seconds.

Maybe next weekend Ill be able to do my first "In Projector" tests, but so far all is working great in my development environment. :smash:
 
Sounds great Luca! Can't wait to try this out for myself. One thing though: do you think 40 sec is enough for the fans to be left on for? I know that at least on my friends rear PJ tv the fans run for at least a minute, maybe two (I'll double check on that).
 
Good question...

I arbitrarily picked 40 seconds. I think once its actually in the projector, and I can do real world tests Ill pick a real value. The aim is to cool the bulb off as fast as possible, so that It will start up again quickly if need be.

This first version will be pretty basic, just the main power control functions (Lamp/Fan/Motion Detector). I want to eliminate the jitters I get everytime I turn on my projector due to the fact that I may forget its on... fall asleep... leave the house... etc. In the next version I plan to add more sophistication... (Temp sensing, fan speed control, bulb life counter, etc) It would be cool to be able to lower the fan speed and only raise it if things get too hot...
 
muxing with keypress period

One thing you do have to take into account: You can't change states because of the number of times a button is pressed, since one "human press" may be seen by the microprocessor as hundreds. (As the contact is being made or broken.) So you have to debounce the button-press by requiring the input signal to remain in the pressed state for say 100 milliseconds. As long as you are doing that, why not also check for a much longer button-press? Then you can use a 100-2000 msec button-press for on/reset timeout, and a 2000+ msec button-press to begin the shutdown sequence.

The user would hold down the "on/off" button until the light went off, so he would have instant feedback that he pressed the button long enough.
 
Debouncing is built into the button press logic. The software will only detect one button press per button press.... even if the user holds down the button, or the button bounces.


The only problem I face is interpreting a button press within the context of the current state of the controller.

For example:

In the shutdown state.... the button press signifies: Enter the Booting State.

In the Booting state... the button press is ignored.

In the Running state... the button press signifies: Enter the Shutting Down state (start shutting the projector down)

In the Shutting down state... the button press is ignored.

I have realized though... that I need more states! For example... there is a Running Near Shutdown Because of No Motion Detected State... and a Running Near Shutdown Because of Max Time On Reached State.... I also need to determine what the button press means in each of these states.


In otherwords... if the projector is getting ready to shutdown because it hasnt detected any motion for 2 hours and 55 minutes... and you press the POWER button, that should reset the Motion Counter.

AND

If the projector is getting ready to shutdown because it is nearing the Max Time On Timeout... and you press the power button, that should reset the Max Time On Counter AND the Motion Counter.

HOWEVER

If the controller is just in the Normal Running mode... and you press the Power Button... the projector should shut down.
 
human factor issues

I think you are making the user interface too complex: In some states, pushing the button means "shut down". In other states it means "extend running time". So the user would have to know which state the projector was in before deciding to push the button. He would also have to remember what the button press does in that state. Another thing to think about: What if you need to visit the kitchen or bathroom near the end of the timeout period, but you want it to keep running? You would have to stand there and wait for it to change to the "timing out soon" state before you could push the button!

This is why I suggested one type of button press should always mean "shut down", and another type of button press should always mean "extend running time". You can implement that with two buttons, or one button using the button-down time.
 
Well when the controller is nearing a shutdown due to lack of motion detected (5 minutes before shutdown), it beeps 2 times in succession (beep beep.... beep beep... beep beep) it does this for the remaining 5 minutes of the timeout. When the projector is nearing shutdown due to Max Time On limit reached, it beeps 3 times in succession during the last 5 minutes of the count down. So all the user needs to remember is (2 beeps wave an arm to trigger the motion detector... 3 beeps, get up and hit the power button).

Everytime motion is detected the motion timeout counter gets reset, so you really have 3 hours since the last motion was detected before the projector will shut down, so getting up to go to kitchen should trigger the motion detector, and unless you spend 3 hours in the kitchen you shouldnt have anything to worry about.

Currently the Max Time On timeout is set to 6 hours Im thinking of changing the Near Max Time On beeps to start say 10 minutes before shutdown, and yes... if you went to the bathroom say 11 minutes before the max time on limit was reached, and spent 12 minutes in the bathroom, you would come back to a shutdown projector.

I added the Max Time On feature because someone made a comment "Well what if the dog keeps pacing back and forth triggering the motion detector, the projector could stay on for ever!" So with the Max Time On timeout even if this were the case (great dane pacing back and forth for days), the projector would shut down after 6 hours no matter how much motion is in the room unless someone physically pressed the power button.

Maybe what I will do is force the user to Press and Hold, the power button to shut down, and a quick press will reset the Max Time On counter, so if you were planning to say go to the store quickly for more beer... and didnt want to shut the projector down, you could give the power button a quick press before you left to ensure that the max time on timeout would not expire before you got back, but no matter what state the projector was in, Press and Hold on the power button causes shutdown (unless the projector is already shut down)

So basically the revised interface would be:

In shutdown/standby Press, or Press and Hold causes the controller to enter the Booting State

In booting state Press is ignored, Press and Hold causes the controller to enter the Shutting Down state

In Running state press resets the max time on counter (and the motion timeout counter), Press and Hold causes the controller to enter the Shutting down state (no matter whether the projector is near any timeouts)

In ShuttingDown state, press and Press and Hold are ignored.

Better?
 
sounds perfect

With those state transitions, press-and-hold always means "shut down". and press always means "on" (except during shutdown state when you can't turn the lamp back on immediately). I think that will be very easy for everyone to understand.

I don't worry about automatically shutting down, but I have a different problem with my projector: It just has a lamp switch and a fan switch, but you also have to turn on the video-to-vga converter box, the sound system, and the satellite receiver box (or select the DVD player). It all ends up being too many settings for my wife to want to bother with, so she just uses the standard TV. (And she is a Veterinarian, so she is not stupid.)

If I built a microprocessor-based master controller, I could then have one button for "turn everything on with satellite input", one button for "toggle between satellite & DVD player", and a third button for "turn everything off". The master controller could learn the remote controller sequences for each of the devices, and then use IR to drive them.
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.