Shop OBEX P1 Docs P2 Docs Learn Events
S2 internal Pen Lifter and a couple questions for Phil - Page 2 — Parallax Forums

S2 internal Pen Lifter and a couple questions for Phil

2»

Comments

  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-06 15:59
    Umm, there is still no Servo.start...

    Put it right after S2.start.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-06 16:05
    W9GFO wrote:
    Umm, there is still no Servo.start...
    Umm, I see one where you said to put it.

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-06 16:08
    Nikos,

    This is more of a stylistic critique than a substantive one. Since Spin is an indentation-sensitive language, you should probably avoid indentations where they are not needed by the language's syntax. Having them there can make the program a bit confusing to read.

    -Phil
  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-06 16:13
    Umm, I see one where you said to put it.

    -Phil

    Really!? I looked for it like seven times. Must be the indenting that threw me.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-06 16:14
    PUB Main 
    
    
     S2.start
       [b]SERVO.Start                 ' Start servo handler[/b]
     s2.wait_stop
     Pen_Down '---------------------------------
    

    You're younger than me, too! :)

    -Phil
  • NikosGNikosG Posts: 705
    edited 2012-03-06 16:29
    Sorry for the bad writing
    I hope now is more easy to read ....
    CON
       _CLKMODE = XTAL1 + PLL16X 
       _CLKFREQ = 5_000_000
     '-----------------------------
       Up    = 1200' 2080
       Down  = 1600
       ServoPen  = 5
     '----------------------------- 
                          
    OBJ 
    s2 : "S2"
    SERVO : "Servo32v7"    '-------------- for pen lifter
    
    PUB Main 
    
    S2.start
    SERVO.Start    ' Start servo handler
    
    repeat until s2.moving
     s2.wait_stop
    Pen_Down '---------------------------------
    
    S2.button_mode(true, true)
    S2.set_led(s2#POWER, s2#BLUE) 
    S2.start_motors 
    S2.set_speed(7) 
    S2.here_is(0,0)       
    S2.move_to(300,0)       
    
    repeat until s2.moving   
     s2.wait_stop
    Pen_Up
    
    S2.move_to(600,0)       
    
    repeat until s2.moving   
     S2.wait_stop
    Pen_Down
       
    S2.move_to(900,0)       
    S2.move_to(900,300)       
    
    repeat until s2.moving   
     s2.wait_stop
    Pen_Up  
       
    S2.move_to(900,600)       
    
    repeat until s2.moving   
     s2.wait_stop
    Pen_Down  
       
    S2.move_to(900,900)       
    S2.move_to(600,900)
    
    repeat until s2.moving   
     s2.wait_stop
    Pen_Up  
       
    S2.move_to(300,900)       
    repeat until s2.moving   
     s2.wait_stop
    Pen_Down
       
    S2.move_to(0,900)       
    S2.move_to(0,600)
    
    repeat until s2.moving   
     s2.wait_stop
     Pen_Up
       
    S2.move_to(0,300)       
    
    repeat until s2.moving   
     s2.wait_stop
    Pen_Down
         
    S2.move_to(0,0)       
      
    
    PUB    Pen_up
    SERVO.Set(ServoPen,Up)    ' 2400: max        600:min
    
    PUB Pen_Down
    SERVO.Set(ServoPen,Down)    ' 2400: max        600:min
    

    Nothing again.......
    Now the robot do nothing. Even the wheels doesn't move.
    The new command "repeat until" blocked the program
  • NikosGNikosG Posts: 705
    edited 2012-03-06 16:52
    This is very funny,
    I made a Pen lifter and I can't use it :) !

    BTW. Thank you very much for your time !
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-06 17:21
    Nikos,

    Your indentation is causing trouble this time. Don't put s2.wait_stop inside the loop; put it after. This post is now irrelevant, since the repeat loop didn't accomplish anything anyway.

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2012-03-06 19:34
    Nikos,

    I've taken your program, modified it, and substituted LED on/off for pen down/up. It works as expected with the LED turning on and off in the appropriate places. So, if you restore the commented-out statements, and your pen-lifter still doesn't work, the problem lies in your interaction with the Servo object. Here's the modified code:
    CON
    
      _CLKMODE      = XTAL1 + PLL16X 
      _CLKFREQ      = 5_000_000
    
       Up           = 1200' 2080
       Down         = 1600
       ServoPen     = 5
                          
    OBJ
    
      s2    : "S2"
      SERVO : "Servo32v7"    '-------------- for pen lifter
       
    PUB Main 
    
      S2.start
      
      'SERVO.Start    ' Start servo handler
       
      S2.button_mode(true, true)
      S2.set_led(s2#POWER, s2#BLUE) 
      S2.start_motors 
      S2.set_speed(7) 
      S2.here_is(0,0)
      Pen_Down       
      S2.move_to(300,0)       
      Pen_Up
      S2.move_to(600,0)       
      Pen_Down
      S2.move_to(900,0)       
      S2.move_to(900,300)       
      Pen_Up  
      S2.move_to(900,600)       
      Pen_Down  
      S2.move_to(900,900)       
      S2.move_to(600,900)
      Pen_Up  
      S2.move_to(300,900)       
      Pen_Down
      S2.move_to(0,900)       
      S2.move_to(0,600)
      Pen_Up
      S2.move_to(0,300)       
      Pen_Down
      S2.move_to(0,0)       
      Pen_Up    
    
    PUB Pen_Up
    
      s2.wait_stop
      s2.set_led(s2#LEFT, s2#OFF)
    
      'SERVO.Set(ServoPen,Up)    ' 2400: max        600:min
    
    PUB Pen_Down
    
      s2.wait_stop
      s2.set_led(s2#LEFT, s2#GREEN)
    
      'SERVO.Set(ServoPen,Down)    ' 2400: max        600:min
    

    -Phil
  • NikosGNikosG Posts: 705
    edited 2012-03-07 01:37
    Thanks Phil,

    These commands with the on/off LED as the pen lifted Up/Down are amazing. Will make the final result more spectacular.
    Unfortunately the problem is in the interaction with the Servo object as you said...
    I commented-out the servo commands and it doesn't work.

    What can I do about this?

    However using only the Servo32v7 Object the following commands....
    PUB Servo32_DEMO
    
        SERVO.Start                 ' Start servo handler
        
      repeat
        ' Syntax: SERVO.Set(Pin, Width)
        SERVO.Set(ServoCh1,2080)    ' 2400: max       Pen Up
         repeat 800000               ' Wait a short bit
               
        SERVO.Set(ServoCh1,1600)    ' 1500 usec (centered)  600:min   Pen Down
         
          repeat 800000
    
    I have the right result and the servo motor lifts Up and Down the pen without problem.

    How can I overcome the interaction problem with the Servo object when I use simultaneusly the S2 object?
    Should I had use multitasking commands?
  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-07 01:57
    Try this program, I have changed the values already for you.

    S2_write_Saints_NikosG.spin
  • NikosGNikosG Posts: 705
    edited 2012-03-07 06:50
    Rich,

    When I run your code for first time I hadn't realize to press the S2 button as your code demanded.
    So I thought that something wrong was again....
    I was very disappointed as I looked at your magnificent code and I was ready to give up. Then I realized that I had to press the S2 button.
    When I shaw the result I cheered!!!!! Rich you are the best!!!! What AMAZING letters!!!!
    I realized the real beauty of s2 pen lifter when I shaw the result.
    Here is what my S2 wrote:

    attachment.php?attachmentid=90357&d=1331131045

    It was a litle problem with "A" letter but it doesn't matter!!!!

    I have no words to thank you and Phil for your help. I Feel real thankful!!!
    I intend to make a ful set of letters for S2 robots with pen lifter and I also Ihope you will find useful my new pen lifter suggestion!
    1024 x 768 - 53K
  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-07 11:22
    I'm glad you got it worked out. I see you have the exact same problem with the "A" that I did. I guess that means it is the code not the robot.
  • NikosGNikosG Posts: 705
    edited 2012-03-07 14:21
    Don't worry Rich,

    This is something I can fix.
    I have in mind to make a program with all the alphabet. The user will give a word and the the s2 robot will write the word in to the ground.
    You will receive this file in order to test it with your s2.
    In order to run this code the s2 robot is necessary to have a pen lifter.
    When I finish the video with my pen lifter I'll post it into the forum and I hope that everyone will be able to add one in their robot
  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-07 18:03
    Thanks Nikos.

    Will you also make the letters scalable?
  • NikosGNikosG Posts: 705
    edited 2012-03-08 05:44
    W9GFO wrote: »
    Thanks Nikos.

    Will you also make the letters scalable?

    Rich,

    The letters will be scalable. The only I haven't decide yet is the font type . If you have any suggestion please tell me.
    The idea is to to choose a font type of writing from a computer software (e.g. Ms word , Power Point). Then I'll print every letter on ruled faint paper, and I'll find the coordinates and then using a specific excell file I'll create the spin code of every letter with parameters in order to be scalable. I intent to assign the letters creation as project to my students in order to finish in short time.
    The font type of "saints" is pretty god. Have you immitate a patricular font type from Ms Word?
    If you thing that a particulat font type is more appropriate for this purpose please let me know.
  • W9GFOW9GFO Posts: 4,010
    edited 2012-03-08 13:04
    I think ideally you would have two fonts. One of them a single line font and the other a block type font with maybe with rounded edges. The single line font so that it doesn't take an eternity to write something out and the blocky font to keep accumulative errors to a minimum.

    I also had a student create the Saints font, for the Interlake Saints Robotics Club, not the football team.
  • NikosGNikosG Posts: 705
    edited 2012-03-15 15:23
    W9GFO wrote: »
    I think ideally you would have two fonts. One of them a single line font and the other a block type font with maybe with rounded edges. The single line font so that it doesn't take an eternity to write something out and the blocky font to keep accumulative errors to a minimum.

    I also had a student create the Saints font, for the Interlake Saints Robotics Club, not the football team.

    Rich,


    I followed your advise about the S2 fonts.
    Here is the project: “Alphabet for S2”: a collaborative project
    I created a new "A" . In my s2 it works properly. You can try it in your S2.

    Nikos
Sign In or Register to comment.