Need Help! PWM Timing Help


Results 1 to 2 of 2

Thread: PWM Timing Help

  1. #1

    Default PWM Timing Help

    I have some external FETs driving solenoids at 12v, controlled by Kflop I/O 27,28,29, & 30. I want to use a C program in Kflop to allow me to PWM the solenoids to reduce force with an M code and variable call. This isn't a problem but I have found that the PWM RMS voltage varies depending on the number of other C threads that are running at the same time. I believe Kflop is executing one thread every 90 microseconds, so depending on the number of threads, the signal may stay on a longer or shorter amount of time due refreshing rate.

    Is there an easy way around this or a better method I can use? (The hardware config is somewhat fixed at this point). See sample PWM code:

    #include "KMotionDef.h"
    #include "TactileCalData.h"
    #include "TactileDef.h"


    #define INITIAL_ON_T .04
    #define PULSE_ON_WIDTH .0008
    #define PULSE_OFF_WIDTH .0004


    main()
    {
    SetBitDirection(SIGNAL_2_BIT,1);
    SetBit(SIGNAL_2_BIT);
    Delay_sec (INITIAL_ON_T);


    for (; //loop forever
    {
    SetBit(SIGNAL_2_BIT);
    Delay_sec (PULSE_ON_WIDTH);
    ClearBit(SIGNAL_2_BIT);
    Delay_sec (PULSE_OFF_WIDTH);
    }
    return 0;
    }

    Thanks! -Troy

    Similar Threads:


  2. #2
    Member TomKerekes's Avatar
    Join Date
    May 2006
    Location
    USA
    Posts
    4045
    Downloads
    0
    Uploads
    0

    Default Re: PWM Timing Help

    Hi Troy,

    Why not use some of the KFLOP hardware PWM generators? See the PWM1KHz.c example.

    Regards

    Regards
    TK http://dynomotion.com


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


About CNCzone.com

    We are the largest and most active discussion forum for manufacturing industry. The site is 100% free to join and use, so join today!

Follow us on


Our Brands

PWM Timing Help

PWM Timing Help