Shop OBEX P1 Docs P2 Docs Learn Events
HB-25 controller and BS2 problems!!! — Parallax Forums

HB-25 controller and BS2 problems!!!

xcqnudtxcqnudt Posts: 11
edited 2007-07-17 04:22 in BASIC Stamp
Hello
I am a chinese user.Last week, i bought a HB-25 motor controller with BS2.
Using the controller,i have some questions.i think you can help me,thanks!

1. i wanna to make the dc motor forward 220ms,then stop 2.15s,next reverse 210ms,and then stop. i write the following code.

·' {$STAMP BS2}
·' {$PBASIC 2.5}
·'
[noparse][[/noparse] I/O Definitions ]
·HB25··········· PIN···· 15············· ' I/O Pin For HB-25
·'
[noparse][[/noparse] Variables ]
·index·········· VAR···· Byte··········· ' Counter For Ramping
·DEBUG "the program is beginning!!", CR
·Main:
·· FOR index = 1 TO 10
···· PULSOUT HB25, 1000·········· ' Motor 1 Full Forward for (20+2)*10=220ms
····· PAUSE 20
·· NEXT
·· FOR index =1 TO 100··········· ' Motor 1 stop for (20+1.5)*100=2.15s
···· PULSOUT HB25,750
···· PAUSE 20
·· NEXT
·· FOR index = 1 TO 10··········· ' Motor 1 Full reverse for (20+1)*10=210ms
····· PULSOUT HB25,500
····· PAUSE 20
·· NEXT
·· FOR index =1 TO 100··········· ' Motor 1 stop for (20+1.5)*100=2.15s
···· PULSOUT HB25,750
···· PAUSE 20
·· NEXT
·· DEBUG "the program is done!"
·END

··· While downloaded the program, the motor runs continual all the time. that is to say, HB-25 controller cann't control the motor right with the code.But if i change "END" into "STOP",i find the motor runs forward for a while(about 220ms?? i am not sure!),then stops permanently.But if i add a "DO...LOOP",the motor can be controlled right.i am puzzled to that,please interpret the phenomenon.
··
··· Then i write another one as follows, however,the motor can be controlled right.But i am not sure whether the program is right??!Please help to me!Thanks again.

·' {$STAMP BS2}
·' {$PBASIC 2.5}
·'
[noparse][[/noparse] I/O Definitions ]
·HB25··········· PIN···· 15············· ' I/O Pin For HB-25
·'
[noparse][[/noparse] Variables ]
·index·········· VAR···· Word··········· ' Counter For Ramping
·'
[noparse][[/noparse] Initialization ]
·DO : LOOP UNTIL HB25 = 1··············· ' Wait For HB-25 Power Up
·LOW HB25······························· ' Make I/O Pin Output/Low
·PAUSE 5································ ' Wait For HB-25 To Initialize
·PULSOUT HB25, 750······················ ' Stop Motor 1
·Main:
· FOR index = 1 TO 10·················
····· PULSOUT HB25, 1000·········· ' Motor 1 Forward
····· PAUSE 200
····· PULSOUT HB25, 750
····· PAUSE 1000
····························
····· PULSOUT HB25, 500·············· ' Motor 1 reverse
· ····· PAUSE 200
· ····· PULSOUT HB25, 750
· ····· PAUSE 1000
··NEXT
·STOP

2. How to control the DC motor forward and reverse for same time?? For example, first make the motor run forward for 200ms,then stop for 1s,next reverse for··· 200ms,and then stop.As we all know, it is (20+2=22ms) the motor runs forward once , but 21ms the motor runs reverse.i don't know how to program.Please give··· me the code,thanks.

3. i don't know the time controller execute an instruction, whether i consider the time or not,while programming.For example,in book"Robotics with the Boe-Bot"(this book is in the attachment) page 82,the 13th line mentioned "and it takes around 1.3ms for the loop to execute" and in page 83,the 19th line mentioned "1.6ms ---- code overhead",i am puzzled by these two numbers, how many instructions are executed in 1.3ms,1.6ms respectively?? 1.6ms represents what,the time code is compiled 、 the time instructions are executed or others???

