Last time, I mentioned that I would try to build something on a breadboard to demonstrate its functionality. So, I took on the task of constructing my circuit using local components. It was quite challenging to find the IR2104 driver, and although I was told it could be possible to proceed without it, I realized that if, for any reason, my microcontroller stopped functioning correctly in this configuration without the driver, it would pose a problem. Therefore, I decided to continue with my setup.
To test it and truly showcase my ability to create something homemade, I am aware that it may not be the most professional approach and could potentially introduce a lot of noise. This setup is not intended for error-free projects but rather for beginners, which was my initial idea. Ultimately, I managed to achieve the goal of varying the voltage and being able to connect loads to its output. Based on the transistor's data, we could work with a power of 10W, but as the creator, I would suggest operating it at half the power to avoid straining the power supply and damaging circuit components during testing.
The electronics part was relatively easy and tested, as you can see in the images. As the duty cycle changes, the voltage varies, while I keep the frequency constant. This allows me to control the voltage. I documented the process with the help of an oscilloscope, and you will see that it is indeed possible.
To generate the pulse or PWM signal, I used the ATtiny85 microcontroller, as I mentioned before. Why not an Arduino or a more popular controller? The idea behind this choice was to keep the cost low and ensure a compact size.
{gallery}Testing |
---|
Duty Cycle 10% |
Duty Cycle 27% |
Duty Cycle 36 % |
Duty Cycle 47% |
Duty Cycle 90% |
I didn't follow any mathematical formula to determine the duty cycle. It was more of a trial-and-error process until I found the optimal values. Programming the ATtiny85 repeatedly to achieve the desired outcome was a time-consuming task, but it was definitely worth it. In the future, I plan to establish these optimal values as fixed values in the graphical user interface (GUI). While the objective was to create a variable power supply, I prefer to set commonly used fixed values in electronics that are safe for operation. However, I will keep them variable.
Finally, I'm sharing the code for the ATtiny85 so that you can see how I varied the duty cycle to obtain the ideal values. I also experimented with different frequencies to find the most suitable and stable one.
#include <avr/io.h> const int pinPWM = 6; // Especifica el pin donde deseas generar la señal PWM void setup() { DDRB |= (1 << pinPWM); // Configura el pin como salida TCCR0A = (1 << COM0A1) | (1 << WGM00); // Modo de salida PWM no invertido TCCR0B = (1 << CS01); // Prescaler de 8 OCR0A = 39; // Valor del comparador para obtener una frecuencia de 1 kHz OCR0B = 9; // Valor del comparador para un ciclo de trabajo del 25% } void loop() { // No se requiere ninguna lógica adicional en el bucle principal }
In the next and final installment, I hope to have my graphical user interface (GUI) ready and establish communication with the Raspberry Pi to bring this challenge to a conclusion.