RcTime Problems
zapur1
Posts: 4
Hi
I'm having some major problems. My debug is puting out 0 and nothing else. The code is below and circuit attached, I'm just using the BS2 Functions from the Object Library. i'm using a 350 ohm resistor and 0.1uf capacitor. Please Help!!!!
I'm having some major problems. My debug is puting out 0 and nothing else. The code is below and circuit attached, I'm just using the BS2 Functions from the Object Library. i'm using a 350 ohm resistor and 0.1uf capacitor. Please Help!!!!
BS2.start (31,30) repeat ' RCTime on Pin starting at State, returns discharge time, returns in 1uS units dira[noparse][[/noparse]Front_Right_light]~~ ' Set as output outa[noparse][[/noparse]Front_Right_light]:=1 ' Set high BS2.Pause(10) ' Allow to charge Front_Right_Reading := BS2.RCTime(Front_Right_light,0,@Front_Right_Reading) ' Measure RCTime BS2.DEBUG_DEC(Front_Right_Reading) ' Display
Comments
the Quoted line is the one that's giving you problems. Have you looked at the code for the RCTime function in the BS2 function library? The code comments are pretty clear in it's use, and show simple examples of how to do this yourself. Anyway, the above code should look like this.
yea, the state argument is a bit strange, but it wants the state the RC circuit will start in. (not what it will finally become) This is exactly how the BS2 implements this command.
Akk, does your circuit look exactly like the picture you posted? 'cause if it does the circuit's ready state is a logic LOW and it's resting state after a reading is a logic HIGH. exactly the opposite of what your code expects. change the following lines to fix this.
Best of luck,
Marty
P.S. the stickies on the top of this forum a WELL worth reading, and so is the manual, data sheet, and all the PE kit labs. The full up Blinker.spin and Output.spin from the manual's tutorial is a remarkably sophisticated program for something that's maybe a page long in total. also search.parallax.com provides a much more usable forum search function than the forum's built in search.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Lunch cures all problems! have you had lunch?
Post Edited (Lawson) : 7/30/2007 6:06:48 AM GMT