Shop OBEX P1 Docs P2 Docs Learn Events
RcTime Problems — Parallax Forums

RcTime Problems

zapur1zapur1 Posts: 4
edited 2007-07-31 10:08 in Propeller 1
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!!!!
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


172 x 109 - 2K

Comments

  • LawsonLawson Posts: 870
    edited 2007-07-30 05:57
    zapur1 said...
    Front_Right_Reading := BS2.RCTime(Front_Right_light,0,@Front_Right_Reading) ' Measure RCTime

    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.

    Front_Right_Reading := BS2.RCTime(Front_Right_light, 1)          ' Measure RCTime
    



    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.

         outa[noparse][[/noparse]Front_Right_light]:= 0                ' Set low.  this is the default state, but it's good to set it anyway
         
         Front_Right_Reading := BS2.RCTime(Front_Right_light,0)          ' Measure RCTime
    
    




    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
  • zapur1zapur1 Posts: 4
    edited 2007-07-31 10:08
    A really weird thing is when I change the program to like that the propeller chip crashes and doesn't give out a reading with both state circuits.
Sign In or Register to comment.