Shop OBEX P1 Docs P2 Docs Learn Events
Need help with VERILOG and a Parallax Servo! — Parallax Forums

Need help with VERILOG and a Parallax Servo!

TobbenTobben Posts: 5
edited 2010-05-19 03:25 in General Discussion
Hi!
I have bought a Parallax Servo, http://www.parallax.com/tabid/768/txtSearch/900-00005/List/0/SortField/4/Default.aspx
I'm working on a project, where I need the servo to go to 0 degrees and to 180 degrees.
I use a Altera DE2 card and Quatus II.

Anyone that knows how to make·a block in verilog to do this?

Thanks from a Norwegian student!smile.gif

Comments

  • TobbenTobben Posts: 5
    edited 2010-05-13 11:20
    I forgot to say that there is to clock inputs on the card, one on 50 MHz, and on on 27 MHz.
  • FranklinFranklin Posts: 4,747
    edited 2010-05-14 01:42
    I guess I could ask, how do you get the card to output a 1ms to 2ms pulse? That is key to controlling the servo.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • TobbenTobben Posts: 5
    edited 2010-05-14 08:14
    With verilog i can create a block to create a 1 ms and a 2 ms pulse, but I'm not sure how to write the code.. Is 1 ms 0 degrees and 2 ms 180 degrees?
  • W9GFOW9GFO Posts: 4,010
    edited 2010-05-14 09:29
    Tobben said...
    Is 1 ms 0 degrees and 2 ms 180 degrees?

    No.

    Center is 1.520 milliseconds for Futaba Servos, 1.500 milliseconds for others. A crude approximation is .010 milliseconds per degree. You will have to experiment to find the correct pulse widths for your servo. Your servo will also respond to pulse widths outside the 1 mS to 2 mS range. Each servo is different so be sure to approach the endpoints in small steps so as not to bind the servo and strip the gears.

    The servo will expect to receive a pulse fifty times every second. A little slower or faster is okay. If the pulses get too far apart it will move in a jerky fashion.

    Rich H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.

    Post Edited (W9GFO) : 5/14/2010 9:35:32 AM GMT
  • TobbenTobben Posts: 5
    edited 2010-05-14 09:50
    Okay, thanks. I've already managed to make a 1 mS puls, and with .010 mS per degree I would expect the servo to somewere between -90 degrees and 0, but the servo dosen't stop at all, and I have to cut the power.

    This is the verilog file (if anyone understands it :P )



    module impuls1ms (in,clock,s1ms,GND);

    input in,clock;
    output reg s1ms, GND;

    integer status,teller,t2000;

    initial
    begin
    status=0;
    teller=0;
    t2000=0;
    GND=0;
    end






    always @ (posedge clock)
    begin




    if (in==0)
    begin
    GND=0;
    teller=0;
    t2000=0;
    status=0;
    s1ms=0;
    end
    else
    begin

    t2000=t2000+1;
    if(t2000==5000)
    begin
    t2000=0;
    teller=teller+1;


    if (teller==195)
    s1ms=1;
    else if (teller==200)
    begin
    teller=0;
    s1ms=0;
    end
    end
    end
    end




    endmodule
  • W9GFOW9GFO Posts: 4,010
    edited 2010-05-14 17:14
    Are you sure that you don't have this (continuous rotation) servo?

    www.parallax.com/StoreSearchResults/tabid/768/txtSearch/servo/List/0/SortField/4/ProductID/102/Default.aspx

    A standard servo will go to a position and stay there.

    A continuous rotation servo keeps turning. The speed and direction it turns depends on the pulse width.

    Rich H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.
  • TobbenTobben Posts: 5
    edited 2010-05-18 12:17
    Yes I'm sure. It can only rotate 180 deg.
  • W9GFOW9GFO Posts: 4,010
    edited 2010-05-19 03:25
    So when you say "but the servo dosen't stop at all" do you mean that it hits the stop but tries to keep going? If so, it sounds like the pulse width is not actually 1.000 mS.

    Rich H

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Simple Servo Tester, a kit from Gadget Gangster.
Sign In or Register to comment.