Shop OBEX P1 Docs P2 Docs Learn Events
Running multiple instances of the HB25 object — Parallax Forums

Running multiple instances of the HB25 object

DiverBobDiverBob Posts: 1,110
edited 2013-12-24 20:18 in Propeller 1
I am using the HB25.spin object from the OBEX in single mode and need to run multiple instances, one for each motor (3). It appears that each instance requires a seperate cog if I'm reading the code correctly which means this object may not be the best one to use in this instance. Any suggestions on workarounds or other HB25 object that would work better?

Thanks for the info!

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-12-23 20:58
    What about the normal servo object? Doesn't the HB-25 take input like a CR servo?

    Servo32_v9 is the latest I believe.
  • garyggaryg Posts: 420
    edited 2013-12-23 21:37
    Bob
    I'm thinking that Duane's suggestion might work out well.
    The only problem with it, is that you will need to write a routine that will initialize your HB25s.
    If you are running each HB25 separately, without them being daisy chained, After initialization, they should act like a CR servo.

    I hope this helps in some manner.
    Gary
  • DiverBobDiverBob Posts: 1,110
    edited 2013-12-24 06:27
    Good idea! Let me give this a try out today. I'm not using any of the HB25's built in routines, just running it as a PWM controller for the DC motors with a seperate feedback loop under program control. I got focused in on using HB25 objects and didn't consider other possibilities.
  • DiverBobDiverBob Posts: 1,110
    edited 2013-12-24 13:53
    The Servo object works fine in my routines. Does someone have an code example of using this object to control multiple servos? I tried a couple of ideas and they didn't pan out...
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-12-24 14:14
    I generally use a 50Hz main program loop in my servo projects. I calculate each servo position within the loop and update the servo positions.

    Post #2 of my 32-servo demo has the code I used attached to it.

    I used the same sort of control loop in my hexapod projects.

    While this technique works well for my applications, I'm pretty sure there are other ways to do this. Paul K posted code he uses in his hexapod.
  • ratronicratronic Posts: 1,451
    edited 2013-12-24 15:48
    Bob this is a simple example using the servo object that comes with the Propeller tool. You will have to play with the RAMP number to suit your needs. But with using ramping it uses 2 cogs, only 1 cog without ramping.

    Edit: changed code to set up properly
    Con                        
                                                             
      _CLKMODE = XTAL1 + PLL16X                              
      _XINFREQ = 5_000_000
      
      RAMP = 10     'higher # = longer ramping time
      
      MTR1 = 15     'prop port hb25's
      MTR2 = 16
      MTR3 = 17
      
    Var
      long a
     
    Obj
      srv : "servo32v7"
      
    Pub Main
    
                                                        
      srv.start
      srv.ramp
        
      srv.set(MTR1, 1500)   'turn off hb25's
      
      srv.set(MTR2, 1500)
      
      srv.set(MTR3, 1500)
        
      if a == 0
        srv.setramp(MTR1, 1700, RAMP)
        waitcnt(clkfreq/2 + cnt)        'wait for motor to move
    
      srv.setramp(MTR1, 1500, RAMP)
    
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-12-24 17:22
    If ratronic's code is not what you are looking for I have some code that is used with a Sony remote for IR and also a Ping and also some code @Duane Degn wrote for use with an RC Xmtr/Rcvr.
  • DiverBobDiverBob Posts: 1,110
    edited 2013-12-24 20:18
    Thanks Dave for the code example. I wasn't sure I could just set one servo after another like that.
    Having problems with the motors overshooting the target ADC value. The code I'm using stops in plenty of time but it seems to take the motor longer than expected to actually stop. I think once there is a load on the motors the overshoot will drop down. I'm still tweaking the code after a full day of experimenting with it.
Sign In or Register to comment.