Assembly to PBasic
NWUpgrades
Posts: 292
I am having an issue with a stepper motor controller that I had posted about on the Basic Stamp site. I was told that this code is in Assembly.· 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
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
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Leon
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Amateur radio callsign: G1HSM
Suzuki SV1000S motorcycle
http://forums.parallax.com/forums/default.aspx?f=5&m=348254&g=348336#m348336
http://www.parallax.com/Store/Accessories/MotorServos/tabid/163/CategoryID/57/List/0/Level/a/ProductID/65/Default.aspx?SortField=ProductName,ProductName
http://forums.parallax.com/forums/default.aspx?f=5&m=353227&g=353231#m353231
http://search.parallax.com/search?q=stepper&ie=&site=parallax&output=xml_no_dtd&client=parallax&lr=&proxystylesheet=parallax&oe=
http://forums.parallax.com/forums/search.aspx?f=7
If you need PBasic, then you are posting in the wrong forum. I would suggest you locate a forum that deals with PBasic, as this forum aimed at SX users who program in SX assembly and SX/B. If any other programmers hang out here, then great, but don't expect to find many who aren't programming SX assembly or SX/B.
Thanks,
PeterM
I think you missed the point of those links. If you navigate the Parallax website to the unipolar stepper motor they sell you can find examples on how to use it in the PDF documentation on that product page. It shows how to connect it to a BASIC Stamp and also shows code examples.
That assembly code you posted was just a fragment of a larger program and isn't worth messing with. Just figure out exactly what you want your program to do and use the examples that Parallax already provides as a guide.
http://www.parallax.com/Portals/0/Downloads/docs/prod/motors/Stepper_Motor_27964.pdf