Shop OBEX P1 Docs P2 Docs Learn Events
Controlling two HB25 Motor Controllers with the Lynxmotion PS2 Controler — Parallax Forums

Controlling two HB25 Motor Controllers with the Lynxmotion PS2 Controler

BrianmcmBrianmcm Posts: 33
edited 2009-02-08 00:47 in Propeller 1
Newbie needs some help. I'm trying to create a Spin program that allows me to control two HB25 Motor Controllers using the Lynxmotion PS2 wireless controller.·Using the PS2 objects·off of the exchange I was able to·"map" the·two joysticks to get the full·motion range, 0-255.·I then created a simple formula to convert the output to a·pulse variable to send to the HB25.·The HB25 object used·generates a pulse range from 900 to 2090, also from the exchange. Now I'm trying to get those variables to the HB25; the intent is for individual motor control. I've included the program. When I download it no errors are generated, but I don't have any response from the HB25's. I've tested them using the HB25 object that is part of the enclosed code to verify they work.
Any guidance would be most helpful.

Thank you
Brian

Comments

  • John AbshierJohn Abshier Posts: 1,116
    edited 2009-02-07 22:30
    You are mixing integers and floats in
    HBLeft := ((fmath.FMUL(PS2.get_LeftY, 4.6875)) + 900) <# 2090
    HBRight := ((fmath.FMUL(PS2.get_RightY, 4.6875)) + 900) <# 2090
    Fmul requires two floats and I would bet that PS2.get_LeftY returns and integer. You then add the float from fmath to the integer 900
    HBLeft := (fmath.FTrunc(fmath.FMul(fmath.FFloat(PS2.get_LeftY),4.6875)) + 900) <# 2090 or somithing like this should work

    John Abshier
  • BrianmcmBrianmcm Posts: 33
    edited 2009-02-07 23:21
    John,

    Thanks for the reply, unfortunately that didn't solve the problem. I seem to stuck trying to get the variable reated from the get.LeftY or get.RightY to the PUB that "drives" the controller. Somehow I'm not getting the resultant to the "Motor" method correctly.

    I've tried a variety of approaches, with no success.

    THanks again
  • John AbshierJohn Abshier Posts: 1,116
    edited 2009-02-08 00:47
    I didn't read past the first error. You are repeatedly calling Motor which makes two cognew calls. That won't work because you will run out of cogs quickly. When I used the HB-25 I just used the Servo32v3 object in the Propeller Library since I also needed it to control my steering servo. There is an HB-25 object in the Object Exchange. I have not used it.

    John Abshier
Sign In or Register to comment.