Shop OBEX P1 Docs P2 Docs Learn Events
New dynamixel ax12+ servo driver object 'dynacom' — Parallax Forums

New dynamixel ax12+ servo driver object 'dynacom'

ratronicratronic Posts: 1,451
edited 2011-01-15 17:47 in Propeller 1
I just submitted this to the object exchange. It is a driver object to use with dynamixel ax12+ digital servos up to 1megabit connection rate. These guys are pretty neat - they have over 200 oz/inch torque and provide feedback for current position, voltage, temperature and other things. Attached is a video showing the arm I am using it with and a spin program 'dyna-arm' that uses just some of it. If anyone has a problem with the program,·let me know.

Edit : Updated to version DynacomV3.spin 10/6/11. You can now change the baud rate for the dynamixels. It now allows using continuous rotation mode. When using the writedata method to write to a 2 byte control register i.e. goal position, moving speed, etc. write the value (up to 11bits) to the first byte address of the 2 byte control register and the program will write the low/high bytes for you. Also updated the example use file to give examples of using the methods.

Edit2: 9/10/13 added version 4 now returns directional torq, can set servos between servo and continuous rotation modes

http://www.youtube.com/watch?v=4gsbQlyYEx4

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
···································Fix it, if ain't broke!


D Rat

Dave Ratcliff N6YEE

Post Edited (ratronic) : 6/9/2010 2:25:40 PM GMT

