Shop OBEX P1 Docs P2 Docs Learn Events
Help, Please. Generate multi phase sine wave. — Parallax Forums

Help, Please. Generate multi phase sine wave.

Hello,

Right out the box, I'm a newbie to Propeller.

I need to generate five PWM sine waves each 72 degrees out of phase with each other.

Is this possible?

Thank you
«13

Comments

  • At what frequency, and using what kind of output?

    There are several ways to do this either in Spin or, if you need high frequencies, PASM. You can generate the output as PWM using the cog counter-timers, but you will need three cogs to generate five signals. There is a sine table in the ROM which is handy for this sort of thing, but it covers 0-90 degrees so you will have to scan it backward-forward and invert it to get the other quadrants.
  • Yes, but the output from the propeller is going to be square way and not sine wave. Your going to have to use some kind of RC combination to make it look like a sine wave.

    Mike
  • With the counter-timers you can do PWM with 12.5 ns granularity at 80 Mhz, which looks pretty smooth at audio freqs. That's why we need to know the output frequency target.
  • Mark_TMark_T Posts: 1,981
    edited 2019-02-02 17:04
    iseries wrote: »
    Yes, but the output from the propeller is going to be square way and not sine wave. Your going to have to use some kind of RC combination to make it look like a sine wave.

    Mike

    The question is about PWM approximations to sine waves, the 5-phase motor's inductance does all the low
    pass filtering needed.

    Firstly is this is a 5 or 10 wire stepper?
  • Thank you for the replies.

    My propeller is running at 100Mhz.

    The frequency needed is 1mhz max but mostly 40khz.

    My stepper is a Pentagon 5-wire motor.

    I read somewhere that the counters are slower due to init., startup and stopping.
    The article said DAC's would be faster and more accurate.
    The Propeller does not have an internal DAC but the internal video should be better than the counters, right?


  • jmgjmg Posts: 15,173
    bteddy wrote: »
    The frequency needed is 1mhz max but mostly 40khz.

    What frequency needs to be 1mhz (or 1MHz?) - do you really have a motor that can swallow 1MHz sine waves

    A link to the actual Motor would help, along with what step rate you need, and drive scheme.

  • The motor is 1MHZ at fuff step

    The range is 1/1 to 1/256 microsteps.

    The rpm is 2400 max.

    The motor is not the question.

    The wave form is. How do I generate it?
  • jmgjmg Posts: 15,173
    edited 2019-02-02 21:20
    bteddy wrote: »
    The motor is 1MHZ at fuff step

    The range is 1/1 to 1/256 microsteps.

    The rpm is 2400 max.

    The motor is not the question.

    The wave form is. How do I generate it?

    You do need to provide better information, if you expect help. Readers here are not clairvoyant (tho some come close ;) )

    The Motor is very much the question, as google suggests there are no motors "1MHZ at fuff step" - but I can find 40KHz pulse rate motors.
    Google also suggests you need 10 independent drivers (5 HI side, 5 LO side), so it seems you seek 10 DACs, with ability to update all 10, at 1us intervals.

    Very few MCUs can manage that, the Prop2 could do that, but is it not yet in full release.


    How many of these do you expect to make ?


  • Sorry, the motor is not the question.
    I did not not ask for help with the motor.
    You put to much faith in Google.
    stc-cvk569fm_k.jpg
    Google is wrong some times.
    That's why I am here asking.

    "Google also suggests you need 10 independent drivers (4 HI side, 5 LO side), so it seems you seek 10 DACs, with ability to update all 10, at 1us intervals."

    It is only five, "Five wave forms"(what i am asking about), "five" hi/lo drivers, "five" half bridges, that connect ti the five motor wires.

    If you don't know please don't respond dragging this unto an unrelated topic.

    To all others, sorry about any confusion.

    This is what I would like to do. Right now I don't care about wave specs. I just need to know how to get 5 wave forms 72 degrees out of phase each.
    5-phase-torque-displacement.jpg

    Thank you
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2019-02-02 20:39
    You don't drive half bridges or full bridges with sine waves. They are either all the way on or all the way off. Otherwise they will overheat. You can simulate a sine drive by PWMing them, though, and let the motor inductance smooth out the ripples. I'm pretty sure that's what you need -- not an analog sine-wave output. And, yes, depending upon the PWM frequency, the Prop's video subsystem might be the way to go.

    -Phil
  • Exactly,

    Now, how would I do that, please?

    Thanks
  • So what PWM frequency do you need?

    -Phil
  • 40KHz
  • To get 8-bit sine-wave resolution, the pulse positions will have to have a timing resolution of 97ns. That's only slightly more than nine clocks in your 100 MHz system. Do you really need 8-bit sine resolution?

    -Phil
  • Sorry, I don't know.
    Is 8 bit to large?

    I was shooting for 12 bit resolution.
    While researching this I saw something that said 32 bit was way to much, 16 bit was slightly out of some MCU's reach
    but 12 bit was a good compromise.

    Create a sine table of 256 samples
    12 bit resolution from mcu.
    3.3v output swing
    72 degree separation.

    I'm just trying to learn how to create the wave forms.
    Larger/smaller, faster/slower I can work out later.
    With the wave forms I can experiment if the signal is too small I can run them thru a amplifier to get what i need.

    This is just the first step.

    Thank You
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2019-02-02 21:32
    bteddy wrote:
    With the wave forms I can experiment if the signal is too small I can run them thru a amplifier to get what i need.
    Amplifier? Now you're talking analog again. That is not what you want. Which bridge driver will you be using?

    How many full steps per rev does your motor have? How many micro-steps per step do you really need? What's the desired maximum RPM?

    -Phil
  • Don't know yet that is why the experiment.

    What do you mean analog again?
    A pulsed wave can be amplified to increase amplitude or divided to increase frequency.

    Forget about the use, please.

    How do i create the multi wave?
  • jmgjmg Posts: 15,173
    edited 2019-02-02 21:40
    bteddy wrote: »
    Google is wrong some times.
    That's why I am here asking.
    With half baked questions, you cannot hope to get much here, hence everyone has to ask you more questions...
    bteddy wrote: »
    "Google also suggests you need 10 independent drivers (4 HI side, 5 LO side), so it seems you seek 10 DACs, with ability to update all 10, at 1us intervals."

    It is only five, "Five wave forms"(what i am asking about), "five" hi/lo drivers, "five" half bridges, that connect ti the five motor wires.

    Oriental Motor, who actually make 5-phase motors, have PDFs that show the excitation I mention.
    Now you can perhaps see why the motor matters ?

    The image you link, is for a Motor+Driver package, so you appear to be wanting to replace an existing Motor driver, with your own design ?

    bteddy wrote: »
    This is what I would like to do. Right now I don't care about wave specs. I just need to know how to get 5 wave forms 72 degrees out of phase each.
    5-phase-torque-displacement.jpg

    As already mentioned, you need (at least) 5 DACs to do that, plus the power drivers to turn those sine-waves into motor levels.
    The Prop 1 does not have DACs, but Prop 2 does.
    Prop1 can do Pulse Density modulation in HW, (2 per COG) but you will doubtless already know why that is less than ideal for motor drive. PWM needs SW assist.

    The Prop 1 can generate NCO type step control, so it can nicely manage Step/Direction to a smarter DAC motor driver.

    There are small MCUs that can manage the Table-DACs part, but that is an analog signal, so you need another modulation stage to turn into MOSFET-drive/current feedback.

  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2019-02-02 22:23
    jmg,

    It's not yet clear whether he needs analog output or PWM output. He seems to be going back and forth on this matter. On the one hand he mentions a 40kHz PWM rate and bridge drivers; on the other, an amplifier. So I'm perplexed.

    OTOH, if he's using a driver that converts an analog input to PWM, I might recommend a different part, and let the Prop do the PWMing with the video driver. The PASM code would be harder to write, but it would use fewer than the three or four cogs necessary to produce five DUTY-mode outputs.

    -Phil
  • bteddy,

    The forum members are tying to be helpful but you still have not stated what you are trying to do other than experimentation.

    What parts do you have and what are you trying to do with them?
  • OK, your confused, I'm sorry you can't see this.
    I thing it's great your helping and haven't just said f it and disconnected.
    Thank You.

    I give short little questions for this reason, your reading to much into a simple question.

    I have a Parallax Propeller.
    I want to make 5 PWM waves 72 Degrees apart come out of it.
    That is it. How do I do that.

    All else is irrelevant.
    How it's interfaced, irrelevant
    What it is being interfaced to, irrelevant.
    I never said analog, it was assumed.
    All the other stuff came from your questions.
    I said i'm a newbie at the propeller at the start.

    To reiterate.
    All I am asking on the parallax board is
    "HOW TO MAKE THE PARALLAX PROPELLER SIMULTANEOUSLY PRODUCE 5 PWM WAVES 72 DEGREES APART"
    The previous line is for bold only, I am not yelling at anyone, please don't take it that way.

    Thank You for all you responses

  • well, lets just assume he has a P1

    one COG can do serial comms with simple serial, 7 COGs free to output a sine wave each. Each COG could use pins direct, timers or the Video circuit to output sine waves (or PWMs for them)

    It is possible to start COGs apart from each other by providing a start CNT to wait for so separating the COGs by 72 degree should be possible

    Using a P2 and TAQOZ might be way simpler, but that is not a option, yet

    Anyways don't scare him away just because he is unsure where to ask what...

    Enjoy!

    Mike
  • bteddy wrote:
    I never said analog, it was assumed.
    When you showed analog waveforms and mentioned the word "amplifier" there was a very good reason for that assumption. Please note that context is very important when you ask for assistance here. The more details you can provide, the better -- even if they seem irrelevant at the time. So when someone asks you questions about the motor and driver, your answers can provide clues as to how to answer your original question. For example, if you said your driver was such-and-such and we looked up that driver and saw that it required a PWM'd drive signal, we could have eliminated a lot of guesswork from the get-go.

    -Phil
  • Thank you MSROBOTS that is some of what I needed.

    Could I run the PWMs continously if I used multiple sine lookup tables each table at a different phase?

    Could phase 2 ,3, 4 be synced to phase 1 example phase 1 from cog0 video generator, then phase 2 from cog 1 delayed time period to equal 72 degrees etc.

    How would I get the video generator to act as a pwm?

    B




  • My 8-channel PWM generator uses the video generator. You can read about it here:

    https://forums.parallax.com/discussion/104121

    -Phil
  • That is what I was looking for!

    Thank YOU!
  • bteddy

    jmg and Phil Pilgrim are two of the smartest people on the forum. Tread lightly if you want EXPERT help.
  • I threw in the video generator because that is the fastest way to get data out, but also the most complicated, since it is mainly build for video, but can and is misused for other purposes.

    My guess is that you should work with the timer/counter of the P1. each COG has two of them and they run independent from your program in the COG. so your program can check parameter in a mailbox, and vary the settings of the counter outputting pwm.

    You should write some PASM code to do that and then you have a very precise timing, basically you can count instructions, without interrupts the code of the P1 in PASM is taking the same sysclocks every time.

    As of synchronization, usually instructions take 4 clocks, but waitcnt has a resolution of one sysclock. So basically you can set some start value when starting the COG to wait for a certain sysclock and then jump into the main routine.

    Since you will use the same code for all sine COGs you can vary the distance between pwm pulses of different COGs (your 72 displacement) down to one sysclock by waiting a different amout of clocks after start of the pwm COG.

    All of this might not be easy as a starter project, but not to complicated either. I would first write a small Spin program to run some tests, using serial for input output to the PC.

    Then the PASM program in a COG talking over a 'mailbox' (a HUB ram location both COGs need to know and agree upon) and just start talking from Spin to my PASM COG. maybe just blinking some led on off, something simple to have the communication line fro user-terminal-spin-pasm running.

    This is something most P1 program do and you will find examples of mailboxes everywhere where PASM is used by SPIN.

    If you have that running, you might start doing pwm instead of blinking and start using the counters.

    Programming the propeller is confusing at the beginning, because you have to rethink what you usually do since COGs are not threads, the run completely independent. But the programming model using one main COG and communicate with the other COGS over agreed HUB locations can lead to a very simple program separating the main code from the driver code.

    You might need to read a lot about the timer/counter and hoe to talk to PASM cogs, but I promise to you that when done it will be some astonish short code.

    Anyways, Enjoy!

    Mike
  • bteddy wrote: »
    My stepper is a Pentagon 5-wire motor.
    From the website:
    Oriental Motor stepper motors with a step angles of 0.36° or 0.72° are wound in the bipolar New Pentagon configuration and, therefore, require a bipolar type driver. The New Pentagon bipolar driver allows the stepper motor to be driven at full step, half step and even microstep resolutions while ensuring that maximum torque is being generated by the motor on every step. This is a unique advantage for 0.36° or 0.72° stepper motors. The New Pentagon bipolar drive method also provides extremely smooth motion as well as maintaining torque and step accuracy regardless of the step resolution.

    The New Pentagon motor/driver system is able to achieve this performance because the motor windings are all interconnected, as shown in the figure below. Since the coils are all interconnected, there is only one winding circuit that needs to be energized for the motor to operate. By having only one circuit to control, the driver can do a better job of controlling the amount of current in the motor, which leads to better torque stability and no loss of positioning accuracy as the microstepping resolution is increased.


  • Thanks to msrobots and phipi I have what I was looking for, a place to start.

    I found a link to a template for multicore programming with Propeller.
    https://www.parallax.com/sites/default/files/downloads/AN011-SimpleTemplate-v1.0.pdf

    I don't know who to suggest this to but Parallax should do one for the video, the pwm, the counters, etc..

    Thanks to all.

Sign In or Register to comment.