Shop OBEX P1 Docs P2 Docs Learn Events
String or list channel numbers on PSCU — Parallax Forums

String or list channel numbers on PSCU

Carol HazlettCarol Hazlett Posts: 312
edited 2012-11-13 20:36 in General Discussion
I have a 6 legged, 3DOF spider type walker using a BS2 and 2 Prop Servo Controllers. I want to have a custom starup mode that will have the robot in a standing position when powered on. Right now I just have the servos going to center when powered on. I have changed the start up to PM1 as per the instruction manual. My question is, is there a way to list or string the channel numbers so I can give a certain value to several at once? The line in the manual is for changing channels 0 to 31 all to the same value, but I would like only 12 channels of one value, 3 of another and three of another value. Or is the only way to do each channel one at a time? Will that even work? The channels are not sequential so I cannot batch them as the instructions show, I am reluctant to rewire them to be numbered in a batch as that would make working on the walking gaits rather difficult.

Comments

  • Carol HazlettCarol Hazlett Posts: 312
    edited 2012-11-08 22:17
    I think I have a way to do it using variables. Will let you know if it works and post my code.
  • Carol HazlettCarol Hazlett Posts: 312
    edited 2012-11-13 20:36
    I was unable to get anything to work for programming start-up mode on the prop servo controller, so I have just settled for letting it zero the servos when I turn the spider on. I have written a routine to make the bot stand up but I am having to program each individual servo instead of being able to use the PSCI software. The version number of the PSCU will come up in the software but the sliders will not move a servo. I suspect that the software just does not work with the current version of the PSCU as it was written originally for another earlier board. I would like help with my code also, there is not much info on how to program the PSCU and I am sure someone has a better method than I used. I am posting the code and a link to the video of what the code does. Go to www.facebook.com/Robothon and look for the video posted on Nov. 13, 2012 at 7:45 PM.

    
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
    'First attempt at programming the Minds-i Spidey
    '6 legged 3DOF walking robot.
    'Created by Carol Hazlett 11/8/2012
    
    '---[Variables]-------------------------------------------------------
    
    pw                VAR     Word
    ra                VAR     Byte
    Sdat              CON     15
    Baud              CON     396
    counter           VAR     Byte
    
    FRHip             CON     16              'Forward right hip servo
    FRKnee            CON     17              'Forward right knee servo
    FRFoot            CON     18              'Forward right foot servo
    
    MRHip             CON     27              'Middle right hip servo
    MRKnee            CON     28              'Middle right knee servo
    MRFoot            CON     29              'Middle right foot servo
    
    RRHip             CON     24              'Rear right hip servo
    RRKnee            CON     25              'Rear right knee servo
    RRFoot            CON     26              'Rear right foot servo
    
    FLHip             CON     8               'Forward left hip servo
    FLKnee            CON     9               'Forward left knee servo
    FLFoot            CON     10              'Forward left foot servo
    
    MLHip             CON     3               'Middle left hip servo
    MLKnee            CON     4               'Middle left knee servo
    MLFoot            CON     5               'Middle left foot servo
    
    RLHip             CON     0               'Rear left hip servo
    RLKnee            CON     1               'Rear left knee servo
    RLFoot            CON     2               'Rear left foot servo
    
    Main:
    
    
      GOSUB Stance
      GOSUB Stand
      GOSUB Wave
    
    
    END
    
    
    
    Stance:
      ra = 15
      'Front left leg
      pw = 750
      SEROUT Sdat, Baud+$8000,["!SC", FLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 300
      SEROUT Sdat, Baud+$8000,["!SC", FLKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 400
      SEROUT Sdat, Baud+$8000,["!SC", FLFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
    
      'Middle left leg
      pw = 700
      SEROUT Sdat, Baud+$8000,["!SC", MLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 300
      SEROUT Sdat, Baud+$8000,["!SC", MLKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 400
      SEROUT Sdat, Baud+$8000,["!SC", MLFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
    
      'Rear left leg
      pw = 750
      SEROUT Sdat, Baud+$8000,["!SC", RLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 250
      SEROUT Sdat, Baud+$8000,["!SC", RLKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 350
      SEROUT Sdat, Baud+$8000,["!SC", RLFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
    
      'Front right leg
      pw = 750
      SEROUT Sdat, Baud+$8000,["!SC", FRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 1190
      SEROUT Sdat, Baud+$8000,["!SC", FRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 1140
      SEROUT Sdat, Baud+$8000,["!SC", FRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
    
      'Middle right leg
      pw = 750
      SEROUT Sdat, Baud+$8000,["!SC", MRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 1230
      SEROUT Sdat, Baud+$8000,["!SC", MRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 1200
      SEROUT Sdat, Baud+$8000,["!SC", MRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
    
      'Rear right leg
      pw = 750
      SEROUT Sdat, Baud+$8000,["!SC", RRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 1200
      SEROUT Sdat, Baud+$8000,["!SC", RRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 1200
      SEROUT Sdat, Baud+$8000,["!SC", RRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      RETURN
    
    Stand:
    
      ra = 11
      'Front left leg
      pw = 750
      SEROUT Sdat, Baud+$8000,["!SC", FLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 1200
      SEROUT Sdat, Baud+$8000,["!SC", FLKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 750
      SEROUT Sdat, Baud+$8000,["!SC", FLFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
    
      'Middle left leg
      pw = 700
      SEROUT Sdat, Baud+$8000,["!SC", MLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 1200
      SEROUT Sdat, Baud+$8000,["!SC", MLKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 750
      SEROUT Sdat, Baud+$8000,["!SC", MLFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
    
      'Rear left leg
      pw = 750
      SEROUT Sdat, Baud+$8000,["!SC", RLHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 1150
      SEROUT Sdat, Baud+$8000,["!SC", RLKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 750
      SEROUT Sdat, Baud+$8000,["!SC", RLFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
    
      'Front right leg
      pw = 750
      SEROUT Sdat, Baud+$8000,["!SC", FRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 280
      SEROUT Sdat, Baud+$8000,["!SC", FRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 760
      SEROUT Sdat, Baud+$8000,["!SC", FRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
    
      'Middle right leg
      ra = 5
      pw = 750
      SEROUT Sdat, Baud+$8000,["!SC", MRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 300
      SEROUT Sdat, Baud+$8000,["!SC", MRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 750
      SEROUT Sdat, Baud+$8000,["!SC", MRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
    
      'Rear right leg
      ra = 5
      pw = 750
      SEROUT Sdat, Baud+$8000,["!SC", RRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 320
      SEROUT Sdat, Baud+$8000,["!SC", RRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
      pw = 750
      SEROUT Sdat, Baud+$8000,["!SC", RRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
      PAUSE 50
    RETURN
    
    Wave:
      FOR counter = 1 TO 10
        ra = 11
        pw = 750
        SEROUT Sdat, Baud+$8000, ["!SC", FRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
        PAUSE 100
        pw = 1190
        SEROUT Sdat, Baud+$8000, ["!SC", FRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
        PAUSE 100
        pw = 300
        SEROUT Sdat, Baud+$8000, ["!SC", FRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
        PAUSE 100
    
        ra = 7
        pw = 750
        SEROUT Sdat, Baud+$8000, ["!SC", FRHip, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
        PAUSE 100
        pw = 750
        SEROUT Sdat, Baud+$8000, ["!SC", FRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
        PAUSE 100
        pw = 750
        SEROUT Sdat, Baud+$8000, ["!SC", FRFoot, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
        PAUSE 100
      NEXT
        pw = 280
        SEROUT Sdat, Baud+$8000, ["!SC", FRKnee, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
        PAUSE 100
    
    RETURN
    
    
Sign In or Register to comment.