Running multiple sensors with BS2?
Shadowcasterx4ffc
Posts: 13
I'm having some problems with BS2 programming. I'm not entirely sure how to make multiple programs and sensors·run at the same time using a single Board of Education. I'm trying to control a fan (using a temperature sensor)·and a light bulb (using a light sensor) with an RC4 board, which is hooked up to the BoE. We're not having problems with the RC4 or BoE, it's just the coding itself.
Comments
The BS2 can only do one thing at a time.
So you have to figure out a way to do everything you need to at once.
I'm hoping your using some kind of relay or H-bridge to control your fan.
Otherwise it could seriously damage you stamp.
Get back to us on how your fan/lightbulb is setup.
Is the RC4 board some kinda relay board?
I'm working on a greenhouse with some other guys at school, so we need to be able to run multiple sensors such as temperature, light, and moisture, so we can control sprinklers and lights.
Thanks for the help anyway.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Eugene
Greenhouse Project
Have two bit variables... lets say its named Fan and Light
Start:
Check temp sensor
if temp is too high and fan = 0 THEN turn on fan
else if temp is too low and fan = 1 THEN turn off fan
check light sensor
if light sensor is dark and Light = 0, turn on light
if light sensor is light and Light = 1, turn off light
pause X
goto start
That's the basic flow I'd use... you need a loop that will do the sensor checks and execute the shutons and shutoffs
of the relays as needed.
The pause X is because you'll need to play with this number and see what a good pause time is. I'm afraid that if
its too low then the fans/lights will flicker as they reach the detection threshold you set.
Also remember that you need to have the light sensor far enough away from the bulb to not be triggered by it.
If you need actual code, I can supply you with that, I'm just in a bit of a hurry at the moment.
Disclaimer: I'm a newbie, taking my advice may be hazardous to your health(electronics).
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Eugene
Greenhouse Project
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Eugene
Greenhouse Project
Do you need anything else from us?
PS: I love your avatar image.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Eugene
Greenhouse Project
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Eugene
Greenhouse Project
www.parallax.com/tabid/535/Default.aspx
If you are new to microcontrollers you might want to start with "What's a Microcontroller" first.
What you're trying to do is actually fairly easy and is something that Basic Stamps excel at.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Rick
Do you have the Demo Code for the RC4
If you do not here is the Demo Code
I· would run the demo code for the RC4 first and understand how to control it
Then run the Demo for the Temperature Sensor that you are going to use and learn how to control it
Then run the Demo for the Light Sensor that you are going to use and learn how to control it
Once you have learn·how to control each item then write a routine that check·each sensor and base on the set point that you have for·each sensor will turn that relay on then go back to the routine and check the sensors again
I have found until you have a good understanding of the sensors that you are going to use it is very hard to get a routine written that will work
Ugha has the right· ·here
Ugha
·
Start:
Check temp sensor
if temp is too high and fan = 0 THEN turn on fan
else if temp is too low and fan = 1 THEN turn off fan
check light sensor
if light sensor is dark and Light = 0, turn on light
if light sensor is light and Light = 1, turn off light
pause X
goto start
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··Thanks for any··that you may have and all of your time finding them
·
·
·
·
Sam
Post Edited (sam_sam_sam) : 3/8/2008 6:34:03 PM GMT
Anyway, I don't think we have the demo code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
-Eugene
Greenhouse Project
Post Edited (Shadowcasterx4ffc) : 3/10/2008 4:40:08 PM GMT