HB-25 program?

I an working with the program HB-25 motor controller object by C J v1.4 . I am trying to find the pin out for this program but can find nothing. The documentation given is just not getting through to me. What am I missing???? 13 july 2019(sat)


  • That code (CJ_HB25_014.spin) is a library object. You'll need to specify that file in your program's OBJ section and call its methods, as needed. The pin from your propeller to the HB-25's 'W' input gets set when you call the object's config method (see it's definition below) with that pin as the first parameter... So, you get to choose which propeller pin to use.
    HB-25 pins (you need 'W' to control the HB-25 and 'B' for ground). In this case R is not connected...
    From the CJ_HB25_014.spin code:
    ' HB-25 motor controller object   By CJ
    ' v1.4                                                            (optional)
    '                                      first                        second
    ' propeller        1KΩ                 HB-25                        HB-25
    '    pin ────────────────────  W ────────────────────────────── W
    '                 not connected  R                  not connected R
    '    GND ──────────────────────  B ────────────────────────────── B
    '(propeller ground)              J present                        J removed
    '                               +12-power supply for motors      +12-power supply for motors
    '                               GND-ground(motor power supply)   GND-ground(motor power supply)
    '                                M1-motor terminal───┳──┐_        M1-motor terminal───┳──┐_ ←poor drawing of motor
    '                                M2-motor terminal───┻──┘         M2-motor terminal───┻──┘
    '         IMPORTANT: M1 should be connected to one terminal on the motor you are using, :IMPORTANT
    '         IMPORTANT: M2 should be connected to the other terminal on the same motor     :IMPORTANT
    config's definition:
    pub config(pin1, mode1, state1)  'pin, 0-single 1-dual, 0-manual 1-auto refresh, returns ID of refresh cog
    Your code:
        thePin = 14        ' Propeller pin 14 (use any pin that you desire)
        theMode = 0      ' single mode
        theState = 0       ' manual refresh
        hb : CJ_HB25_014.spin
    main myCode
        hb.config(thePin, theMode, theState)
        ' other code
    500 x 500 - 64K
    Livermore, CA (50 miles SE of San Francisco)
  • Thank you for your input. I have used the HB-25 (cube) and have made it work more or less. What you are telling me is that this program is called up-on by another program. A program that I do not know how to wright???? I will try the program that you have given me. I understand the electronic hook up to the HB-25. It is the software that is my down fall. Thank you for your software input. I will try my best to use your program to make it go. Thant you very much for your guidance. You are the flashlight in my darkness. 17 july 2019(wen).
  • GenetixGenetix Posts: 1,408
    edited 2019-07-19 - 04:14:57

    That Object has 4 PUBlic Methods that can be used by your program.
    pub config(pin1, mode1, state1)  'pin, 0-single 1-dual, 0-manual 1-auto refresh, returns ID of refresh cog
    pub set_motor1(pulse1)  'set first HB-25     [1000-2000]
    pub set_motor2(pulse2) 'set second HB-25(ignored in single mode)     [1000-2000]
    pub pulse_motors    'send pulse(s) to HB-25(s)

    Pulse_Motors is the only Method that doesn't use Parameters.

    Config needs a Pin number, Mode (0 for single or 1 for dual), and a State (0 for manual or 1 for auto refresh)
    Set_Motor1 and Set_Motor2 need a Pulse rate from 1000 to 2000 since the code will limit values to this range.
      pulse1 #>= 1000            'limit pulses to valid values
      pulse1 <#= 2000

    Referring to the code segment dgately posted.
    The CONstants section are for any values that will not change such as Pin numbers.
    The OBJects section is for any Objects that your program will use such as Parallax Serial Terminal.
    HB will be what your program uses for the HB25 Object, but the actual Object is called CJ_HB25_014.spin
    Your program will then have a series of PUBlic or PRIvate Methods depending on what it is doing.
    PUBlic Methods can be called by another program will PRIvate Objects can only be used in the same program they are in.

    I like to create a Setup or Initialization Method.
    ' HB25 Object Test Code
    ' *** This is a Comment. ***
    CON     ' Constant Declarations
        HB25_Pin = 14        ' The HB25 is connected to Pin 14
        SingleMode = 0     ' Use only a single motor
        DualMode = 1     ' Use both motors
        HB25_Mode = SingleMode     ' Set the HB25 to use only a single motor
        ManualState = 0     ' The HB25 State is manual refresh
        AutoState = 1     ' The HB25 state is auto-refresh
        HB25_State = AutoState       ' Set the HB25 state to manual refresh
        M1_Pulse = 1500     ' Motor 1 Pulse rate (1000 - 2000)
    VAR     ' Variable Declarations
        ' None at this time
    DAT     ' Data (EEPROM) Declarations
        ' None at this time
    OBJ     ' Object Declarations
        HB25 : CJ_HB25_014.spin     ' HB25 Object
    PUB Initialization     ' Initialize the HB25
        HB25.Config(HB25_Pin, HB_25_Mode, HB25_State)     ' Configure the HB25
        HB25.Set_Motor1(M1_Pulse)     ' Set the Motor 1 Pulse rate
    PUB Main     ' Main Method (Yours)
        REPEAT     ' Repeat forever
          ' Place any code to repeat AT LEAST 1 space under it.
          HB25.Pulse_Motors     ' Pulse the Motor
          waitcnt (clkfreq/2 + cnt)     ' 1/2 second delay
        ' Any code here will not REPEAT because it is not under REPEAT

    CONstants allow you to quickly change the code.
Sign In or Register to comment.