SPIN CODE EXAMPLES FOR THE BEGINNER (Public Version)

135678

Comments

  • Dave ScanlanDave Scanlan Posts: 160
    edited 2006-03-17 - 22:52:42
    ·EXAMPLE 11

    ·A SECOND WAY TO CODE A FUNCTION: FIND THE LARGEST OF TWO VALUES (Ver. 2)
    '
    '                                     EXAMPLE 11
    '
    '     A SECOND WAY TO CODE A FUNCTION: FIND THE LARGEST OF TWO VALUES (Ver. 2)               
    '*********************************************************************************  
    'IMPORTANT: This example may require an understanding of examples 04,05,06 and 10
    '*********************************************************************************
    'WHAT'S NEW IN THIS EXAMPLE:
    '
    '     FUNCTION W/O USING THE "RESULT" KEYWORD": In this example, we will return 
    '                                               a result without using the
    '                                               keyword "Result".  We will make up
    '                                               a word we want to use.  
    '*********************************************************************************  
    'DIFFICULTY LEVEL: Intermediate
    '
    'PURPOSE: This code demonstrates how to code a function.  This function will return
    '         the largest of two values. The function will not use the keyword "Result."
    '
    'Submitted by Dave Scanlan, March 16, 2006         
    'File: Example11_FunctionFindLargestVer2.spin
    '*********************************************************************************
    'CORRECT OUTPUT:  The largest value (10) will be displayed on the video monitor.
    '*********************************************************************************
    CON
      _clkmode      = xtal1 + pll16x
      _xinfreq      = 5_000_000
    ' 
    VAR
    'No global variables used.
    '
    OBJ
      VideoDisplay: "TV_Terminal"            
    '
    PUB Start | X, Y, LargestValue        'X, Y, and LargestValue are Local variables.
      VideoDisplay.Start
      SetScreenToWhiteOnDarkBlue
    '
      X := 5
      Y := 10
    ' 
      LargestValue := FindTheLargest(X,Y) 'Calls the function and assigns the
    '                                      result to "LargestValue."
      VideoDisplay.Dec(LargestValue)
    '
    PRI FindTheLargest (X,Y) : Largest     'Largest returns the result. Note the ":".
      If X > Y
        Largest := X
      Else
        Largest := Y
    '
    PRI SetScreenToWhiteOnDarkBlue                  
      VideoDisplay.Out(3)                           
      VideoDisplay.Out(5)
    '
    '
    'ADDITIONAL INFORMATION ON HOW THIS FUNCTION WORKS:
    '  Rather than use the reserved word "Result" we can choose the word we
    '  want. In the function declaration below "Largest" was used to return
    '  the function's value.
    '  PRI FindTheLargest (X,Y) : Largest
    '
    '  IMPORTANT: You must use the colon ":" before Largest.
    '             We could have used any valid identifier.
    '             Largest holds a pointer to the function's return value.
    '
    'IN ORDER TO KEEP THINGS SIMPLE, I HAVE ELIMINATED SOME OF THE DETAILS.  REFER
    'TO THE DOCUMENTATION WHEN YOU GET IT.
    


    FEWER COMMENTS (EASIER TO READ)

    EXAMPLE 11
    HOW TO CODE A FUNCTION THAT FINDS THE LARGEST OF TWO VALUES (Version 2)··
    '
    '                              FEWER COMMENTS (EASIER TO READ)
    '
    '                                     EXAMPLE 11
    '
    '      HOW TO CODE A FUNCTION THAT FINDS THE LARGEST OF TWO VALUES (Version 2)                
    '*********************************************************************************  
    'IMPORTANT: This example may require an understanding of examples 04,05,06 and 10
    '*********************************************************************************
    'DIFFICULTY LEVEL: Intermediate
    '*********************************************************************************
    'CORRECT OUTPUT:  The largest value (10) will be displayed on the video
    '                 monitor.
    'Submitted by Dave Scanlan, March 16, 2006         
    'File: Example11_FewerComments.spin
    '*********************************************************************************
    CON
      _clkmode      = xtal1 + pll16x
      _xinfreq      = 5_000_000
    ' 
    VAR
    '
    OBJ
      VideoDisplay: "TV_Terminal"            
    '
    PUB Start | X, Y, LargestValue        
      VideoDisplay.Start
      SetScreenToWhiteOnDarkBlue
    '
      X := 5
      Y := 10
    ' 
      LargestValue := FindTheLargest(X,Y) 
    '                                     
      VideoDisplay.Dec(LargestValue)
    '
    PRI FindTheLargest (X,Y) : Largest   'Largest returns the result. Note the ":".
      If X > Y
        Largest := X
      Else
        Largest := Y
    '
    PRI SetScreenToWhiteOnDarkBlue                  
      VideoDisplay.Out(3)                           
      VideoDisplay.Out(5)
    


    Post Edited (Dave Scanlan) : 3/20/2006 6:23:58 AM GMT
  • Dave ScanlanDave Scanlan Posts: 160
    edited 2006-03-17 - 22:58:31
    '********************************************************************************* 
    '            EXPLANATION OF TERMS IN EXAMPLES USING PROCEDURES
    '********************************************************************************* 
    '  PROCEDURE
    '     The term procedure is an umbrella term that can refer to a function procedure
    '     (function), a sub-procedure, or an event procedure. (Microsoft's definition)
    '
    '     (1) FUNCTION PROCEDURE (or FUNCTION)
    '         When a function is called it performs some procedure and always
    '         returns a value when the procedure ends.
    '     (2) SUB-PROCEDURE
    '         When a sub-procedure is called, it too performs some procedure, but it
    '         does not return a value when the procedure ends.
    '
    'PUB and PRI are both procedures.  Since they both return values, they are a
    'special type of procedure, a procedure called a "function procedure" or just
    'a function. 
    ' 
    'In early examples in this series of examples, PUB and PRI were called
    'procedures.  I did this to keep the reader from looking for a return value
    'which is necessary with a function.  There was a return value but it
    'could not be seen by the reader. When you get the documentation, you
    'can dive deeper into this subject. In example 10 and 11, there was  
    'an explicit return value.
    '*********************************************************************************
    '*********************************************************************************
    'In the future, PUB and PRI will be referred to as METHODS (POSSIBLY).
    '*********************************************************************************
    '*********************************************************************************
    'NOTE: No attempt was made to cover all the variations of the above terms. 
    '      Only Microsoft's thinking was given. Event procedures were not covered.
    '*********************************************************************************
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··

    Post Edited (Dave Scanlan) : 3/28/2006 4:49:23 PM GMT
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-03-18 - 00:18:06
    What you're calling procedures and functions, Parallax is calling methods.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Dave ScanlanDave Scanlan Posts: 160
    edited 2006-03-18 - 00:42:01
    Hi Jon,

    In OOP, methods are constructed from both sub-procedures and functions, usually functions and seldom sub-procedures. (Microsoft)· The lack of any standardization on these terms is enough to drive a person crazy.· Check your documentation, Parallax is calling PRI and PUB both functions and methods.

    Microsoft uses the term procedure to refer to (1) function procedures (functions), (2) sub-procedures and (3) event procedures.· The rational for this is that the three all perform some "procedure."

    Others will say that there are just (1) procedures, (2) functions, and (3) event procedures.

    Here is what Sun says about functions, procedures, and methods·in Java:
    Java has no functions. Object-oriented programming supersedes functional and procedural styles. Mixing the two styles just leads to confusion and dilutes the purity of an object-oriented language. Anything you can do with a function you can do just as well by defining a class and creating methods for that class. Actually, I agree with Sun but not everyone does.· These terms (function, procedure and method)·have their differences.

    Here is what Microsoft says about functions, procedures and methods: Objects not only contain their own data but they know how to perform tasks on that data. Tasks are performed by various functions and procedures defined in the Class Definition.These functions and procedures are called Methods in OOP. Once again only those Methods exposed by the Public Interface are available to outside users.

    If I had the power, I would change many of the OOP words.· Methods is one of these, class is another, instantiation is another, and polymorphism is another.· These are horrible terms for such simple concepts.

    I was planning to sort out the difference in my final example, but if you folks at Parallax want I·will go back and use the word method, only.


    Dave
    ·

    Post Edited (Dave Scanlan) : 3/18/2006 4:16:39 PM GMT
  • Dave ScanlanDave Scanlan Posts: 160
    edited 2006-03-20 - 04:37:23
    UPDATE
    If you had your choice, which term/s would you choose for a module of code that is used to control the behavior of an object? Also, which of these terms would be best for a programmer transitioning from PBASIC to Spin?

    Possibilities:
    Function and Procedure
    Function
    Routine
    Method
    Sprocket








    Post Edited (Dave Scanlan) : 3/20/2006 6:53:22 PM GMT
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-03-20 - 05:28:09
    Dave -

    From my own "blind" viewpoint (not having the documentation), it would greatly depend on what was meant by "an action", which hasn't been defined heretofore, at least not on this web page. I do hope that "actors" and "actions" don't get thrown into the fray as well.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • Dave ScanlanDave Scanlan Posts: 160
    edited 2006-03-20 - 05:42:22
    Thanks, Burce, I will clean up my wording.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-03-20 - 16:27:04
    From a progmatic point of view, the terms in question have different meanings:

    · A Program may contain PUBlic or PRIvate SUBroutines, METHODS, PROcedures and FUNctions·depending on the needs of the program to
    ···· work with other programs or to achieve the programs goal.·
    ···· PUBlic or PRIvate would·determin if·another program's·SUBroutines, METHODS, PROcedures or FUNctions can access this code.
    ·····The connotation of SUBroutine would imply the code contained is called INLINE,
    ········ as if typed in the main code, and is intended to be called more then once by the calling Code; not permitted any PARAM's,
    ·········have access to the caller's VAR space, and not return any values.
    ·····The connotations of PROcedure, METHOD and FUNCTION·are identicale, with slight differences:
    ········ A METHOD·is designated as the way to do something as designed by the Object's Author.·
    ··········· IE:· Methods are not coded by the·programmer, they are used by the programmer.
    ··········· Exclusions for this connotation exist to permit adding functionality to the base object.
    ··········· This·would accept or require PARAM's and not have access to the callers VAR space.
    ··········· This may or may not return a simple value indicating success / failure.
    ········ A PROcedure would imply programmer generated code.· This would accept or require PARAM's,
    ··········· and not have access to the callers VAR space.
    ··········· This may or may not return a simple value indicating success / failure.
    ········ FUNctions are either coded by the object's Author or the programmer.· It would REQUIRE PARAM('s), and
    ··········· requires a return VALUE.· It would NOT have access to the caller's VAR space.

    ··· Now, all thing considered, this is·a composit of C, C++, Visual C, Delphi, and ALL of Microsoft's VB's.· When I start programming the Propeller, I will maintain this point of view, if only to pereserve readability, and 'documentation ability' (is that a word??) of a given project.··Ok, humble and as simple as it seems, maintaining this 'outlook' has managed to keep VAR's and objects from being bashed from various code points.· It also premits the encapsulation of a object within a single code space, the project within a single code space.··Please excuse the spelling errors:· The reason for my post was to express a point of view relitive to how·I view code points, not an essay of coding.

    Humbly yours,




    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • Dave ScanlanDave Scanlan Posts: 160
    edited 2006-03-20 - 18:46:28
    [b]If you had your choice, which term/s would [u]you[/u] choose for a module of code that is used to control the behavior of an object? Also, which of these terms would be best for a programmer transitioning from PBASIC to Spin?
    
    [u]Possibilities:
    [/u]Function and Procedure
    Function
    Routine
    Method
    Sprocket[/b]
    

    Kaos Kidd,

    Thanks for·your excellent comments.· Your input is appreciated.· If I read you correctly, you seem to imply a preference for "procedure" and "function".

    I am not exactly sure which term or terms will be used.·Some of us with the documentation have debated this issue for several days.

    I think the term will be (1) Function or (2) Method.

    Which of these two would be best for the programmer transitioning from PBASIC to Spin?

    Dave

    Post Edited (Dave Scanlan) : 3/20/2006 6:59:27 PM GMT
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-03-20 - 21:01:18
    Dave:
    Understanding how SPIN works from reading yours and others codes, I believe the terms Procedure and Function correctly identify what's going on within the syntax of the language. Transitioning from any language incures a understanding of how the language works. As I have read in the code you and others have provided, you are authoring true Procedures and Functions. In truth, anyone comming from C++ (or higher), Delphi or VB won't have a problem with 'Procedures' and 'Functions' because it simplifies the appliction constructs into one of three coding points. This in turn simplifies the overall project so the new programmer.

    In my honest and humble opinion, after programming for more then 3/4 of my life, the best choices would be 'Procedures' and 'Functions'. Other terms need explanation, and, when it comes down to the code, all are effectivly the same: It's still Procedures and Functions. Code is Code is Code. From Newbies to the experts, all will like the 'simplist' layout the terms imply. Thanks for listening; Somtimes it feels good to be heard.

    [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • Dave ScanlanDave Scanlan Posts: 160
    edited 2006-03-20 - 21:43:12
    Kaos Kidd wrote:
    

    In my honest and humble opinion, after programming for more then 3/4 of my life, the best choices would be 'Procedures' and 'Functions'. Other terms need explanation, and, when it comes down to the code, all are effectivly the same: It's still Procedures and Functions. Code is Code is Code. From Newbies to the experts, all will like the 'simplist' layout the terms imply. Thanks for listening; Somtimes it feels good to be heard.
    
    


    The terms 'Procedures' and 'Functions' would also tap into the OOPic coders.· They use these two term with Objects.

    Thanks,

    Dave


    I HOPE OTHER WILL GIVE THEIR OPINIONS, TOO.
  • Dave ScanlanDave Scanlan Posts: 160
    edited 2006-03-20 - 21:50:07
    Kaos Kidd,

    Would you mind if I post your response to another forum? Your response shows a deep understanding of the issues.

    Dave

    Post Edited (Dave Scanlan) : 3/20/2006 11:12:24 PM GMT
  • Beau SchwabeBeau Schwabe Posts: 6,415
    edited 2006-03-21 - 00:29:26
    RF Transmitter Eliminator

    Here is something fun to play with.... My daughter has a small 49MHz RF remote control Jeep.... I scoped the Transmitter (100K resistor from ANT and battery GND ; scope across resistor)
    to reverse engineer the signal. (your mileage may vary). A small variation of the idea and you can do the same with IR remotes.


    The setup is as simple as connecting an 8 inch piece of solid #22 hookup wire into whatever pin you assign for transmitting from the demo board.


    49MHz_Demo
    [b]CON[/b]            
    
      [b]_CLKMODE[/b] = [b]XTAL[/b]1 + [b]PLL[/b]16X
      [b]_XINFREQ[/b] = 5_000_000
    
         TXPin = 0
    
    [b]VAR[/b]
                    
    [b]OBJ[/b]
      CTR : "CTR"
      
    [b]PUB[/b] CTR_Demo
      
      CTR.SynthFreq("A",TXPin, 49_700_000)                      [i][b]'SynthFreq({Counter"A" or Counter"B"},Pin, Freq)[/b][/i]
    
      [b]repeat[/b]
        SyncHeader
        Forward
    
    [b]PUB[/b] Ping( uS , Pin)| Dly, SyncPoint
        Dly := ((clkfreq / 1_000_000)* uS)
        SyncPoint := [b]cnt[/b]
        [b]dira[/b][noparse][[/noparse]Pin] := 1                                        [i][b]'Modulate pin by making it an INPUT or an OUTPUT[/b][/i]
        [b]waitcnt[/b](SyncPoint += Dly)
        [b]dira[/b][noparse][[/noparse]Pin] := 0                                        [i][b]'Modulate pin by making it an INPUT or an OUTPUT[/b][/i]
    
    [b]PUB[/b] Delay( uS )| Dly, SyncPoint
        Dly := ((clkfreq / 1_000_000)* uS)
        SyncPoint := [b]cnt[/b]
        [b]waitcnt[/b](SyncPoint += Dly)
    
    [b]PUB[/b] SyncHeader
        [b]repeat[/b] 4
          Ping(1500,TXPin)
          Delay(500)
    
    [b]PUB[/b] Signal(Mode)
        [b]repeat[/b] Mode
          Ping(500,TXPin)
          Delay(500)
    
    [b]PUB[/b] Reverse
        Signal(16)                  [i][b]'15 to 17[/b][/i]
    
    [b]PUB[/b] Rev_Right
        Signal(28)                  [i][b]'27 to 29[/b][/i]
    
    [b]PUB[/b] Rev_Left
        Signal(34)                  [i][b]'33 to 35[/b][/i]
    
    [b]PUB[/b] Forward
        Signal(40)                  [i][b]'39 to 41[/b][/i]
    
    [b]PUB[/b] Fwd_Left
        Signal(46)                  [i][b]'45 to 47[/b][/i]
    
    [b]PUB[/b] Fwd_Right
        Signal(52)                  [i][b]'51 to 53[/b][/i]
    
    [b]PUB[/b] Right
        Signal(58)                  [i][b]'57 to 59[/b][/i]
    
    [b]PUB[/b] Left
        Signal(64)                  [i][b]'63 to 65[/b][/i]
    
    
    




    CTR
    [b]PUB[/b] SynthFreq(CTR_AB, Pin, Freq) | s, d, ctr, frq
    
      Freq := Freq #> 0 <# 128_000_000     [i][b]'limit frequency range[/b][/i]
      
      [b]if[/b] Freq < 500_000                    [i][b]'if 0 to 499_999 Hz,[/b][/i]
        ctr := constant(%00100 << 26)      [i][b]'..set NCO mode[/b][/i]
        s := 1                             [i][b]'..shift = 1[/b][/i]
      [b]else[/b]                                 [i][b]'if 500_000 to 128_000_000 Hz,[/b][/i]
        ctr := constant(%00010 << 26)      [i][b]'..set PLL mode[/b][/i]
        d := >|((Freq - 1) / 1_000_000)    [i][b]'determine PLLDIV[/b][/i]
        s := 4 - d                         [i][b]'determine shift[/b][/i]
        ctr |= d << 23                     [i][b]'set PLLDIV[/b][/i]
        
      frq := fraction(Freq, CLKFREQ, s)    [i][b]'Compute FRQA/FRQB value[/b][/i]
      ctr |= Pin                           [i][b]'set PINA to complete CTRA/CTRB value[/b][/i]
    
      [b]if[/b] CTR_AB == "A"
         [b]CTRA[/b] := ctr                        [i][b]'set CTRA[/b][/i]
         [b]FRQA[/b] := frq                        [i][b]'set FRQA                   [/b][/i]
         [b]DIRA[/b][noparse][[/noparse]Pin]~~                        [i][b]'make pin output[/b][/i]
         
      [b]if[/b] CTR_AB == "B"
         [b]CTRB[/b] := ctr                        [i][b]'set CTRB[/b][/i]
         [b]FRQB[/b] := frq                        [i][b]'set FRQB                   [/b][/i]
         [b]DIRB[/b][noparse][[/noparse]Pin]~~                        [i][b]'make pin output[/b][/i]
    
    [b]PRI[/b] fraction(a, b, shift) : f
    
      [b]if[/b] shift > 0                         [i][b]'if shift, pre-shift a or b left[/b][/i]
        a <<= shift                        [i][b]'to maintain significant bits while [/b][/i]
      [b]if[/b] shift < 0                         [i][b]'insuring proper result[/b][/i]
        b <<= -shift
     
      [b]repeat[/b] 32                            [i][b]'perform long division of a/b[/b][/i]
        f <<= 1
        [b]if[/b] a => b
          a -= b
          f++           
        a <<= 1
    
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    [url=mailto:bschwabe@parallax.com]Beau Schwabe[/url]

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 3/21/2006 12:35:26 AM GMT


    Beau Schwabe --- Robotics applications- PCB design, embedded software, and mechanical
    Oklahoma Robotics -

    www.Kit-Start.com - bschwabe@Kit-Start.com ෴෴ www.BScircuitDesigns.com - icbeau@bscircuitdesigns.com ෴෴

  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-03-21 - 15:32:19
    Dave,
    Feel free to post it where you like.. I'd like to read where it gets posted at... just to continue my edification [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-03-21 - 15:59:23
    Beau...
    that's awesom...
    I understood what you were doing, got lost in some of the math, but I did understand what you were doing...
    heck, just add a few buttons and POOF... instant remot control... nice... real nice...

    And you said IR as well?
    How would you go about getting the controll singles needed for the IR?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • Beau SchwabeBeau Schwabe Posts: 6,415
    edited 2006-03-21 - 16:49:49
    Kaos Kidd,

    IR modulation or Ultrasonic for that matter could be done the same way, just set a pin so that it "spits" out a constant 38kHz or 40kHz and
    instead of making it HIGH or LOW, just make it an INPUT or an OUTPUT depending on the bit pattern that is necessary.

    There are several ways to "getting" the control signals.... perhaps the most intuitive way is to connect a simple IR receiver to a scope and
    study the pattern(s). This is a bit tedious, but doing it this way I think you learn something in the process. ( <-Welcome to reverse engineering )



    Note: Q1 in the schematic is an Infrared Phototransistor

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    [url=mailto:bschwabe@parallax.com]Beau Schwabe[/url]

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 3/21/2006 5:13:59 PM GMT
    251 x 123 - 7K


    Beau Schwabe --- Robotics applications- PCB design, embedded software, and mechanical
    Oklahoma Robotics -

    www.Kit-Start.com - bschwabe@Kit-Start.com ෴෴ www.BScircuitDesigns.com - icbeau@bscircuitdesigns.com ෴෴

  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-03-21 - 16:59:27
    LOL, I jsut read that as an AD for Parallax's USB scope... LOL... but it would be a good thing to have...
    I've so many things to learn...
    one step at a time...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-03-21 - 18:56:20
    Ok, the power output is going to be low, but if one were to take the output of the pin used, and dump it into a wide band amplifer, a rather effective remot controller could be created...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • Beau SchwabeBeau Schwabe Posts: 6,415
    edited 2006-03-21 - 19:19:37
    Kaos Kidd,

    HUH???

    For IR:
    Just drive a transistor from the I/O, which in turn will drive the LED.


    For RF:
    A simple LC tuned to the appropriate frequency will get you 200ft-300ft



    FCC Disclaimer, use the below information wisely.
    I/O >----Cap-----o-----Coil----<GND
                     |
                     |
                  Antenna 
    
    



    1) Determine frequency

    2) Determine appropriate total length of antenna ( The Coil windings + Antenna constitute the total antenna length ) based
    on desired frequency.

    3) For best "Q" factor, use an AIR CORE coil which has a diameter close to or equal to the coil length (< not wire length)

    4) Based on coils inductance from step 3 determine variable capacitors range to "tune" the desired resonate frequency.

    5) When Coil/Cap/Antenna are in resonance, it is not uncommon to "see" 50V-100V between Antenna and GND from a
    3.3V signal on the I/O.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    [url=mailto:bschwabe@parallax.com]Beau Schwabe[/url]

    IC Layout Engineer
    Parallax, Inc.


    Beau Schwabe --- Robotics applications- PCB design, embedded software, and mechanical
    Oklahoma Robotics -

    www.Kit-Start.com - bschwabe@Kit-Start.com ෴෴ www.BScircuitDesigns.com - icbeau@bscircuitdesigns.com ෴෴

  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-03-22 - 14:37:18
    Hmmm...
    Sorry, again, when I said "Hello" some 166 posts ago, I said all I remember about analog circuits. However, to my saving grace, I did come across my texts and have started re-re-reading them. When I posted that, I was thinking.. "outout from CB antenna into KICKER into antenna"... not even remembering the LC tuner ciorcuits I spent so much time on...

    Thanks...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • Beau SchwabeBeau Schwabe Posts: 6,415
    edited 2006-03-22 - 16:50:57
    New Life for old remotes

    Here is an IR receiver object that works with a JVC camcorder, just to show you what you can do
    with Spin. The Idea here is to create a standalone object in Spin or Assembly that would be
    specific to a particular remote. From here, the object becomes a plug-n-play that can be used in
    ANY other Propeller program that you want to use a specific remote with. I selected this remote,
    because I rarely use it for the camcorder, and now I can use it in a project if I want.


    Enjoy,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    [url=mailto:bschwabe@parallax.com]Beau Schwabe[/url]

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 3/23/2006 10:48:11 PM GMT
    403 x 567 - 68K
    1297 x 1534 - 438K
    352 x 240 - 26K
    320 x 240 - 16K


    Beau Schwabe --- Robotics applications- PCB design, embedded software, and mechanical
    Oklahoma Robotics -

    www.Kit-Start.com - bschwabe@Kit-Start.com ෴෴ www.BScircuitDesigns.com - icbeau@bscircuitdesigns.com ෴෴

  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-03-23 - 15:27:05
    Beau, your like a magician here... WOW...
    And the code is very readable... and understandable...

    I take it, with some reverse hacking, a simple IR reciever could be used to detect the sync and the bit count, right?
    THen you could basically point any remote at it, and start pressing keys to "train" or "get" the bit patterns needed, again, right?
    Ok, WHEN I get my propeller and demo board, and some hardware, I'll ask again... for some details; I'd really like to learn how to make
    one of thoes "learning" remotes...
    One more little thing, I take it that if you know the xmit freq, you could make a simple reciever and let the propleller show you what's needed to control the RC device, right?

    I know, lots of questions, lots of people, not enough time...

    I love reading this stuff!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • Beau SchwabeBeau Schwabe Posts: 6,415
    edited 2006-03-23 - 19:46:12
    Beau, your like a magician here... WOW...
    jumpin.gif It's not me, it's what's in the Propeller smilewinkgrin.gif

    I take it, with some reverse hacking, a simple IR receiver could be used to detect the sync and the bit count, right?
    That's what 'IR_Test - Archive [noparse][[/noparse]Date 2006.03.22 Time 17.15].zip' is doing with a 'JVC_RMV715U' remote.
    Keep in mind the IR scheme that is used by a remote can vary widely. Using a scope or something to visualize the pattern
    generated can greatly help when it comes to writing a program to interpret the data.

    THen you could basically point any remote at it, and start pressing keys to "train" or "get" the bit patterns needed, again, right?
    This goes with the above statement as well. ...A Scope or something to visualize the pattern helps.

    ...I'd really like to learn how to make one of those "learning" remotes...
    Think of them as a digital recording device. These just "read" the signal pattern and record it for later play back when an associated key is pressed.

    One more little thing, I take it that if you know the xmit freq, you could make a simple receiver and let the propeller show you what's needed to control the RC device, right?
    With some RF remotes, the answer to your question is yes, but RF can be a bit more dynamic than IR, implementing schemes that would be difficult to decipher unless you had a scope.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    [url=mailto:bschwabe@parallax.com]Beau Schwabe[/url]

    IC Layout Engineer
    Parallax, Inc.


    Beau Schwabe --- Robotics applications- PCB design, embedded software, and mechanical
    Oklahoma Robotics -

    www.Kit-Start.com - bschwabe@Kit-Start.com ෴෴ www.BScircuitDesigns.com - icbeau@bscircuitdesigns.com ෴෴

  • Tom WalkerTom Walker Posts: 509
    edited 2006-03-23 - 19:47:36
    Beau,
    Do you think using a scope would help? [noparse]:)[/noparse]

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Truly Understand the Fundamentals and the Path will be so much easier...
  • Beau SchwabeBeau Schwabe Posts: 6,415
    edited 2006-03-23 - 19:50:33
    Tom,

    An invaluable instrument for many things.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    [url=mailto:bschwabe@parallax.com]Beau Schwabe[/url]

    IC Layout Engineer
    Parallax, Inc.


    Beau Schwabe --- Robotics applications- PCB design, embedded software, and mechanical
    Oklahoma Robotics -

    www.Kit-Start.com - bschwabe@Kit-Start.com ෴෴ www.BScircuitDesigns.com - icbeau@bscircuitdesigns.com ෴෴

  • Kaos KiddKaos Kidd Posts: 614
    edited 2006-03-23 - 20:07:19
    Beau...
    Thanks for taking the time to 'splain it all. The scope for Parallax is on the Birthday wish list... the Boss (ie Mrs KK) will "see" about it... LOL... as far as the other points you explained, I'm understanding it. When I get my propeller "system", I'll get a chance to dive head first. I'v started trying simple RCTIme circuits with the bs2, the touch plate from one thread for an example, but the success rate is slow. But, I'm delibertly going about it with the old text books, workin it out myself. Seems I'll get more out of it. Oh, and your antenna shcematic was listed in my text, almost exactly as you drew it here... Nice touch..

    Thanks..

    Fred

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Just tossing my two bits worth into the bit bucket


    KK
    ·
  • Stan671Stan671 Posts: 103
    edited 2006-04-13 - 20:39:14
    Dave and others, please keep those excellent Spin code examples coming.· I like the two listings with and without comments.· I am trying to get up to speed with Spin and I find studying examples and stealing from them as the best way to get started with my own projects.

    I am very excited about the Propeller and it's possibilities.· We live in exciting times!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Stan Dobrowski
  • Dave ScanlanDave Scanlan Posts: 160
    edited 2006-04-14 - 01:47:26
    Hi Stan,

    I plan to publish about four more examples fairly soon.· For sure these will be done when the propeller is released.

    Dave
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-04-16 - 02:41:17
    Dave,

    ·· It was a pleasure meeting you today at the Robotics Group!· Perhaps in the future we will also see a Robot Project of yours which uses the Propeller.·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    [url=mailto:csavage@parallax.com]csavage@parallax.com[/url]
    Chris Savage | Engineering Tech | Main Office: (916) 624-8333 | Direct to Tech Support: (888) 997-8267 | Website | Twitter | Google+
  • Dave ScanlanDave Scanlan Posts: 160
    edited 2006-04-16 - 03:17:35
    Dave,
       It was a pleasure meeting you today at the Robotics Group!  Perhaps in the future we will also see a Robot Project of yours which uses the Propeller
    
    

    Chris,

    It was a pleasure meeting you too.· Your presentation on the Propeller was excellent.· I can't think of anything you missed.

    Yes, I would like to construct a robot·using·the Propeller...perhaps this summer when I·have some free time.· BTW, the club members I talked to·thought the Propeller was priced appropriately.

    Dave
Sign In or Register to comment.