Basic stamp 2 programing

can somebody help me write the program for the following:

In order to measure variable quantities, the BASIC Stamp utilizes the software command
RCTime. RCTime relies on the charge/discharge behavior of a resistor-capacitor pair to indicate
the relative value of the variable quantity. In most of our applications, a fixed capacitor is used
with a variable resistance device. Many electrical sensors/transducers change resistance in
response to an external stimulus. You will be introduced to these types of devices which include
thermistors, RTD’s (resistive temperature device), strain gages, and photocells in future
experiments. Alternately, if there was a variable capacitance (a humidity sensor is an example)
device used to sense a quantity, a fixed resistor would be utilized to produce a decay rate that
would be compatible with the BASIC Stamp.
Experiment 1b: Identify and select the Cadmium-Sulfide (CdS) photocell. The specifications
indicate that the dark resistance is approximately 20 MW, while the light resistance is less than
1kW. Use a 1 KW resistor and a 1.0 μF capacitor along with the photocell. Note, the capacitors
that you have in your kit are either disc or tantalum capacitors. Their capacitance is written on
the body of the device. They should have either a 104 or 105 marked on the units. The 104
stands for 10 X 104 picofarads or 0.1 μF. Please refer to the RCTIME command reference to
calculate values of R and C for other applications. Using the RCTime and DEBUG commands,
write a short program to read the output from the photocell and then output the value to the
debug screen to read. Once the program is running, cover the photocell with your hand and note
the change in the display value. If necessary, modify the program so that lower numbers are
displayed under dark conditions and higher numbers under light conditions. Please note that the
display will be in integers only, ranging from 0 to 65535. The RCTime variable should be in the
range from 5,000 to 65,000. Adjust the component values to bring the variable value into
specification.

if you can, please help me

hcein

Sounds like homework (fall classes have started). If it is homework, you are probably paying an instructor good $$$ to explain these things to you, so ask the instructor first to get some of your investment back. Also, the "Use a 1 KW resistor…) indicates someone probably didn’t proof read their instructions. If it isn’t homework, then what have you tried so far to solve the problem?

Do you have a stamp board? Per the instructions, it sounds like you were given parts to perform this assignment. Like zoomcat said, get your moneys worth and ask the teacher to explain any grey areas and at the very least try it your self.

of course it’s homework; if i were able to do it i wouldn’t search for help over the internet guys!!! and i asked the teacher and what he explained didn’t really make sense so i had no choice to try here since nobody wants to have a zero on an assignment, i had to ask for help before givin up,

I’ve been trying this homework for 2 weeks now

So post up some of the code or info on what you have been trying for two weeks that isn’t working. You will probably need to demonstrate that you have been making some effort yourself to resolve the issue before people will spend their effort to figure it out for you.

Not to be rude but two weeks of research on the internet would have explained enough about the subject so that you would be able to understand. There are examples all over the place and all you would need to do is try one example and see for your self how it works.

You never even answered my question: Do you even have a stamp board?

I don’t think anyone on this forum is going to do the work for you without some evidence that you at least tried to learn this on your own.

here’s what i did:

CdS CON 0

light VAR Word
Loop:
LOW CdS
PAUSE 1
RCTIME CdS,0,light
DEBUG Home,DEC5 light,CR
PAUSE 100
GOTO Loop

When i cover the CDS cell with my finger, the output is still the same, it doesn’t detect when i cover it.

yes i have a stamp board; and i don’t really want you to do the homework for me, all i am asking is some help. i should have posted the work i did since the begining, you’re right, i just wanna know if somethig is wrong with what i programmed so far coz it ain’t workin

hello i figured out my problem

CdS CON 0

light VAR Word
DO
LOW CdS
PAUSE 1
RCTIME CdS,0,light
DEBUG Home,DEC5 light,CR
PAUSE 100
Loop

this works, when i run it it gives me a big value, and when i cover the photocell it returns 0. that works.

and thanks for trying to help me

Glad you figured it out! You learned more by figuring out what you did wrong on your own than if we just pointed it out. If you go to the Parallax website, they have tons of information about this sort of stuff for the future.

I have to give you a lot of credit for figuring it out because this stuff aint easy when you don’t know whats going on in the beginning. We have all been there before. Quick advice for the future; if you post as much information upfront, such as your current code, results, problems and even a link to a photo, members would help as much as they can.

here’s a link to Parallax.com a great place for tons of information:

www.parallax.com

Here is a link to another site that explains more about this topic:

utc.edu/Faculty/Tatiana-Allen/rctime.html

thanks a lot man

Here is another simple program that displays the results to the debug window:

result  VAR     Word

Test:
  HIGH 7                                ' charge the cap
  PAUSE 1                               '   for 1 ms
  RCTIME 7, 1, result                   ' measure RC discharge time
  DEBUG DEC ? result                    ' display result
  END

I got this right out of the Stamp program software also known as the IDE (interface development environment).

When you are in the Stamp IDE, press F1 and a help file will open you can do a search for “RC Time” and that is how I found this example code.

yeah i got that one too;

thanks for the help

And here is the example that they gave in the same help topic:

http://img407.imageshack.us/img407/9141/rctimejh6.gif

yeah got that too am using this program

CdS CON 0
light VAR Word
DO
LOW CdS
PAUSE 1
RCTIME CdS,0,light
DEBUG HOME,DEC5 light,CR
PAUSE 100
LOOP

when i run it it returns 0 under light and when i cover the cell with my hand the value increases.

my problem now is how to make it do the contrary: i mean:

how to make it return 0 under dark and high number under light

Why do you need to have the sensor return a 0 when dark and >0 when light? If your program works as is, why do you need it to be different?

You can always just invert the value the sensor is returning, making a 0 be 1 and 1 be 0. This does not alter the way the sensor works, but does give your program the values you are asking for.

Sensors are designed to operate a certain way, and we have to use the values they return as is for input to our programs. We can’t just change the values a sensor returns. If we are not getting the values we need from a sensor, we may have to search out a different sensor that works closer to the way we need.

8-Dale

that’s the way the teacher want it,

i’ll try what you suggested and i ll reply right after

no it doesn’t work, i get oooo1 when i run it and when i cover the cell the number doesn’t go to 0, i ll go and read to get some more info

thanks for trying anyway

Did you try changing the state?

It’s been a long time since I messed with Pbasic.

Try this code:

' {$STAMP BS2}
' {$PBASIC 2.5}

Time VAR word

do

HIGH 2
 PAUSE 100
 RCTIME 2,1, time   '<---------- change the 0 to a 1 like I have done
 DEBUG HOME, "Time =  " , DEC5 time

loop

the values still increase when i cover the cell