Hello Mauricio,
I totally agree with Wings(y) about the lack of drive provided by the 2N3404s, and this would be one potential cause of your overheating problem. I think use of N-channel logic FETs, to replace these transistors, would be a very good solution, so as not to stress the outputs from the MCU.
However, I can also see a further problem. With the circuit arrangement you are using, the bridge transistors will be very slow to turn off. This is because the base circuits effectively become open circuit. The turn-off should be considerably faster with a resistor connected between base and emitter of each transistor. Perhaps a value of 100 ohms should be suitable.
However, even with this reduction of turn-off period, there is still a possibility of both PNP and NPN transistors, within the same leg, conducting for a short period. Therefore, I would still suggest that you implement a short dead time period within your code, with the following PTAD output drive sequence.
0x10, 0x50
0x40, 0x60
0x20, 0xA0
0x80, 0x90
then repeat the sequence
The first state of each pair would remain for, say 5 microseconds or so, and the second state would remain for a period dictated by the motor rotational speed. The presence of the first state ensures that, whenever a phase changes polarity, there is no drive present for the dead time period.
The code to handle this might consist of two constant arrays, one array for the transitory state and the other array for the conducting state.
volatile const unsigned char Transit[] = {0x10, 0x40, 0x20, 0x80};
volatile const unsigned char MotordePaso[] = {0x50, 0x60, 0xA0, 0x90};
The following code demonstrates the use of these values -
for ( ; ; ) {
for (i = 0; i = 3; i++) {
PTAD = Transit[i];
Deadtime(); /* Deadtime delay */
PTAD = MotoredePaso[i];
Delayms(5)
}
}
In practice, TIM output compare interrupt might be used for timing purposes (but not for deadtime) to provide a means of varying the motor speed, and possibly reversing the direction of rotation.
Regards,
Mac