Shop OBEX P1 Docs P2 Docs Learn Events
using different frequencies — Parallax Forums

using different frequencies

Kris CardoenKris Cardoen Posts: 46
edited 2013-01-28 17:27 in Propeller 1
Hi,

Normally I use the following freq in my programs


> system.Clock(80_000_000) 'Setting the clock

Now, I have connected encoders that support up-to Frequency = up to 30khz

I'm having trouble using the encoders, I guess that 80kz is too fast...

But when I change my setting to system.Clock(25_000_000) for example my Parallax Serial Terminal Plus gives strange symbols.

Is it possible to have different fequencies for different cogs and if not how can I solve this problem?

 OBJ  Encoder : "Quadrature Encoder"
  pst     : "Parallax Serial Terminal Plus"
  pin     : "Input Output Pins"                'instance for using I/O pins
  time    : "Timing"                           'instance for timing
  system  : "Propeller Board of Education"     'instance for board of education    


VAR
  long Pos[3]                            'Create buffer for two encoders (plus room for delta position support of 1st encoder)
  long forwardCounts
  long backwardsCounts 
PUB Main
  system.Clock(30_000_000) 'Setting the clock                                  'Initialise clock  
  pst.Start(115_2000)  
  Encoder.Start(0, 1, 1, @Pos)           'Start continuous two-encoder reader (encoders connected to pins 8 - 11) 
  repeat
    pst.Str(String("pos 0 = "))
    pst.dec(Pos[0])
    pst.newline


    pst.Str(String("forwardCounts = "))   
    '<read Pos[0]
    ' or Pos[1] here>         'Read each encoder's absolute position
    forwardCounts := Encoder.ReadDelta(0)   'Read 1st encoder's delta position (value since last read)
    pst.Dec(forwardCounts)
    pst.newline
    time.Pause(2000)

any help would be much appriciated

Comments

  • jmgjmg Posts: 15,173
    edited 2013-01-28 13:28
    Now, I have connected encoders that support up-to Frequency = up to 30khz

    I'm having trouble using the encoders, I guess that 80kz is too fast...

    This does not quite make sense. Where does ' that 80kz ' come from ?
    What does 'trouble using' mean, exactly ?

    Encoders are state/edge based, so will work from seconds-per-click, up to some HW/SW ceiling, and usually a library will say what it is tested to.
    Some libraries will give error flags on illegal states, which can indicate over-run issues, and/or they may miss counts above a certain rate.
  • Kris CardoenKris Cardoen Posts: 46
    edited 2013-01-28 13:59
    I've got the system.Clock(80_000_000) from the examples http://learn.parallax.com
    I'm quite new at this so please forgive my ignorance :-)


    I was not able to read the signals from the encoders. Because it says max 30MZ max for the encoders I was wondering if
    I had to modify my setting in the spin code to a lower value.


    If I understand from your feedback this should not be a problem.
    I guess I will have to look at the output signal of the encoders, maybe there is another reason for the problem.


    Anyway thanks for helping to rule out this as a possible problem.
  • jmgjmg Posts: 15,173
    edited 2013-01-28 14:13
    I was not able to read the signals from the encoders. Because it says max 30MZ max for the encoders
    but above you said 30KHz ? - where exactly is 'it says' ?
    If I understand from your feedback this should not be a problem.
    I guess I will have to look at the output signal of the encoders, maybe there is another reason for the problem.

    Can you control the speed of the encoders ?
    Do they count Ok at low speeds ?
    You need to report what does work, and what does not, and what test points you have tried.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-01-28 16:15
    but above you said 30KHz ? - where exactly is 'it says' ?

    I think he meant MHz.
  • kuronekokuroneko Posts: 3,623
    edited 2013-01-28 17:27
    But when I change my setting to system.Clock(25_000_000) for example my Parallax Serial Terminal Plus gives strange symbols.
    This method only accepts 5M/10M/20M/40M/80M as valid clock frequencies (see method description). Anything out of range will result in 5M overall speed which is too slow for 115200 baud.
Sign In or Register to comment.