Comments

  • hover1hover1 Posts: 1,929
    edited 2010-05-05 00:01
    Nice one Dave! I love the feedback from these servos. And the networking. I will be getting a few of these when I set up my new shop in a month.

    One observation. The CD_LTC1298 object was not included in the attachments. It only took me a minute to find in in the Object Excahange. I made an attachment with all objects included for those that are OBEX challanged. tongue.gif

    Jim
  • Cluso99Cluso99 Posts: 18,069
    edited 2010-05-05 00:51
    Dave: Very impressive video ! Congratulations.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Links to other interesting threads:

    · Home of the MultiBladeProps: TriBlade,·RamBlade,·SixBlade, website
    · Single Board Computer:·3 Propeller ICs·and a·TriBladeProp board (ZiCog Z80 Emulator)
    · Prop Tools under Development or Completed (Index)
    · Emulators: CPUs Z80 etc; Micros Altair etc;· Terminals·VT100 etc; (Index) ZiCog (Z80) , MoCog (6809)·
    · Prop OS: SphinxOS·, PropDos , PropCmd··· Search the Propeller forums·(uses advanced Google search)
    My cruising website is: ·www.bluemagic.biz·· MultiBlade Props: www.cluso.bluemagic.biz
  • Mike GMike G Posts: 2,702
    edited 2010-05-05 17:08
    Nice job Dave. One comment, if I read the code correctly your driver assumes 1Mbps. If a user updates the AX-12 baud register (0x04), they'll need another device like a USB2Dynamixel to reset the baud or they will need to modify the driver appropriately.

    This PASM driver will handle all the Dynamixel baud settings.

    Post Edited (Mike G) : 5/5/2010 5:13:53 PM GMT
  • ratronicratronic Posts: 1,451
    edited 2010-05-05 18:01
    @ Mike G = dynacom is a simple driver I came up with to communicate at 1m. So the pasm code doesn't allow for a different baud rate. I ran into the problem with the accidently changed baud while I was using Mike Gebhard's dynabus. Even though his code allows for changing the baud rate - when you don't know what it's changed to that's the problem. So I think maybe I will implement a protective mechanism to keep dynacom from allowing changes to the baud rate address 4. It only works at 1m baud.

    edit: sorry Mike I didn't realize that was you! Thank you for the dynabus code that I followed to make this. I'm not sure why anybody would want to use a slower baud rate.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ···································Fix it, if ain't broke!


    D Rat

    Dave Ratcliff N6YEE

    Post Edited (ratronic) : 5/5/2010 6:12:22 PM GMT
  • Mike GMike G Posts: 2,702
    edited 2010-05-05 18:14
    That's why you'll find a start and stop method. Fire up a COG at whatever baud and ping. When you get a hit either send the reset instruction or stay at that the current baud.

    Edit: People want to use a lower baud because the AX-12 allows for different baud rates. It makes the Propeller a more useful AX-12 tool. Just a suggestion smile.gif

    Post Edited (Mike G) : 5/5/2010 6:21:49 PM GMT
  • ratronicratronic Posts: 1,451
    edited 2010-05-05 18:23
    @ Mike , the problem I mentioned above I had when I was playing with dynabus spin and was my own mistake accidently changing the baud rate to a unknown value - do you have a method of communicating with a dynamixel thats been set to a unknown rate?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ···································Fix it, if ain't broke!


    D Rat

    Dave Ratcliff N6YEE
  • Mike GMike G Posts: 2,702
    edited 2010-05-05 19:10
    Ping the Dynamixel bus at different baud rates until you get a response.

    If you want to do it on the fly, then create a method that gets/sets the baud value in HUB memory. Read the memory location into you PASM code.

    There's the the brute force method. Send the reset instruction using the broadcast ID at all possible baud rates.
  • ratronicratronic Posts: 1,451
    edited 2010-05-05 20:10
    Thanks for that Mike, I am going to go play with that right know! I was thinking of changing the way of the transmit bit time period delay back to your dynabus way of doing it, I never have had a problem with the transmit part of dynabus - just the receve. I am no where near your capabilty when it comes to programming , but I was unable to come up with a way to deal with the receive bit period·other than to make it set i.e. at 1mhz. Have you exhausted all possibiltys to get it tighter?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ···································Fix it, if ain't broke!


    D Rat

    Dave Ratcliff N6YEE

    Post Edited (ratronic) : 5/5/2010 8:52:58 PM GMT
  • Mike GMike G Posts: 2,702
    edited 2010-05-05 22:26
    I didn't know there was a problem with the receiver so I never though about tightening up the code.

    Do you have any unit test code that highlights the problem?

    Post Edited (Mike G) : 5/5/2010 11:12:46 PM GMT
  • ratronicratronic Posts: 1,451
    edited 2010-05-05 23:54
    I justed tryed to duplicate the problem I was having and its not showing up!· I mainly came up with this for beginners to use the dynamixel easier. Here is the code I was trying with dynabus and also·the same code using dynacom. I spent a long time deciphering dynabus it's complicated. If it were not for your code I woudn't even be using dynamixels with the propeller. I thought I was really on to something when you sent me an email about using waitcnt. I have modified dynacom to not let the user change the baud rate register (4) with it. They will have to use the other controller/program if they want to change it. This will work for dynamixels that are set to 1m baud ONLY!(Like they are when new, out of the box)

    here are the two examples that do the same thing - both turn off the torq for servo 1 and then keep up dating the screen with it's current position using prop i/o #8

    dynabus

    dBus.Start(8, 1_000_000)····························
    bytearray[noparse][[/noparse]0] := 0·················
    writedata(1, 24, 1)···············
    repeat····························
    · readdata(1,36,2)················
    · tv.out(1)·······················
    · l := dbus.getaxbuffer(5)········
    · h := dbus.getaxbuffer(6)········
    · n := h * 256 + l················
    · tv.dec(n)·······················
    · tv.str(string("·· "))

    dynacom
    ········
    dy.start(8)··························
    dy.srvtqoff(1)·············
    repeat·····················
    · tv.out(1)················
    · tv.dec(dy.getsrvpos(1))··
    · tv.str(string("·· "))····

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ···································Fix it, if ain't broke!


    D Rat

    Dave Ratcliff N6YEE

    Post Edited (ratronic) : 5/6/2010 1:01:04 AM GMT
  • ratronicratronic Posts: 1,451
    edited 2010-05-06 12:39
    Now this morning I tryed this test again, and the test I made for dynabus is randomly flashes bigger #'s in the read out (several times a second) but the same test using dynacom is stable. Maybe I have not figured out the proper use of dynabus. I attached both tests for you to look at Mike. This is one of the·reasons I made the mod to the receiver bit delay period. I have no problem checking a register a single time, only when it accessed rapidly. Let me know if I was just using it wrong.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ···································Fix it, if ain't broke!


    D Rat

    Dave Ratcliff N6YEE

    Post Edited (ratronic) : 5/6/2010 12:55:33 PM GMT
  • Mike GMike G Posts: 2,702
    edited 2010-05-06 14:20
    Don't know... dynacom and dynabus appear to be the same?

    Why are you using the old DynamixelAsmBus driver (4/2008) and not the December 2009 build?
  • ratronicratronic Posts: 1,451
    edited 2010-05-06 14:29
    I will have to update to the new dynaasmbus driver. I am looking at it right now using the same setup, just flopping between the two programs. Do you have a link to the new driver?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ···································Fix it, if ain't broke!


    D Rat

    Dave Ratcliff N6YEE
  • Mike GMike G Posts: 2,702
    edited 2010-05-06 14:34
    The new driver is in this thread. It's the same one I emailed it to you a few weeks ago.
  • ratronicratronic Posts: 1,451
    edited 2010-05-06 14:40
    Ok I will have to give it try. I just want to make sure that what I submitted to the obex is developed from your latest! I would have never been able to come up with your assembly routine on my own. Thanks for all of your assistance Mike.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ···································Fix it, if ain't broke!


    D Rat

    Dave Ratcliff N6YEE
  • ratronicratronic Posts: 1,451
    edited 2010-05-06 15:08
    That worked stable! I am assuming it's the one named 'bioloid dynabus updated' in the obex, but anyhow it works stable. I will have· to study that one and see if I can modify mine and reenable the baud changes - Thank you.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ···································Fix it, if ain't broke!


    D Rat

    Dave Ratcliff N6YEE
  • ratronicratronic Posts: 1,451
    edited 2010-06-08 22:27
    I just updated the top post in this thread and the object exchange with a version that now let's you change the connection rate to the dynamixels from the propeller. They can be set from anywhere from 7.843k to 1M baud.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ···································Fix it, if ain't broke!


    D Rat

    Dave Ratcliff N6YEE

    Post Edited (ratronic) : 6/9/2010 2:18:28 PM GMT
  • Duane DegnDuane Degn Posts: 10,588
    edited 2010-06-09 03:15
    Thanks Dave and Mike.· I love the AX-12s.

    Dave, I assume you mean the baud can be set anywhere from 7,843bps to 1M.· 7843k would be pretty fast.

    Thanks for the objects, I'll try them soon.· I have a bunch of AX-12s in a robot arm I want use in my chemistry work; these objects·should help.

    Duane Degn
  • ratronicratronic Posts: 1,451
    edited 2010-06-09 04:36
    Oops, that was a typo, yes 7.843k to 1M baud

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ···································Fix it, if ain't broke!


    D Rat

    Dave Ratcliff N6YEE
  • winterbottom321winterbottom321 Posts: 3
    edited 2011-01-14 19:10
    I'm running my ax-12+ in cont rotation mode by setting the goal positions to 0 as the manual explains. I can then get it rotating at various speeds by setting address 32 to anything from 0 to 1023 but I can't get it to change rotation direction. The manual says to flip bit 10 of address 33 under goal speed setting (page 18 in the manual)? I tried writing:

    writedata(1, 33, 1)

    and this

    writedata(1,32, 1024) (thinking it would fill the first byte at full speed and then change the next bit in # 33)

    both don't work.

    Help?
  • ratronicratronic Posts: 1,451
    edited 2011-01-14 20:15
    winterbottom321 - when I wrote this I didn't consider continuous rotation mode. I have attached a revised DynacomV2.spin program (also in the first post and the obex) that will let you do it. When set for operating in continuous rotation mode you use these #'s - 0 to 1023 (for 0 to full speed counterclockwise), and 1024 to 2047 (for 0 to full speed clockwise) to register 32. My program will automatically write the low and high byte values for you. This goes for any of the two byte control registers. Just write the full value to the first byte of a two byte control register.

    Edit: I removed the limitation on the writedata method to write a number bigger than 1023. I know a byte is limited to 255 but because of the communication of the prop to the ax12 you can write a 11bit # to the lowest byte in the two byte control registers in my program. Also the ax12 requires both the low and high bytes communicated to it in a single packet on the communication side of things so you can't write to the high byte by itself in the two byte control registers.

    Example: if the dynacom object is named dy - dy.writedata(1, 32, 2000) - that will set servo id#1 register's 32 and 33 to 2000 almost full speed clockwise.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-01-15 11:16
    I had an AX-12+ with an unknown baud rate, so I wrote some code that will find the buad rate or ID of an AX-12+. The code I wrote uses Dave's object.

    I posted the code a while back but I thought I'd share a link to it here in case anyone else has the same problem.

    It's also relatively easy to change the baud and/or ID using the object. I think in Dave's code you can only have one AX-12+ connected when you change its ID (which is a good idea to keep code small). My code asks for the old ID and only changes the one controller's ID. The object is intented as untility and is only useful when the Propeller in connected with a PC to interface with it. You wouldn't want all these seldomly used features to blot your robot's code.

    Thanks again Dave and Mike.

    Duane
  • ratronicratronic Posts: 1,451
    edited 2011-01-15 11:55
    Thanks for that link Duane. I have a few times in the past accidentally changed the baudrate to an unknown value - what a PITA. So what I do is I send a reset to the broadcast id $fe at all the possible baud rates. Then when it's done you will have an ax12 thats set to id1 and 1m baud. When I first came up with this program (from the work of Mike G.), I once accidently set the baud rate to 2m baud. The prop won't talk to it that fast (with this program) but the CM5 controller that came in my Bioloid begginner kit would. That is one reason I have the writedata method setup to protect register 4 (baudrate) from being set to 0 (2m baud).
  • Duane DegnDuane Degn Posts: 10,588
    edited 2011-01-15 14:09
    Dave, I was afraid I had set mine to 2M baud. I figure if I had, I'd have to write an all PASM routine that could hopefully communicate fast enough using a hard coded message (reset).

    The code I linked to tries to ping to the AX-12 on each baud rate. The AX-12 will answer a ping on the wrong (but close) baud sometimes so I also check register 4 to see if the baud pinged with is really its correct baud. I think your reset idea is probably better in many cases; I didn't want to go that route since I was curious what the settings were and, as I mentioned, it's possible to communicate with the AX-12 with the wrong rate so I wouldn't have been sure what it had been set to if I had sent a reset command.

    I also modified your smartarmmouse object to use with a RC controller. It's a lot fun. Thanks for that program too. I think your smartarmmouse (which is great as is) could be even better with some ramping. I haven't tried ramping with my arm yet but I have a camera mount and I made the speed of the AX-12 proportional to it distance to the target position. I thought it smoothed the movement a lot. It takes an extra cog to continously montitor position and update the speed. One of these days I'm going to try some thing like that with my robot arm (I think I have the same kind you have).

    Duane
  • ratronicratronic Posts: 1,451
    edited 2011-01-15 17:47
    This is the method I use to reset an ax12 to ID# 1 @ 1m baud for sure and it only takes 7 or 8 seconds at most. From there it's easy to change id/baud to what ever you want. Be carefull though, it will change every ax12 that's connected to ID#1 @1m baud.

    Edit: this is for when the baudrate and or ID is unknown
    Con            'dynamixel ax12 servo reset  servo reset to ID#1 at 1m baud       
      _clkmode = xtal1 + pll16x        'WARNING - every servo connected will be reset
      _xinfreq = 5_000_000                                                           
     
      dyna = 8     'prop i/o where ax12 is connected                                 
     
    Var                                                                              
     
    Obj                                                                              
      db : "vga_text"     'db = debug                                                
      dy : "dynacomv2"                                                               
     
    Pub main | i                                                                     
     
      db.start(16)                                                                   
      db.str(string("Wait several seconds for DONE",13,13))                          
      repeat 4                                                                       
        repeat i from 1 to 255                                                       
          dy.start(dyna, 2000000/i+1)                                                   
          dy.reset($fe)                                                              
      db.str(string(13,"DONE - servo now @ID#1 @1m baud"))
    
Sign In or Register to comment.