Shop OBEX P1 Docs P2 Docs Learn Events
Little Step-U Motor Controller for Propeller — Parallax Forums

Little Step-U Motor Controller for Propeller

edited 2008-03-30 19:36 in Propeller 1
·Hello,
··········· I am working on a project which connects a Propeller to a ‘Little Step-U Motor Controller’ (Parallax Item code 27938) and ‘4-Phase / 12 Volt Unipolar Stepper Motor’· (Parallax Item code 27964).· I have found several *.spin files for stepper motors, however I have not found anything for the ‘Little Step-U’ controller in the form of an object, or demo.· Has anyone tried this?· There is BS2 code on the Parallax website, however I am trying to make this work on a Propeller.· Thanks in advance.
·
Cheers,
Michael

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-29 22:18
    You won't find any examples because the motor controller is just a serially controlled device and takes care of all the actual motor control. You can use the BS2 Function Library to help with the translation of the BS2 demos into Spin. You could also use the Simple_Serial driver with only an output pin specified (I think you would give -1 for the input pin number ... check the documentation).

    The same commands are set to the motor controller. Instead of using SEROUT statements, the Propeller would use calls to serial I/O routines that either transmit a string or convert a number to a sequence of digits and transmit it.

    Post Edited (Mike Green) : 3/29/2008 10:24:16 PM GMT
  • edited 2008-03-30 19:27
    Mike,
    Thanks for the direction. I have tried both the Simple_Serial as well as the BS2_functions. I have pasted my code below. This project is wired up the way the Little Step-U manual suggests.

    ... also from the manual...
    >Software commands
    >Communication with the Little Step-U is by a TTL level serial interface at 2400bps. All
    >commands must begin with a "{" character and end with a "}" Characters outside of the braces
    >(including carriage return and line feeds) are ignored.

    I think there is a problem with how I deal with the serial message is to be sent. In the following code I used ‘{D1000}’, which is supposed to rotate the motor 1000 steps. I am not sure if I should treat this is a string or what? What would the correct syntax look like? The last five lines are different versions that I have tried.

    Cheers,
    Michael

    ' P0 -> serial in
    ' P2 -> busy
    ' P3 -> IP2
    ' P5 -> Vcc (Vss with res and cap)

    CON

    _CLKMODE = XTAL1 + PLL16X
    _XINFREQ = 5_000_000

    steps_per_rev = 48 ' # of steps per rev
    time_step = 5 ' time step
    speed = 200 ' rotation speed

    VAR
    Long stack1[noparse][[/noparse]50] ' Stack for 2nd BS2 Cog

    OBJ

    serial : "Simple_Serial"
    BS2 : "BS2_Functions_1_3_5" ' Create BS2 Object

    PUB main

    serial.start(-1 , 0, 2_400) 'start(rxPin, txPin, baud)
    BS2.start (-1, 0) '(rx, tx)

    serial.tx(string("{D1000}")) '(txByte)
    BS2.Debug_Str(string("{D1000}")) '(stringPtr)
    BS2.SEROUT_STR(0,string("{D1000}"), 2400, 1, 8) '(Pin, stringptr, Baud, Mode, bits)
    BS2.SEROUT_DEC(0,string("{D1000}"), 2400, 1, 8) '(Pin, Value, Baud, Mode, Bits)
    BS2.SEROUT_CHAR(0,string("{D1000}"), 2400, 1, 8) '(Pin, char, Baud, Mode, Bits)
  • Mike GreenMike Green Posts: 23,101
    edited 2008-03-30 19:36
    1) Make sure you don't try to initialize both serial drivers with the same I/O pin. Only one of them will be able to work at a time.

    2) string("{D1000}") supplies the address of the string constant. This is exactly what is needed by either BS2.SEROUT_STR or serial.str

    3) If you want to provide a variable numeric value, you can combine the .str calls with a .dec call like:
    serial.str(string("{D"))
    serial.dec(1000)
    serial.str(string("}"))

    4) The same sort of thing works with the BS2 calls
Sign In or Register to comment.