Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Is it possible to make a 3 phase Sine PWM signal, 5 KHz with a PIC18F4550?

Status
Not open for further replies.

Luis J.I.

New Member
I'm in the process of designing a device and
Circ_EnV4.png
Frec_progr.png
in a way I could build 3 sinusoidal signals, 120 degrees delayed each, so it is a triphasic system at a frequency a little lower than 5,000 Hertz. (The instruction for hpwm in picbasic I didn't find the way to use it correctly) To make this, I thought I could vary the width of pulses (switching 3 pins and using a bridge to generate the negative part), but, if I need to control each cicle in 1/5000 Sec. and each cicle with at least 40 pulses to make 1 cicle of the wave, and each pulse could have 10 values of width on time, the minimal time unit would be about 500 nS, but I need a program of about 200 instructions (look for sensors, 3 ADs, ), so, I need about 40 mS for each program cicle. So in order to compare time with an 'interruptions made' clock, I'd need a clock 80 times faster than my original design with a 20 MHz clock: 1.6 GHz
So, in these order of ideas, I'm thinking in a redesign with a 1.8 GHz capable microcontroler. But then that is why I preffer to ask for help:
1. Is there a way of generating a 5,000 Hertz triphasic signal with the pic 18f4550, even if I add some peripheral devices?
2. If not, Is there a microcontroller capable of this PWM Speed or, for a program method, with a clock of 1,8 GHz? Is it expensive?
3. I use pic basic pro, I'd try to use same compilation method, unless it be impossible
4. Maybe there are some other devices than a uController, that are thought to generate this signals and I don't know them, but you could talk me about them
5. I saw in (https://www.microchip.com/forums/m819149.aspx) the next sentence: ""From a PIC24 CPU, I have a 3.3 Volt PWM output, modulated at 1 kHz using an 8-bit lookup table for the sine values. The PWM frequency is 32.768 kHz." this with on AN1523
6. I saw in ( https://www.microchip.com/forums/m1158178.aspx) the next phrase: "I see on the table at page 30 of the document DS61111E that when the peripherals are running at 50MHz I can get 234kHz with 7.7bit resolution which would be ok for my application." but I didn't find further information about it
Looking in MAPS I am considering PIC24FJ32MC104-I/PT because I saw that it can generate a fast PWM signal, but I see I ignore how they do it I have tryed to understand HPWM instruction in PicBasic Pro, which offer to use the PWM channel independently of the program, but, it is not clear to me how to follow the lookup table to get a sine kind wave. (If I had to use C or mikroC, I ignore if there is a simmilar function there) I have some questions about the final filter, but first if I just could generate the wanted 5,000 Hz signal with the 18f4550, it would be great.

I reviewed the AN900 document, but it is oriented to a system with retrofeed, but it is not clear for me how was generated the signal.

I did a lookup table, but I wonder what happen if each pulse I have to change the duty, the time between pulses is determined by the program, not by the HPWM, or I have not understood how it works. I want to make a stable frequency sinusoidal signal, repeated as a triphasic one. I have to tune it respect my physical system and then don't touch it any more. So the first question is the uProcessor, if I can use 18f4550 (even with a 48 MHz cristal, that I would get, because now I have a 18f4550 and the 20 MHz cristal) and how to achieve this 5 KHz, which seem very afordable comparing with the 6th point above.

If you had the patience of reading this, thank you, although you can't help me this time.

Thank you in advance and
best regards
Luis Jiménez I.

Attached the image of the 18f4550 circuit in proteus and a graphic idea of the signal
 
I doubt you will get the results you need with that MCU, and it would be extremely complex. You need one with at least three PWM units.

The ideal device is a PIC24 or DSPIC33, with multiple PWM units.

Then, use three PWMs all synchronised to the same time source (eg. a timer to set the cycle rate), put them in "centred" PWM mode and feed the sine values to them, each offset by 120 through the sine tables.

You do not offset the PWM timing itself, only the duty cycles change.

There is a lot of info on the Microchip site about these techniques, typically used with such as brushless DC (BDLC) motors.

See this app note, especially Page 15 & figure 14; is shows how all three PWMs run together in centred mode, but with varying duty cycles to create the correct phase-to-phase output voltages.


You can download the example source code to go with that app note here, for a range of MCUs. You can use the space vector & PWM parts with your own cycle rate time generator code:
 
This might be of interest -


Its a single chip solution, has ARM core, and many other resources. The approach shown uses
no CPU intervention, all done with DMA and DAC.

IDE (PSOC Creator) and compiler free. Low cost $10 board to get started -

1623343853124.png





Regards, Dana.
 
Last edited:
the document 01017A.pdf is too much oriented to motor control with feedback and pid. It is much more complex than what I'm trying to do. Do you know about a simpler document where PWM be treated (as for an inversor, although they are too slow (60 Hz) compared with 5 KHz) and explained in a more easy way? The problem is to understand how it works the PWM hardware implemented on microchip Ucontrollers and how can I interact with it on my code. As I said, preferable PicBasic Pro, but otherwise I'd need to know what C compiler is selectable to make the hex files. I understand the theory of PWM, i did an inverter previously, but without the HPWM (hardware pwm) available in picbasic, which is just what I need to use, the hardware implemented PWM, even if I would change to C compiler. So I hope somebody could help me to curve my ignorance relative to this item, cause the document related is too much of what I'm needing. Some day I will understand it, but let it come later, as a next step.

Even if I could generate just one positive half sinusoidal PWM at 5 KHz, repeat this in a bridge to generate the negative part, and replicate the same signal in another 2 pins with the 2 different delays needed, it only would need just one hardware PWM. Do somebody think it is possible? Is it possible to return a PWM signal to a pin and generate the same signal but delayed in another pin?
Thanks
Luis
 
Last edited:
This might be of interest -


Its a single chip solution, has ARM core, and many other resources. The approach shown uses
no CPU intervention, all done with DMA and DAC.

IDE (PSOC Creator) and compiler free. Low cost $10 board to get started -

View attachment 131833




Regards, Dana.
At first sight I tought it was just publicity of something different, now I saw it better, I'll see what it is about, Can I generate the 5 KHz triphasic signal with it and stop or initiate it from the 18F4550? Thank you for your answer
 
Yes on start and stop, trivial to handle. If input is mechanical with
bounce also use its debounce internal resource. It can be as simple
as an HW enable choice in DDS to a sync of waveform to stop at
a a particular sample value.

If needed changing the freq over a serial link would be easy as
well, just sending a command from Microchip to PSOC and
changing the DDS freq.

Note the output of the Wavedacs that create the sine are unipolar,
so if you need bipolar you would AC couple them. Additionally the
Wavedacs can generate anything, and have some other standard
forms like Tri, Ramp, Square, arbitrary....

Regards, Dana.
 
Last edited:
you must be able to over come the challenge by adding more external hardwires. instead of holding a particular output at high for width "ON" time you can use external latch. another signal to unlatch. you can first develop and test a single waveform circuit and think of multiplexing rest of the 2 waves using external circuit with required time delay.
 
Last edited:
This is an example gating sine in a burst, eg. the control. In this case the burst
is synchronous with the start of the sine sample set. Counters are used to count
the total number of waveform samples, hence cycles. Again single chip solution.
This is more control than you asked for, just an example of what can be done with
a SOC type part.


The # samples / cycle is configurable in the Wavedac. In the example link I showed
earlier used was 100 samples/sine wave cycle.


Here is an examination of sinewave distortion versus sample set size -


Checkout the right hand window in IDE, very few of the chips resources used,
many capabilities remain for other use.


Regards, Dana.
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top