Shop OBEX P1 Docs P2 Docs Learn Events
Propeller Control Board (28205) Source Codes — Parallax Forums

Propeller Control Board (28205) Source Codes

jamesvwestonjamesvweston Posts: 16
edited 2009-01-27 00:47 in Propeller 1
Hello Everyone,
This is my first post on the boards, and I'm fairly new to robotics. Currently, I have experience with one other robotic platform (Ridgesoft's Intellibrain) and I was looking to get into something a little more advanced that was also more flexible. My University picked up the Propeller Control Board (28205), and I'm having a hard time using it. I have only been successful in using the LCD screen, and haven't been able to get any other compents to work (GPS, Servos, etc etc). I've read almost the entire manual for the Propeller Manual and am having problems with the Spin language. Could someone post a few examples for the Propeller Control Board (28205), and more specifically a simple code that will make a servo that is hooked up to the Servo 0 position on the board?
Thanks for the help!
-Jimmy

Comments

  • SRLMSRLM Posts: 5,045
    edited 2009-01-26 04:17
    Take a look at the Propeller downloads page for more documentation, and take a look specifically at the Propeller Education Labs for more information on spin and the propeller.

    For reverse engineering code, take a look in the object exchange (obex.parallax.com) for source code to do all sorts of stuff, including what you want. You'll have to change the pin numbers, but that's about it.
  • jamesvwestonjamesvweston Posts: 16
    edited 2009-01-26 04:58
    Thank you for the information, but I'm really looking for a good example code. I've tried a lot of different things, and I think that my head is getting sore from pounding it into the wall haha.
    I'll give a very simple set up. Using The Propeller Control Board, I have a parallax continuous rotation servo hooked up to servo position 0. I'm just looking for a chunk of code that will make the thing spin.
    I've tried this by creating a motor object from servo4.spin and Servo32v3.spin, and I just haven't gotten anywhere.
    Thanks,
    -Jimmy
  • SRLMSRLM Posts: 5,045
    edited 2009-01-26 06:15
    Most of the objects in the exchange have sample/test programs so you can test it out. If you just want a routine, here's the servo routine I use. It's part of a larger test program. You'll have to change the pin value, but try it out and see what happens.

    CON
    
      _xinfreq = 5_000_000                      
      _clkmode = xtal1 | pll16x
    
      CLS = 16, CRSRX = 14, CLREOL = 11
    
    VAR
      long uS
    
    OBJ
      debug  : "FullDuplexSerialPlus"
      
    PUB TestIr | servoPin, servo, counter
    
      'Set Pin values
      servoPin := 11
    
      'For testing, set the pulse value
      servo := 1500
    
      uS := clkfreq / 1_000_000 
    
      'Start serial communication, and wait 6 s for Parallax Serial Terminal connection.
      debug.Start(31, 30, 0, 57600)
      waitcnt(clkfreq*6 + cnt)
      debug.str(string("Begin rotation"))
    
      repeat counter from 0 to 500
        servoProcess(servoPin, 1500 + counter)
        waitcnt(clkfreq/1000*20 + cnt)
    
      debug.str(string("Done"))
    
      repeat
    
    PRI servoProcess(pin, length) | w
       outa[noparse][[/noparse]pin]~
       dira[noparse][[/noparse]pin]~~
    
       w := length * uS
       outa[noparse][[/noparse]pin]~~               ' If pulse width is non-zero
       waitcnt(w + cnt)          '  produce the requested pulse
       outa[noparse][[/noparse]pin]~
    
    
  • jamesvwestonjamesvweston Posts: 16
    edited 2009-01-26 15:11
    Plugged that code in there, and no luck. I'm certain that my servos are working. I'm still able to print on the LCD screen, but nothing is happening at all with the servos.
    I changed the ServoPin values, and still got nothing.
    I included a picture of the setup. You can clearly see the servo is plugged into Servo Port #0. The other attachment on the board is the LCD screen, which is hooked into Aux Connection #19
    1600 x 1200 - 598K
  • SRLMSRLM Posts: 5,045
    edited 2009-01-26 16:28
    Hmmm. I assumed that 8 I/O pins went to the servo headers, but apparently there is an IC in there. So, obviously the code I provided won't work. Sorry about that. Here's some code pulled from the product page:
    {{
    ┌──────────────────────────────────────────┐
    │ Servo4017_v1.0.spin                      │
    │ Author: Parallax, Inc.                   │               
    │ Copyright (c) 2008 Parallax, Inc.        │               
    │ See end of file for terms of use.        │                
    └──────────────────────────────────────────┘
    ┌──────────────────────────────────────────────────────────────────────────────┐
    │ Controls up to 8 servos using two Propeller I/O pins and a Johnson decade    │
    │ counter (4017 or similar) IC. Requires one available cog and two I/O pins.   │
    └──────────────────────────────────────────────────────────────────────────────┘
    Schematic:
    
                  
             10KΩ │┌────────┐ 
             │     └┤VDD   Q1├─ Servo 0
     MRPin ─┻──────┤MR    Q2├─ Servo 1
     CPPin ────────┤CP0   Q3├─ Servo 2
                    │      Q4├─ Servo 3
                    │      Q5├─ Servo 4
                    │      Q6├─ Servo 5
                  ┌─┤!CP1  Q7├─ Servo 6
                  ├─┤VSS   Q8├─ Servo 7
                  │ └────────┘
                  
    
    
    Usage:
    
     • Connect the CP0 and MR pins from a 4017 to two different Propeller I/O pins
       and connect !CP1 to Vss
     • Call Start(CP0, MR) where 'CP' and 'MR' are the Propeller I/O pins that are
       respectively connected to CP0 and MR of the 4017
     • Call Set(Servo, Position) where 'Servo' is a number from 0 to 7 indicating
       which servo will be moved and 'Position' is a number from 60_000 to 180_000
       indicating the position to which the servo will be moved.
     • Call Enable(n) to enable all servos from 1 to 'n'      
    }}
    
    
    CON
    
        _clkmode = xtal1 + pll16x                           
        _xinfreq = 5_000_000                                
    
    
      MINTIME       =    60_000
      CENTER        =   120_000
      MAXTIME       =   180_000
      PERIOD        = 80_000_000 / 50
    
    
    VAR
    
      long  Enabled
      long  Cog
      long  CP
      long  MR
    
      long  Address
      long  ServoData[noparse][[/noparse]8]
      long  Stack[noparse][[/noparse]40]
    
    
    PUB Start(CPPin, MRPin) | Index 'Launch the servo engine in a new cog
                                    
      CP := CPPin
      MR := MRPin
      Enabled := 0
    
      repeat Index from 0 to 7
        ServoData[noparse][[/noparse]Index] := CENTER
    
      return Cog := cognew(RunServos, @Stack)
    
    
    PUB Stop                        'Stop the currently running cog, if any
                                    
      if !Cog
        cogstop(Cog)
    
    
    PUB Enable(Number)              'Enable servos 0 through 'Number' 
    
        Enabled := Number 
    
      
    PUB Set(Number, Value)          'Set the position of servo 'Number' to 'Value'
    
        if MINTIME =< Value and Value =< MAXTIME and 0 =< Number and Number =< 7 
          return ServoData[noparse][[/noparse]Number] := Value
        
    
    PRI RunServos | Index, NextCNT, StartTime, Iterations
    
      outa[noparse][[/noparse]MR]~~                    'Initialize pin states
      outa[noparse][[/noparse]CP]~
      dira[noparse][[/noparse]MR]~~
      dira[noparse][[/noparse]CP]~~
    
      NextCNT := MINTIME + cnt      'Initialize NextCNT value
      repeat
        StartTime := NextCNT        'Reset StartTime value
        Iterations := Enabled       'Set number of iterations
        if 1 =< Iterations and Iterations =< 8
          outa[noparse][[/noparse]MR]~                 'Ensure that the 4017 is held in not reset                       
          repeat Index from 0 to Iterations - 1
            outa[noparse][[/noparse]CP]~               'Falling edge is ignored 
            waitcnt(NextCNT)        'Wait for width of current pulse                 
            outa[noparse][[/noparse]CP]~~              'End current and start next servo pulse
            NextCNT += ServoData[noparse][[/noparse]Index]
    
        outa[noparse][[/noparse]CP]~                   'End of the last pulse       
        waitcnt(NextCNT)            'Hold the 4017 in reset until
        outa[noparse][[/noparse]MR]~~                  'the next pulse train starts 
    
        NextCNT := StartTime + PERIOD
    
    
  • jamesvwestonjamesvweston Posts: 16
    edited 2009-01-26 22:50
    Ok, thanks for pointing that object out to me. It has been confusing finding out which objects I can use with the board I have. It seems most are developed for the Propeller Demo Board (Even the blinking LED examples).
    When I loaded the following code, some weird stuff happened. The first time I loaded it, the wheel spun successfully. Without changing anything in the code, the blue LED on the board, the LCD screen's backlight, and the servo
    will all turn on and off at the same time. They will be turned on just enough to notice, and then cut off for about 2 seconds.


    CON             
        _clkmode = xtal1 + pll16x                           
        _xinfreq = 5_000_000
    
    OBJ
      servo :       "Servo4017_v1.0" 
      lcd   :       "Serial_Lcd"
      
    PUB Main
      lcd.init(19, 19200, 2)
      lcd.backLight(true)
      lcd.cls
      lcd.str(string("Testing"))  
      servo.Start(22, 23)
      servo.Set(0, 180_000) 
      servo.Enable(7)        
      lcd.finalize   
    
    
  • Paul BakerPaul Baker Posts: 6,351
    edited 2009-01-27 00:08
    This means that you are not providing enough current to drive the servos, the voltage sags, the regulators stop working and the Propeller resets. What battery pack are you using (how many cells) and are you using alkalines or rechargable?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
  • jamesvwestonjamesvweston Posts: 16
    edited 2009-01-27 00:19
    My face is officially red, haha.
    The batteries were almost dead. That solved the problem. At least the servos are spinning with that code.
    Thanks guys
  • Paul BakerPaul Baker Posts: 6,351
    edited 2009-01-27 00:47
    Don't be embarassed, it happens from time to time with even the most experienced people. When something like that happens to me there's the immediate :slaps forhead: response followed immediately by relief that it was a very simple thing to remedy, those are always the best problems to have.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
Sign In or Register to comment.