Shop OBEX P1 Docs P2 Docs Learn Events
Calling All Programmers- HELP!!!!! — Parallax Forums

Calling All Programmers- HELP!!!!!

NWUpgradesNWUpgrades Posts: 292
edited 2009-06-13 15:17 in BASIC Stamp
I am having an issue with a stepper motor controller that I had posted about earlier. I have since went to themfgr's web site and found their code. The problem is I am not the best at programming and was wondering if there is anyone that can convert the code to PBasic for me, or tell me whet I need to do. I have tried known working code that John sent me some time ago, but the motor will only go CW, unless I swap the wires from the motor to the controller, then I can get it to go CCW. I am using Pin 0 for Direction and Pin 1 for Step. Thanks in advance for any help.

Here is their code:
;16c54 step motor asm;Control by pulse and signals (JP1 Removed);==========================================MODE_A BTFSC PORTB,3 ;CP pouse in? GOTO MODE_A_BACK ;CP=1 no pouse BTFSC FLAG, 0 GOTO $+2 ;high-->low GOTO MODE_A ; BCF FLAG, 0 BTFSS PORTB,2 ;when RB2 =low voltage and RB2-DIR=high,TEMP=TEMP+1 ,contrarily TEMP=TEMP-1 GOTO A_LOOP1 INCF TEMP, F GOTO A_LOOP2 A_LOOP1 DECF TEMP, F A_LOOP2 CALL STEP_RUN ;one pouse step one,so differ frequency can adjust step motor speed. GOTO MODE_A MODE_A_BACK BSF FLAG, 0 ;normal RB3=H,FLAG D0=1 GOTO MODE_A

Comments

  • $WMc%$WMc% Posts: 1,884
    edited 2009-06-12 01:49
    Take a look at EXP#27 of the Stamp Works Manual pg. 150

    I dont see how You got the code You posted to compile? But if you did thats cool.

    I dont know if the SX28 would roll with the code You posted. Its ASM and NOT BASIC


    ________$WMc%______

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA

    Post Edited ($WMc%) : 6/12/2009 1:54:55 AM GMT
  • NWUpgradesNWUpgrades Posts: 292
    edited 2009-06-12 02:02
    I am using a BS2 Stamp, Not an SX 28. I do not have the Stamp Works Manual, only the Boe Bot and the What's A Microcontroller. I got this code from the Mfgr's web site here: http://www.nbglin.com/cpjsimage/motor.txt It is from China, Which makes communicating with them directly more than difficult!!
  • $WMc%$WMc% Posts: 1,884
    edited 2009-06-12 02:08
    NW

    So You did get Your code to compile with the BS2 editor?

    _____$WMc%_______

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA
  • NWUpgradesNWUpgrades Posts: 292
    edited 2009-06-12 02:17
    No, Nt the code I posted here. The only code I can get to compile is the code I posted in my previous post.
  • Clock LoopClock Loop Posts: 2,069
    edited 2009-06-12 23:23
    I have a BS2 stamp, and know that the code you posted is not BS2 code.

    It looks like a form of assembly. I am not skilled enough to decode it. I can make out some, what you need is more info on that stepper. Like a data sheet. Or if you know its basic construction, you can try out various methods of moving known steppers. If all you have is that code, you will need to learn assembly.

    Post Edited (Clock Loop) : 6/13/2009 2:28:47 AM GMT
  • NWUpgradesNWUpgrades Posts: 292
    edited 2009-06-13 00:36
    I Know the code is not for the BS2, Which would be the specific reason I asked for PROGRAMMERS help.
  • Clock LoopClock Loop Posts: 2,069
    edited 2009-06-13 02:25
    Woah, well, you need an ASSEMBLY PROGRAMMERS help then.

    Specifically.


    You will find those guys in the SX forum.
  • NWUpgradesNWUpgrades Posts: 292
    edited 2009-06-13 02:33
    Thanks, I will copy my post there.
  • Dave-WDave-W Posts: 94
    edited 2009-06-13 02:42
    NWUpgrades
    I think it would be better if you started from scratch and use some code that already exists in the Parallax site.
    Then, you could follow the code that was provided to you that may not be complete.
    Lay out some requirements and some specs of the stepper you are aready using. Give us the input and output requirements that this system requires and what is the end results.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Dave W.
  • NWUpgradesNWUpgrades Posts: 292
    edited 2009-06-13 02:54
    I already have code, but it is not working correctly. That is why I was trying to see if someone could decipher the code I posted, since it is from the Mfgr. of the controller card. The code I have has worked in the past with other controllers, but not this one for some reason.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}


    ··· StepperDir····· PIN···· 0······················ ' direction control
    ··· StepperMove···· PIN···· 1······················ ' movement

    ··· CW············· CON···· 0
    ··· CCW············ CON···· 1

    ··· idx············ VAR···· Byte

    ··· Reset:
    ··· OUTPUT StepperDir
    ··· HIGH StepperMove····························· ' move on high-to-low transition

    ··· Main:
    ··· StepperDir = CW
    ··· FOR idx = 1 TO 100
    ··· PULSOUT StepperMove, 500
    ··· PAUSE 15
    ···· NEXT

    ··· StepperDir = CCW
    ··· FOR idx = 1 TO 100
    ··· PULSOUT StepperMove, 500
    ··· PAUSE 5
    ··· NEXT

    ··· GOTO Main
  • $WMc%$WMc% Posts: 1,884
    edited 2009-06-13 03:24
    NW

    Try google, It will surprise You.




    _____________$WMc%________

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    The Truth is out there············································ BoogerWoods, FL. USA
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-06-13 05:22
    Hi, looking at the device apart from Vdd and Vss you only have the two inputs , direction and control pulse. I feel you are perhaps going down the wrong path with the assembly code.

    Direction is straight forward , its either logic 1 or logic 0 , so set at a logic level it should go one way or the other if the provided pulses are ok and the jumpers are set right.

    Maybe you could try a regular square wave using a simple piece of code
    DO
    PAUSE 50
    TOGGLE StepperMove
    LOOP
    

    Mess with the 50 and see if it makes a difference. Go through the different combination of jumpers with each change

    Jeff T.
  • LeonLeon Posts: 7,620
    edited 2009-06-13 11:31
    The original code is assembly language for the PIC16C54. It's rather badly written.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • UnsoundcodeUnsoundcode Posts: 1,532
    edited 2009-06-13 15:17
    I think the problem is·possibly the original Pbasic code. If the stepper has a movement of 7.5 degree per step and the pulsout duration is 500 (1 mSec) then the motor is being told to move·~2 revolutions in 1 tenth of a second alternating cw / ccw. Apart from motor slip I dont think you would see much rotation in such a short period of time. I can't say for sure because I haven't dealt with steppers in this situation but it seems to me all you would see is a "twitch".

    Jeff T.
Sign In or Register to comment.