Shop OBEX P1 Docs P2 Docs Learn Events
NEED HELP! Target following webcam... — Parallax Forums

NEED HELP! Target following webcam...

ksychengksycheng Posts: 11
edited 2006-07-09 00:10 in Learn with BlocklyProp
Hi all,

My project is to make a webcam that is going to following a certain target wearing a certain color belt.· I used a webcam to obtain a unique set of RGB values and then process the values using C++ and find out the angle the webcam needs to rotate in order to get the target in the middle of the view...

I don't know how to obtain the angle information from C++ through the serial connection and how to get the servo motor to rotate accordingly...

PLEASE HELP!!!

Comments

  • achilles03achilles03 Posts: 247
    edited 2006-07-07 15:40
    You're going to have to get your C++ program to be able to export data regardless. That's not a basic stamp issue. If the C++ side of your project is the problem, then I don't know if you're asking in the right forum.

    Once you're able to export the data (RS232 or something), getting a basic stamp to control the servos is a breeze.

    Dave
  • ksychengksycheng Posts: 11
    edited 2006-07-07 15:50
    Can you teach me on how to export data from C++? how C++ and my basic stamp communicate?

    also...I am NOT using a Parallax servo motor and the pulsout command doesn't seem to work...do I HAVE TO have a Parallax servo motor? because now, I can't really control the servo motor how much to rotate...I have a Hitec servo motor now...
  • achilles03achilles03 Posts: 247
    edited 2006-07-07 17:22
    You should be posting questions regarding C++ in a C++ forum (these forums are primarily for parallax products). It's like me asking astronomy questions in a poetry forum.

    You need to figure out how to get your C++ program to communicate asyncronously (like RS232; i.e. 300bps-9600bps), and I'm not sure if many people that read these forums are experienced with that. Once you can output data from your C++ program, all you need to use is the SERIN command with the BS2 in order to receive the data from your C++ program.
  • ksychengksycheng Posts: 11
    edited 2006-07-07 17:24
    Thanks and sorry for posting in the wrong forum...

    but anyhow, I NEED TO have a Parallax Servo Motor in order to use the PULSOUT function, right?
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-07-07 19:28
    No you don't, you just have to know what your servo expects. Fortunately most of the follow a standard pulse framework. I did a write up in this forum a few months back explaining thier construction an method of operation, I'll see if I can find it for you.

    Good to see you back Dave, haven't seen you in a while, though that may be due to me not having enough time to stay current with the Basic Stamp Forum.

    <edit> Found it, here's the synopsis I was refering to: http://forums.parallax.com/showthread.php?p=566049·</edit>

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is one giant teacup ride.

    Post Edited (Paul Baker) : 7/7/2006 7:37:07 PM GMT
  • ksychengksycheng Posts: 11
    edited 2006-07-07 21:02
    um......for some reason...it doesn't work for my servo motors...

    when I send a pulse let's say PULSOUT 13,650, it would just shake and wouldn't move at all.....even if I send a pulse of 600 it's the same...I don't know y...

    I had to use for loops to control the movement of the motors...

    I don't think there is anything wrong with my connection...
    I connected the servo motors according to the colours given and the bottom (4th) pin to the I/O pin 13...

    Please assist...

    Thanks
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-07-08 00:26
    Are you providing the pulse every 20ms? There must be a steady train of 1-2ms pulses spaced 20ms apart.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is one giant teacup ride.
  • ksychengksycheng Posts: 11
    edited 2006-07-08 01:36
    can you provide me with·some lines of code that I can use to test if the servo motor is working properly?

    wouldn't the PULSOUT 13, 600 work?
  • Beau SchwabeBeau Schwabe Posts: 6,548
    edited 2006-07-08 02:27
    ksycheng,

    PULSOUT 13, 600
    
    



    This only solves part of the equation. In order for the servo's to be happy, you need to repeat the above command (or the alike) every
    15mS to 25mS. So your code might look something like this...

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    MainLoop:
      PULSOUT 13, 600
      PAUSE 20
      GOTO MainLoop
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • ksychengksycheng Posts: 11
    edited 2006-07-08 02:31
    yes my motor work under continuous rotation, however, I want it to rotate under control...meaning I want to determine how long it would take the motor to rotate a certain degree and get it to do that...however, I can't get it to do that...
  • ksychengksycheng Posts: 11
    edited 2006-07-08 02:38
    sorry..........I got 1 more question.......sorry.........I am new to this...

    SERIN 16, 85,[noparse][[/noparse]SDEC3 myNum]

    what does the first number (16) and second number (85) mean??? I want it to read in a signed 2 digit number, I just need the range of -90<-->90, however, I can't get it to work.......

    SDEC3 is interpreting a signed 3 digit decimal number, right???

    Thanks again for all your help~~
  • Beau SchwabeBeau Schwabe Posts: 6,548
    edited 2006-07-08 03:34
    ksycheng,

    If you are using the latest PBASIC editor, you can type "SERIN" or any other command and highlight it by pressing 'SHIFT + HOME' and then press F1.
    This should bring up a help screen with all of the information you should need.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
    1440 x 900 - 388K
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-07-08 17:50
    ksycheng said...
    yes my motor work under continuous rotation, however, I want it to rotate under control...meaning I want to determine how long it would take the motor to rotate a certain degree and get it to do that...however, I can't get it to do that...
    You are using a continuous rotation servo? Thats not the right tool for the job, I am assuming you want sweeping control to pan the webcam. You need a standard servo for that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is one giant teacup ride.
  • ksychengksycheng Posts: 11
    edited 2006-07-08 18:03
    oh......maybe that's the case...what's the difference though?

    I don't want the webcam to go through steps...I want it to rotate smoothly, would it still rotate smoothly for the standard servo??
  • Paul BakerPaul Baker Posts: 6,351
    edited 2006-07-09 00:10
    The difference is that the continuous rotation servo rotates 360 degrees, the pulse provided indicates the speed and direction of the rotation. A standard servo has a limited length of travel (typically between 90 and 180 degrees), the pulse provided indicates the final angular position desired, this is done exponentially (faster the further away from the final position, slower when closer to it), this can be made linear by doing progression of pulse widths until the final angle is achieved (servo thinks it almost there, then you change it to be further away before it gets there). But this should not be an issue when your target is already aquired, since a person will likely move slowly through the image.

    The only difference between the two types is the feedback in a continuous rotation servo is cut and set so that the servo always thinks it's centered. Read my post in the link provided to get an understanding of the mechanism.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Life is one giant teacup ride.
Sign In or Register to comment.