Shop OBEX P1 Docs P2 Docs Learn Events
HB-25's and SimpleIDE — Parallax Forums

HB-25's and SimpleIDE

NWCCTVNWCCTV Posts: 3,629
edited 2014-09-05 13:08 in Learn with BlocklyProp
Has anyone at Parallax tested SimpleIDE with the HB-25's. My observations are the following: They do not work with the Servo code. I have spent the past couple of days coding 2 servos on my PropBOE board and when I ported it to my Wild Thumper, it did not work the way it is suppose to. I guess I may end up going back to Spin since I have working code for that.

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-09-04 21:09
    It sure seems strange that the HB-25 would work with Spin but not C. How about posting the C code?
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-09-04 22:34
    That's what I thought. However, there is something wrong because the below code works just fine when connected to my PropBOE with 2 Servos on pins 14 and 15.

    EDIT: Do not pay attention to the comments. I fix that after the programs work.
    int main() // main function{
    sirc_setTimeout(200); // -1 if no remote code in 0.2 s
    while(1) // Repeat indefinitely
    { 
    print("%c remote button = %d%c", // Display button # decoded
    HOME, sirc_button(2), CLREOL); // from signal on P10
    int button = sirc_button(2); // Check P10 for remote message
    if(button == 16)
    {
    servo_speed(0, 100); // P18 servo full speed CCW
    servo_speed(1, -100); // P19 servo full speed CW
    }
    else if(button == 17)
    {
    servo_speed(0, -100); // P18 servo full speed CW.
    servo_speed(1, 100); // P19 servo full speed CCW.
    }
    else if(button == 18)
    {
    servo_speed(0,100);
    servo_speed(1,25);
    } 
    else if(button == 19)
    {
    servo_speed(0,25);
    servo_speed(1,100);
    } 
    else
    {
    servo_speed(0, 0); // Set P18 speed to 0
    servo_speed(1, 0); // Set P19 speed to 0
    }
    }
    }
    
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-09-04 22:48
    Thge HB-25s have some very particular timing requirements regarding the pulse widths and the time between pulses. If your timing is off, the units will not run the motors. Also, you need to make sure that the HB-25 is alive before you start sending pulses. This is done by keeping the HB-25 "servo" pin as an input on startup until it goes high.

    -Phil
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-09-04 22:53
    Phil, I am aware of all that you are saying. I have it working just fine in SPIN. HB-25's are up and running about 2 minutes before anything else. No pause is needed as there are 2 HB-25's on the WT. The motors are turning slightly but nowhere near how they are suppose to. For instance, the reverse command only one side turns and it is very slow. Forward command same thing but only 2 wheels on one side turn. When using a turn command the motors turn at a snails pace on both sides.

    EDIT: Should I place a pause in between each of the commands? Was not needed in the spin code which I am attaching below:
    Con
    
    
    _CLKMODE = XTAL1 + PLL16X 
    _XINFREQ = 5_000_000
    
    IRP = 2 'ir receiver i/o port pin
    
    Var
    long code
    
    Obj
    
    pst : "parallax serial terminal"
    irt : "irtest"
    servo: "PropBOE Servos" 'Servo control object 
    Pub Main
    pst.start(115200)
    irt.start(IRP, @code) 'after this "code" will contain the # for button pressed or 255 if no button is being pressed
    repeat
    pst.char(1)
    pst.dec(code)
    pst.chars(32, 3)
    waitcnt(clkfreq/100 + cnt)
    if code == (16) 'done, bail
    servo.Set(0, -250) ' P14 servo full speed counterclockwise
    servo.Set (1,250)
    elseif code == (17)
    servo.Set (0,300)
    servo.Set (1,-280)
    elseif code == (19)
    servo.Set (1, 75)
    servo.Set (0, -250)
    elseif code == (18)
    servo.Set (1, 250)
    servo.Set (0, -75) 
    else
    servo.Set(0, 0) 
    servo.Set(1, 0)
    
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2014-09-04 23:29
    The Spin code probably does run more slowly, so you might need extra pauses in your C code to meet the HB-25's timing requirements.

    -Phil
  • edited 2014-09-05 00:08
    It looks like your C code is using +/- 100, but up to 300 with Spin. What if you drive the motors as hard with your C code as you do with your Spin code?

    As for HB25 timing, I usually make sure the pulse train is going before turning on the HB25s. The first print statement has a built-in 0.8 second delay to prevent PCs from trying to install the Propeller as a plug and play serial device. I think Parallax Serial Terminal has the same thing, so you should be okay there. If you delay a certain time between starting code and powering up HB25 in Spin, that same delay should be about right with C.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-09-05 06:40
    According to what I read in the servo.h file, the servo_speed command s done in percentages so 100 is 100 percent and 25 is 25 percent, etc. I will try later today to increase and see what happens.
  • edited 2014-09-05 07:53
    +/- 100 with servo_speed is for Parallax Continuous Rotation Servos.

    Full speed on the HB25s is going to be +/- 500 with the Spin and C libraries you are using.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-09-05 12:42
    Really? My bad. I had thought that since the HB-25's act the same as servos that the speeds were the same. Thanks for that info. I will modify the code and see what happens.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-09-05 13:08
    Perfect!!! All works well now. I still think Parallax needs some sort of example programs for the WT. I have been messing with this for over a year and did not realize that my speeds were set too low. I was under the assumption that I had to use the same speeds as Servos since that is what the HB-25's are similar to as far as programming goes. Any how, I am glad I got this going and now need to go on to my next issue.
Sign In or Register to comment.