Shop OBEX P1 Docs P2 Docs Learn Events
Error in assembly (Probably really easy) — Parallax Forums

Error in assembly (Probably really easy)

crcordillcrcordill Posts: 29
edited 2008-02-11 21:37 in Propeller 1
Hey guys
I am making a PID controller for my robot. I'm having some trouble with the PWM. I have never written in assembler, and I am wary to do so. So instead I wrote some code in SPIN. After putting it on the oscilloscope, I found out that it was too slow. I would miss my counter and my pin would go high and wreak havoc on my motor driver board. To fix this, I went and found in the counter examples the Scaling PWM program. I changed some of the parameters and I get it to work great. My driver loves it. When I tried to implement it in my PID2 program I get an error saying: "Source Register/Constant cannot exceed $1FF". I have no idea what this means or how to fix it really. I tried to stick everything in that I could in the same and I had no luck. I'm sure that this is an easy thing to fix, but I just don't understand what they are asking. Any help would be great. Thanks in advance.
Craig

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-02-11 16:21
    What you actually have is a duplicate label. You're using "period" as a constant and as the label for a cog variable. The compiler is quitting on the first error (using the CON value which is > $1FF) without detecting the second error (duplicate label).
  • deSilvadeSilva Posts: 2,967
    edited 2008-02-11 20:57
    For PWM you can also refer to propeller.wikispaces.com/PWM
  • MightorMightor Posts: 338
    edited 2008-02-11 21:37
    Hey there,

    Many moons ago I had a go at implementing PWM in ASM on a prop and managed to make it work. You can tweak it at your heart's content, it is designed to allow the programmer to tweak the base frequency and each PWM channel's duty cycle. I was working on a cleaner version with more of the SPIN "helper code" written in ASM, but this did the trick for me. I am using it in one of my bots so it's been field tested, so to speak. I am sure deSilva remembers my constant struggle with ASM when I was writing this [noparse]:)[/noparse]

    The ASM code is quite well commented, so if nothing else it'll be somewhat edumacashional.

    Gr,
    Mightor

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    | To know recursion, you must first know recursion.
    | I reject your reality and substitute my own!
    | - Adam Savage
Sign In or Register to comment.