Shop OBEX P1 Docs P2 Docs Learn Events
Stingray motor/motion control object posted in obex — Parallax Forums

Stingray motor/motion control object posted in obex

Nico SNico S Posts: 9
edited 2010-04-09 13:09 in Robotics
Hi all,

Just posted my first object in obex. smile.gif
As i started recently with the stingray robot and the propeller chip programming, my first project was to create a dedicated·object for easy control of the movements.
The object is written in SPIN and PASM, and doesnt use other objects.
The PASM code doesnt make use of counters to generate the PWM signal as i want to use the counters for future wheel/motor encoders.
To control the motors the object generates a 1Khz PWM signal.
It supports Forward, backward, turning, rotation movements with speed and ramping control.
As this is my first real object please feel free to comment, give tips/hints on the code.

The object can be found under Stingray motor / motion control in the motor control section.

Have fun !
Best regards,
Nico Schoemaker



·

Comments

  • mugurmugur Posts: 105
    edited 2010-03-05 00:36
    Great news. Thank you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    images-team.ro
  • ercoerco Posts: 20,256
    edited 2010-03-05 04:17
    Good news, Nico.

    Does anybody have their Stingray driveable by IR remote?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·"If you build it, they will come."
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2010-03-05 18:17
    Nico,

    It is nice to see customer contributions. This month has seen the start of the Encoder object for the Stingray. Once I have sufficient progress I will start a thread on that.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage

    Parallax Engineering
    ·
  • WhitWhit Posts: 4,191
    edited 2010-03-05 19:13
    It sure would be nice if everyone who added a Stingray object would include the word "Stingray" in the title - like Nico did. This would make search's easy.

    Great work Nico!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Whit+


    "We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths." - Walt Disney
  • Nico SNico S Posts: 9
    edited 2010-03-05 22:36
    Thanks !!
  • hover1hover1 Posts: 1,929
    edited 2010-03-05 23:22
    Search !? What search? ?!? tongue.gif

    It will be here soon. Jim E is working on it

    Jim
    Whit said...
    It sure would be nice if everyone who added a Stingray object would include the word "Stingray" in the title - like Nico did. This would make search's easy.

    Great work Nico!

  • Chad_CChad_C Posts: 2
    edited 2010-04-08 02:33
    Good Code.
    The only issue I was having with it was that I was really trying have the ability to control the motor speeds individually. I tried making a new PUB called TurnWheel(LSpeed, RSpeed) where 'LSpeed' was the left motor speed and 'RSpeed' was the right motor speed. For some reason, when executing TurnWheel with LSpeed = -30 and RSpeed = 30, the Left motor just stops while the right motor keeps spinning at the proper speed. I tried going through the PASM code. I could follow the code down to where the C flag should be set but I had issues fixing it.

    Using the PUB code below to control the motor speeds individually, is there anything that I'm missing or why this code will not work? I have not modified the assembly portion of the code or any of the other routines in the SRMotorControl.spin. I tried uploading the .spin code as an attachment just in case.
    Any Help would be appreciated.

    Thanks,
    Chad_C

    PUB TurnWheel(LSpeed,RSpeed)

    if (LSpeed == 0) AND (RSpeed == 0)
    MoveForward(0)

    repeat until vCommand.byte[noparse][[/noparse]0] == 0 'Wait until current getCommand is processed by the cog

    LSpeed <#= 100 'Limit Speed to 0..100
    LSpeed #>= 0

    RSpeed <#= 100 'Limit Speed to 0..100
    RSpeed #>= 0

    vCommand.byte[noparse][[/noparse] 1] := LSpeed 'Set leftspeed to LSpeed
    vCommand.byte[noparse][[/noparse] 2] := RSpeed 'Set rightspeed to RSpeed
    vCommand.byte[noparse][[/noparse] 0] := 1 'Update flag

    Post Edited (Chad_C) : 4/8/2010 2:38:24 AM GMT
  • Roy ElthamRoy Eltham Posts: 3,000
    edited 2010-04-08 02:57
    These lines are limited the values to between 0 and 100:

    LSpeed <#= 100 'Limit Speed to 0..100
    LSpeed #>= 0

    RSpeed <#= 100 'Limit Speed to 0..100
    RSpeed #>= 0

    So your -30 is getting clamped to 0. Change those 0's to -100's and see if that works?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Check out the Propeller Wiki·and contribute if you can.
  • Chad_CChad_C Posts: 2
    edited 2010-04-09 00:10
    Thanks for the response. I'm an idiot LOL. I can't believe I overlooked that; it was driving me nuts. Changing the LSpeed and RSpeed values did fix it.

    Thanks Again,
    Chad_C
  • WhitWhit Posts: 4,191
    edited 2010-04-09 13:09
    Chad_C,

    Glad you posted! - no telling how many people you helped. No question is a dumb question. Glad you are up and running.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Whit+


    "We keep moving forward, opening new doors, and doing new things, because we're curious and curiosity keeps leading us down new paths." - Walt Disney
Sign In or Register to comment.