Hi, I need to generate a Low Frequency PWM , preferrably with an 8 pin PIC device ... the PIC isn't doing much else other than generating a 3-stage PWM output ( i.e PWM 1 value for a period, the PWH 2 for a time period and then Period 3 continuous, until an input is triggered or the PIC is reset. The base frequency needs to around 250 Hz though. Am I correct in thinking this should be achievable with the PWM module on a PIC12F1840 with the internal oscillator set to 32kHz ? It's for a hydraulic valve application.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
By my calcs ( using the compiler ) the max chip frequency would be 4mHz for that slow PWM signal.
You may be to do this will a timer and just generate your own signal at 32 mHz.
Evan
#chip PIC12F1840, 4
#option Explicit
#define PWM_Freq 0.25 'Set frequency in KHz
#define PWM_Duty 50 'Set duty cycle to 80 %
PWMOn 'Turn on the PWM
WAIT 10 s 'Wait 10 seconds
PWMOff 'Turn off the PWM
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Evan ... really appreciate your help ... I need to get a prototype board set up for the PIC12F1840, so it may be a couple of days before I can test.
I line 2 should it be: #define PWM_Duty 50 'Set duty cycle to 50 %
Also "You may be to do this will a timer and just generate your own signal at 32 mHz." should this be MHz ?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I need to generate a Low Frequency PWM , preferrably with an 8 pin PIC device ... the PIC isn't doing much else other than generating a 3-stage PWM output ( i.e PWM 1 value for a period, the PWH 2 for a time period and then Period 3 continuous, until an input is triggered or the PIC is reset. The base frequency needs to around 250 Hz though. Am I correct in thinking this should be achievable with the PWM module on a PIC12F1840 with the internal oscillator set to 32kHz ? It's for a hydraulic valve application.
By my calcs ( using the compiler ) the max chip frequency would be 4mHz for that slow PWM signal.
You may be to do this will a timer and just generate your own signal at 32 mHz.
Evan
Thanks Evan ... really appreciate your help ... I need to get a prototype board set up for the PIC12F1840, so it may be a couple of days before I can test.
I line 2 should it be: #define PWM_Duty 50 'Set duty cycle to 50 %
Also "You may be to do this will a timer and just generate your own signal at 32 mHz." should this be MHz ?
You are correct.
You would have to set the timer2 to interrupt at the frequency you need. Then toggle the output port.
You might be able to try this perhaps?
A "simple" way of generating low frequency PWM, and it looks as though it was written for a 12F1840 too.
https://sourceforge.net/p/gcbasic/discussion/projects&guides/thread/807f5e795b/#a92e