Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 22 of 22

Thread: Going Crazy burning up Teensies

  1. #1
    Senior Member
    Join Date
    Nov 2012
    Posts
    104

    Going Crazy burning up Teensies

    I have a circuit and code that worked fine in testing but now that I have packaged it all I does is burn up teensies both LC and 3.2. The attached PDF shows the connections to the teensy. Sorry I am not good at drawing schematics. The project is a thread winder. It is quite simple. A target is set and the thing winds until it is reached. Motor turns are (still works until teensy burns up) counted by a field effect switch with open collector output. The motor is controlled with an FET switch with PWM input from the Teensy. The display is an IIC OLEDSSD1306.

    I have checked everything 50 times and have blown up 5 teensies. Again this worked fine until I packaged it up. My only guess at this point is that the motor leads are generating RFI which is getting into the Hall effect line? I am not sure but I think it only burns up after running the motor. If this could be the case, should I shield the motor leads or the signal and power leads to the hall switch or both?

    and here is the full code which I have cleaned up to make it less confusing:


    Code:
    #include <SPI.h>
    #include <Wire.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>
    #define SCREEN_WIDTH 128 // OLED display width, in pixels
    #define SCREEN_HEIGHT 64 // OLED display height, in pixels
    // Declaration for an SSD1306 display connected to I2C (SDA, SCL pins)
    #define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
    Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
    
    int pot_position;
    int count =0; 
    int target = 100; // start high so it can be hand runt 
    int CounterState = 0;         // current state of the button
    int LastCounterState = 0;  
    int undershoot;
    int final_target;
    int volt_out;
    int speed_table[] = {// LOG 4 to give fine control at lower speeds 102 entries
       0,0,1,1,1,2,2,2,3,3,4,4,5,5,6,6,7,8,9,10,10,11,13,14,15,
       15,16,17,19,20,22,24,25,27,29,31,33,36,38,41,43,46,49,52,
       55,58,62,65,69,73,77,81,86,90,95,100,105,110,116,122,127,
       134,140,146,153,160,168,175,183,191,199,208,216,226,235,
       245,245,245,255,255,255,255,255,255,255,255,255,255,255
       ,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
       255,255,255,255
    }; // add a few extra to be sure
    
    void setup() {
      Serial.begin(9600);
      delay(1000);
      Wire.setSDA(18);
      Wire.setSCL(19);;
    
      Serial.println("setup begin");
      pinMode(2, INPUT_PULLUP); // count switch input      
      pinMode(9, INPUT_PULLUP); //  restart switch input 
      pinMode(10, INPUT_PULLUP); //  set target switch   
      pinMode(15, INPUT_PULLUP); //  pedal switch input    
      pinMode(16, INPUT_PULLUP); //  switch to choose between on off and continuous pedal    
         
      // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
      if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // Address 0x3D for 128x64
        Serial.println(F("SSD1306 Display 0 allocation failed"));
        for(;;); // Don't proceed, loop forever
      }
      delay(1000);
      display.clearDisplay();
      display.setTextColor(WHITE);
      display.setTextSize(2); 
      display.clearDisplay();
      display.setCursor(0, 0);
      display.println(count);
      display.println(target);
      display.display(); 
    }  // end setup
    
    void loop(){
      if (digitalReadFast(9) == LOW){ // reset switch is low
        count = 0;
        display.clearDisplay();
        display.setCursor(0, 0);
        display.println(count);
        display.println(target);
        display.display();     
      } // probably should make the next line an else if but it works
      if (digitalReadFast(10) == LOW){ // setting target switch is low keep updating target value until switch is off
        final_target = count +1;
        target = count +1;///check to see if this is right do a few runs with target and see if it stops correctlyfinal_target = 
      }  
      else {
    //    final_target = target - undershoot +1;// not using undershoot right now
        final_target = target;    
      }
      check_counter_state();
      if (count >= final_target){ // stop if target reached
         analogWrite(23, 0);              
      }
      else{
         pot_position = analogRead(A0) -1; // read the speed control pot
         if (pot_position < 0){
            pot_position = 0;
         }
         volt_out = speed_table[int((pot_position/10))]; 
         if (volt_out < 2){
            analogWrite(23, 0);// PWM out pin sw 23 or A9
         }
         else{
          if(digitalReadFast(15) == LOW){
            if((target - count < 35 )and(digitalReadFast(10) == HIGH)){ // slow down to not overshoot
              analogWrite (23,20);
            }
            // can add code to ramp in a few brackets here eg
    //        else if (count < 10){
    //          analogWrite (23,volt_out/6);// PWM out pin sw 23 or A9
    //        }
    //        else if(count < 20){
    //          analogWrite (23,volt_out/4);// PWM out pin sw 23 or A9
    //        }
    //        else if(count < 30){
    //          analogWrite (23t,volt_out/2);// PWM out pin sw 23 or A9
    //        }
            else{
              analogWrite (23,volt_out);// PWM out pin sw 23 or A9
            }
          }  
          else{
            analogWrite(23, 0);// PWM out pin sw 23 or A9
          }
         }
      }
    }
    void check_counter_state() { 
      CounterState = digitalReadFast(2);// output of hall effect switch
      if (CounterState != LastCounterState) {
        if (CounterState == HIGH) { // try LOW to have it not start at one
          count++;
          display.clearDisplay();
          display.setCursor(0, 0);
          display.println(count);
          display.println(target);
          display.display(); 
          }
          LastCounterState = CounterState;
      }
    }
    Attached Files Attached Files

  2. #2
    Senior Member
    Join Date
    Nov 2012
    Posts
    104
    Forgot to mention that the display is powered with 5 volts which is what all tutorials suggest. The teensy LC is not 5 volt tolerant and it is possible that my initial success was with Teensy 3.2 but they are not available and I burned up my last one

  3. #3
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    829
    It's very difficult to advice you with the limited data you provided.
    Do you happen to have schematics of the whole setup? Can you share photo's of your setup? Partnumbers of FETs, sensors and motors? How do you power the whole circuit?

    Paul

  4. #4
    Senior Member
    Join Date
    Nov 2012
    Posts
    104
    The whole thing is powered by a 12 volt power supply. The teensy is powered by an adjustable step down converter that tests as a steady 5 volts. The fet board is a no name but here it is on ebay https://www.ebay.com/itm/133969622565 I attached a PDF drawing that shows all the connections to the teensy. If I drew a schematic (which I am bad at) it would not show anything more? The speed control pot, the hall switch and the display all share a common ground. The display is powered by the 5 volt supply and the common ground. The scl 0 and sda 0 are connected to the teensy. All switches are switched to the common ground. The hall sensor is a 551003H02A and works with an input voltage of 2.7 volts to 12 ??? The motor is a brush type DC motor of generic type. Here are some pictures showing the front and the back and the contents of the box. The guts are out for testing. Sorry for the crappy pictures, I hope they are good enough to show what is needed. I think I provided all the answers except for a schematic. I would have to hand draw it. I can just add connections to the board picture i sent but I really think that shows everything but the common grounds.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	winder2.jpg 
