Shop OBEX P1 Docs P2 Docs Learn Events
Little Step-U "{U}" command problem — Parallax Forums

Little Step-U "{U}" command problem

PodionPodion Posts: 90
edited 2012-12-08 08:22 in Propeller 1
Hy all

I have a Little Step-U whit a Propeller.

I try to see the position whit the command "{U}" and its not working.

there is the code i use.

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2012-11-29 07:30
    Hi Podion,

    your variable "myString" is a local long.

    But strings must be defined as global arrays of byte defined in the var-section

    If I remember right it is no problem to code
    VAR
      byte MyString[10]
          
    
    OBJ
      Stepper : "Extended_FDSerial" 
      BS2     : "Extended_FDSerial"
         
           
    PUB Main
       Stepper.start(11,10,1,2400)     'rx pin,tx pin,mode,baud rate
       Debug.start(31,30,0,2400)     'rx pin,tx pin,mode,baud rate
    

    To go on developing I recomend to send the ONE command at a time via Parallax Serial Terminal
    seeing how the Step-U reacts and then coding sending this command in SPIN testing again.

    After that testing the next command.

    best regards
    Stefan
  • lardomlardom Posts: 1,659
    edited 2012-11-29 10:36
    I wrote a program a few years back in Pbasic. I don't have a complete answer but your VAR block is empty. You need i/o pin assignments. Can you post how your Prop is connected to the "Little Step U"?
    Also if you are looking for the 'number' that "{U}" represents you probably want PUB DEBUG_DEC("{U}").
  • PodionPodion Posts: 90
    edited 2012-11-29 22:54
    StefanL38 wrote: »
    Hi Podion,

    your variable "myString" is a local long.

    But strings must be defined as global arrays of byte defined in the var-section

    If I remember right it is no problem to code
    VAR
      byte MyString[10]
          
    
    OBJ
      Stepper : "Extended_FDSerial" 
      BS2     : "Extended_FDSerial"
         
           
    PUB Main
       Stepper.start(11,10,1,2400)     'rx pin,tx pin,mode,baud rate
       Debug.start(31,30,0,2400)     'rx pin,tx pin,mode,baud rate
    

    To go on developing I recomend to send the ONE command at a time via Parallax Serial Terminal
    seeing how the Step-U reacts and then coding sending this command in SPIN testing again.

    After that testing the next command.

    best regards
    Stefan



    I made the variable has you show and it is not working.

    the commande Debug.start(31,30,0,2400) 'rx pin,tx pin,mode,baud rate dont work the i have no OBJ call Debug and the BS2_Functions only accept (31,30)
  • PodionPodion Posts: 90
    edited 2012-11-29 23:00
    lardom wrote: »
    I wrote a program a few years back in Pbasic. I don't have a complete answer but your VAR block is empty. You need i/o pin assignments. Can you post how your Prop is connected to the "Little Step U"?
    Also if you are looking for the 'number' that "{U}" represents you probably want PUB DEBUG_DEC("{U}").

    The Prop is connected like this Serial in - P10 --> as Rx to Prop Serial out - P11 --> as Tx from prop
    Busy - P12

    The "{U}"is a commande that is sending by the prop to the Little Step-U and after the Little Step-U send a reply to the prop. thats what i understand in the manuel.

    [FONT= ]U [/FONT][FONT= ]- SHOW CURRENT STATUS[/FONT]
    Syntax {U}
    Returns [aaaa,bbbb,ccc]
    The {U} command instructs the Little Step-U to send the current values of the Position,Speed and Ramp registers back to the controller. The data consists of enclosing squarebrackets ("[" and "]") containing the three (decimal) values separated by commas.Example: A stepper is being used to move a print head mechanism. In order todetermine the paper width the user has selected, the motor is moved to one stop andzeroed and then moved slowly to the other stop with RAMP set to 0. When the motorstops (BUSY goes low), the position is retrieved with the {U} command. The controllercan then use this value to scale the print head movement commands and ensure that animage will fit on the page.
  • kuronekokuroneko Posts: 3,623
    edited 2012-11-29 23:20
    Do you get any response at all from the external h/w? Does this produce any output?
    Stepper.str(string("{U}"))                                                               
      repeat
        BS2.DEBUG_CHAR(Stepper.rx)
    
  • PodionPodion Posts: 90
    edited 2012-11-30 02:05
    kuroneko wrote: »
    Do you get any response at all from the external h/w? Does this produce any output?
    Stepper.str(string("{U}"))                                                               
      repeat
        BS2.DEBUG_CHAR(Stepper.rx)
    

    This code produce a out. but nothing on the display terminal at 9600. But at 2400 the symbol is þ.
  • kuronekokuroneko Posts: 3,623
    edited 2012-11-30 02:29
    Podion wrote: »
    This code produce a out. but nothing on the display terminal at 9600. But at 2400 the symbol is þ.
    Just noticed that you run Stepper with inverted rx (mode == %0001). Is that really necessary? I can't find anything in the datasheet which suggests inverted signals. Also, there is no mention that the response contains a CR, only that it is enclosed by [ and ]. If that is true BS2.SERIN_WAIT will never return.
  • StefanL38StefanL38 Posts: 2,292
    edited 2012-12-01 03:23
    Ok so as several things are not working my recommendation ist to go back to a "system" where all things are well known as working.

    The parallax serial terminal (PST) is known as well working. Write a litlle test-prg that is just sending the characters {U} from the prop to the PST.
    does the PST display the sended characters?

    Do you have a posability to connect your PC directly to the little-step-U via a usb to serial converter?
    if yes send the characters {U} from PST to the little-step-U
    Does this work?

    other ideas: does the little step-step-U need some kind of initialisation?
    If yes How does this initialisation looks like? where is the code for it?

    Pplease tell us what hardware do you have what kind of measuring equipment DMM, oscilloscope, second USB-to-serial-converter etc do you have?

    best regards
    Stefan
  • msiriwardenamsiriwardena Posts: 301
    edited 2012-12-01 09:09
    Podion,
    I used the "Little Step-U" in a project a while ago.I had problems with serial communication with the the Prop.
    What solved the problem was to place a "serial level shifter" for serial communications betwwen Little Step-U and the Prop.

    The problem in my set-up was the IP1 asd IP not responding as it is suppose to.
    I am not sure whether this id the same issue.

    I used a level shifter from "Sparkfun".


    Siri

    PS - I initially used the resistors to connect Rx anf Tx to the prop that did not help. "Little Step-U ----> 5v Prop ----> 3.3V"
  • PodionPodion Posts: 90
    edited 2012-12-05 00:15
    StefanL38 wrote: »
    Ok so as several things are not working my recommendation ist to go back to a "system" where all things are well known as working.

    The parallax serial terminal (PST) is known as well working. Write a litlle test-prg that is just sending the characters {U} from the prop to the PST.
    does the PST display the sended characters?

    Do you have a posability to connect your PC directly to the little-step-U via a usb to serial converter?
    if yes send the characters {U} from PST to the little-step-U
    Does this work?

    other ideas: does the little step-step-U need some kind of initialisation?
    If yes How does this initialisation looks like? where is the code for it?

    Pplease tell us what hardware do you have what kind of measuring equipment DMM, oscilloscope, second USB-to-serial-converter etc do you have?

    best regards
    Stefan

    The PST dose not display the character sended.

    I dont have usb to serial converter.

    The little step dont need to bee init.

    For now i just have a multimeter has measuring tools.
  • lardomlardom Posts: 1,659
    edited 2012-12-05 07:14
    @Podion
    ...but nothing on the display terminal at 9600. But at 2400 the symbol is þ.
    If you see gibberish on the display perhaps the baud rate doesn't match.

    I stayed logged in and looked at your code:
    PUB StepInit | mystring
      
     
     Repeat  
       Stepper.str(string("{U}"))              'Returns [position.speed,ramp]        
       waitcnt(clkfreq/10+cnt)
       BS2.Serin_Wait(11,@myString,"[",2400,1,8)        'Data format received       
       BS2.Debug_Str(string("  ",13))
       BS2.Debug_Str(@mystring)                             
       waitcnt(clkfreq+cnt)
    

    "mystring" is a private variable and will display '0'
    "@" refers to a memory location and the value at that location = 'zero'.
    "Stepper.str(string("{U}"))" This will only display bytes. "position.speed,ramp" are three comma separated values
  • msiriwardenamsiriwardena Posts: 301
    edited 2012-12-08 08:22
    @Podion,

    I used the "Liile-U-Stepper" using Prop without using the BS2 object.
    The attched code is not tested but should work with a liile changes.

    Hope this helps.

    Siri

    PS: need code to display the variables to a screen via PST/serial device etc,
Sign In or Register to comment.