View previous topic :: View next topic |
Author |
Message |
-Terppa-
Joined: 08 Jan 2018 Posts: 59 Location: Finland
|
Invert PWM- signal 18f46k80 |
Posted: Thu Jan 21, 2021 6:13 am |
|
|
Hello all PIC gurus!
I have fast question. Is that chip(18f46k80) any hardware support to invert PWM- signal? Or is it only change to use hardware (transistors,ICs,Etc)?
keypoints in code:
Code: |
.
.
setup_timer_2(T2_DIV_BY_16,99,1);
.
.
setup_ccp2(CCP_PWM); //pin c2
setup_ccp5(CCP_PWM); //pin b5
.
.
enable_interrupts(GLOBAL);
|
WIN7x64
Compiler 5.092
Thank you for your help! |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9246 Location: Greensville,Ontario
|
|
Posted: Thu Jan 21, 2021 6:30 am |
|
|
fast answer
OK, I didin't look ,but
if you take the opposite PWM value, that's 'inversion' ?
say PWM is on 70%, off 30%...inversion would be on 30%,off 70% . |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Thu Jan 21, 2021 7:01 am |
|
|
Your chip has two different types of module to generate PWM outputs.
The CCP modules, and an ECCP module.
The CCP does not offer any way to invert the output, except as Jay says
to just reverse the number used. So for a given required duty cycle:
set_pwm1_duty(1023-cycle);
The ECCP module, supports active low or active high outputs, so setup
for a single PWM, and select active low, and you have the inverted signal.
There is only one ECCP module on your chip though.
Remember the ECCP, can simultaneously generate complementary
signals, with a dead band delay between them. |
|
|
-Terppa-
Joined: 08 Jan 2018 Posts: 59 Location: Finland
|
|
Posted: Thu Jan 21, 2021 7:48 am |
|
|
Thank you Mr temtronic and Mr Ttelmah
Code: |
"say PWM is on 70%, off 30%...inversion would be on 30%,off 70%" |
Yes. just like that.
Code: |
"just reverse the number used. So for a given required duty cycle:
set_pwm1_duty(1023-cycle);" |
This may have only way because i need at least 2- pwm pipe and only one ECCP module.
Thank you guys! |
|
|
|