4. i wanna to control Maxon DC Brushless motor--EC6(with controller),but i don't know how to connect to HB-25??pin4 to M1,pin5 to M2??Or the output of the control to M1,M2??EC6-manual is in the attachment.Thanks!




Post Edited (xcqnudt) : 7/13/2007 3:39:08 AM GMT

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-07-13 04:15
    xcqnudt said...(trimmed)
    ··· While downloaded the program, the motor runs continual all the time. that is to say, HB-25 controller cann't control the motor right with the code.But if i change "END" into "STOP",i find the motor runs forward for a while(about 220ms?? i am not sure!),then stops permanently.But if i add a "DO...LOOP",the motor can be controlled right.i am puzzled to that,please interpret the phenomenon.
    The reason this is happening is actually covered in the documentation under the section on Safe Power-Up and Power-Down.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • azmax100azmax100 Posts: 173
    edited 2007-07-13 05:51
    Hi,

    You should switch on the BS2· before switching on the HB25. If u are using same switch for both BS2 & HB25 try to seperate them. When switch off u have to switch of the HB25 first.

    As Chris advised please refer to the HB25 documentation.

    Hope this will help.
  • CCraigCCraig Posts: 163
    edited 2007-07-13 15:32
    If you have a spare pin available on the BS2, you could use it to power on the HB25. You would then, have to do a shutdown through software. Much easier with two switches.

    HTH, Chris

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm not scared of your robot. I'm covered by Old Glory (youtube)
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-07-13 15:45
    What the HB-25 really wants is to have the I/O line LOW when it powers up. If the BASIC Stamp immediately makes its output pin LOW when it senses a HIGH from the HB-25 that should work just fine. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • xcqnudtxcqnudt Posts: 11
    edited 2007-07-14 02:50
    first,thanks,Chris Savage 、CCraig、azmax100

    i don't think i explain it clearly, i am sorry for that!

    My BS2 controller is placed on the BOE(board of education,Rev. c, serial not usb)!

    i am sure i follow the sequence about Power-Up and Power-Down!

    But i get the same result, i have been puzzled for a long time,please help me!!

    u can download my code and try, thanks everyone

    And what's your answer to question 2,3,4??

    Post Edited (xcqnudt) : 7/14/2007 4:13:45 AM GMT
  • xcqnudtxcqnudt Posts: 11
    edited 2007-07-14 02:52
    Chris Savage :

    yesterday, i sent u an e-mail, received or not??

    i think u can help me, thanks again!!
  • xcqnudtxcqnudt Posts: 11
    edited 2007-07-14 04:12
    later, i will upload the experimental picture!!
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-07-14 18:47
    Hello,

    Yes, I received your e-mail however it was a copy of everything you already posted to the forum. In order to not duplicate efforts we will tend to answer in the forums where everyone can benefit from the information exchanged. I don’t know if I understood you, but I did understand your code, and that is what I was referring to and pointed out in the documentation. When you use an END statement the lines on the BASIC Stamp change every 2.3 seconds and cause invalid pulses to be received by the HB-25. Your code should never END. You should use STOP or keep it within a LOOP.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • xcqnudtxcqnudt Posts: 11
    edited 2007-07-15 02:17
    the experimental picture is in the attachment!!
    853 x 640 - 70K
  • xcqnudtxcqnudt Posts: 11
    edited 2007-07-15 02:19
    Chris Savage:

    what's your answer to the question 2,3,4???
  • xcqnudtxcqnudt Posts: 11
    edited 2007-07-15 13:59
    please help me , thanks !!
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-07-15 18:58
    2. The answers are available in several places. First of all I would recommend re-reading the manual you attached as well as our “What’s a Microcontroller?” manual. Then if you go through the HB-25 documentation you will see that the HB-25 does not require continuous pulses like a servo. So if you need to move for a specific time one way and switch you could just use the PULSOUT followed by a PAUSE of the time you required and then the next pulse value.
    3. See question number 2.
    4. I don’t know anything about this motor, but from the looks of it you cannot control it with an HB-25. It likely takes a special controller. The Motor seems to have separate power and motor winding inputs.

    I wanted to mention that it isn’t polite to prompt forum members for replies when you don’t get an immediate reply. Many of us spend considerable time on these forums replying to posts and we reply when we have something useful to offer. Please do not duplicate these requests to other forums, e-mail and private messages and allow some time for people to reply. Two minutes is not enough. We want to help, but you must understand that the forums are not an instant response system and you don’t always get an answer for every question posted. Take care.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • xcqnudtxcqnudt Posts: 11
    edited 2007-07-16 00:56
    first i am sorry to everyone for my action, and i promise i will obey the rule of the forum.

    next thanks Chris Savage for your answer to question2-4!

    i agreed to your answer to question4, i thought HB25 can't control the Maxon EC6 DC brushless motor, which was proved yesterday!!

    But to question 2 and 3, i don't think u give me the exact answer , can u give me the your BS2 code to control DC motor forward and reverse for 200ms ???(after the motor runs forward 200ms , there is 1s stop, then reverse 200ms)

    whether i follow your step, i can control the motor freely??

    i read the book "what's a microcontroller?" , but i don't know i should refer which part is useful to my question 2 and 3!!please explain it in detail!
  • CCraigCCraig Posts: 163
    edited 2007-07-16 14:57
    Question 2 and 3 are related.

    You need to re-read and study the 'Robotics with the Boe-Bot' book.

    Starting on page 75, Activity #6. 'ControlServoRunTimes.bs2' and 'BothServosThreeSeconds.bs2' on pages 82 to 84 will show you everything you need to know.

    In the WAM (What's a Microcontroller) book, start on page 114, 'ServoTest.bs2' and continue from there.

    The run times for a loop can vary depending on how big (how many instructions) they contain. The best way to determine this is with a scope and toggle a pin. If you have a scope you can find out how long your loop runs.

    Please NOTE: I have no idea what 'mode' you are running on your HB-25. You may not need to send it constant pulses. Please refer to the HB-25 manual.



    HTH, Chris

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'm not scared of your robot. I'm covered by Old Glory (youtube)
  • xcqnudtxcqnudt Posts: 11
    edited 2007-07-16 15:29
    thanks CCraig·for your answer!!

    NOTE: the HB-25 is working in mode 1(the J jumper is in place)!

    i think that is obvious in the experimental· picture (in the attachment )!!
    ·
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-07-16 16:29
    The answer is available in the HB25 documentation.· "Hit the books."

    !·· !!·· !!!

    But, anyway:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
     
    ' -- 1.0ms Full REVERSE, 1.5ms Neutral (off), 2.0ms Full Forward
     
    HB25  PIN  15            'P15 is the I/O used
     
    Motion:
      LOW HB25
      PULSOUT HB25, 1000     'Sends FWD pulse
      PAUSE 200
      PULSOUT HB25, 750      'Sends "STOP/Neutral" pulse
      PAUSE 1000             '1-sec stop-time
      PULSOUT HB25, 500      'Sends REV pulse
      PAUSE 200
      PULSOUT HB25, 750      'Sends "STOP/Neutral" pulse ***
      PAUSE 1000             '1-sec stop-time            ***
      GOTO Motion                                        ***
    
    

    Update -- I added a "stop/neutral" & 1-second PAUSE after the REV run for the purpose of running this in a loop.· When you don't want to run it in a loop, just omit the lines that end with the ***.

    Post Edited (PJ Allen) : 7/16/2007 4:53:53 PM GMT
  • xcqnudtxcqnudt Posts: 11
    edited 2007-07-17 01:43
    thanks PJ Allen

    i will try your code later , thank u!

    but i think your code is similar with my code in the first post!!

    the only difference is "for....next" in my code, "goto" in your code ??!!
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-07-17 04:22
    xcqnudt,

    In your program, with your FOR...NEXTs, you keep re-sending the HB25 commands.· It goes FWD and STOPs ten times, and then it goes REV and STOPs ten times.· The point is that·you should·only have to send the HB25 command/s·once, because that command·stays in effect till you send some other command (to slow down, stop, or change direction.)

    In my program (and, most importantly, the sample programs included with the documentation·-- http://www.parallax.com/dl/docs/prod/motors/HB-25MotorController-V1.2.pdf·),·the HB25·gets·commanded once, it dwells there for the PAUSE, and goes·on through the rest of the program lines.

    Has this been beat to death yet?· ??· ???
Sign In or Register to comment.