With very little experience programming (30+ years ago) I'm attempting to learn SPIN.


  • Paul,

    There is a bunch of people here happy to help. I'm not the sharpest tool in the shed when it comes to SPIN, but sometimes I can actually help. :)
  • Don't hesitate to ask questions! When you do, make sure they're in the Propeller discussion group to get the best response.
  • Thank you gentlemen.
  • Moving to Propeller1 group.
  • I'm using a Parallax book "Programming and customizing a Propeller Micro Controller" and a Propeller WX board for all the experiments.
  • Plus I have Parallax's employee's at my disposal but it's always good to get many different views.
  • ASKMEASKME Posts: 172
    edited 2017-08-29 - 21:20:23
  • PublisonPublison Posts: 11,788
    edited 2017-08-29 - 21:24:03
    Andy's book that goes with the Propeller Education Kit is very good:


    I'm sure Ken would let you check one out of stock.

    EDIT: I see that is the same that Tom suggested.
  • Heck Andy is right down the hall.
  • MikeDYurMikeDYur Posts: 2,176
    edited 2017-08-30 - 15:12:45
    ASKME wrote: »
    With very little experience programming (30+ years ago) I'm attempting to learn SPIN.

    It has been a wonderful road in my quest to learn spin. I dabbled in other languages, but spin just seemed to click and be fun at the same time. Hope .spin will not be forgotten.

    BTW: I still consider myself a dabbler in spin, and am vary content with that. But I do take life at a slower pace, and don't try to push anything to extremes.
  • You already know Spin. You just don't realize it. The hard part is remembering that it isn't a stupid f........g computer language... and you don't have to learn all that stuff before you start working with Spin.

    Put the books aside... books are a waste of valuable time. Pick a project... any project. The only project "requirement" is that it has to be really important to you... compelling. Something you can't stop thinking about. Then announce your project... so that you can't back out.

    After that, you are done. Spin will come to you like water flowing off a putting green.

    Everything you need is already in the OBEX or hidden cleverly in the forum. If you can't find it, someone will point to it.

  • The Propeller Education Kit (PEK) text gives a great overview of Spin and the old Propeller Manual had a Spin Tutorial in it.

    On of the best ways to learn Spin though it to look at other people's code such as the demo programs that are included with the Propeller Tool and the assorted programs found in Obex.

    I am guessing you come from the BASIC era and Spin is very BASIC-like though it has some PASCAL and other language elements.
    I started with the BS2 which uses PBASIC and found Spin was about 75% similar though some of the commands were different.

    I personally find Spin easier to work with and understand than C.

    Just be warned though, that Andy's text (PEK) doesn't take much advantage of CONstants which makes programs so much easier to reuse and modify.
    Even after looking in the Propeller Manual it took looking at example code before I understood how to use CONstants.

    I also personally prefer to declare global VARiables than create them within Methods.

    By the way, a Method is what is called a Function, Procedure, or Subroutine in other languages, and an Object is otherwise known as a library.

    Also be aware that there are PRIvate and PUBlic Methods. A PRIvate Method works only within an Object while a PUBlic Method can be used by another Method.
  • Heater.Heater. Posts: 21,233
    edited 2017-08-30 - 07:05:46
    I also personally prefer to declare global VARiables than create them within Methods.
    I hate to be picky but it's the way a roll and this is just wrong.

    There are no global variables in SPIN. A VARiable in Spin is only visible from the object it is defined in. A Spin object is a single file that contains all the objects VAR, CON, PUB, PRI, DAT sections.

    The choice of keeping data in an objects instance variables or restricted to the local variables of a method is better not a matter of preference but of functionality.
    By the way, a Method is what is called a Function, Procedure, or Subroutine in other languages, and an Object is otherwise known as a library.
    This is also wrong. Or at least not common definitions of the terminology.

    A "function" takes parameters and returns a result based on those parameters. It does not depend on anything else but those parameters. No object or global variables. It does not have any "side effects", like changing object or global variables. It is stand alone, not part of any object. See "Functional programming" https://en.wikipedia.org/wiki/Functional_programming

    A "procedure" is any bunch of code wrapped up with a name that can be called from many places. It may well use data that is not passed in it's parameters. It is not part of an object.

    "subroutine" - see procedure.

    A "method" is code that is part of an object. It may well have parameters but the point is it can act on data belonging to a particular instance of that object. Methods in different objects act on different object instance variables.
    ...an Object is otherwise known as a library
    No. A library may well contain a bunch of functions, procedures and objects (classes in the C++ and other worlds). I suspect that there are many libraries one can pull from OBEX tha contain mutiple objects.

  • RJO, With all due respect I'm thinking it will be just a bit more complicated then you are saying. When I say that I have very little experience programming I'm under stating that fact. I graduated 30+ years ago and Programming was not a major. Anything I learned back then I've forgotten years ago. I have several projects that I'm passionate about so that will not be problem.

  • ASKME,

    I think a lot of people got their start on the Propeller with this document, a good Spin tutorial and reference. Even if you never programmed anything before.

  • I like the original better since it had some programming example in the manual:

  • Publison-thank you. I downloaded everything Parallax has on line so I'm pretty well set up. I've done several experiments with very minimal code, lights on, lights off, and other simple exercises. When I start writing actual code is when I will need the most help. I still cant conceptualize the layout process even though I understand the basic rules as laid out in the book I'm using.
  • I feel like I'm going about learning SPIN the hard way...
  • ASKME wrote: »
    I feel like I'm going about learning SPIN the hard way...

    Are you dissecting working code, changing variable and constant values to see what happens? Play with working code and trying to understand how it works, helps me a lot.
  • MikeDYur: Thanks for the advice. Trying to learn this from a book is like pulling teeth, I don't like it and need a new approach. I'm learning SPIN for my own personal use. I'm not doing it for work.
  • I understand why they call it a Language, it's like learning to speak a New Language.
  • ASKME wrote: »
    MikeDYur: Thanks for the advice. Trying to learn this from a book is like pulling teeth, I don't like it and need a new approach. I'm learning SPIN for my own personal use. I'm not doing it for work.

    Yeah same with me, every so often have to apply what you've learned from a book, or you just don't retain it, read to be reading.
  • Don't pull your teeth. Put away the book. Read some pages of the Language Reference as often as you can, but learn from working your way through code which does something interesting. OBEX is a good source, but not everything you find there is written with clarity for the beginner in mind. If you get stuck in trying to dechiffer ultra-compact code then skip to something else, something easier.

  • One of the ways I found useful to learn a programming language is to pick a project tutorial that interests me (from a web page, book or magazine), do the electrical wiring as shown in the tutorial, but don't use the program in the tutorial. Tutorials can be found here:
    Click on the drop down and select Propeller- spin language.

    I start by checking the data sheets for the components (start with a simple project that does not have complex devices - that's why LEDs are usually the first thing used).

    Then write out an outline of what you want it to do and in the sequence and logic it needs. (a sort of pseudo code - e.g "if this, then do that, other wise do something else).

    Once you have that use the reference manuals to choose the language elements that do what your pseudo code lays out.

    Spin has some shortcut features that make it efficient, but can be confusing to a new user, so keep it simple.

    If you feel that you are too novice to try writing your own software then go through the tutorials as written and Andy's propeller education kit book, since he explains each aspect of the programs clearly. Then after you have followed his example in the book make you own modifications to it and see how it works. (change pins, change timing, etc.) Don't just skim read his programs, make sure that you understand what each is doing and how it does it. If there is a line that is not clear ask a question.

    If you are more into electronics experimentation using software as a tool, Jon Titus wrote "Experiments for the Propeller Quickstart" available as a free pdf here: learn.parallax.com/tutorials/language/spin/experiments-propeller-quickstart
    Using a programming language to do real control and measurement can help make it easier to understand how the language works.

  • twm47099: Thanks for the advice. I think I need to look at it from a different angle. I have virtually no experience but I am willing to learn or at least try. atleast
  • Heater.Heater. Posts: 21,233
    edited 2017-09-12 - 01:38:43
    Yes. Don't get hung up on wading through the language book. Whichever book for whichever language. It's all too much to absorb at once.

    My approach to learning a new programming language for a long time now is:

    1) Find the minimum program that runs and does something.

    In many languages on PC's and such that is traditionally something that print's "Hello world!". For languages targeting micro-controllers it can be something that flashes an LED. The "blinky" program.

    2) With that in place you know your tools work. The compiler and loader.

    So now you can play with it. Try to understand some new language feature, from the book or tutorial. Modify your working "blinky" program to do that. If it breaks never mind. Go back and try again.

    In fact, breaking a program in various ways deliberately is a good move. Then you get used to what the error messages the compiler spits out mean.

    Slowly, slowly you get the hang of what you can do with the language.

    Then it's time to start to think about what tasks you actually want to do....

    So yes "it's like learning to speak a New Language." Because it is learning a new language. Slowly, slowly, trial and error.

  • great advice Heater. I'm literally disposing the book (maybe not literally) and taking a new approach. Both you and twm47099 have similar approaches and I'm going to try reverse engineer it for a lack of a better term. Thank you ALL for your help.
  • Tracy AllenTracy Allen Posts: 6,534
    edited 2017-09-11 - 21:54:03
    Back in February 2006 when the Propeller first came to light, everyone was trying to learn Spin, wrestling with basic concepts and methods. Here is a March 2006 thread with lots of examples and discussion:
  • Tracy Allen: Thank you for the information it was very helpful.
Sign In or Register to comment.