Shop OBEX P1 Docs P2 Docs Learn Events
Propller Questions — Parallax Forums

Propller Questions

skydve76skydve76 Posts: 5
edited 2012-02-23 08:50 in General Discussion
Hello, I only have arduino experience so I have a few questions. I have never used the propeller nor read much documentation, only some. I want to program the Prop using Asm. I would use Inline Asm using the spin compiler.

From my understanding, 1 Cog will run the spin interpreter. Using inline asm, that code will then run another cog. So does this mean that I only have 7 cogs I can use when using asm, as 1 cog runs the interpreter (which I wont even be using)?

I need to control servos, using a cog to control PWM output, does it work ok or do the servos jitter? I would have to write a smart loop to control more than 1 servo with a cog. Anyone know of a simple circuit to hook up to control servos with an analog pin? It seems if I had only a few servos maybe 1 cog can control all 3 using a clever loop, but it seems if I wanted to use say 9 servos they would probably jitter or not keep up.

Looking forward to prop version 2, is it known yet if existing code will run unaltered on the new version 2? So we could take existing programs and get a big increase in speed?

Thanks for answering my noob question and not telling me to Read The Friendly Manual.

BTW I am looking at programming an auto pilot type device. I know some exists but I want to DIY more from a hobby perspective. I think the Prop would be the best out there! I could dedicate 1 cog to each axis and still have cogs to process data and sensors. Not well thought out yet but just exploring my options. Servo control is a must!

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-02-22 10:11
    The Propeller can control servos in its sleep (well sort of).

    I've been using lots of servos with my Props lately. See post #2 of my index for some of my projects. I've edited this post and added some direct links here too. Make sure you take a look at the first link where the Prop is controlling 32 servos.

    You can't use PASM inline (I've heard there's some experimental stuff though). Normally you lanch PASM code to it's own cog. That's what the servo driver does. It runs in its own cog and your main loop just tells it were you want the servo to be. The PASM driver takes care of refreshing the servos at 50Hz.

    Edit: Here's some of those servo links.
    http://forums.parallax.com/showthread.php?137597-QuickStart-Driving-32-Servos-(Video)
    http://forums.parallax.com/showthread.php?138088-Popsicle-Stick-Hexapod-Attempt-(walks-with-tether)
    http://forums.parallax.com/showthread.php?137197-QuickStart-Servo-Tester
  • skydve76skydve76 Posts: 5
    edited 2012-02-22 10:25
    "You can't use PASM inline"

    What do you mean by this. What I mean is using the Spin Compiler, I can write inlime PASM in the spin code. The spin code will launch the PASM on antoher COG. So does that mean if I am using PASM for all my code, I lose 1 cog as the interpreter is left running for the spin code, which I wont have any?

    I'll look at your examples. It may answer my questions. Do the servos jitter or buzz at all? I need to control high precision digital servos, so they are more senstive to PWM variations than standard servos.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-02-22 11:04
    skydve76 wrote: »
    The spin code will launch the PASM on antoher COG. So does that mean if I am using PASM for all my code, I lose 1 cog as the interpreter is left running for the spin code, which I wont have any?
    Normally the program starts with Spin which then launches PASM code into various cogs. It's possible to reuse the initial cog for other purposes and I supose it's possible to have a program with no Spin other than the intial launching of cogs but it would be very awkward to write and use IMO.

    You might want to take a look at my QuickStart servo tester. It launchs PASM into a cog to monitor the touchpads, it also lauches the servo control PASM to another cog. The main loop of the program remains in cog #0 which is written in Spin which reads the information from the touchpad cog and sends commands to the servo cog. This is a very common way of writing a Propeller program. I suppose it would have been possible to write the Spin portion is PASM but for what reason? As it is, Spin is plenty fast enough for the program's needs and it's a lot easier to have the main loop written in Spin.
    skydve76 wrote: »
    Do the servos jitter or buzz at all? I need to control high precision digital servos, so they are more senstive to PWM variations than standard servos.

    Any jitter or buzz would be caused by my cheap servos. The Prop should be sending out pulses accurate to the nearest microsecond. Some digital servos can use refresh rates of less than the normal 20ms. I haven't tried it myself, but the Prop could provide a much higher refresh rate. I'm not sure how hard it would be to modify the standard servo drivers to provide a faster refresh rate though.

    The Prop can also read the pulses from an RC receiver. I've also removed the small transmitter board from a Spektrum transmitter and used a Prop to mimic the serial signal the transmitter would normally send. I've used this technique to fly RC helicopters with a Wii Nunchuck.

    Here's a picture of the Spektrum transmitter board so you see what I'm talking about.

    attachment.php?attachmentid=89812&d=1329937414

    The Prop is a great match of all sorts of RC projects.
    700 x 159 - 206K
  • skydve76skydve76 Posts: 5
    edited 2012-02-22 13:01
    I dont recognize that RX, is it a satelite RX?

    The reason I would only want to us PASM is that I have done quite a bit of ASM in my time. I know all the C languages, and various asm. It just comes down to getting registers and adressing down, which is not too bad.

    I dont care to learn spin as that would be too much overhead in case I decide to go with another PIC solution later. Asm is Asm for the most part. I pick it up fast and really enjoy it. Compared to learning Intel Asm with MMX and SIMD, these pics are easy.

    But learning another language that only has one application does not interest me. If the spin interpreter cod sits idle so be it. I have 7 more!

    Also do you know if V2 prop will run V1 code?
  • mindrobotsmindrobots Posts: 6,506
    edited 2012-02-22 13:09
    Skydve76,

    GCC is coming to a Propeller near you. You said you know C, so there would be little learning curve for you and you would only have to delve into PASM if you needed/wanted to. Check out the propeller FCC alpha test sub-forum under the propeller forum. It's going into beta test in about a month, a simple IDe is available now and Eclipse integration is coming.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2012-02-22 13:21
    skydve76 wrote: »
    I dont recognize that RX, is it a satelite RX?

    It's out of a TX. I know I had just mentioned the Prop's abliltiy to received pulses from a RX. I then jumped to the TX discussion. The TX comes out the four channel TX that come with the Blade micro copter that are RTF. I plug both the TX and a Nunchuck into one of my Propeller boards and I can then use the Nunchuck as a four channel remote. I use the accelerometer to control throttle and rudder.
    skydve76 wrote: »
    The reason I would only want to us PASM is that I have done quite a bit of ASM in my time. I know all the C languages, and various asm. It just comes down to getting registers and adressing down, which is not too bad.

    If you know C, what's to learn about Spin? Just use "repeat" instead of "for & next" and a few other thing like that. It's the logic of program that's hard, the language is just a few words to keep straight. You will want to watch out for ">=" and "<=". You need to use "=>" and "=<".

    Edit: What Rick said +1

    The Spin interpreter is launched into a cog. It's not part of that cog. I imagine there's a way of using PASM in all the cogs. I just have never tried it.
    skydve76 wrote: »
    I dont care to learn spin as that would be too much overhead in case I decide to go with another PIC solution later. Asm is Asm for the most part. I pick it up fast and really enjoy it. Compared to learning Intel Asm with MMX and SIMD, these pics are easy.
    The only assembly I've learned is PASM so I don't know how it compares with other assembly languages. I've read on this forum it's pretty different. Apparently the way flags don't change until you tell them to is unique to PASM.
    skydve76 wrote: »
    Also do you know if V2 prop will run V1 code?
    I haven't been following the Prop2 news very closely. I'm just starting to feel comfortable with the Prop1.
  • max72max72 Posts: 1,155
    edited 2012-02-23 08:50
    Welcome to the forum.
    I know it is possible to have all 8 COGS running PASM, but you must ask for help in the propeller forum.
    in every cog you can either run the spin interpreter or the PASM code.

    The "usual" way is to have the main COG written in spin and the other COGS at the service of the main one. This way you have the main code easier to maintain and the faster code running independently.
    PASM objects usually can either run as a kind of coprocessor (float, graphics..) and execute code when asked to, or simply running independently in the background (4 serial ports, 32 servo...).
    Inline assembly is being referenced to when you execute asm code inside the spin main code so it could have been misleading. There are at least two implementations, but I guess this is not what you are looking for.

    For servo handling check this object
    http://obex.parallax.com/objects/51/
    With 1 COG you control 32 servos, with an extra COG you also have ramping.

    Massimo
Sign In or Register to comment.