Shop OBEX P1 Docs P2 Docs Learn Events
A substantial and interesting BS2 program translated into Spin — Parallax Forums

A substantial and interesting BS2 program translated into Spin

SamMishalSamMishal Posts: 468
edited 2009-06-27 05:11 in Propeller 1
Hi All,
One the·techniques of teaching is to teach a new skill by comparing and contrasting it to an already known skill. In that light I decided to translate a substantial program written in PBasic for the BS2 into Spin so as it would run very much in the same manner on the Propeller. However to keep the learning process more interesting the Spin program improves slightly on the BS2 program.
The·benefit·of this to people learning the Propeller and Spin is that they can put the two programs side by side and be able to immediately see how the constructs they are already familiar with from their experience with PBasic and the BS2 are translated into constructs within the Spin language. I am hoping this will be an aide for people trying to learn Spin.
The program is also fun in that it allows you to enter RTTTL (ring tones) strings and play them. The Spin program is a translation with an additional improvement of a program given in the Stamp In Class course called “What’s A Microcontroller?”. The program appears on pages 251 to 255.
http://www.parallax.com/Store/Education/KitsandBoards/tabid/182/ProductID/327/List/1/Default.aspx?SortField=ProductName,ProductName

The best way to appreciate the Spin program attached below is to read the chapter in the course or at least print out the BS2 program and study its actions (assuming you are an experienced BS2 user). Then try to see how each aspect of the program has been translated into Spin.
The chapter explains the actions of the program·and both the Spin and BS2 programs are· documented extensively. I hope this will prove to be of help for many.

Note for Spin programmers:
The program is all self contained and is deliberately avoiding the use of OBEX Objects to make the program more friendly to the BS2 programmer. However, the program can be made into an object with ease and also some methods in it are already in the BS2_Functions.Spin object, so they can be removed and the BS2_Functions object can be imported instead.
·
Samuel
·

Post Edited (SamMishal) : 6/26/2009 8:11:43 AM GMT

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2009-06-26 12:13
    Hallo Sam,

    nice done. I think by overviewing people will see you don't have to learn russian to code on the propeller.

    To reach people that hardly can code in basic it would be good to have VERY simple programs to learn the new syntax

    VERY simple means:

    making an LED on an IO-PIN blink endlessly with a loop

    making an LED on an IO-PIN blink a 100 time with a loop

    include a second led that lights up only if counter div 3 == 0
    include some leds that light using a case construction
    small exercises showing a basic program: "OK now it is up to you to port it into SPIN"

    etc.

    best regards

    Stefan
  • HumanoidoHumanoido Posts: 5,770
    edited 2009-06-26 14:18
    SamMishal - that's totally awesome! Great job on the conversion!
    I learned much from your program and hope you'll do more
    translations from BS2 to SPIN.

    humanoido

    Post Edited (humanoido) : 6/26/2009 2:24:06 PM GMT
  • SamMishalSamMishal Posts: 468
    edited 2009-06-27 05:11
    Thank you guys....I am glad you found it useful.

    I will try to translate some more stuff....if you have a
    suggested program you would like me to translate please
    let me know.....I will try my best.

    I REALLY love the Propeller and Spin and I think it is the
    neatest thing to come out for a long time.....

    The Propeller is sooooo capable it is a pleasure to see how a
    project that tasks·the abilities of the stamp or even the SX runs
    with so much ease and with so much left over power on the Propeller.



    Sam
Sign In or Register to comment.