My motor driver blew up. Why?

So I’m in a really bad mood since I tried so hard to make this work and it literally blew up in my face (I’m fine, just pissed).

I bought THIS:

…and fed it the code from THIS:

unsigned int index = 0;
boolean flag = true;

unsigned int duties[] = {
15,
31,
47,
63,
79,
95,
111,
127,
143,
159,
175,
191,
207,
223,
239,
255,
255,
239,
223,
207,
191,
175,
159,
143,
127,
111,
95,
79,
63,
47,
31,
15
};
unsigned int timestamps[] = {
434,
898,
1366,
1839,
2321,
2813,
3318,
3841,
4386,
4961,
5573,
6238,
6979,
7843,
8950,
11574,
9470,
7322,
6417,
5710,
5104,
4559,
4059,
3589,
3143,
2715,
2301,
1899,
1505,
1118,
734,
355
};


void setup() {
  
// This 8 bit timer2 code is for the 60Hz sine wave generation
  DDRB |= (1 << PB3);       // Pin 11
  DDRD |= (1 << PD3);       // Pin 3

  DDRB |= (1 << PB1);       // Pin 9 output
  DDRB |= (1 << PB2);       // Pin 10 output

  cli();

  TCCR2A = 0;
  TCCR2B = 0;
  TCNT2 = 0;
  
  OCR2A = 255;                    // Channel A duty
  OCR2B = 255;                    // Channel B duty

  TCCR2A |= (1 << WGM20);       // Mode 7
//  TCCR2A |= (1 << WGM21);   
//  TCCR2B |= (1 << WGM22);

//  TCCR2A |= (1 << COM2A0);    // Non-Inverting Mode on Pin A
  TCCR2A |= (1 << COM2A1);
//  TCCR2A |= (1 << COM2B1);


  
  TCCR2B |= (1 << CS20);        // Prescaler 1

//  TIMSK2 |= (1 << OCIE2A);
//  TIMSK2 |= (1 << OCIE2B);
//  TIMSK2 |= (1 << TOIE2);

// This 16 bit timer1 code is so we can count and keep track of when to change the duty on Timer2

  TCCR1A = 0;                   // Clear register
  TCCR1B = 0;                   // Clear register
  TCNT1 = 0;

  OCR1A = 0;                // Define OCRA for timekeeping.  This will be modulated by Timer2.

  TCCR1A |= (1 << WGM10);
  TCCR1A |= (1 << WGM11);       // Mode 15, Fast PWM with OCR TOP
  TCCR1B |= (1 << WGM12);
  TCCR1B |= (1 << WGM13);

  TCCR1A |= (1 << COM1A1);      // Non-inverting on A pin

  TCCR1B |= (1 << CS10);        // Prescaler 1


  sei();
  
}

void loop() {


}

ISR (TIMER1_COMPA_vect) {

  index++;                            // Increment the index

  if(index > 31) {                // Check if the end of the array has been reached
    index = 0;                    // If so, immediately go back to the first entry
//    TCCR2A ^= (1 << COM2A1);      // A should start generating a waveform while B shuts off and vice versa
//    TCCR2A ^= (1 << COM2B1);      // When Sine is +, channel A will produce only positive pulses, when Sine is - channel B will produce only negative pulses
  }

  OCR1A = timestamps[index];          // Update the time interval till the next duty change
  
  OCR2A = duties[index];                      // Update the duty of Channel A
//  OCR2B = duties[index];                      // Update the duty of Channel B
  
  
  
}

I scoped it in advance many times and the output looked good.

First I connected the output of the driver to the primary coil of my transformer. Then I connected the 24V battery. Then I connected the GND signal pin to the GND on my nano, the PWM pin to high and the DIRECTION pin to pin 11 which was sending out the pulses. As soon as put power to the nano board, the motor driver violently exploded… 4 times, just for emphasis. So wtf did I do wrong? Was it that I connected things in the wrong order or was it the code or something else? I just bought 2 more boards so I don’t have to wait another 2 weeks after the next explosion but this is more than just a little annoying. Thanks for your patience.

What’s a transformer doing in a DC motor circuit?
Please post a schematic so we can see what you have.

Likely the wrong order of connecting power. Why not power all at the same time?
Another possibility is you did not STOP the motor before reversing the power. I know you are not using a motor, but the same thing applies.
Paul

Never wire up any circuit with the power connected.

So is the determination that, because I didn’t hook up the battery last, that’s why it blew up?

Hooking up the battery last may be good form in most cases but why is that the root-cause of failure in this case?

Crossroads: There’s nothing to post. Literally it’s a transformer connected to the motor driver’s motor terminals. We could suffice to call it an H-Bridge rather than a motor driver because I’m not using it to run a motor.

You’re asking for a diagnosis on a circuit only you can see.  :rofl:

Post an  as-built   schematic.

I don’t know what you’re laughing at. I was pretty clear on the setup. If you want me to draw a rectangle with 2 lines coming off it and a curly line attached to that, I can do that but I don’t see how that’s going to make this a “serious” post all of a sudden. It’s the product in the link above attached to a transformer, which is a coil. What else do you want to know about the “circuit” ?

Paul: Sorry I missed the 2nd part of your post. The board referenced above has a DIR pin, which can either be low or high. I don’t believe it allows for anything other than those 2 states or any overlap thereof.

Mike: There was 1 incident where I exploded a home-made power supply because I had the power off and then turned it on. Since then I’ve made it work correctly by turning it on first. I realize this exception may be because I designed THAT thing wrong in the first place but this is perhaps why I didn’t repeat that habit now.

Hi,
Please post a circuit with your Nano, the Cytron controller, your transformer and ALL your power supplies and their labelled connections.

Troubleshooting can be a very frustrating job to do, but without a concise schematic, you are up the creek and need to step back and draw one.

95% of the work that comes across my work bench only has a connection diagram (if I’m lucky) and no schematic.
Even obvious faults, like smoke escaping needs some degree of reverse engineering to work out how the device works.

Tom… :smiley: :+1: :coffee: :australia:
PS, A picture is worth a thousand words… :+1: :+1:

You are dealing with a simulated motor. You must stop the simulated rotation before you can reverse the simulated motor. Are you giving the magnetic field enough time to decay before you switch the current to create the opposite pole magnetic field. Otherwise you are trying to overcome the existing magnetic field collapsing voltage and they likely add together.
Paul

Hi,
Did you download the manual and how to get started.?
Why have you written such a complicated bit of code, when a simple pot, PWM code would have been a good test?
It has a MAXIMUM PWM frequency of 20Khz, so the standard frequencies in the Nano should be more than adequate.

Tom… :smiley: :+1: :coffee: :australia:

I understand Tom. Here you go.

Paul. I get what you’re saying. I don’t think that’s what’s going on and I only say that because the transformer was custom made to my specs which were for 20kHz and that’s what I’m giving it more or less. If it was built correctly by the company I used (and they build transformers all day long) then I am hoping they tuned it for the 20kHz I asked for.

I skimmed the manual but the operation seems highly intuitive so I can’t say I combed it thoroughly. Admittedly I didn’t need the above code just to test the board. Could have used something much simpler but I had time to burn waiting for it to ship so I worked on the “good copy” while I was waiting and had it at hand when it arrived.

Hi,
These two component would have helped.


You were looking for trouble fwd then rev, the inductive component of the transformer has probably produced a back EMF in the hundreds of volts and broken through the MOSFETs, and so failing, 100s of amps from your 24v battery to do the rest.
The battery would basically see a short circuit.

Tom… :smiley: :+1: :coffee: :australia:

But wouldn’t that only occur if the frequency was chosen incorrectly? I can try again with a 9v battery or something pathetic like that and see what it does but if you’re right, that would mean my transformer was built to entirely different and wrong specs from what I asked for.

Hi,
You are using a square wave, the current in an inductor does not flow like with a sinewave.
Sudden changes in current, cause sudden changes in magnetic field, which induces a massive back EMF.
Why so big, because the magnetic field is trying to collapse instantly, so the magnetic field as it suddenly collapses, cuts the inductor conductors at a very high speed, so inducing high back EMFs.
With a sinewave the field increases and collapses at a slower rate, with no sudden changes.

I hope that makes sense, just home from work and starving.

When you designed your transformer, the equations you would have used would assume a sinewave.

Tom… :smiley: :+1: :coffee: :australia:

Specifications please. Particularly relevant is primary DC resistance, as thats what’s equivalent to the stall current of a motor. You haven’t said what the secondary connects to?

And are you implying its a tuned transformer (a completely different beast to drive).

Study how PULSE TRANSFORMERS are made. At 20kHz, you will not be using any common iron. I have seen some, years ago, that used many, tiny, iron rods. What, specifically, did you specify for the magnetic material? Now days they would use some special ferrite mix.
Paul

Mark:

Ferrite 3C97
0.41T
280mm^2
f = 20kHz
Np = 1.75
Ns = 17.55
Ip = 16.17A
Is = 1.47A

Secondary was an open circuit (scoped) when tested.

Hi,

Np == primary turns = 1.75 ? ?
Ns == secondary turns = 17.55 ? ?

What is the primary inductance?
How much Primary current did you calculate?

Have you posted a picture of your transformer?

Tom… :grinning: :coffee: :coffee: :australia:

I used a transformer design tool to calculate this and the manufacturer confirmed them. Stuff like the inductance are implicit values that were part of the back-end calculations. I don’t know them. The current values are the last 2 parameters above.

Is there something wrong with this?