Shop OBEX P1 Docs P2 Docs Learn Events
Propeller DATA - Page 3 — Parallax Forums

Propeller DATA

13»

Comments

  • CJCJ Posts: 470
    edited 2006-07-08 19:52
    it has to do with that nasty little dot, it is stored as a floating point, rather than an integer

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Who says you have to have knowledge to use it?

    I've killed a fly with my bare mind.
  • NewzedNewzed Posts: 2,503
    edited 2006-07-08 20:05
    Phil, I tried that and got an error:

    "Expected an expression term" and it highlighted TRUNC

    Then I wrote:

    travel := (pulsetrain*10/103)
    term.dec(travel)

    and that works.· In addition it proves out the pulsetrain, which should be 1907 for 185 mils of travel.

    103 is the (pulses per mil) * 10

    Sid
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-07-08 20:21
    Sid,

    Well, that'll teach me to post stuff before I try it! So I tried this:

    ··term.dec(CONSTANT(TRUNC(HoleDepth)))

    and it works. I suspect there's a compiler oversight involved in the original error. There's no logical reason for it not to compile that I can think of.

    -Phil

    Update: Okay, the error makes sense after all. TRUNC and its kin are constant functions, which can only be used in constant expressions. Using the CONSTANT keyword envelopes TRUNC in a constant environment instead of a runtime expression.

    Post Edited (Phil Pilgrim (PhiPi)) : 7/8/2006 8:46:40 PM GMT
  • NewzedNewzed Posts: 2,503
    edited 2006-07-08 20:30
    Thanks, Phil.· Now that one works!

    It's in the program but commented out.· I think I'll keep the one I wrote for the time being, because if I get something besides 185, I'll know something is wrong with the pulsetrain.

    Sid
  • NewzedNewzed Posts: 2,503
    edited 2006-07-08 23:10
    SSteve, I forgot something important - sorry!

    Every time the mill changes direction, I have to crank in a "backlash compensation".· If I the X table goes Left, then Left, that's OK, but if the· X table goes Left, then Right on its next move, I have to crank in 155 pulses on the Right direction before it starts its Right travel.· Same thing when changing from Right to Left.· For In and Out, it takes 130 extra pulses.· So the program is going to have to remember the last direction it went, L, R, I, or O.· How can I accomplish this?· I need the same thing in Autorun.· I could try different things but I don't want to mess up what is now a good program.

    Sid
  • SSteveSSteve Posts: 808
    edited 2006-07-08 23:11
    Phil Pilgrim (PhiPi) said...
    Sid,

    Well, that'll teach me to post stuff before I try it! So I tried this:

    ··term.dec(CONSTANT(TRUNC(HoleDepth)))

    and it works. I suspect there's a compiler oversight involved in the original error. There's no logical reason for it not to compile that I can think of.

    -Phil

    Update: Okay, the error makes sense after all. TRUNC and its kin are constant functions, which can only be used in constant expressions. Using the CONSTANT keyword envelopes TRUNC in a constant environment instead of a runtime expression.

    Your original code:

    ··term.dec(TRUNC(HoleDepth))

    will work when version 1.0 of the Propeller Tool is released. Check out the last line on page 145 of the newly-released Propeller manual. (I already checked with Parallax and was told that this code will work in 1.0 even though it won't compile in 0.95.1.)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    OS-X: because making Unix user-friendly was easier than debugging Windows

    links:
    My band's website
    Our album on the iTunes Music Store
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2006-07-08 23:37
    Hmm. That's interesting — and just when I thought the old way made sense. smile.gif Now I wonder what it'll do with TRUNC(1.5 + 3.8). On the one hand, if it's truly shifted into constant mode, this should compile. On the other hand, if embedded expressions still need the CONSTANT function to evaluate at compile time, it probably won't. Eventually, it would be nice to see CONSTANT disappear altogether, with the compiler deciding which subexpressions it can evaluate at compile time and which it can't.

    -Phil
Sign In or Register to comment.