This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Problem with inverted signals from separated PWM generators

Other Parts Discussed in Thread: TM4C123AE6PM

Hello everyone, 

I have a question regarding PWM in TM4C123ae6pm. Basically, I have 4 PWM signals, they are used in pairs so software writes a value in one output, other is the inverted value of his couple. with some deadband period. Now what I need to have is that signal A from a first couple and signal A from the second couple is also inverted. Thus signal A from the first couple is the same as signal B from the second couple. 

Therefore when I have let's say 25% in signal A(first couple) in signal A (second couple) I will have 75% with that first part 25% is zero and other 75% is one (basically inverted, sorry for complicating ). That means signal A has 2 inverted signals, one generated by the generator itself and other is regulated by me. Signal I get at the in generator 3 is not in sync with a signal in generator 2. So signal in GEN_2 goes 25% up and when it goes down signal in GEN_3 goes down for 25% period. So signal in GEN_3 is constantly late behind signal from GEN_2 by the amount of time that signal in GEN_2 is in 1. previously did not use 

PWMSyncTimeBase();  

function: And searching this forum I ran into that. I tried to configure for these two generators to work simultaneously but second signal stys the same. Have you got any advises for me on how to achieve that signals, or maybe there is something else problem, not this synchronization that I am thinking of?

  • Hello Djedjica,

    So if I get it correct GEN_2.A must be same as GEN_3.B and GEN_3.A must be same as GEN_2.B, in terms of duty cycle and rise/fall edges?

    Code would be a good place to start!!!

    Regards
    Amit
  • Hello Mr Ashara,

    Yes you are right, I think I got it now, I used same value for PWM load and same value for pulse width but I inverted signal on second generator, here is code that is in main loop (duty cycle is variable within project):

    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_4, ui32PulseWidthPhDC_ph2 + 1);
    
    PWMPulseWidthSet(PWM0_BASE, PWM_OUT_6, ui32PulseWidthPhDC_ph2 + 1);
    PWMOutputInvert(PWM0_BASE, PWM_OUT_6_BIT, true);
    PWMOutputInvert(PWM0_BASE, PWM_OUT_7_BIT, true);

    And here is function for PWM configuration

    void PWM_Configuration()
    {
    	SysCtlPeripheralEnable(SYSCTL_PERIPH_PWM0);
    	SysCtlPWMClockSet(SYSCTL_PWMDIV_1);
    
    	GPIOPinConfigure(GPIO_PE4_M0PWM4);
    	GPIOPinConfigure(GPIO_PE5_M0PWM5);
    	GPIOPinTypePWM(GPIO_PORTE_BASE, GPIO_PIN_5 | GPIO_PIN_4);
    
    	GPIOPinConfigure(GPIO_PD0_M0PWM6);
    	GPIOPinConfigure(GPIO_PD1_M0PWM7);
    	GPIOPinTypePWM(GPIO_PORTD_BASE, GPIO_PIN_1 | GPIO_PIN_0);
    
    	ui32PWMClock = SysCtlClockGet()/1;
    	ui32PWMLoad = ((ui32PWMClock)/PWM_FREQUENCY)-1;
    
    	PWMGenConfigure(PWM0_BASE, PWM_GEN_2, PWM_GEN_MODE_DOWN);	//generator 2 --> PE4 PE5
    	PWMGenPeriodSet(PWM0_BASE, PWM_GEN_2, ui32PWMLoad);
    
    	PWMGenConfigure(PWM0_BASE, PWM_GEN_3, PWM_GEN_MODE_DOWN);	//generator 3 --> PD0 PD1
    	PWMGenPeriodSet(PWM0_BASE, PWM_GEN_3, ui32PWMLoad);
    
    	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_4, ui8PWMAdjust*ui32PWMLoad/1000);	//generator 2
    	PWMDeadBandEnable(PWM0_BASE, PWM_GEN_2, 80,80);
    	PWMOutputState(PWM0_BASE, PWM_OUT_4_BIT | PWM_OUT_5_BIT, true);
    
    	PWMPulseWidthSet(PWM0_BASE, PWM_OUT_6, ui8PWMAdjust*ui32PWMLoad/1000);	//generator 3
    	PWMDeadBandEnable(PWM0_BASE, PWM_GEN_3,  1,1);
    	PWMOutputState(PWM0_BASE, PWM_OUT_7_BIT | PWM_OUT_6_BIT, true);
    
    	PWMSyncTimeBase(PWM0_BASE, (PWM_GEN_2_BIT|PWM_GEN_3_BIT));
    }

    It seems fine to me now, signals are in sync now, but I'm not quite sure I used this function PWMSyncTimeBase() at the right way. 

  • Amit Ashara said:
    Code would be a good place to start!!!

    Friend Amit - you are (too) kind.   Code (and a clear timing diagram, illustrating ALL desired signal outcomes) would be the ONLY place to start!

    Poster does not reveal target application - might there be (other) means - as well - to accomplish this (hidden) objective?

  • Sounds like an H-Bridge setup, in which case the easiest way to generate the second 1/2H is with a pair of inverters.

    The first is generated by the PWM engine with deadband turned on.

    Robert
  • Hello Djedjica

    PWMSyncTimeBase uses the argument of the generators and not the physical output bit. I think that is a typo in the description of the API (though the function will still work as expected).

    You should use the PWMSyncTimeBase after the PWM Generators are enabled.

    Regards
    Amit
  • Thank you Mr. Ashara.

    Mr. Adsett, yes it is H-bridge setup, sorry for not being so clear in my first question, I was writing in hurry.

    Mr. cb1 I don't understand why are you being so hostile nor do I understand what could possibly be my hidden objective. I actually tried to delete question several times when I got correct output on the oscilloscope which was before it was answered by Mr. Ashara, just not to bother you with something which is solved. (Maybe you should check with team that does web, I got Google chrome freezed when trying to delete question and it repeated 5 times than I gave up on deleting post.) I thought the question is trivial for you guys who are in this subject much longer than I am, and turns out I was right. 

    Nevertheless I am sorry if my question was vague at first, you will be getting code snipetts from now on :)

    Kind regards, 

    Djedjica

  • Djedjica said:
    Mr. cb1 I don't understand why are you being so hostile nor do I understand what could possibly be my hidden objective

    I'm fairly sure he wasn't being hostile.  It's just his manner of speaking and text will often convey emotions that are not intended.

    Djedjica said:
    Mr. Adsett, yes it is H-bridge setup, sorry for not being so clear in my first question, I was writing in hurry.

    Not to worry, we approach clarity a piece at a time.

    Robert

  • Thank you Robert.

    Clearly there was NO "hostility" - there was (and remains) the suggestion that a, "Timing Diagram" (exceeds) 1000 words of complex, 4 signal, description.

    Your writing struggled to describe - the timing diagram would simplify, strengthen & speed your objective.  (even a native English speaker would have been challenged by a (strictly) written description.)    You'd do well to better differentiate between "constructive guidance" and hostility...

    Being outsiders - posters Robert, f.m. & I are not bound to (full) PC convention.  Vendor sought code - yet code AND timing diagram provides the best description of your desires...

    We did note one deadband parameter set of (1,1) (w/in your code) which is unlikely to offer full/proper "shoot-thru" protection...  (that's not hostile, either...)

  • Hello cb1

    We all know that the forum is a place where "sparks:" fly and in all fairness, no one is hostile... Urgency creates the situation...

    Regards
    Amit
  • Hi Amit,

    I don't know about such "sparks" - poster's issue would have greatly benefitted from the inclusion of a timing diagram. Identifying such "post weakness" is (far) from hostile. (firm/I make a pretty fair living identifying & correcting such issues - note that "Paying" clients never (mistakenly) characterize such "constructive guidance" as does this poster. (very mistakenly)

    As to urgency - a proper posting - including such a 4 channel waveform/diagram - insures the quickest & most prepared response.
  • Hello everyone,

    I apologize if I started something that should not be discussed about in this forum. I have huge respect for you all that help all of us with our small and big problems and many of my issues are solved with searching or posting this forum. So I thank you all for that.

    Mr. cb1, forgive me if I am wrong, but I understood your post as a bit hostile since you were not talking to me with advice to post diagrams and code but you were talking to Mr.Amit as how he is kind to even try answer my question which is without diagrams and code and insinuating I have some hidden objective in posting that question, you may have gave me advice in doing so in future, indirectly, but you were certainly not speaking directly to me about that. But than again I am sure you know better than me, and there are some posters with some "hidden" objective so you felt need to warn Mr. Amit about that. I ensure you that was not my intention,  I simply thought that this PWM configuration is trivial to you and as I said I was in hurry to have this posted and hopefully get the answer the same day since I am not in the same time zone as you are.

    As for Deadband parameter, yes I am aware of that, we were doing some testing and optimizing this parameter in system so this parameter stayed like this in time when I was posting to the forum. 

    Thank you all, 

    Kind regards, 

    Djedjica

  • No forgiveness is sought - but kindly note that "intent" is often difficult to glean in a courtroom - perhaps even harder, here.

    There is NO doubt that a timing diagram would have strengthened your post - I write often here w/suggestions which I believe will aid the community - in general.   That's a very desired goal - is it not?    

    Vendor reps here are under great time pressure - I sought (thru humor - not hostility) - to aid the vendor by "Flagging" the need for a clarifying diagram!    Many times this vendor has appreciated & adopted such suggestions...  (we "outsiders" - responding to far fewer posts - may (on occasion) identify items which aid vendor's guidance)

    We're all glad that you solved your PWM issue.