Shop OBEX P1 Docs P2 Docs Learn Events
WHAT IS THE REALTIONSHIP BETWEEN Voltage of the sensor and Pulse Width Modulati — Parallax Forums

WHAT IS THE REALTIONSHIP BETWEEN Voltage of the sensor and Pulse Width Modulati

AndresAndres Posts: 10
edited 2009-10-10 21:54 in Accessories
The combination of Sharp Sensor and the AD0831 CONVERTER will produce a digital signal. How that Digital Signal will be useful to control the duration of the Servo Motor.

I already went over "Robotics with the BoeBot" Chapter 2 for controlling Servo motor. But it doesn't talk about how the SENSOR OR THE AD0831 CONTROLS THE CONTINUOUS SERVO MOTOR.

Comments

  • sylvie369sylvie369 Posts: 1,622
    edited 2009-10-10 18:22
    In general you read sensor readings into your program (that is, into the Basic Stamp module), and you separately use that program to control the servo motors. You can make whatever decisions you want to make about how to use the sensor readings to control the motors. That's why you have a computer on the robot: so it's not just a hard-wired "always do the same thing" kind of connection.

    Suppose your sensor readings ran from 0-10, representing the number of inches to the nearest object. You could write code that would have your motors run forward (moving the robot forward) when the readings were 5 or above, but stop once the reading is below 5. Alternatively you could write code that would have the motors run backwards if the sensor reading is less than 3, forward if its from 3 to 6, and stop if it's above 6. Or any other combination you want.

    In essence, you have this:
    Sensor readings ---> Code that decides on the basis of the readings what actions to take ---> Servo motor control

    So there is no single answer to your "what is the relationship?" question. It's whatever you program it to be. You learn to set up hardware/software so you can read sensors, and hardware/software so you can control motors, and then software (alone) to decide how to relate the two.
  • AndresAndres Posts: 10
    edited 2009-10-10 18:52
    My project is about a curtain that moves from 10cm to 30cm depending on the sensor reading. When I test the sensor at 10cm will give me a 255 decimal value or 11111111 binary number and if i go to 12cm then the reading is 277. Then I can gives a PULSOUT PIN, 650 or 1.3ms duration so it will go clockwise. But the problem is that is not going top stop. The only way to stop is applying another PULSOUT PIN, 750 where is going to return back to the positon where the servo motor start.

    Do you know a solution for this problem

    THANK YOU

    This program will read the sensor and give and output in binary number and a decimal value.

    [noparse][[/noparse] Title ]
    ' Basic Analog and Digital - PL3_1R0.bs2
    ' Program Listing 3.1 Revision 0.
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    '
    [noparse][[/noparse] Declarations ]
    adcBits VAR Byte
    v VAR Byte
    r VAR Byte
    v2 VAR Byte
    v3 VAR Byte
    '
    [noparse][[/noparse] Initialization ]
    CS PIN 0
    CLK PIN 1
    DataOutput PIN 2
    DEBUG CLS 'Start display.
    '
    [noparse][[/noparse] Main Routine ]
    DO
    GOSUB ADC_Data
    GOSUB Calc_Volts
    GOSUB Display
    LOOP
    '
    [noparse][[/noparse] Subroutines ]
    ADC_Data:
    LOW CLK
    LOW CS
    PULSOUT CLK, 210
    SHIFTIN DataOutput,CLK,MSBPOST,[noparse][[/noparse]adcBits\8]
    HIGH CS
    RETURN

    Calc_Volts:
    v = 5 * adcBits / 255 '? new line
    r = 5 * adcBits // 255 '? new line
    v2 = 100 * R / 255 '? new line
    v3 = 100 * r // 255 '? new line
    v3 = 10 * v3 / 255 '? new line
    IF (v3 >= 5) THEN v2 = v2 + 1 '? new line
    IF (v2 >= 100) THEN '? new line
    v = v + 1 '? new line
    v2 = 0 '? new line
    ENDIF '? new line
    RETURN

    Display:
    DEBUG HOME
    DEBUG "8-bit binary value: ", BIN8 adcBits
    DEBUG CR, CR, "Decimal value: ", DEC3 adcBits '? new line
    DEBUG CR, CR, "DVM Reading: " '? new line
    DEBUG DEC1 v, ".", DEC2 v2, " Volts" '? new line
    RETURN
  • Mike GreenMike Green Posts: 23,101
    edited 2009-10-10 21:54
    You have already asked this question and received at least one answer. It is against forum rules to post a question in more than one forum or to otherwise post duplicate messages. It also doesn't get you a better or faster answer, in fact it interferes with the process of helping you.
Sign In or Register to comment.