May 18, 2024, 08:16:46 AM

News:

Be sure to checkout our Vixen interfaces in the Library forum -- if you want PC automation at near zero cost, EFX-TEK and Vixen is a great combination of tools.


Get Control of a Wiper Motor- Prop2/HB25/QTI Sensor

Started by randyaz, April 08, 2007, 01:09:29 PM

Previous topic - Next topic

randyaz

April 08, 2007, 01:09:29 PM Last Edit: August 25, 2008, 11:30:38 PM by randyaz
    I finally figured out how to use a Parallax QTI Line Sensor, HB25 Motor Controller, and a BS2 to sense and control the shaft position of a wiper motor.

    I made a 3" disk with "tic" marks in PaintshopPro, glued it to a cardboard disk, drilled out the center, mounted it over the shaft, then hot glued the QTI to a standoff, and hot glued that to the motor over the "tic disk".

http://www.spooksterville.com/gallery/main.php?g2_view=core.DownloadItem&g2_itemId=441&g2_serialNumber=2

The QTI outputs a pulse each time it sees a transition from black to white. The BS2 reads the pulses and sends positioning commands to the HB25. The shaft can be positioned anywhere you want it... either side of a tic mark

http://www.parallax.com/detail.asp?product_id=555-27401
http://www.parallax.com/detail.asp?product_id=29144

Whats it good for? turning props, heads, lifting arms/legs/torsos, pulling a prop a precise distance...and back...at controlled speeds and directions

Here's an example:

' -----[ I/O Definitions ]-------------------------------------------------

' qti r Output Connects To P0. w to Vdd

HB25      PIN        15
trigger    PIN        14

' -----[ Constants ]-------------------------------------------------------

T2400           CON     396
T9600           CON     84
T38K4           CON     6

Inverted        CON     $4000
Open            CON     $8000
Baud            CON     Open | T38K4            ' fast baud for accessories

IsOn            CON     1                             ' for active-high I/O
IsOff           CON     0



' -----[ Variables ]-------------------------------------------------------

oldBits           VAR     Nib                          ' Previous State Of I/O Pin 0
newBits         VAR     Nib                          ' Current State Of I/O Pin 0
counter         VAR     Byte                        ' Counter (0-255)...change to word if need more counts
index            VAR     Word                       ' for ramping motor, if used

' -----[ Initialization ]--------------------------------------------------

OUTS = %1000000000000000                  ' Set All Output Pins Low but 15
DIRS = %1111111111111110                   ' I/O Pin 0 is Input

newBits = INA

' -----[ Program Code ]----------------------------------------------------


main:
'DO WHILE trigger= IsOff: LOOP              ' un-comment if using a trigger


DO : LOOP UNTIL HB25 = 1                   ' Wait For HB-25 Power Up
LOW HB25                                           ' Make I/O Pin Output/Low
PAUSE 5                                              ' Wait For HB-25 To Initialize
PULSOUT HB25, 750
PAUSE 5000

Program:

counter = 0

PULSOUT HB25, 800                              'start motor

encoder:
DO WHILE counter < 62

     newBits = INA                                ' Get State Of I/O Pin 0
     IF newBits <> oldBits THEN              ' Have Bits Changed?
     counter = (counter + 1)                   'Start counter

      SELECT counter
        CASE = 10                                 'ccw
        PULSOUT HB25, 710

        CASE = 20
        PULSOUT HB25, 780                    'cw

        CASE = 40
        PULSOUT HB25, 600                    'ccw

        CASE = 61
        PULSOUT HB25, 750                    'stop
      ENDSELECT

  DEBUG HOME, ? counter                    ' Show New Counter On Screen

oldBits = newBits                                ' Update oldBits

   ENDIF

LOOP

RETURN

[/list]

JonnyMac

Randy,

I fear that in some lighting conditions your circuit may not work; let me suggest that you use RCTIME to read the disc as that's how the circuit is designed.  If you want to use it as a pure digital device then you should connect it to one of the P12..P15 pins and set the SETUP jumper to UP; of course, you still have to rewire the sensor so that the white wire gets +5 and the red white goes to your input pin.  The latter setup give you more reliable output from the sensor.

And I wonder if your code is giving you two counter increments per black pad.... What you really want to do, I think, is update the count when you go from white to black, or black to white, but not both.  A little additional logic can handle this for you.

Cool beans, though, and thanks for sharing.
Jon McPhalen
EFX-TEK Hollywood Office

randyaz

Thanks Jon!  I'll try the RCTIME circuit. For now, what Im doing works in low to normal lighting. I haven't tried it in total darkness...like enclosed inside a prop, but I suppose a LED would solve that.

Actually, the count for each color transition works to give alittle more resolution to the positioning giving a reference point on either side of the tic instead of just one tic/one count and the fewer tics there are the more rpm it can handle.

This is nothing new...the boe bot folks have been using it all along. Thats what gave me the idea to try and apply it to a wiper motor and prop building.  Im working on the fringe of my skills so any advise is greatly appreciated!

JonnyMac

Okay, for edge detection hot-wire the sensor so that QTI.W gets 5v all the time so that the on-board LED is activated, and connect QTI.R to one of the pins that has a SETUP jumper and move that to UP -- that should get things working reliably in all conditions.  This should cause the output to toggle with color change (black will be high, white will be low).

Since you're doing edge-to-edge transitions you should probably make the dark and light segments the same size for the best accuracy.
Jon McPhalen
EFX-TEK Hollywood Office