0
\$\begingroup\$

I'm doing an environmental control group project for my embedded systems module. I want to generate two PWM signals:

  1. Control fan speed from ADC readings from a TMP36
  2. Dim an LED strip depending on ADC readings from Silonex Norp.

We've been using MPLAB X IDE 5.35 and MCC compiler.

The system is set to 20 MHz with HS oscillator and internal (FOSC) clock.

I'd calculated my PR2 value to be 197 and my duty value at 799 and was using CCP2 on RC1 for the LED and ECCP1 on RC2 for the fan. My lecturer just informed me I can't have both generating simultaneously as they're both competing for timer2.

When I've just tried running via Proteus it can't seem to work well above 75% duty sometimes acting as 20%. I've theorized that perhaps it's struggling as 799 doesn't meet the full 1023 count.

Has anyone got any suggestions for generating the two signals so they can be simultaneous, please?

\$\endgroup\$
3
  • \$\begingroup\$ What's the minimum PRF you can tolerate? What's the min and max duty cycle you're going to produce? Wondering if you can make both from a timer triggered ISR? \$\endgroup\$ Commented Nov 20 at 17:39
  • \$\begingroup\$ Why did you scale your ADC result? Duty_cycle = adc_value/1023 * 792 \$\endgroup\$ Commented Nov 20 at 21:27
  • \$\begingroup\$ Please show your sourcecode \$\endgroup\$ Commented Nov 24 at 9:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.