Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Assembly( moving a servo by frequency)

  1. Feb 23, 2008 #1

    I am building an automated sorter for a school project. I have to sort 3 different sized blocks. I am using a infrared sensor to do this, I determine the size of block on how long the beam is broken. When the size of block is determined, the circuit board moves a servo motor to a corresponding path, using frequency.

    My question is what is the assembly program to move the servo motor by frequency so it goes to the correct corresponding path. Ill appreciate any help on this. Thanks for understanding.
  2. jcsd
  3. Feb 23, 2008 #2


    User Avatar
    Gold Member

    Welcome to PF, Conpeats.
    This is by no way anything that I have any knowledge of. What you refer to as 'sorting by frequency' is an unknown concept to me.
    Although I don't know how to do it, it seems to me that you should be able to just feed the timer output to a compiler that feeds an appropriate 'kick' signal to a pair of solenoids. A #1 signal would do nothing, so as to allow a block to continue straight on; a #2 or #3 would fire the first solenoid to send it on another path; and a #3 alone would direct it elsewhere via the 2nd solenoid.
    Don't worry, though; someone else will be along to help you.
  4. Feb 24, 2008 #3


    User Avatar
    Science Advisor
    Homework Helper

    Are you asking about driving a stepper motor with a uP(microprocessor)?
    And how to program the uP?
  5. Feb 24, 2008 #4
    yes. Im using a 9s12mini dragon processor. Im using it to drive a servo motor and the best way to move it for me is by frequency. I already know the frequencies i just dont know how to program it
  6. Feb 24, 2008 #5
    So you need help outputting different frequencies in assembly code?

    An easy way to accomplish this is using onboard timers. I'm not sure what your processor has onboard, but microcontrollers I have worked with usually have several different timers and several different timer modes. There was one timer mode that acted like an auto-reload when the timer overflowed. for example if the timer overflowed at FFFF0H, you could set it to reload to any value such as E8F10H if needed...

    so you could change the reload value anywhere in code as needed to whatever you need to accomplish different frequencies
  7. Feb 25, 2008 #6
    Since our project is an automated sorter. How we are determining to sort the blocks is by a infared sensor (sharp gp2d12-LR) and how much time it is blocked. The longer its blocked the bigger the block. Then after we determine the block size, it slides down a chute to its designated path. We move the chute to the designated path, determined by the sensor, using a servo motor. We already know the frequencies needed to put the chute to the correct path. I am having trouble with the assembly program. I dont know how to write a program to move our servo motor using a frequency.

    I appreciate all your responses so far its helped some but im a novie when it comes to assembly.
  8. Feb 26, 2008 #7
    Is this servo motor a stepper motor?
  9. Feb 26, 2008 #8
    can you post your motor model? could take a look and see how its driven and what you need. dont know what you mean by changing frequency, like step frequency?
  10. Mar 3, 2008 #9
    well building off what I said before...here is some noob psuedo code of how i would do it (i'm a noob to assembly as well) and it might spark some ideas of your own..

    reset timer to 0000H
    wait for sensor
    start timer
    wait for sensor change
    stop timer
    store timer value
    if timer value < 5 and >10 then
    set timer reload value = 887AH
    set timer reload vlaue = 189BH
    end if

    Timer Overflow Interrupt:
    complement output

    There's a very quick draft. reload values set frequency, and the continual complementing output produces your frequency. there'd be lots more you'd have to be concerned about and also many other ways to do it (like using a LUT). and depending on how you're controlling your servo there will most likely be more outputs. this was just to hopefully spark some ideas
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook