587,006 active members*
2,853 visitors online*
Register for free
Login
Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2014
    Posts
    22

    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

  2. #2
    Join Date
    May 2006
    Posts
    4047

    Re: PWM Timing Help

    Hi Troy,

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

    Regards
    TK
    http://dynomotion.com

Similar Threads

  1. Timing screw
    By Guycnc in forum French
    Replies: 0
    Last Post: 05-12-2012, 06:27 PM
  2. Timing M7/M9 on/off?
    By Gashmore in forum G-Code Programing
    Replies: 2
    Last Post: 07-25-2011, 09:08 PM
  3. timing belts that don't cog
    By oxford in forum Linear and Rotary Motion
    Replies: 7
    Last Post: 10-18-2010, 10:32 PM
  4. THC Timing?
    By Red Earth in forum Waterjet General Topics
    Replies: 27
    Last Post: 04-16-2007, 04:03 PM
  5. Timing Belts .200 xl
    By elogicca in forum DIY CNC Router Table Machines
    Replies: 1
    Last Post: 11-14-2006, 03:09 AM

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
  •