Shop OBEX P1 Docs P2 Docs Learn Events
Total newbie question — Parallax Forums

Total newbie question

m00sem00se Posts: 6
edited 2010-11-01 13:28 in Propeller 1
My knowledge of DIY electronics is limited to changing a lightbulb, so this question might seem a bit odd...

I bought the Propellor servo controller, and I'm able to move the servo using the "Parallax Servo Controller Interface", however I would like to do some scripting. The manual gives some examples like:
' {$STAMP BS2}
' {$PBASIC 2.5}
ch VAR Byte
pw VAR Word
ra VAR Byte
Sdat CON 15
baud CON 396
ra = 7
ch = 11
DO
pw = 1100
SEROUT Sdat, Baud+$8000,["!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
PAUSE 1000
pw = 300
SEROUT Sdat, Baud+$8000,["!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
PAUSE 1000
LOOP

I understand the code, but I have totally no idea how to get this running on the controller.


Thanks in advance

Comments

  • Rick_HRick_H Posts: 116
    edited 2010-10-30 11:18
    I'm not familiar with the Propeller servo controller but that's not propeller code, that's PBasic code used for the basic stamp. you may want to post some part numbers of the devices your useing or post in the stamp forum.
  • m00sem00se Posts: 6
    edited 2010-10-30 11:24
    It's item #28830
  • LeonLeon Posts: 7,620
    edited 2010-10-30 11:51
    It has a Propeller on the board, and responds to commands via a serial port. The OP presumably needs to connect a Stamp to it in order to use that program.
  • Invent-O-DocInvent-O-Doc Posts: 768
    edited 2010-10-30 12:02
    I advise the following:
    1. Do some of the tutorials with the propeller on a propeller demo board
    2. Downlaod the Basic Stamp library from the object exchange. It will make it very easy to port PBASIC programs over to the propeller. Eventually you can do the tasks natively in spin.

    Alternate: Go with a Basic Stamp controlled BOE-BOT

    Good luck!
  • m00sem00se Posts: 6
    edited 2010-10-30 13:45
    Ok, I got the Basic Stamp Editor which does indeed run the code, however it does not connect to the board (no device found). This is strange, because the "Parallax Servo Controller Interface" has no problem using the same Com-port and settings.
  • LeonLeon Posts: 7,620
    edited 2010-10-30 13:50
    I told you that you needed to connect a Stamp to that board to use that program. You will need to buy one if you haven't already got one. The Stamp editor is looking for a Stamp board, hence the error message.
  • m00sem00se Posts: 6
    edited 2010-10-30 13:58
    Leon wrote: »
    I told you that you needed to connect a Stamp to that board to use the program. You will need to buy one if you haven't already got one.
    I do not really get it; the board has a USB-connection and it can control 16 servos using a computer. Sounds simple. So I can not imagine the only thing I can do with this is move a servo from one position to another (which is basically what the Parallax Servo Controller Interface does).

    Furthermore, the code I mentioned comes out of the manual of this product and it does not mention I need another hardware part.
  • LeonLeon Posts: 7,620
    edited 2010-10-30 13:59
    It looks like a Stamp PBASIC program to me, and won't run on anything else. Someone else is trying to do the same sort of thing (I think):

    http://forums.parallax.com/showthread.php?t=126712
  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-30 14:13
    To clarify (hopefully) what's been said already ...

    The Propeller Servo Controller is preprogrammed with a program that takes commands from the serial port, interprets them, and produces the servo control pulses needed to implement the commands. As programmed from Parallax, it needs either a PC or some kind of microcontroller to send the commands expected. If you want to use the existing program, you will need some kind of controller. The sample program you listed is intended for the BS2 Stamp.

    If you want the Propeller Servo Controller to work on its own, you can do that, but you'll need to replace the existing program with one of your own. There are "objects" in the Propeller Object Exchange that will take care of the servo handling for you and one of them (Servo32v2) is used by the program that comes with the Servo Controller.

    To write programs for the Propeller, all you need is a copy of the Propeller Tool. This comes with some of the objects that you will need. The others can be found in the Object Exchange. There are plenty of tutorials available. Check out the "Getting Started" thread in this forum.
  • hover1hover1 Posts: 1,929
    edited 2010-10-30 14:28
    Leon,

    Thanks for linking him to the other thread. I was just about to do so.

    OOps, Mike Green step in as I was writing this. Mike covered most of what I was going to say.

    What I might add to Mike's wisdom, you could use the PSCI software found on the Servo Controller page at the lower left to save scripted moves that can be saved on a PC and run over the USB port.

    You could also take the Basic examples and use them to program the Propeller in PropBasic:

    http://forums.parallax.com/showthread.php?t=118611

    Jim









    Leon wrote: »
    It looks like a Stamp PBASIC program to me, and won't run on anything else. Someone else is trying to do the same sort of thing (I think):

    http://forums.parallax.com/showthread.php?t=126712
  • m00sem00se Posts: 6
    edited 2010-11-01 06:16
    Thanks for the answers.

    I can get the proper 'spin' onto the board now, however I can't seem to find a way to address sub routines of the spin. For example, the following sub:
    PUB SetServoPosition            '' Set a new servo position
        Ramp := 0#>Ramp<#63
        If ((Enabled & |<Channel)>>Channel) == 1     '' Check if servo is enabled
           Servo.Set(Channel,0)        '' Disable Servo if servo flag is disabled 
        else
           If ServoRamp[Channel] == 0
              Servo.Set(Channel,500#> PW*2 <# 2500)
           Servo.SetRamp(Channel,500#> PW*2 <# 2500,RampSpeed[Ramp])
        ServoRamp[Channel] := Ramp
        ServoPosition[Channel] := PW
    
    ... is part of the spin, so I now expect to be able to tell the board to change a certain servo to a certain position. Following my logic or do I totally miss something :confused::idea::confused:

    So:
    - How do I send an order after the spin is loaded.
    - What do I send?

    I already wrote a script in .NET to send strings to the board, but my successes are currently limited to blinking a led on the board.


    ============================
    Edit: I got it working by just sending the bytes directly to the board!
  • Mike GreenMike Green Posts: 23,101
    edited 2010-11-01 09:03
    Download "Servo32v7" from the Object Exchange or locate "Servo32v7_RampDemo.spin" in the collection of demo programs included with the Propeller Tool. The demo program illustrates how to call the "Servo32v7" object which is the one used internally in the Servo Controller.

    Alternatively, you could download and examine other servo drivers from the Object Exchange like this one that only handles two servos, but is simple, written in Spin only, and well documented.
  • StefanL38StefanL38 Posts: 2,292
    edited 2010-11-01 09:10
    From the the you write about programming I think I can assume that you know
    not very much about programming and different programming languages.
    That's really OK. You just can't expect that by changing two or three characters the thing will run.

    The propeller-servo-controller is pre-programmed with a firmware.
    firmware is sonething different than a software. It's the BASE for the software.

    If you change the firmware this is like if you would change the system32.dll
    of operation system "windows vista" or "windows 7" to act in a different way. You should do this only if you know windows 7 VERY VERY good.

    To write scripts for the propeller-sevo-control-board to do some pre-configured movements is done on the PARTNER of the propeller-servo-control-board (short term: pscb)

    You have the pscb that RECEIVES commands.
    example: the VER?-command

    If the partner of the pscb is a PC and on the PC there is running the program hyperterminal the "script" for this would be

    typing on the keyboard VER? Enter

    If the partner of the pscb is a arduino you would have to program some arduino-code to send the bytesequence "VER?#13" to the pscb

    If the partner is a basic-stamp the code you qouted above would be programmed into a basic-stamp to send the bytesequence "VER?#13" to the pscb

    in every programming language you have some characters that are specific to the programming language and some "characters" that represent the serial bytesequence.
    So first thing to do is to understand which part of the code is that one
    thet represents the bytesequence.

    Then you have to learn how to add the programming-specific-part
    that makes the hardware send the bytesequence.

    If you tell us with what kind of hardware and with wich programming-language you want to send the serial bytesequences to the pscb the forum
    can help you to realise that.

    so please tell us what is the hardware of the propeller-servo-control-board
    you want to use

    and what is the programming-language you want to use.

    If you tell as "the big frame" what you want to do in the end this help too
    to find suitable solutions.

    So feel free to write a big posting that describes that all.
    Write some guesses how you think it should work.
    If you do that the forum can see clearly where you are and can guide you towards the target. Right now most of it is guessing in the fog

    best regards

    Stefan
  • m00sem00se Posts: 6
    edited 2010-11-01 13:28
    StefanL38 wrote: »
    From the the you write about programming I think I can assume that you know
    not very much about programming and different programming languages.
    Well, my programming isn't that bad, I'm just from the generation that has never assambled an Altair 8800, and I just have never used a microcontroller like the Propeller before. My lack of understanding the jargon might explain my slow learning curve here
    StefanL38 wrote: »
    so please tell us what is the hardware of the propeller-servo-control-board you want to use
    The hardware, as mentioned before, is a Parallax Servo Controller (part number 28830). Connected to a pc by USB.
    StefanL38 wrote: »
    and what is the programming-language you want to use.
    Well, I wanted to use the propellor tool using 'spin' as Mike suggested, but I really didn't get a servo to move; and yes, I did read some tutorials.

    So I switched to adressing the serial port directly. Instead of for example following PBasic code (which requires a Stamp as I have now learned):
    SEROUT Sdat, Baud+$8000,["!SC", ch, ra, pw.LOWBYTE, pw.HIGHBYTE, CR]
    

    ...I did it like this (VB.NET):
    Private Data As Byte() = New Byte(7) {&H21, &H53, &H43, 0, 0, &H0, &H0, &HD}
    Private Position as Integer
    ...
    Data(5) = Position And &HFF   'Integer to lower byte
    Data(6) = Position >> 8          'Integer to higher byte
    port.Write(Data, 0, 8)
    

    ...which does work fine and is in some way sufficient as I don't need to use the board without a pc attached. However I thought it could be done easier.
Sign In or Register to comment.