Shop OBEX P1 Docs P2 Docs Learn Events
SPIN COGS, Objects, Methods, parameters, variables. — Parallax Forums

SPIN COGS, Objects, Methods, parameters, variables.

stephenwagnerstephenwagner Posts: 147
edited 2010-02-25 22:16 in Propeller 1
I am having a difficult time understanding how input/output parameters and variables are passed from one COG to another and from one Object to another and so forth using SPIN. I have been studying the PE examples. I also have been studying the available objects at the exchange and Prop Tool examples and help files. I would like to incorporate the Quadrature Encoder object into my time delay project. One knob for the delay length and or loop cycles ·and the other knob for the amplitude and or shift left and or right. I understand the delay time would be in increments of 12.8uSec at 78KHz and the amplitude would be in increments of 3dB voltage/6dB power. I also understand there would be limits. Any advice and or tips and or a good SPIN Object study example would be appreciated.

SJW

Comments

  • kwinnkwinn Posts: 8,697
    edited 2010-02-25 14:38
    Go to the OBEX and search for "quadrature". You will get 3 objects:

    1 - Quadrature Encoder, which can read up to 16 2 bit gray code encoders and provides the delta (relative position value since last time read).

    2 - Dual Quadrature Encoder, which can read 2 encoders and gives you speed as well as delta.

    3 - Quadrature interface SPI Lsi7366, a demo app for using the LSI 7366 encoder interface chip.

    Either 1 or 2 would work for you, but 2 is slightly simpler. You should download both and take a look at them.
  • stephenwagnerstephenwagner Posts: 147
    edited 2010-02-25 18:11
    The real issue is I don't understand how the output parameters of one Object get passed into another Object.

    SJW
  • Dave HeinDave Hein Posts: 6,347
    edited 2010-02-25 22:16
    Stephen,

    You would call the start·method for the Quadrature Encoder object is as follows:

    ·QuadEnc.Start(StartPin, NumEnc, NumDelta, PosAddr)

    The parameters are the starting pin number, number of encoders, number of delta values and the address of a long buffer that holds the encoder and delta values.· It assumes that the encoders are wired up starting at StartPin.· The positions are store in the first NumEnc entries of the position buffer.· The next NumDelta entries are used to compute the delta postion values since the last time it was checked.· You would use the ReadDelta method to get the delta postions.· If you want the absolute postions you would just look at the entries in the postion buffer.

    Dave
Sign In or Register to comment.