Shop OBEX P1 Docs P2 Docs Learn Events
Draft for Review - PE Kit Lab - Fundamentals: Methods and Cogs — Parallax Forums

Draft for Review - PE Kit Lab - Fundamentals: Methods and Cogs

edited 2007-07-01 13:41 in Propeller 1
Attached is the 0.8 version of the·third in the Propeller Education Kit lab series·- Methods and Cogs.·

Please send corrections to editor@parallax.com, and post suggestions and recommendations to this thread.

An updated (probably 0.9) version with questions, exercises and projects along with·some additional information about waitpeq and·PUB vs. PRI·will be posted after Parallax reopens on Jan 2.·

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay

Education Department
Parallax, Inc.

Comments

  • John R.John R. Posts: 1,376
    edited 2007-01-04 02:20
    The 0.8 version made sense, anxiously wating for more...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.

    8 + 8 = 10
  • SSteveSSteve Posts: 808
    edited 2007-01-06 19:08
    How about including an example of sharing VAR and DAT between cogs? I was trying to debug a problem in an object I was writing and couldn't figure out from the manual (or this lab) if a VAR in an object was accessible from a method running in a different cog. (See http://forums.parallax.com/showthread.php?p=623742 for the details). It seems obvious once you learn it, but you've got to learn it first.

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

    links:
    My band's website
    Our album on the iTunes Music Store
  • BTXBTX Posts: 674
    edited 2007-01-06 20:48
    Hi Andy:

    What about to include more advance ways to use cogs, in asm and spin ?
    Like Steve ask... and more .....

    Many concepts are not clear for many people, specially when we want to explore, more advance features..., there are many posts asking this kind of questions.
    I've post a big effort to not ask ...but sometimes is really impossible without help, many hours wasted trying to solve certain problems, could be avoided.

    Regards.
    Alberto.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
  • John R.John R. Posts: 1,376
    edited 2007-01-25 23:06
    Andy;

    Any word on the updated version?, or the next lessonsmile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.

    8 + 8 = 10
  • Brian_BBrian_B Posts: 842
    edited 2007-02-07 03:37
    Andy,
    I'm reading through Methods & Cogs . In figure 2 you are using ina[noparse][[/noparse]23] to change the flow of the program , I thought you had to declare [noparse][[/noparse]23] a input before you used it ?

    Thanks ,Brian
  • Paul BakerPaul Baker Posts: 6,351
    edited 2007-02-07 04:05
    The default state is input, so there is no need to declare it as such.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Paul Baker
    Propeller Applications Engineer

    Parallax, Inc.
  • Brian_BBrian_B Posts: 842
    edited 2007-02-07 12:41
    Thanks , I think what's throwing me off is that I was expecting to see somthing like

    ina[noparse][[/noparse]23] == 1
    or
    ina[noparse][[/noparse]23] == 0

    Brian

    PS. here's the code I was working on , now it works :-)

    Post Edited (Brian Beckius) : 2/7/2007 6:47:19 PM GMT
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-06-29 01:13
    From page 5.
    I think this one only runs LauchBlnkCogs and does not fall through to execute Blink(). At least, that's what I think I see when it runs.

    My problem is knowing why it doesn't fall through. I've looked in the manual and read here and there. So far, I've no luck in finding an explanation.

    Since this is the first instance of this [noparse][[/noparse]compiler?] behavior dropped on the beginning prop user maybe that explanation accompany this listing.

    '' BlinkWithCogs.spin

    VAR
    long stack[noparse][[/noparse]30]

    PUB LaunchBlinkCogs

    cognew(Blink(4, clkfreq/3, 9), @stack[noparse][[/noparse]0])
    cognew(Blink(5, clkfreq/7, 21), @stack[noparse][[/noparse]10])
    cognew(Blink(6, clkfreq/11, 39), @stack[noparse][[/noparse]20])


    PUB Blink( pin, rate, reps)

    dira[noparse][[/noparse]pin]~~
    outa[noparse][[/noparse]pin]~

    repeat reps * 2
    waitcnt(rate/2 + cnt)
    !outa[noparse][[/noparse]pin]
  • edited 2007-06-29 01:44
    Fred,

    Cog 0 never gets to the Blink method, but cogs 1, 2, and 3, do because the Blink method gets launched into each of them with three cognew commands.· Even though cog 0 runs out of commands and shuts itself down, cogs 1, 2, and 3 will still run for a while.

    For background information on how a method behaves when it runs out of commands, download and examine pages 4 and 5 of I/O and Timing.· It's available from Propeller Education Kit Labs.

    Andy

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.

    Post Edited (Andy Lindsay (Parallax)) : 6/29/2007 1:49:30 AM GMT
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-06-29 06:44
    Andy,
    Thanks for the quick reply. I hadn't thought about the cog 0 shutting down after launching the others. Which means that cognew loads a new spin interpreter. Guess I need to spend more time reading the manual. (PDF manual recommendation: bookmarks for lexicon entries or let us add comments at least)

    I did the I/O and Timing already -- putting ducks in a row and knocking them down one by one -- and I confess I scanned that page looking mostly at the gray boxes.

    I gather my question (why does BlinkWithCogs.spin stop executing after the third cognew and not fall through to Blink() probably with 0 values in the arguments?) has to do with the compiler's evaluation of method blocks. I am now getting a sense of Forth without a semicolon. That is, the top word (method) is all the program there is. The rest of what happens is what's called by the top method.

    Which means that I will have to go back and rescan every damn bit of spin that I've been saving on my computer to undo my fall through execution hypothesis. Things ought to be a lot clearer now.

    So my two cents: add a paragraph here, where your code adds a second PUB to make note of the compiler's behavior. Because up until this program* all the examples have been single method programs with execution dropping down the page, managed only by repeats, waitcnts and an if or two.

    Fred

    * Correction: actually its·page 3 (Methods and Cogs)·for the first instance·of two PUB's in·CallBlink.spin.· Main gets stuck in a repeat so I didn't bother to worry about falling through there.


    Post Edited (Fred Hawkins) : 6/29/2007 6:55:48 AM GMT
  • Rob7Rob7 Posts: 275
    edited 2007-06-30 03:35
    Andy,
    Thanks for the update !
    Keep up the good work.
    I know some of us are all new to the propeller, with me shuffeling colllege classes and a family, some of us are all still willing to take the time to learn something new and persue our intresets .
    Thak's for all the hard work .


    Rob 7.
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-07-01 13:41
    Previously I wrote: (PDF manual recommendation: bookmarks for lexicon entries or let us add comments at least). And lo, Ariba answers with PreSpin.

    Ariba's PreSpin has a lexicon feature that lets you highlight a word in your spin files and click on the question mark icon to bring up the appropriate page in the manual's pdf.

    If you don't highlight anything and click the question mark, the program's panel expands a bit to show you the list of entries with a scroll bar with the last viewed item highlighted. Single click on anything in the list to move to that page in the manual.

    Notepad.exe can edit the index file so you can add your own bookmarks for the manual.

    http://forums.parallax.com/forums/default.aspx?f=25&m=195896

    I've attached an alternative index that includes the assembly language. The little program that does this can't handle duplicate entries so I put the assembly stuff at the tail of the file. Highlight the word 'assembly' in a spin file then click the question mark to put the manual at the beginning of chapter five. Then unhighlight the spin file and click the question mark to open the list at 'assembly language'. Opcodes are below, and spin commands are above.

    Post Edited (Fred Hawkins) : 7/1/2007 1:45:47 PM GMT
Sign In or Register to comment.