Comments on: Generating PWM with PIC Microcontroller – MPLAB XC8 https://electrosome.com/pwm-pic-microcontroller-mplab-xc8/ You Inspire.....We Create..... Mon, 08 Apr 2019 22:39:25 +0000 hourly 1 https://wordpress.org/?v=6.1.1 By: Yousif https://electrosome.com/pwm-pic-microcontroller-mplab-xc8/#comments/7393 Mon, 08 Apr 2019 22:39:25 +0000 https://electrosome.com/?p=11152#comment-7393 Very good tutorial mate , thanks alot , i just have a question , is it possible to generate an inversed PWM signal ?

]]>
By: Emanu https://electrosome.com/pwm-pic-microcontroller-mplab-xc8/#comments/6977 Tue, 09 Jan 2018 18:21:00 +0000 https://electrosome.com/?p=11152#comment-6977 Very interesting, i like to see this program in c18 toolsuite, please help me!

]]>
By: Clement Victor https://electrosome.com/pwm-pic-microcontroller-mplab-xc8/#comments/6907 Sat, 21 Oct 2017 09:59:00 +0000 https://electrosome.com/?p=11152#comment-6907 An excellent tutorial on PWM
Beautifully done

]]>
By: Rolando Aguilera https://electrosome.com/pwm-pic-microcontroller-mplab-xc8/#comments/6809 Mon, 26 Jun 2017 08:57:00 +0000 https://electrosome.com/?p=11152#comment-6809 can u explain this part of the code please? Where did you get the logic of AND operator and then right shifting?
PWM1_Duty(unsigned int duty)
{
if(duty>2;
}
}

]]>
By: Aravind NA https://electrosome.com/pwm-pic-microcontroller-mplab-xc8/#comments/6742 Tue, 11 Apr 2017 19:22:00 +0000 https://electrosome.com/?p=11152#comment-6742 Hi,does it possible to produce 100hz-200hz by using above method?nice tutorial….

]]>
By: Freddy https://electrosome.com/pwm-pic-microcontroller-mplab-xc8/#comments/6709 Sat, 18 Mar 2017 04:47:00 +0000 https://electrosome.com/?p=11152#comment-6709 Hi Ligo, could the push button switches be replaced with a potentiometer (one per PWM), i am having trouble with what the circuit/code adjustments would be to do this.

]]>
By: Pier https://electrosome.com/pwm-pic-microcontroller-mplab-xc8/#comments/6642 Tue, 14 Feb 2017 10:21:00 +0000 https://electrosome.com/?p=11152#comment-6642 Great Tutorial, thanks for sharing!

]]>
By: Jogesh https://electrosome.com/pwm-pic-microcontroller-mplab-xc8/#comments/6598 Wed, 04 Jan 2017 04:39:00 +0000 https://electrosome.com/?p=11152#comment-6598 Hi Ligo, I follow all your PIC projects using XC8 and have simulated many of them. This PWM project has code “#if”, “#elif” and “#endif”. Unfortunately my MPLAPXIDE and XC8 are giving errors for these instructions. Please help in resolving this. Many Thanks. Jogesh

]]>
By: Ligo George https://electrosome.com/pwm-pic-microcontroller-mplab-xc8/#comments/6500 Sun, 27 Nov 2016 08:58:00 +0000 https://electrosome.com/?p=11152#comment-6500 In reply to Shonda Jackson.

Hi,
PWM module is not intended for LOW frequencies. You may try coding with normail GPIO pins for that.

]]>
By: Shonda Jackson https://electrosome.com/pwm-pic-microcontroller-mplab-xc8/#comments/6438 Sat, 29 Oct 2016 20:28:00 +0000 https://electrosome.com/?p=11152#comment-6438 Do you have a reference or link to any info about code that I would like to change the PWM freq dynamically – i am using mikroc w 8MHz crystal on a PIC18F26K22 chip and PWM works fine at the higher frequenices, but it does not allow me to set frequencies less than 500 Hz.

For example, utilizing PWM1_Init(487) – I try to compile and I get an error “Argument is out of range”

I do have success at lower freq if i try a Short Delay Routine (SDR) such as :
while(RB0_bit == 1)
{
RC2_bit = 1;
Delay_us(1019);
RC2_bit = 0;
Delay_us(1019);
}

My problem can be summed up this way
1. I am able to run the PWM from 500 Hz to 1000 Hz fine by itself.
2. I am able to run the SDR from 5 Hz to 500 Hz fine by itself
3. When I try to combine PWM and SDR – the PWM range (500 – 1000 – the PWM works fine but it seems that even though use the command PWM1_STOP() – it seems that the PWM process does not release control of the pin so that I can manipulate the signal utilizing the SDR for frequencies less than 500 Hz.

I have tried USING ONLY using the SDR for the entire range of 5 Hz to 1000 Hz utilizing a switch statement, but I get a compilation error (There is not enough ROM space) as well when I try to compile.

switch (freq)
{
case 184: while(RB0_bit == 1) { RC2_bit = 1; Delay_us(1019); RC2_bit = 0; Delay_us(1019); } break;
case 183: while(RB0_bit == 1) { RC2_bit = 1; Delay_us(1024); RC2_bit = 0; Delay_us(1025); } break;
case 182: while(RB0_bit == 1) { RC2_bit = 1; Delay_us(1030); RC2_bit = 0; Delay_us(1030); } break;
case 181: while(RB0_bit == 1) { RC2_bit = 1; Delay_us(1035); RC2_bit = 0; Delay_us(1036); } break;
case 180: while(RB0_bit == 1) { RC2_bit = 1; Delay_us(1041); RC2_bit = 0; Delay_us(1042); } break;
// etc …
// etc …
case 10: while(RB0_bit == 1) { RC2_bit = 1; Delay_us(18750); RC2_bit = 0; Delay_us(18750); } break;
case 9: while(RB0_bit == 1) { RC2_bit = 1; Delay_us(20833); RC2_bit = 0; Delay_us(20833); } break;
case 8: while(RB0_bit == 1) { RC2_bit = 1; Delay_us(23437); RC2_bit = 0; Delay_us(23438); } break;
case 7: while(RB0_bit == 1) { RC2_bit = 1; Delay_us(26785); RC2_bit = 0; Delay_us(26786); } break;
case 6: while(RB0_bit == 1) { RC2_bit = 1; Delay_us(31250); RC2_bit = 0; Delay_us(31250); } break;
case 5: while(RB0_bit == 1) { RC2_bit = 1; Delay_us(37500); RC2_bit = 0; Delay_us(37500); } break;
}

]]>