Shop OBEX P1 Docs P2 Docs Learn Events
Propeller Servo Controller — Parallax Forums

Propeller Servo Controller

ajwardajward Posts: 1,130
edited 2013-11-04 12:54 in General Discussion
Yup, me again...

Kinda related to my other question, I'm planning on driving those tower servos with a Basic Stamp through a Propeller Servo Controller. At first there will be 6 servos and if that works I might build up to 12. Just wondering if the BS2 will be up to the task?

The latest shiny thing will be (I hope) a bipedal 'bot. There are several kits available, but with a little scrounging and some parts already on hand, I can save several bucks.

Thanks!!!

Amanda

Comments

  • Martin_HMartin_H Posts: 4,051
    edited 2013-10-30 06:03
    The Propeller Servo controller will certainly be up to the job, and having a BS2 send position information to it shouldn't be that taxing. Where I think the BS2 will be challenged is holding the position information for 12 servos. The BS2's RAM is fairly limited and that's a lot of state information What you might do is store the actual servo pulse values in an array in the EEPROM and use a nibble sized index into the array as the position information.That should only consume 6 bytes and leave you with enough for other tasks such as sensor state.
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2013-10-30 09:48
    Amanda, Should be doable. Remember you can query the PSC for the current position of any servo (actually the last set value), so you don't need to have your BS2 hold servo position information. And, if you know Spin, you can reprogram the PSC to add other features, off-loading most any labor-intensive task to the Prop chip on the board. As I recall, the servo code uses only a couple of cogs, leaving the others free for collecting sensor data, or whatever. Assuming you use 12 servos, that still leaves 4 pins free.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2013-10-31 10:33
    Martin_H,

    You got me thinking... why not add some scratch pad memory to the PSC?

    Attached is a new trial firmware version of the PSC that provides 256 Bytes of scratch pad memory to the the BS2

    !SCMR{Address,[Value]} - Read Memory at Address : Address Range 0-255
    !SCMW{Address,Value} - Write Memory to Address : Address Range 0-255
    !SCMG{Address,Size,[N1..Nsize]} - Get Block of Memory starting at Address and Size : Address Range 0-255
    !SCMP{Address,Size,N1..Nsize} - Put Block of Memory starting at Address and Size : Address Range 0-255

    Note: Square brackets indicate a returned value

    Note: with Put and Get functions, memory addressing will wrap around, meaning if you specify a starting address of 250 and request a Size of 10, then the
    address bytes written or returned will be from locations .... 250,251,252,253,254,255,0,1,2,3
  • vanmunchvanmunch Posts: 568
    edited 2013-10-31 12:24
    I used a BS2 and two PSCs to control my first hexapod that used 18 servos. The PSC are very useful and rock solid.

    BS2 hexapod video:
    http://youtu.be/V3KSQxtWOYQ
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-10-31 12:54
    Unless you're using the BASIC Stamp for something else besides servo control, why use a BASIC Stamp at all? Just program the PSC with your entire app.

    -Phil
  • ajwardajward Posts: 1,130
    edited 2013-10-31 13:19
    Martin_H wrote: »
    The Propeller Servo controller will certainly be up to the job, and having a BS2 send position information to it shouldn't be that taxing. Where I think the BS2 will be challenged is holding the position information for 12 servos. The BS2's RAM is fairly limited and that's a lot of state information What you might do is store the actual servo pulse values in an array in the EEPROM and use a nibble sized index into the array as the position information.That should only consume 6 bytes and leave you with enough for other tasks such as sensor state.

    Thanks Martin!

    Appreciate the information. Not sure I'll be worrying about sensors for some time. When I get six servos working together, I'll be ecstatic!
    I should clarify... my uC board is a Stamp BOE with a BS2P... a bit more ram and a bit more speed. (More speed is always better... 'cept when CHP is nearby!) :lol:

    Amanda
  • ajwardajward Posts: 1,130
    edited 2013-10-31 13:24
    Amanda, Should be doable. Remember you can query the PSC for the current position of any servo (actually the last set value), so you don't need to have your BS2 hold servo position information. And, if you know Spin, you can reprogram the PSC to add other features, off-loading most any labor-intensive task to the Prop chip on the board. As I recall, the servo code uses only a couple of cogs, leaving the others free for collecting sensor data, or whatever. Assuming you use 12 servos, that still leaves 4 pins free.

    Gordon... Not sure reprogramming the PSC is something I'm up to. I'm "kind of" comfortable with Spin, but a lot of things I see y'all accomplish with it rank right up there with magic! :smile:
  • ajwardajward Posts: 1,130
    edited 2013-10-31 13:26
    Unless you're using the BASIC Stamp for something else besides servo control, why use a BASIC Stamp at all? Just program the PSC with your entire app.

    -Phil

    Phil... I wasn't aware you could do that. More things to research. Thank You! :-)

    Amanda
  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2013-10-31 17:56
    ajward wrote: »
    Gordon... Not sure reprogramming the PSC is something I'm up to. I'm "kind of" comfortable with Spin, but a lot of things I see y'all accomplish with it rank right up there with magic! :smile:

    For a Propeller it's much easier than it might appear. You basically run your additional code in a separate cog. For the PSC, you have six (I think) cogs free, as the code only uses two. Each cog does its thang separately.

    For a board like the PSC the limiting factor is the number of I/O pins. If you do expand to 12 servos, that leaves only four pins free. But those four could be applied to lots of different things. For example, you could play sound effects through a cog and a free pin. Or you could add remote control on one of the pins. Have a cog run some Sony SIRC code (see the Obex), and if it detects a valid button press from a remote, it can communicate that back to your BS2.

    Yes, you can put everything in the PSC, but then you'd lose any code you've already developed for your robot in PBASIC.
  • Martin_HMartin_H Posts: 4,051
    edited 2013-11-01 11:47
    Martin_H,

    You got me thinking... why not add some scratch pad memory to the PSC?

    Beau, this is a really good idea. I eventually made the jump from the BS2 to the Propeller, but for people who really prefer the BS2, this could help them do more sophisticated projects.
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2013-11-01 12:23
    Martin_H,

    Thanks Martin ... I need a couple of testers to make sure the code addition functions properly as described. I didn't have an actual PSC to test with so I was only able to test the code snip in isolation. If all is well we will incorporate that into future PSC's. Note: the !SCVER?<CR> command has been incremented also.
  • ajwardajward Posts: 1,130
    edited 2013-11-01 15:03
    Martin_H,

    Thanks Martin ... I need a couple of testers to make sure the code addition functions properly as described. I didn't have an actual PSC to test with so I was only able to test the code snip in isolation. If all is well we will incorporate that into future PSC's. Note: the !SCVER?<CR> command has been incremented also.

    I updated the firmware in both my controllers and would be happy to test the new code... I just need to figure out how to implement the new features.

    @
  • JonnyMacJonnyMac Posts: 9,107
    edited 2013-11-01 15:15
    Unless you're using the BASIC Stamp for something else besides servo control, why use a BASIC Stamp at all? Just program the PSC with your entire app.

    Exactly. The bi-directional buffers on the PSC allow pins not driving servos to be used as outputs.
  • ajwardajward Posts: 1,130
    edited 2013-11-01 15:17
    Been tinkering with the PSC's for a while this afternoon... learned what a neat device it is. Having its own on-board Prop is awesome. It's sorta like a ServoPal on steroids! ('Course y'all knew that, didn't ya?) :smile:

    Amanda
  • ercoerco Posts: 20,256
    edited 2013-11-01 20:16
    I haven't tried a PSC yet. Nor have I tried the Pololu 6-servo mini maestro controller I bought during their "Black Friday" sale. They go up to 24 channels, and like the PSC they have built-in programming capabilities and unused channels can be GPIOs.

    One day I'll use it and everything else in my "to try" box...

    Speaking of which, those Black Friday sales are coming up this month... :)
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2013-11-02 23:11
    ajward wrote:
    I updated the firmware in both my controllers and would be happy to test the new code... I just need to figure out how to implement the new features.
    ... Oops! Sorry about that. Here are a few Basic Stamp II examples.

    I found a PSC over the weekend I didn't know I had, and was able to Test the code. I also found a few things that I had updated that didn't make it's way into the distributed firmware. (<- We will be making that correction shortly) .... here is basically the history update for the Firmware:

    PSC Firmware Update History:
     History:
              Version 1.0 - (05-15-2008) initial concept
    
              Version 1.1 - (12-20-2010) Modified ReadServoPosition PUB
                                         - previous version only returned the
                                           target destination when ramping to
                                           the location
              Version 1.2 - (04-04-2013) Updated Servo32 driver to fix minor bug          
    
              Version 1.3 - (10-31-2013) added 256 BYTES of scratch pad memory access
    

    Below is the latest PSC firmware (tested) and example Basic Stamp II code to communicate with the new scratchpad features

    Basic Stamp II Code example:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    Sdat      PIN 15                      ' Serial Data I/O pin
    Baud      CON 396                     ' Constant for 2400 baud
    buff      VAR Byte(5)                 ' temporary variable
    Address   VAR Byte                    ' Address variable for ScratchPAD memory
    
    FindPSC:                              ' Find and get the version
    DEBUG "Finding PSC", CR               ' number of the PSC.
    SEROUT Sdat, Baud+$8000, ["!SCVER?",CR]
    SERIN Sdat, Baud, 500, FindPSC, [STR buff\3]
    DEBUG "PSC ver: ", buff(0), buff(1), buff(2), CR,CR
    
    
    ScratchPAD_Write:                     ' Write 1 BYTE to the scratchPAD memory at location 0
    DEBUG "Writing to ScratchPAD", CR
    Address = 0
    buff(0) = 65
    SEROUT Sdat, Baud+$8000, ["!SCMW",Address,buff(0),CR]
    DEBUG CR,CR
    
    
    ScratchPAD_Read:                     ' Read 1 BYTE from the scratchPAD memory at location 0
    DEBUG "Reading from ScratchPAD", CR
    Address = 0
    SEROUT Sdat, Baud+$8000, ["!SCMR",Address,CR]
    SERIN Sdat, Baud, 2000, NoResponse, [STR buff\1]
    DEBUG "ScratchPAD memory value = ", DEC buff(0), CR,CR
    
    ScratchPAD_PutBlock:                 ' Write 5 BYTEs to the scratchPAD memory starting at location 0
    DEBUG "Writing Block of 5-Bytes to ScratchPAD", CR
    Address = 0
    buff(0) = 10
    buff(1) = 20
    buff(2) = 30
    buff(3) = 40
    buff(4) = 50
    SEROUT Sdat, Baud+$8000, ["!SCMP",Address,5,buff(0),buff(1),buff(2),buff(3),buff(4)]
    '                                         |
    '                                         This indicates the Size of the Block you want to write
    DEBUG CR,CR
    
    ScratchPAD_GetBlock:                 ' Read 5 BYTEs from the scratchPAD memory starting at location 0
    DEBUG "Reading Block of 5-Bytes from ScratchPAD", CR
    Address = 0
    SEROUT Sdat, Baud+$8000, ["!SCMG",Address,5,CR]
    '                                         |
    '                                         This indicates the Size of the Block you want to read
    
    SERIN Sdat, Baud, 2000, NoResponse, [STR buff\5]
    DEBUG "ScratchPAD memory values = ", DEC buff(0),",",DEC buff(1),",",DEC buff(2),",",DEC buff(3),",",DEC buff(4), CR
    
    
    
    END
    
    NoResponse:
    DEBUG "No Response from PSC", CR
    STOP
    
  • ajwardajward Posts: 1,130
    edited 2013-11-03 09:07
    Hi Beau,
    ... Oops! Sorry about that. Here are a few Basic Stamp II examples.

    I found a PSC over the weekend I didn't know I had, and was able to Test the code. I also found a few things that I had updated that didn't make it's way into the distributed firmware. (<- We will be making that correction shortly) .... here is basically the history update for the Firmware:

    PSC Firmware Update History:
     History:
              Version 1.0 - (05-15-2008) initial concept
    
              Version 1.1 - (12-20-2010) Modified ReadServoPosition PUB
                                         - previous version only returned the
                                           target destination when ramping to
                                           the location
              Version 1.2 - (04-04-2013) Updated Servo32 driver to fix minor bug          
    
              Version 1.3 - (10-31-2013) added 256 BYTES of scratch pad memory access
    

    Below is the latest PSC firmware (tested) and example Basic Stamp II code to communicate with the new scratchpad features

    Basic Stamp II Code example:

    I installed the firmware on both PSC units and ran the example code. Everything seems to work okay. I changed the code (and values) just a bit to indicate what values were being sent to scratchpad ram.
    Screenshot of debug output:
    untitled.JPG
    589 x 550 - 48K
  • kwinnkwinn Posts: 8,697
    edited 2013-11-03 09:23
    vanmunch wrote: »
    I used a BS2 and two PSCs to control my first hexapod that used 18 servos. The PSC are very useful and rock solid.

    BS2 hexapod video:
    http://youtu.be/V3KSQxtWOYQ

    Very nice. With a hairy spider style cover over the top it would make quite the Halloween decoration.
  • ajwardajward Posts: 1,130
    edited 2013-11-03 15:16
    vanmunch wrote: »
    I used a BS2 and two PSCs to control my first hexapod that used 18 servos. The PSC are very useful and rock solid.

    BS2 hexapod video:
    http://youtu.be/V3KSQxtWOYQ

    That's way cool vanmunch . I ran across an six-legger kit using 18 micro servos. I have most of the servos, but that's a little more than I want to tackle right now. Perhaps down the road a ways. :-)

    @
  • ajwardajward Posts: 1,130
    edited 2013-11-04 09:10
    Red Alert! Rookie question coming...

    When I installed the firmware update to the PSC's, I kind of assumed the code went into a special area kind of like a peecee bios. However from all I can see the update went into the EEPROM just like any other program. Is that the way it works? If I want to run some Prop code in the PSC, I have to load it along with the firmware code? Seems odd, but I guess I can work around that.

    Amanda
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-11-04 09:28
    The firmware is just another Prop program. There's nothing special about it. You can incorporate the driver methods into your own code, if you want, to make your own unique app. Or use the 3-pin headers for anything else you please: they don't have to be used for servos.

    -Phil
  • ajwardajward Posts: 1,130
    edited 2013-11-04 12:54
    Ah... Thanks Phil!
Sign In or Register to comment.