Shop OBEX P1 Docs P2 Docs Learn Events
Qaudrature In / NSTC out; to see Quad. Values???? — Parallax Forums

Qaudrature In / NSTC out; to see Quad. Values????

$WMc%$WMc% Posts: 1,884
edited 2008-10-12 21:39 in Propeller 1
· I'm tryin to send a QAUDRATURE input to a "TV". I'm using " Quadrature Encoder v1.0 "by "Author: Jeff Martin ""(C) 2005 Parallax, Inc."...I thought I Had the OBJ. placement down PAT. But I keep getting an ERROR in the " cognew(@entry, @freq) " statement. """· cognew(@entry,@freq) """(This is in the third line of the 1st " PUB " Statement of what I thing? Is the·NSTC driver INT./start???.....I'm Back hard in the books, But I'm not seeing It....(Whats Wrong w/ the code)???. I have moved the "CON" & "VAR" Statements around so much I'm not sure were they should go.

································································· $Struggle$ing____ $WMc%_____

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2008-10-11 08:50
    hello $WMc%,

    (hm - strange alias...) OK anyway

    I took a look into the original code of Quadrature_Encoder.spin

    there the cognew command is

        Pass := (Cog := cognew(@Update, Pos) + 1) > 0
    
    
    



    in your code you took the Quadrature_Encoder.spin which should be seen as an OBJECT-file
    and be used in the same way as the tv_text.spin-file: meaning using it as an objectfile

    you are are using it as a main-file

    you should create THIRD file wich is the main-file where you define an object QuadEnc and an object tv.

    the cognew should be done INSIDE the objectfile
    and then you call the START-method from your mainfile

    this is the quasi standard how it should be done

    you tried to start the PASM-cog by

       cognew(@entry, @freq)
    
    
    



    but inside your modified Quadrature_Encoder.spin-code
    in the PASM-section the LABEL is still named "Update"

    so your cognew-command uses a label named "entry" which is not defined at all

    This was a very quick look into your code as I have not much time at the moment.
    I did NOT analyze what has to be done with your freq-variable and how this variable works
    But one thing is valid in general: variables are only known INSIDE that object where they are defined
    OTHER objects can NOT access these variable DIRECTLY

    as a first attempt create your OWN mainfile with two objects
    object QuadEnc and
    object object tv

    that uses the original code from the obex or library
    then inside the MAIN write a routine that uses

    QuadEnc.start(...
    and
    tv.start(....

    and then a repeat-loop
    which contains

    tv.dec(freq) 'display the value (in Hz)

    what I'm wondering about is: the original Quadencoderobject gives back
    a POSITION you named your var freq like a FREQUENCY
    how could this object give back a frequency ?

    best regards

    Stefan
  • $WMc%$WMc% Posts: 1,884
    edited 2008-10-12 01:17
    ·· Stefan

    ··· Thank YouFor Your reply,I·kinda understand what Your suggesting,Makeing it happen is easyer said then done. I still don't fully understand the program flow,and it shows. I will try Your Suggestions....

    ································································· Thanks Again Walt McDonald__$WMc%__

    ······
  • evanhevanh Posts: 15,659
    edited 2008-10-12 04:30
    What I've done for a quick test is grab a copy of the TV_Text_Demo.spin from the examples library directory and modified it by deleting the last three repeat lines, then adding the quadrature_encoder object and my own repeat that displays the active position counters.

    Ie: First I added at the top:
    VAR
      long  position
    
    


    then I modified the OBJ list to:
    OBJ
      text : "tv_text"
      quad : "quadrature_encoder"
    
    


    and finally deleted the last repeat and replaced it with:
      quad.Start( 16, 1, 0, @position )  ' Inputs 16 and 17 are used to read a single quadrature encoder
      repeat
        text.out(1)         ' Home
        text.dec(position)
        text.out(" ")       ' Space
    
    



    This allowed me to quickly monitor my wiring and prove the 5 volt to 3.3 volt translation.
  • $WMc%$WMc% Posts: 1,884
    edited 2008-10-12 21:39
    evanh

    Thank You for Your reply; I made the MOD. to "tv_text_Demo.spin" and the other program MOD.s you suggested. And I'm happy to say I now have A working "TV" term. w/ the quadrature encoder!!!...I gonna clean the code up a bit more and I'll post the final.


    Thanks Again___Walt McDonald___$WMc%____out
Sign In or Register to comment.