Hi Troy,
Why not use some of the KFLOP hardware PWM generators? See the PWM1KHz.c example.
Regards
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:
Hi Troy,
Why not use some of the KFLOP hardware PWM generators? See the PWM1KHz.c example.
Regards
Regards
TK http://dynomotion.com