Hello Readers,
I'm Sana, and I'm a Junior Software Developer with Luxoft India. I'm happy to share this post, in which I relate my previous experience with Derive the PWM using timer/interrupt.
Introduction
PWM stands for Pulse Width Modulation. It's a technique that controls analog devices with a digital output.
PWM is used to generate analog signals from digital devices like microcontrollers. The signal produced is a train of square wave pulses. The wave is either high or low at any given time
The objective of deriving PWM (Pulse Width Modulation) using timers and interrupts is to achieve precise control of the output pulse width and frequency. PWM is a commonly used technique in embedded systems and electronic devices to control the speed of motors, brightness of LEDs, Heating and cooling control, and various other applications where precise control of the output signal is required.
Hardware and Software setup
Micro Controller:
Renesas MCU : RL78 / F12 series - R5F109GC- 48PINSEquipment being used:
- Renesas E2 Lite Debugger
- CRO
- Power Supply
- USB Cable
- CRO Probes
Hardware Details
Operational Modes:
OFF Mode:
In OFF State the ECU will transition from the ON Mode to the OFF Mode
when IGN_VOLTAGE < 5-VDCON Mode:
In ON State the ECU will transition from the OFF Mode to the ON Mode
when IGN_VOLTAGE > 5-VDC.IDLE Mode:
When Ignition Voltage is 5-VDC > IGN_VOLTAGE < 10-VDC and user is not switching (not pressing any switch) Heater or Ventilation mode can be consider as IDLE Mode.
It will default to the IDLE sub- mode when in the OPERATIONAL Mode.
In Idle Mode, ECU is in RUN condition , However all the outputs are disable.Normal Operation Mode :
It transits from IDLE Mode to Normal Mode when 10-VDC > IGN_VOLTAGE < 15-VDCHeat Mode:
The ECU will transition from the IDLE Mode to HEAT Mode when Heat Mode Switch is pressed while ECU in Normal Operation Mode.
The ECU will transition from the VENT Mode to HEAT Mode when Heat Mode Switch is pressed while ECU in Normal Operation Mode.Vent (Blower) Mode:
The ECU will transition from the IDLE Mode to Vent Mode when Vent Mode Switch is pressed while ECU in Normal Operation Mode.
The ECU will transition from the HEAT Mode to VENT Mode when VENT Mode Switch is pressed while ECU in Normal Operation ModeDegraded Mode :
It transits from NORMAL HEAT or VENT Mode state to the DEGRADED HEAT state when IGN_VOLTAGE < 8.5-VDC.
It transits from the NORMAL HEAT or VENT Mode state to the DEGRADED HEAT state when IGN_VOLTAGE > 16.5-VDC.
Fault State:
When user disconnect the Seat Cushion HMAT / Seat Back HMAT or BLOWER, then within 10-msec of Normal operation mode will transitioning to the FAULT state.
The ECU shall disable HEATER or BLOWER Functionality within 10-msec transitioning to the FAULT state from Normal operation mode.
The ECU shall set HEAT_IND or VENT_IND to INACTIVE within 16-sec of transitioning to the FAULT state.Fault Protection:
The ECU shall be capable of operating after a fault is removed without incurring any physical damage or functional degradation.
I/O Port configuration:
The I/O Port Configuration is essential for establishing proper communication, facilitating PWM generation, interfacing with peripherals, and ensuring system compatibility in the project. It allows for precise control and validation of signals, enabling successful implementation of PWM using timers and interrupts.
In our Project as per the requirement we made I/o Configuration for all the Ports, based on the input received from the in the form of excel(I/O pin mapping).
Timer Configuration
Timer configuration is essential for precise timing, PWM generation, support for multiple channels, interrupt generation, efficient resource utilization, dynamic adjustments, compatibility with hardware, and system optimization. It enables the project to achieve accurate and controlled PWM signals, enhancing the functionality and performance of the overall system.
In our project we considered Renesas RL78 Microcontroller, which consists of eight 16 bit-timer, Considered channel 0 to channel7.
I/O Port Validation
Validated the I/O Port using LED, by considering Port (P73) as output.
While we RUN the software, LED will be ready to glow.
PWM Validation
- PWM Implementation on Renesas Controller:
Used Timer channels from channel0 to channel7
Channel Usage
0 -- Master of Ch1
1 -- Slave of Ch1 (generates output TO01)
2 -- Slave of Ch2 (generates output TO02)
3 -- Interval timer Ch3
4 -- _ Master of Ch2 _
5 -- Slave of Ch5 (generates output TO05)
6 -- Slave of Ch6 (generates output TO06)
7 -- Interval timer Ch7embed
PWM Feasibility on Evaluation Board:
Renesas evaluation boards have built-in hardware support for PWM generation.
The evaluation board usually includes timer modules, such as the TAU (Timer Array Unit), that can be utilized for generating PWM signals.
PWM Validation:
- TimerChannel1 as Slave and P16 as output, Pin in target board: channel1(CN1) 16pin, with duty cycle 50%
Conclusion
Pulse-width modulation (PWM) is a powerful technique for controlling the power delivered to a load. By varying the duty cycle of a PWM signal, the average power delivered to the load can be controlled. This technique is widely used in a variety of applications, including motor control, LED lighting, and power supplies. Renesas microcontrollers (MCUs) offer a variety of hardware and software features that can be used to generate PWM signals. The Timer/Interrupt units (TIUs) on Renesas MCUs are particularly well-suited for PWM generation, as they offer a high degree of flexibility and control.
Top comments (0)