Shop OBEX P1 Docs P2 Docs Learn Events
Reference and phase with the propeller — Parallax Forums

Reference and phase with the propeller

BeauHoundBeauHound Posts: 6
edited 2008-07-07 13:25 in Propeller 1
I am new to the propeller. Can the propeller act as a frequency multiplier/divider? For example, I would like
to input a 60hz ac line reference pulse and ouput a frequency. For example, 60hz in and 60hz/ 30/hz/24hz out which coincides with the 60hz 6 times ps.
I would like to able to set phase delay, duty cycle. I know how to code this (I think) but is this a valid application for the propeller?
How precise can the timing be with low frequencies like these? Another application needed for multiplying to higher frequency would be stepper motor control(ie step and direction) referenced to a pilot tone 50hz, 60hz, etc. Any thoughts ?

Post Edited (BeauHound) : 5/29/2008 11:40:17 PM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2008-05-29 23:54
    Yes, the Propeller can do this. It would functionally act as a frequency multiplier / divider, but actually would be a frequency synthesizer using the AC reference to reset the phase. The built-in counters would be used for the synthesis with a resolution to 12.5ns (with an 80MHz system clock) and you'd use a zero-crossing detector to track the AC line reference. Another counter could determine the number of system clocks between zero-crossings and that would be used to adjust the times for the frequency synthesizer. The details depend on exactly what you want to generate and the rules you'd want to use for synchronization with the AC line.
  • sjevsjev Posts: 10
    edited 2008-07-03 12:01
    Hi, I've got a comparable challenge that I have been thinking about. This thread is very close to what I need, so I decided to post my question here.

    My application is a printer (actually a 3D printer turn.gif) . Currently several propeller boards are being used for motor control and printhead drive.

    The thing that I haven't figured out yet is the frequency multiplificaton that has to be done. A linear quadrature encoder tracks the position of the printhead carriage, but the resolution of the encoder is much too low ( +- 100 lines per inch). I need to upscale this several times while keeping track of position.

    Suppose I want to multiply the frequency by factor 4. This means that for every encoder pulse I need to produce exactly 4 pulses. I can not just measure the encoder frequency and then set a frequency output, by using this I will probably loose the linear position as not exactly 4 pulses are produced for one encoder pulse.

    How can I measure the period, produce the high frequency pulses and track global position at the same time?
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-07-03 12:30
    sjev: Not sure I understand why you want to multiply your encoder output. This will not increase your resolution, because every pulse would result in four pulses. You would never be able to resolve it down to something other than a multiple of four. When the pulses stop coming, you don't know how far it went past that last pulse and your frequency multiplier would happily count away until it noticed that the pulses stopped coming. You can only process information, you cannot create it. You cannot increase resolution through software.

    Are you driving another device which expects 4 times the resolution and using the Propeller to do the translation? If that's the case, just send out four pulses every time you receive one. The timing of the four pulses would depend on the rate of pulses from the encoder. Keep track of the interval between incoming pulses, and on each received pulse send four pulses at 1/4 the previous interval. In the end, your effective resolution will still only be as good as your encoder.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔


    Post Edited (Ken Peterson) : 7/3/2008 12:37:21 PM GMT
  • sjevsjev Posts: 10
    edited 2008-07-04 06:58
    >Keep track of the interval between incoming pulses, and on each received pulse send four pulses at 1/4 the previous interval.

    That is exactly what I want to do. Indeed, I need to drive a device that expects 4 times the resolution.
    But what is the easiest way to do this, using system counter or just polling?
  • hippyhippy Posts: 1,981
    edited 2008-07-04 17:37
    The problem is it will only work while incoming pulses are present; get a pulse and you can work out the timing to emit four ( or any number ) in that same time, but only later, after the incoming pulse, so your emitted pulses will all be delayed and won't represent where the original encoder is at the time and it all stops working when there are no encoder pulses coming in.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2008-07-04 18:04
    sjev said...
    A linear quadrature encoder tracks the position of the printhead carriage, but the resolution of the encoder is much too low ( +- 100 lines per inch).
    Depending on how you define "resolution", the answer may lie in the encoder itself. Quadrature encoders marketed as "100 counts per inch" provide 100 full cycles per inch for each channel. This means there are 400 equally-spaced edges which you can use to effectively quadruple the advertised resolution. If you've already taken this into consideration, though, you really are out of luck and should consider replacing the encoder with a higher-resolution version.

    -Phil

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    'Still some PropSTICK Kit bare PCBs left!
  • sjevsjev Posts: 10
    edited 2008-07-07 10:15
    > Phil, thanks! Oddly enough I didn't consider the option of just triggering on ALL the edges!
  • Ken PetersonKen Peterson Posts: 806
    edited 2008-07-07 13:25
    Nice observation, Phil. Perhaps accomplishing that would involve polling rather than using a counter, especially if you need to detect a reversal of direction.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sign In or Register to comment.