PWM update period issue

Go To Last Post
7 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

very strange issue :(

I have to drive LENZE servo with differential square pulse. I use one PWM channel via D flip-flop to produce two complement channels.

1st try:
set constant period ( 1 milisec ) with variabile duty. on LENZE servo I took oscilogram of DFSET ( analog value drive produce from my pulse ). it is excellent ! constant horizontal line without any peaks ! conclusion: duty does not matter at all, it is only period that does matter

2nd try:
set variable period ( from 0.3 milisec to 3 milisec ). try few procedures with linear rise and fall. period is updated via ISR routine. took some oscilogram on LENZE servo drive. it looks ok !

3rd try:
same project as 2. - period can be changed in ISR routine, but it does not - ie. write const to UPD register. took some oscilogram at LENZE servo drive. it looks terrible. I get random curve with strong peaks every 20 ms.

I repeat step 1) and 2) and get excellent result. and then again step 3) and get an issue ! and so for hundred times.

I also changed ISR routine, so I did not change UPD register in ISR at all. I did it in main loop. no result.

how can I get constant period ?
any idea ?

Last Edited: Fri. Jan 7, 2011 - 08:52 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

strange issue :( continued

4th try:
using ISR to change period to get linear ramp. took oscilogram at LENZE drive and get graph like this:

........../---\......./---\......./---\.......
........./.....\...../.....\...../.....\......
......../.......\---/.......\---/.......\.....
......./.................................\....
....../...................................\...
...../.....................................\..
..../.......................................\.

rising and falling part of ramp is made setting CPD flag in CMR register to 1 ( for period ). central part of ramp have to be constant, so I set CPD flag in CMR register to 0 ( for duty ). this is new trick, to solve constant period issue. I make some progress, there is no peaks any more. but I got new issue. As you can see from graph, central part of ramp is not constant at all. it vary at two different level for period 20 milisec.

I use PWM rate from 1 to 3 milisec, so how can I get those variations at 20 milisec ? and first of all - how can period be changed if I set flag to DUTY ( does not change frequency at all - see my 1st try )

to put my issue in other word: I can change period of PWM in ISR, but I can not turn off those changes to get constant value.

any idea ?!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I will repeat last sentence from previous post:

I can change period of PWM in ISR, but I can not turn off those changes to get constant value.

nobody has same problem ?
any comment at all ?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Are you sure the output from the D flipflop is what you expect it to be?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Are you sure the output from the D flipflop is what you expect it to be?

thanks for suggestion !
I have no good osci, so I am not sure. oscilogram from LENZE servo is software module built in servo. it is only control I have. beside LEDs on EVK1100 board ;)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just for testing purposes (no servo connected to the D-flipflop) you could try to drop down the PWM frequency (using prescalers on the channel PCWM clock) and perhaps even the CPU/PBA/PBB clock to get everything down to "walking pace". That way you can observe the output from the D-flipflop on a multimeter or a pair of LEDs at 1/65536 (as an example) original speed.

That way you can see if the signals for the servo controller are what you expect them to be, or something else.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I found cool osci - my signal is OK, both on board and after interface. problem is at servo only.

just for a record - I made 5th try: start PWM without any change at all - no interrupt, no write to UPD register, with constant frequency - got same issue !

sorry for borrow your time, it is not AVR issue ! ;)