Shop OBEX P1 Docs P2 Docs Learn Events
please help. I'm new at this. — Parallax Forums

please help. I'm new at this.

liquid12341234liquid12341234 Posts: 3
edited 2008-05-15 12:45 in Propeller 1
hi everybody. This I'd the first time I'm using a BS2 to control something. I'm trying to control a motor that only draws 1A. The circuit is done and I'm at the programming stage. My main power source is a 9 Volt battery. I installed a pushbutton on pin 8 as an input. I want the circuit to behave in a way where, when I press the button the time I hold the button is recorded into a variable. Thenthe controller will take this value and run my motor automatislly with the same duration I held the button. I was thinking of using a counter to record how long I held the button then decrement so the motor will run by itself. Any suggestions on how I should up about my little project? Thanks guys.

Comments

  • Spork FrogSpork Frog Posts: 212
    edited 2008-03-31 19:40
    Hi liquid12341234. Nice to see some newcomers around the forums. However, this should be posted in the BS2 forum, not the Hydra forum. You'll find more people willing to help there.
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-31 20:37
    It's also against forum rules to post the same question in more than one forum. Please don't. You are unlikely to get any better or faster answers.
  • AndreLAndreL Posts: 1,004
    edited 2008-04-02 01:03
    Liquid, did you get your question answered? In a nutshell, you just need to use a digital I/O to control the base of a transistor, fet, or other high power gated device which in the secondary circuit will be your motor. Then counting is fine as you mention. Just make sure you look up some motor driving circuits, so you have the proper protection, etc. But, hopefully the BStamp people have already helped you out [noparse]:)[/noparse]

    Andre'
  • P!-RoP!-Ro Posts: 1,189
    edited 2008-05-14 23:07
    I would probably count by making a loop and the number of times is recorded like this:

    time var word
    length var word
    sub:
    if in1 = 1 then
    gosub counter
    else goto turnonmotor

    counter:
    time = time + 1
    pause 5
    gosub sub

    ' here I advise you to use the high command to turn on a transistor for your motor

    turnonmotor:
    length = time * 5
    high 0
    pause length
    end

    I hope this will work for you, and if I made a mistake, I'm really sorry. Hope it works for you. (p.s., incase you didn't notice, you need to put the name of the microcontroller and the pbasic version at the top)
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2008-05-15 12:45
    I LIKE PI


    Thanks for posting this routine

    time var word
    length var word
    sub:
    if in1 = 1 then
    gosub counter
    else goto turnonmotor

    counter:
    time = time + 1
    pause 5
    gosub sub

    turnonmotor:
    length = time * 5
    high 0
    pause length
    end


    I was thing of doing the same thing along the same line as what you want to but not to control a motor

    liquid12341234

    When I press the button the time I hold the button is recorded into a variable. Then the controller will take this value and run my motor automatislly with the same duration I held the button.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam
Sign In or Register to comment.