0

I am new to MP programming and I am working on a project with codevision program, which requires to:

  • Connect potentiometer at A0.
  1. Generate a PWM signal with an equivalent average DC voltage to the measured value of the voltage of the potentiometer. The measured voltage from the DAC is displayed on line 1 of lcd (16*2).
  2. Choose a suitable RC circuit to get a pure DC voltage.
  3. Connect the generated PWM signal to the ICP1 and calculate its duty cycle and display it on line 2 off the screen.

So the screen should be like:

Pot1 = 0.000 V
Duty Cycle = ..%

I made the first line but I don't know how to implement timer1 into this requirement.

Also timer 1 has ICRH and ICRL and I am confused which of them should be used.

the busybee
  • 10,755
  • 3
  • 13
  • 30
  • You need to narrow down the question further. "How do I implement PWM using hardware x" is too broad a question. You need to study the manual and any app notes available on the topic, make an attempt and then ask specific questions about any problems you are encountering. – Lundin May 12 '22 at 08:43
  • Regarding "Choose a suitable RC circuit to get a pure DC voltage", you will likely need a diff op amp to get something "pure". Since a raw RC circuit will produce a sine wave. But how to do that is a question for https://electronics.stackexchange.com/. – Lundin May 12 '22 at 08:44
  • As @Lundin mentioned, RC circuits won't give you the best waveform for pulse counting. Use a _relaxation_ oscillator based on an OPAMP or a 555 timer. Regarding the _timer1_ module, the best thing you can do is to RTFM! – Daniel Melendrez May 20 '22 at 09:48

0 Answers0