Shop OBEX P1 Docs P2 Docs Learn Events
A little bit of help? — Parallax Forums

A little bit of help?

muppetmuppet Posts: 4
edited 2006-12-08 04:22 in BASIC Stamp
Hi, I'm new to this board and this will be my very first post. Anyways, I've never really worked on a microcontroller before and, if it's possible, I could use some help. I'm sure this may seem like a stupid question, but I'd love all the help I can get. I've got a basic stamp, a motor, and a photoresistor. What I'd like to do is program it to when light to the photoresistor is blocked the motor will begin to spin counterclockwise. When that it is no longer blocked the motor will stop spinning and, well, that's that. I'm just not familiar with programming and the microcontoller manual is helpful, but I just don't get it.

Any feedback would be much appreciated. Sorry to post what must seem like a very newb-ish question.

Comments

  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-12-07 19:46
    Hi Muppet,
    Sounds like a fun project. Have you downloaded and looked at the WAM? text? A lot is covered in there. What kind of motor are you talking about? Makes a big difference.

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    StampPlot - Graphical Data Acquisition and Control
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • muppetmuppet Posts: 4
    edited 2006-12-07 19:53
    I did look at the WAM text and I get the general idea, but it's still not clicking with me for some reason. It's a standard servo (the kind in the WAM text) and that's helpful, but I'm still having trouble. Sorry for being so, well, dumb about this?
  • Martin HebelMartin Hebel Posts: 1,239
    edited 2006-12-07 20:01
    Oh, your not being dumb, quit that. But it would help answer if you asked some specific questions or gave some code you tried and it failed. essentially, you need to:

    Read the photoresistor using RC time
    if the value is too large,
    run a loop to move the servo to needed position
    else
    run a loop to turn servo the other position
    loop back

    -Martin

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Martin Hebel
    StampPlot - Graphical Data Acquisition and Control
    AppBee -·2.4GHz Wireless Adapters & transceivers·for the BASIC Stamp & Other controllers·
  • FranklinFranklin Posts: 4,747
    edited 2006-12-07 20:05
    OK, for starters a standard servo will only rotate about 180 degrees and stop somewhere between +-90 degrees. You need a continous rotation servo or a small dc motor to do what you want. Let us know what you have tried up to now and why you think what you are doing isn't working. perhaps we can then help you over your problem.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • muppetmuppet Posts: 4
    edited 2006-12-08 02:30
    Update: Okay. Sorry for the confusion, but I do have a continuous servo. Also, I can't even seem to get the RC time on the photoresistor. I mean, I set it up like it shows in the WAM, but the photoresistor itself doesn't seem to work. If I press down on the resistor the RC time amount increases, but that's it. If the base number itself is shown to be .0001 would that translate into just one? Like, if anything over 1 would constitute as a 2 and therefore become the number to tell the motor to turn on?

    ...and it seems like my 9 volt battery has gone out. Either that or I've somehow managed to break it. Anyways, I haven't tried any really hard programming yet. Just messing around with what I think makes sense for an If, Then statement. For instance:

    ...
    counter var word
    time var word

    do

    high 2
    pause 100
    RCTIME 2, 1, time
    DEBUG HOME, "time = ". DEC5 time

    IF TIME=2 THEN

    DEBUG "Counterclockwise 10 o'clock", CR

    FOR counter = 1 to 150
    PULSOUT 14, 1000
    NEXT

    ENDIF

    LOOP

    END

    I could be totally wrong with that coding, but since my battery (hopefully) died I have to test it tomorrow sometime. I haven't even gotten around to starting the actual art that goes along with this piece. This may turn out to be such a hassle. If you guys have some more input it would so, so, so very much be appreciated.
  • FranklinFranklin Posts: 4,747
    edited 2006-12-08 03:20
    For the servo part to work you need to send a 1 to 2 ms pulse to the pin and then wait 20 ms before repeating. none of these values are burned in stone. to have my servo stand still I use :
    for counter = 1 to 150
    PULSOUT 14,750
    pause 20
    next

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • muppetmuppet Posts: 4
    edited 2006-12-08 04:22
    Franklin said...
    For the servo part to work you need to send a 1 to 2 ms pulse to the pin and then wait 20 ms before repeating. none of these values are burned in stone. to have my servo stand still I use :
    for counter = 1 to 150
    PULSOUT 14,750
    pause 20
    next

    Wow. Thanks for that. Did the other part of the code seem alright?
Sign In or Register to comment.