Author Topic: PWM issues  (Read 14364 times)

Hminx

  • Newbie
  • *
  • Posts: 6
    • View Profile
PWM issues
« on: May 28, 2024, 02:25:18 AM »
Hi All
I'd appreciate any thoughts on an issue I'm having with a PWM function on a T100MD that I'm using in the development stage of a project which will shift a truck's AMT type  transmission directly to 5th gear. I need to position the gear selector actuator selector opposite 5th gear gate. I'm trying to reproduce to factory pulse train.
The problem is that the amount of PWM seems to be difficult to control for some reason. When Start contact closes the output 7 pulses at 500 hz 90% PWM but wont turn off when start contacts open and continues with the pulse train

                                                 Start         Clk:.05s                                                                                     cf  1
                                             ----II------------II--------------------------------------------------------------------{dCusF}

Function 1
' set pwm level for side shift function   
 SetPWM 1,A,500

    Function 3               
   if testio (r1) = 1
   then
   A = DM[1]
   else A = DM[2]
   endif
   
 
  if testio (r2) = 0
  then DM[1] = 0
  else DM[1] = 9000
  endif

  if testio (r2) = 0
  then DM[2] = 0
  else DM[2] = 3500
  endif


Not sure if this make sense, I know I've only shown a small part the program

Cheers Pete

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re: PWM issues
« Reply #1 on: May 30, 2024, 09:08:02 AM »
PWM output from T100MD (or its successors - the FMD or Fx PLCs) are not designed to output precise number of pulses. It is meant to output a PWM pulse train that average to a mean level proportional to the duty cycle. The 0.05 second ladder logic contact is subject to I/O and program scan time so cannot be counted on to provide the precise amount of time.

The STEPMOVE function will be able to output precise number of pulses for positioning purposes. However, it will only output with 50% duty cycle if that works.

One way you may try is to run the SETPWM statement and then put a  DELAY statement and then turn it OFF.  This will mean that during the PWM output period the CPU program will wait in a delay loop waiting for the n ms to expires in the DELAY(n) function and not do anything else.

SETPWM 1,x, y   ' turn on PWM output
DELAY 50           ' wait 50ms  (0.05s)
SETPWM 1, 0, y  ' turn OFF PWM output
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Hminx

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: PWM issues
« Reply #2 on: June 02, 2024, 02:06:41 AM »
thanks for that
I have attached a shot of the pulse train at the  initial movement of the actuator  the 35% duty cycle is jitter to remove stiction the 90% is to start the actuator moving,  as it nears the required position  i would like to reduce the duty cycle to about 45%
The black line on the attachment shows the percentage of modulation I find it odd that it is varying so much, it also is obvious by looking at the pulse train so is this just a case of ' what ya sees is what ya gets ' with a T100MD
Also why does the PWM 1 output continue with start contact open, I need to hit reset to turn it off.

Appreciate your help
Cheers Pete

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re: PWM issues
« Reply #3 on: June 03, 2024, 05:28:33 AM »
thanks for that
... I find it odd that it is varying so much,..
You can try to increase the frequency of the PWM output  to reduce the variation of the output.

Quote
Also why does the PWM 1 output continue with start contact open, I need to hit reset to turn it off.

SETPWM command is a "set and forget" function. Once it is run the output will continue to operate at the duty cycle and frequency by the CPU hardware. In order to turn off the PWM output you must run another SETPWM command again to set the duty cycle to 0%.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

Hminx

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: PWM issues
« Reply #4 on: July 06, 2024, 12:53:06 AM »
Thanks Support    That helped
Next issue is that I'm trying to run two PMW outputs concurrently controlled by two different custom functions the problem being that i cant get the two output s to operate at the same time, the second  out put wont operate until the first has completed its pulse train  [ can combine both outputs into one custom function but this becomes a bit clumsy and difficult to adjust


support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3174
    • View Profile
    • Internet Programmable PLCs
Re: PWM issues
« Reply #5 on: July 06, 2024, 09:41:56 PM »
Is your custom function that run the first PWM running in a loop until the action is completed? If so that is the reason why the second PWM does not run until the program exits the first custom function.

You have to structure your program such that if you need to run two SETPWM on two separate PWM channels they should be run consecutively.  They could be in different custom function but your program must allow the custom function to exit and then return back on another scan.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS