Shop OBEX P1 Docs P2 Docs Learn Events
Frequency Generation — Parallax Forums

Frequency Generation

rapscaLLionrapscaLLion Posts: 75
edited 2010-08-09 16:30 in Propeller 1
Hi,

I am using the Synth object to generate frequency at the moment. The Synth object gives a 50% duty cycle over a variable period. What I am wondering if there is an object that will allow me to change the duty cycle. What I need is to be able to have a specific, consistent pulse duration followed by a variable delay, the total timing of which results in the same period as the synth object would deliver. I am sure this would be simple enough to write myself in ASM, but I am finally understanding SPIN and haven't gotten far into ASM yet. If someone can point me to an object I can use that would be perfect. I have been unable to find one myself in the obex, but perhaps I have missed one or someone has posted an object on the forum.

Thanks!

Comments

  • LeonLeon Posts: 7,620
    edited 2010-08-04 06:16
    Try looking for PWM.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Leon Heller
    Amateur radio callsign: G1HSM
  • Christof Eb.Christof Eb. Posts: 1,247
    edited 2010-08-04 10:18
    Hi,rapscaLLion,
    I have not seen such an object.
    I don't know the desired range of timings, but perhaps you can solve this· without using the timers.
    If SPIN is not fast enough, you might try it in PropBasic?

    Good Luck, Christof
  • StefanL38StefanL38 Posts: 2,292
    edited 2010-08-04 12:00
  • John AbshierJohn Abshier Posts: 1,116
    edited 2010-08-04 14:26
    Try this one http://obex.parallax.com/objects/467/

    John Abshier
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-08-04 15:20
    What the OP is describing is not PWM. In PWM, the frequency is constant and the pulse width varies. What he asking for is just the opposite: fixed pulse width and variable frequency. AFAIK, such an object has not yet been posted.

    rapscaLLion, what pulse width, range of frequencies, and number of channels are you looking for?

    -Phil
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-08-04 16:25
    I use this all the time. How many outputs do you need? EDIT: maybe it isn't what you need? maybe explain yourself some more?

    Up to 31: obex.parallax.com/objects/506/
    Up to 6: obex.parallax.com/objects/422/
    Only 1: I don't have it in the OBEX, but I have it, if you want it I can upload it

    The lower the number of the outputs, the higher the precision.
    I am not quite sure exactly what you need, but the 31 output object allows unique duties for each output, while the other two objects allow one duty for all outputs. The objects could be modified easily to change that though (I'll do it if you want).
    The other issue, depending on your needs, is the cog has to be restarted to change the frequency, the duty, or which outputs are on.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!

    Some of my objects:
    MCP3X0X ADC Driver - Programmable Schmitt inputs, frequency reading, and more!
    Simple Propeller-based Database - Making life easier and more readable for all your EEPROM storage needs.
    String Manipulation Library - Don't allow strings to be the bane of the Propeller, bend them to your will!
    Fast Inter-Propeller Comm - Fast communication between two propellers (1.37MB/s @100MHz)!

    Post Edited (Bobb Fwed) : 8/4/2010 6:12:38 PM GMT
  • rapscaLLionrapscaLLion Posts: 75
    edited 2010-08-04 16:31
    It's just one output actually. I'll check out the freq synth x6 object.
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-08-04 16:37
    There is the one output program (attached).
    It is way more precise than the other objects, and it goes to a lot higher frequencies (haven't tested exactly how high), but a quick glance says the PASM could go somewhere around 6MHz at 50% duty. But if I remember correctly, there is some math overflow in the SPIN when you go that high, so it won't work. But that can be fixed. I have used it up to 500kHz.

    EDIT: it turns out the limit for this object is about 2.35MHz at 50% and higher (3MHz) if you have the duty close to 24%.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!

    Some of my objects:
    MCP3X0X ADC Driver - Programmable Schmitt inputs, frequency reading, and more!
    Simple Propeller-based Database - Making life easier and more readable for all your EEPROM storage needs.
    String Manipulation Library - Don't allow strings to be the bane of the Propeller, bend them to your will!
    Fast Inter-Propeller Comm - Fast communication between two propellers (1.37MB/s @100MHz)!

    Post Edited (Bobb Fwed) : 8/4/2010 5:04:51 PM GMT
  • tonyp12tonyp12 Posts: 1,951
    edited 2010-08-04 17:38
    By just using the cogs counter there is a limit to the time/freq deisgn.

    Are your trying to adjust A,B, or C?
    640 x 360 - 24K
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-08-04 17:41
    From what I gather, he wants a constant frequency, with a variable duty (thus my suggested object). Which is neither of those. Please correct me if I'm wrong. I wish the counters did what my software does, it seems simple enough, and common (at least in my world).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!

    Some of my objects:
    MCP3X0X ADC Driver - Programmable Schmitt inputs, frequency reading, and more!
    Simple Propeller-based Database - Making life easier and more readable for all your EEPROM storage needs.
    String Manipulation Library - Don't allow strings to be the bane of the Propeller, bend them to your will!
    Fast Inter-Propeller Comm - Fast communication between two propellers (1.37MB/s @100MHz)!
  • rapscaLLionrapscaLLion Posts: 75
    edited 2010-08-04 17:41
    What I'm trying to do is drive a motor. It uses frequency instead of straight PWM. I had it behaving perfectly, but the problem is the synth object I was causing the motor to sing. What I need to do is maintain the synth output but adjust the pulse and wait durations to get the motor running at the same speeds but above the audible range. I'm probably not using the right words here, does this make any sense?
  • Bobb FwedBobb Fwed Posts: 1,119
    edited 2010-08-04 17:44
    You want to maintain an ultrasonic frequency while being able to adjust the PWM. Right? Did my object work for you?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    April, 2008: when I discovered the answers to all my micro-computational-botherations!

    Some of my objects:
    MCP3X0X ADC Driver - Programmable Schmitt inputs, frequency reading, and more!
    Simple Propeller-based Database - Making life easier and more readable for all your EEPROM storage needs.
    String Manipulation Library - Don't allow strings to be the bane of the Propeller, bend them to your will!
    Fast Inter-Propeller Comm - Fast communication between two propellers (1.37MB/s @100MHz)!
  • tonyp12tonyp12 Posts: 1,951
    edited 2010-08-04 19:03
    >What I'm trying to do is drive a motor. It uses frequency

    Always include as much info as possible in the original question.
    Where is the data-sheet for this motor?

    That way we can tell what range the numbers need to be in.
  • rapscaLLionrapscaLLion Posts: 75
    edited 2010-08-08 20:28
    Hi,

    Here are the data sheets for the motor and controller. They are fairly sparse in terms of useful information as you can see. Any help you can provide in terms of how to drive this without encountering the pitchy/whiny noises would be great. There are certain parts of the speed ramp up and down which are practically silent (actual mechanical noise only), and others where the darn thing sounds like a slot machine.
  • StefanL38StefanL38 Posts: 2,292
    edited 2010-08-08 23:15
    First of all well done to attach the datsheets.

    It is a steppermotor with 200 steps per revolution
    and a steppermotorcontroller

    I guess the dutycycle is not important here.
    The steppermotorcontroller is able to create MICRO-steps.

    With switches SW5-SW8 off on on on you are working in halfstep mode
    400 steps per revolution.

    If you choose more steps per revolution this might cause the noise

    You have switches SW1-SW3 to set the current. This means the voltage
    is switched ON/OFF at a high frequency (10kHz-25kHz) to get more torque out of the motor.

    These are two possible reasons for the noise you hear.

    best regards

    Stefan
  • rapscaLLionrapscaLLion Posts: 75
    edited 2010-08-09 16:30
    Thanks.

    We are doing 400ppr with halfsteps. Setting a higher ppr results in the same noise, only much louder. Varying the synth object coding (playing with the pulse and delay timings) results in identical speeds but with varying levels of noise, the only problem is I can't seem to ramp up or down without the motor "singing" with a distinctly "stepping" tone. By that I mean as the speed ramps up, the tone steps up, and vice-versa as the speed ramps down.

    Any thoughts as to how to modify the synth object to limit the singing as much as possible?
Sign In or Register to comment.