Shop OBEX P1 Docs P2 Docs Learn Events
RCTIME Command — Parallax Forums

RCTIME Command

436353436353 Posts: 5
edited 2009-07-14 19:04 in BASIC Stamp
As long as i remember u can't have analog input signals in basic stamps but RCTIME command is used to get variable resistance with out any converter rite? and PWM command to output a variable voltage. Can i use RCTIME command coming from photo resistors and use the variable resistance to control an output?

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-07-14 17:38
    You can certainly use the RCTIME statement to measure the resistance of a photoresistor, then use the value you get to control a PWM statement to generate a voltage. The only thing you will need is some kind of analog buffer. The problem is that the PWM statement only produces a voltage when the statement is executed. It charges a capacitor to a fraction of the supply voltage. When your program is doing the RCTIME statement or other statements, the capacitor is discharging. By using a buffer (op-amp), this slows down the discharge rate of the capacitor and keeps the PWM output pretty steady while your program is doing something else.
  • 436353436353 Posts: 5
    edited 2009-07-14 18:13
    Thanx Mike for the reply.

    Well I was going to use the photoresistor to modulate the servo motor, so I don't think im gonna use the PWM statement (so no analog buffer rite?). Sorry another noob question, im not really familiar with Basic Stamps (did some readings tho). Let say the value of resistance of the Photoresistor is X at certain light and Y at certain light. Now can i use those values to move the servo motor to a specific position. We are actually building an automated window blinds. The main purpose is to modulate (not open and close) the blinds according to how much light there is inside the room and outside the room. I was hoping to do this without the A/D converter since the shipment would be too much for us (we're in Canada and authorized dealers here don't seem to have the A/D converter, or we just didn't look hard enough). I did check Ch 7 of "What's a Microcontroller?" can i use the circuit from there with some change in program and adding custom program to it? Sorry for all the question, I have little time (4 weeks) to come up with a solution.

    Thank you
  • Mike GreenMike Green Posts: 23,101
    edited 2009-07-14 18:38
    Read the "Robotics with the BoeBot" tutorial (www.parallax.com/tabid/535/Default.aspx) for a discussion about servos and how to control them.

    The RCTIME statement and the photoresistors will give you a number that's proportional to the light level, but it won't be anything like linear. The servo would be controlled with a PULSOUT statement and the servo position would be proportional to the number given in the PULSOUT statement. What you will need is some kind of mapping, probably with a table of RCTIME values and corresponding PULSOUT values. Your program would search the table (stored in EEPROM using READ and DATA statements) for the nearest entry to the RCTIME statement result and provide the corresponding value from the table for the PULSOUT statement to use to move the servo.
  • 436353436353 Posts: 5
    edited 2009-07-14 19:04
    Thank You very much Mike,

    This has been a great help. I read up on how to control the servo with PULSOUT statement earlier. Just wasn't sure about analog inputs. This has cleared many confusions. Hopefully I will be able to write the program now. Again thank you very much.
Sign In or Register to comment.