Views:	19 
Size:	153.5 KB 
ID:	28683   Click image for larger version. 

Name:	winder3.jpg 
Views:	18 
Size:	138.7 KB 
ID:	28684  

    Click image for larger version. 

Name:	winder4.jpg 
Views:	20 
Size:	74.9 KB 
ID:	28685  

  5. #5
    Junior Member
    Join Date
    Jan 2021
    Location
    USA
    Posts
    5
    https://fritzing.org/download/
    https://www.kicad.org/download/
    Or even a hand drawn complete schematic would be helpful. Links to data sheets for parts used here are also helpful.

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,576
    Can you say more about the 5V power supply?

    Does it have extra capacitors located close to its input and output? We've seen problems before where those miniature switchers give stable 5V once they're running, but the startup behavior can be pretty horrific (like overshoot up to 7 or 8 volts) without extra capacitors, especially one close to the input. Years ago one made by Traco which Adafruit was selling caused several people a lot of grief. Eventually Adafruit added recommendation on their web page about needing a capacitor.

  7. #7
    Senior Member
    Join Date
    Nov 2012
    Posts
    104
    there are 10 uf (more like 7 and 8 ust be 20%) on the input and output. The teensies do not fry immediately. I think it is after the motor runs for a little while. I had the exact same setup working for hours. Only a problem once I put all the stuff in a small box and have the motor leads parallel to the Hall switch leads.

    I am going to mount the FET board (I previously gave a link to where I bought it but there is no ID, just two FETS an LED and two resistors. I also gave the part number for the field effect switch. There is no data sheet for the FET board. The FETs are D4184 I will try my hand at drawing the really simple schematic. All I have to do is add ground and power lines to the speed control pot the hall effect switch and draw in the switches Here is a "schematic"
    I forgot to mention that I have used the same cheap switching regulator on teensy projects with no problems. In fact I have a product that will be soon shipped so I really hope it works as well it did in testing.

    Will see what mounting the FET board near the motor and having only DV (not PWM) lines go anywhere near the teensy.

    Is the teensy supposed to be immune to damage by RFI that might be picked up by lines going to pins? It it reasonable that this might be the problem? I think I have exhausted everything else and for the fifth time it worked perfectly with exactly the same components (v reg hall effect display FET board) until I put the stuff in a small box.
    Attached Thumbnails Attached Thumbnails Click image for larger version. 

Name:	teensy-schem-2.jpg 
Views:	17 
Size:	64.9 KB 
ID:	28693  

  8. #8
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,576
    Maybe back EMF from the motor is somehow damaging Teensy?

    Do you have a "clamping" reverse diode in parallel with the motor?

    The purpose of this diode is to give a safe path for the motor's current to continue flowing for a brief time after the transistor turns off. Without this diode, you can end up with short duration but very high voltage spikes as the transistor turns off. Ideally it should be "fast" rectifier type diode. 1N4936 or 1N4937 is a popular choice, but almost any diode with "fast" or "fast recovery" in its description should work. The cathode (side with the stripe) connects to the positive lead and the anode connects to the negative lead.

    The other type of circuit that's often used to reduce electrical noise is called a "snubber". This uses a resistor and capacitor in series, which are wired across the motor. Normally you would connect the resistor to the motor's positive lead and the capacitor to the negative lead, and of course connect the other wire of the resistor to the capacitor's other wire. The idea behind this circuit is you may still have a high voltage spike even with the diode, because even those "fast" diodes still take time to respond. At very high frequency, the capacitor acts like a wire, which lets the resistor give that extremely high frequency energy a place to dissipate. Choosing the resistor and capacitor can be tricky. 10nF and 47 ohms is probably a decent starting point. But a better diode usually eliminates the need for a snubber circuit, unless you need to really keep the electrical noise down. Still, if there is any small spike or high frequency noise, a well designed (smart choice on capacitor & resistor) snubber circuit can really reduce noise and increase reliability.

    If you have access to an oscilloscope, you could try watching the voltage on the motor. Make sure the probe is in 10X mode, because the voltage spike can be very high without any diode. Using 1X mode directly exposes the scope. 10X offers a lot of protection to the expensive oscilloscope, and if the spike is really bad you'll need 10X mode to have enough range to see just how terrible it is.

  9. #9
    Junior Member
    Join Date
    Dec 2021
    Posts
    2
    Probably is transients killing GPIOs. I had problems in the past with brushless motors and MCUs getting fried. The way I solved was using digital isolators for all the I/O.

  10. #10
    Senior Member
    Join Date
    Nov 2012
    Posts
    104
    Thanks Paul for the suggestions. I moved the FET board to right near the motor so only unswitched DC goes past the signal wires. I will definitely add the diode before trying to burn up another teensy. I do have a scope but i would have to run the teensy fryer with the motor connected to be able to see the spikes.
    Should I use both the diode and the snubber and if the motor is running at 12 volts? The motor is a brush type not brushless.
    mfmof, what do you suggest as digital isolators? do you mean an opto coupler. now with the pwm lines all moved out of the control box, i probably just need to isolate the line from the hall effect switch?

    I have a bunch of SR3100 which seem good? They are fast shottkeys and the data sheet suggests use as freewheeling diodes in high frequency inverters etc. other than not working well is there any risk of using a cap/resistor snubber with the wrong values?

    https://datasheetspdf.com/pdf/624752...onics/SR3100/1

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,576
    My guess would be the diode is probably ok for a motor of that size.... knowing nothing of the motor's specs, just what I can see in the photo. The diode has no actual reverse recovery time specs either, so this is really just guesswork.

    The main risk with snubber circuits is whether the resistor handle the power and capacitor can handle the current. For much larger motors, special high current capacitors are made specifically for high power snubber circuits. Again, guessing only from the photo, probably an ordinary ceramic or plastic film capacitor will probably work. The amount of power in the resistor will depend on the PWM frequency and also how slow the diode acts. I'd start with an ordinary 1/4 watt through hole resistor and run for several seconds and see if it gets hot. If you need to go to a higher power resistor (unlikely with the diode and a fairly small motor), avoid wire wound types. The resistor needs to not have any inductance.

    You might not really need a snubber at all. The diode will do almost all the work. But a snubber circuit will reduce the high frequency noise and can only improve the long term reliability if the capacitor and resistor are good quality parts able to handle the current & power.

  12. #12
    Senior Member
    Join Date
    Nov 2012
    Posts
    104
    i did just what you said, 1/4 watt through hole and plastic cap will see how it works.

    I have another project that I am actually selling. It has a similar (but a gear type) motor going in two directions using and h bridge. Never had a problem and all the stuff is crammed in a similar small box. Only difference is that I am controlling the "speed" of the motor with home made PWM with a frequency of about 50 HZ

    About the cheap switching v regs. I was trying to use another one fixed at 5 volts. I looked up the specs for the reg chip and it was short circuit and overload protected so I figured it was fine. The Chinese maker must have used counterfeit chips because when the reg was overloaded it failed passing input voltage to the output. Fried a few teensies on that one thinking I had done something wrong. You must love the Chinese crap that blows up your teensies so you can sell more Seriously you can't believe anything today, everything needs to be tested. For that reason I fully tested the adjustable reg I am using now. Overloaded it, shorted it, gave it too low and too high input until it fried.

    I can't seem to find the PWM frequency for the teensy LC. Can it be changed if it is high? I don't think I need a high PWM frequency

  13. #13
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    829
    The default PWM frequency is 488.28 Hz. Got the info from this page.
    You can change the PWM frequency by using the analogWriteFrequency(pin, frequency) function.

    Paul

  14. #14
    Senior Member
    Join Date
    Nov 2012
    Posts
    104
    thanks, a very useful page.

  15. #15
    Senior Member
    Join Date
    Nov 2012
    Posts
    104

    Final question before hopefully not burning up any more teensies

    I am almost ready to try again. I have moved the fet board far from the teensy and have ordered an isolated version. the only load on the 3.3 volt regulator in the teensy LC is a pot as a voltage divider. it draws .6 ma. I am running the FET switch on 5 volts because its output is isolated with an opto. the open collector of the phototransistor should be compatible with the 3.3 volt restriction of the teensy LC

    I would rather not run the OLEDSSD1306 display on the LC 3.3 volt regulator just to be safe. So the question (can not find answer anywhere online) is whether it is OK to run the display on 5 volts and connect the scl and sda lines to the teensy LC without level shifting? I can level shift if necessary but is it necessary?

  16. #16
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    829
    Quote Originally Posted by spencoid View Post
    So the question (can not find answer anywhere online) is whether it is OK to run the display on 5 volts and connect the scl and sda lines to the teensy LC without level shifting? I can level shift if necessary but is it necessary?
    It depends on the exact OLED display used. I would power the OLED by the 3V3 of the Teensy LC [which can supply 100mA max].
    Those small OLED displays usually draw 20-50mA so you should be fine.

    Paul

  17. #17
    Senior Member
    Join Date
    Nov 2012
    Posts
    104
    so even with that same display unit, different boards could do different things on the data lines? i read somewhere that the oled does work on 3.3 but other places that it needs 5 volts. ill try it on 3.3 and see myself. also if the 3.3 volt reg on the teensy is overloaded does it shut down nicely or burn up? i have some 5 to 3.3 volt regs ordered and will use them in preference to the onboard. that way if there is a short or ??? it will burn up a $1.50 part instead of a teensy.

  18. #18
    Senior Member PaulS's Avatar
    Join Date
    Apr 2015
    Location
    Netherlands
    Posts
    829
    Did a quick current consumption test using an SSD1306 OLED display [albeit strapped for SPI mode instead of I2C mode] and powered it by the LC's 3V3 output. Measured the current in the display supply wire: 7mA [even less then I expected...]

    Click image for larger version. 

Name:	IMG_20220625_212026.jpg 
Views:	6 
Size:	105.6 KB 
ID:	28800

    Used this code:
    Code:
    #include <SPI.h>
    #include <Wire.h>
    #include <Adafruit_GFX.h>
    #include <Adafruit_SSD1306.h>
    
    // hardware SPI on Teensy 3.x/LC: MOSI pin 11, SCK pin 13 plus the pins defined below
    #define OLED_DC       9
    #define OLED_CS       10
    #define OLED_RST      14
    #define SPI_bitrate   8000000UL
    Adafruit_SSD1306 display(128, 64, &SPI, OLED_DC, OLED_RST, OLED_CS, SPI_bitrate);
    
    void setup() {
      display.begin(SSD1306_SWITCHCAPVCC);
      display.clearDisplay();
      for (int y = 0; y <= 4; y++) {
        display.setTextSize(2);
        display.setTextColor(1);
        display.setCursor(0, (y * 16));
        display.println("0123456789");
        display.display();
      }
    }
    
    void loop() {
    }
    When I powered this display by 5V, the current measured was 23mA.
    A display strapped for I2C may draw a few milli-amps more due to the SCL/SDA pullups.

    Hope this helps.
    Paul

  19. #19
    Senior Member
    Join Date
    Nov 2012
    Posts
    104
    i made a similar test and ran it before but forget if i ran it on 3.3 or 5 volts. ready to test when i get a minute. trying to make some progress on getting ready for my big solar array arriving soon. means major organizing of workshop to make room for stuff.

  20. #20
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    26,576
    Just to confirm, you added the fast diode in parallel with the motor, right?

    I see a lot of other stuff in msg #15 but no mention of the diode. The diode is by far the most important part.

    (imagine Anakin and Padme meme here...)

  21. #21
    Senior Member
    Join Date
    Nov 2012
    Posts
    104
    yes added diode. https://datasheetspdf.com/pdf/624752...onics/SR3100/1 it worked until i moved parts around. at this point i think the only thing wrong could be the back EMF causing noise. however before i replaced the breakout board and all the wires it will killed at least one and maybe two teensies. that is why i started over one step at a time.. i would rather wait for the new isolated FET board before adding the motor back in. I bought another 20 teensies so I have plenty to kill
    my other circuit using PWM (sort of, it is actually very low frequency maybe 100 hz on off digital) works fine but that uses an h bridge that has built in freewheeling diodes too. I also added the snubber resistor cap. i am pretty confident it is all well now but i am on my last teensie and want to wait for the isolated FET to give it the best chance possible.

    When the teensies failed, some times the 3.3 reg still worked and some times the code still ran (setup h lights LED) but could not be programmed. The worst failures the microprocessor chip got hot and at least one blew a hole in the chip. can damage to GPIO lines cause the chip to fry catastrophically? I would have thought it would just fry a protection diode and kill that IO. I have fried individual IOs on other teensies.

  22. #22
    Senior Member
    Join Date
    Nov 2012
    Posts
    104
    datasheet link for diode got mangled, here is another https://pdf1.alldatasheet.es/datashe...TE/SR3100.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •