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

Thread: Teensy 3.2 not powering up from my custom breakout board

  1. #1

    Teensy 3.2 not powering up from my custom breakout board

    First of all, Merry Christmas to all, I hope you're having a wonderful time. I sure am, finally getting to work on a long term project of mine.

    I've got a teensy 3.2 that will power up and run my code from USB.
    It will also run the code when it is powered by 5V to Vin and GND.
    When I plug it into my breakout board, which feeds 5V to Vin and GND, I get nothing.

    Im assuming i've made an error in my breakout board, so im hoping one of the wise folk here will be able to spot my error.
    Here is my schematic.
    Click image for larger version. 

Name:	Teensy RC 2.2 Schematic.jpg 
Views:	37 
Size:	131.4 KB 
ID:	12395

    Here is a link to the live schematic

    And here is a copy of the code im running, but I don't think it really matters.
    Code:
    #include <TimerOne.h>
    #include "SBUS.h"
    
    // a SBUS object, which is on Teensy hardware
    // serial port 1
    SBUS Transmit(Serial1);
    
    //Channel Map
    //CH01: Roll (pin [A13])  
    uint16_t CH01 = A13;
    int CH01Value = 0;
    
    //CH02: Pitch (pin [A11])
    uint16_t CH02 = A11;
    int CH02Value = 0;
    
    //CH03: Throttle (pin 30 [A19])
    uint16_t CH03 = A19;
    int CH03Value = 0;
    
    //CH04: Yaw (pin 15 [A1])
    uint16_t CH04 = A1;
    int CH04Value = 0;
    
    //CH05: Mode selection switches momentary digital pins - 2 on Left Side, 4 on Right Side:
        //pin 33 [RTL - Left Side]
        int CH05Mode1 = 33;
        int Mode1Value = 0;
        int Mode1LED = 22;
    
        //pin 18 [LAND - Left Side]
        int CH05Mode2 = 18;
        int Mode2Value = 0;
        int Mode2LED = 23;
    
        //pin 26 [STABILISED - Right Side]
        int CH05Mode3 = 26;
        int Mode3Value = 0;
        int Mode3LED = 6;
    
        //pin 9 [POSITION HOLD - Right Side]
        int CH05Mode4 = 9;
        int Mode4Value = 0;
        int Mode4LED = 5;
    
        //pin 25 [LOITER - Right Side]
        int CH05Mode5 = 25;
        int Mode5Value = 0;
        int Mode5LED = 4;
    
        //pin 24 [AUTO - Right Side]
        int CH05Mode6 = 24;
        int Mode6Value = 0;
        int Mode6LED = 3;
    
    //CH06: Camera pitch - Left Slider (pin 29 [A18])
    uint16_t CH06 = A18;
    int CH06Value = 0;
    
    //CH07: Arm [Motor Interlock] (pin 32)
    int CH07 = 32;
    int CH07Value = 0;
    int CH07LED = 20;
    
    //CH08: Brake (pin 17)
    int CH08Brake = 17;
    int CH08Value = 0;
    int CH08LED = 21;
    
    //CH09: Camera Shutter - Right 3-way Switch (pin [A14])
    uint16_t CH09 = A14;
    int CH09Value = 0;
    
    //CH10: Left 2-way Switch (pin 16)
    int CH10 = 16;
    int CH10Value = 0;
    
    //CH11: Left 3-way Switch (pin 14 [A0])
    uint16_t CH11 = A0;
    int CH11Value = 0;
    
    //CH12: Right 2-way Switch (pin 10)
    int CH12 = 10;
    int CH12Value = 0;
    
    //CH13: Left Slider  (pin 29 [A18])
    uint16_t CH13 = A18;
    int CH13Value = 0;
    
    //CH14: Right Slider  (pin [A12])
    uint16_t CH14 = A12;
    int CH14Value = 0;
    
    //CH15: Left Twist (pin 31 [A20])
    uint16_t CH15 = A20;
    int CH15Value = 0;
    
    //CH16: Right Twist (pin [A10])
    uint16_t CH16 = A10;
    int CH16Value = 0;
    
    const int ledPin = 13; //just a heartbeat to show that the code is going
    
    void setup() {
      pinMode(20, OUTPUT);  // LED
      pinMode(21, OUTPUT);  // LED
      pinMode(22, OUTPUT);  // LED
      pinMode(23, OUTPUT);  // LED
      pinMode(6, OUTPUT); // LED
      pinMode(5, OUTPUT); // LED
      pinMode(4, OUTPUT); // LED
      pinMode(3, OUTPUT); // LED
      pinMode(33, INPUT_PULLUP);  // Momentary Switch
      pinMode(18, INPUT_PULLUP);  // Momentary Switch
      pinMode(26, INPUT_PULLUP);  // Momentary Switch
      pinMode(9, INPUT_PULLUP);   // Momentary Switch
      pinMode(25, INPUT_PULLUP);  // Momentary Switch
      pinMode(24, INPUT_PULLUP);  // Momentary Switch
      pinMode(32, INPUT_PULLUP);  // Momentary Switch
      pinMode(17, INPUT_PULLUP);  // Momentary Switch
      pinMode(16, INPUT_PULLUP);  // Momentary Switch
      pinMode(10, INPUT_PULLUP);  // Momentary Switch
    
      pinMode(ledPin, OUTPUT);
    
      // serial to display the channel commands for debugging
      Serial.begin(115200);
    
      // begin the SBUS communication
      Transmit.begin();
    
      // setup the analog read resolution to 16 bits
      analogReadResolution(16);
    
      // setup an interrupt to send packets every 9 ms
      Timer1.initialize(9000);
      Timer1.attachInterrupt(sendSBUS);
    }
    
    void loop() {
     //heartbeat timing
      digitalWrite(ledPin, HIGH);  // set the LED on
      delay(200);                  // wait for a 0.2 seconds
      digitalWrite(ledPin, LOW);   // set the LED on
      delay(100);                  // wait for a 0.1 seconds
      digitalWrite(ledPin, HIGH);  // set the LED on
      delay(200);                  // wait for a 0.2 seconds
      digitalWrite(ledPin, LOW);   // set the LED off
      delay(1000);                 // wait for a second
    }
    
    // reads analog and digital inputs and sends an SBUS packet */
    void sendSBUS() {
      float scaleFactor = 1639.0f / 65535.0f;
      float bias = 172.0f;
      uint16_t channels[16];
      
    	CH01 = analogRead(CH01); // read the analog input
        CH01Value = (uint16_t)(((float)CH01) * scaleFactor + bias); // linearly map the analog measurements (0-65535) to the SBUS commands (172-1811)
        Serial.print("CH01: ");
        Serial.print(CH01Value); // print the channel command (172-1811)
        Serial.print("\t");
    
    	CH02 = analogRead(CH02); // read the analog input
        CH02Value = (uint16_t)(((float)CH02) * scaleFactor + bias); // linearly map the analog measurements (0-65535) to the SBUS commands (172-1811)
        Serial.print("CH02: ");
        Serial.print(CH02Value); // print the channel command (172-1811)
        Serial.print("\t");
    	
    	CH03 = analogRead(CH03); // read the analog input
        CH03Value = (uint16_t)(((float)CH03) * scaleFactor + bias); // linearly map the analog measurements (0-65535) to the SBUS commands (172-1811)
        Serial.print("CH03: ");
        Serial.print(CH03Value); // print the channel command (172-1811)
        Serial.print("\t");
    	
    	CH04 = analogRead(CH04); // read the analog input
        CH04Value = (uint16_t)(((float)CH04) * scaleFactor + bias); // linearly map the analog measurements (0-65535) to the SBUS commands (172-1811)
        Serial.print("CH04: ");
        Serial.print(CH04Value); // print the channel command (172-1811)
        Serial.print("\t");
    	
    	
    	
    	CH06 = analogRead(CH06); // read the analog input
        CH06Value = (uint16_t)(((float)CH06) * scaleFactor + bias); // linearly map the analog measurements (0-65535) to the SBUS commands (172-1811)
        Serial.print("CH06: ");
        Serial.print(CH06Value); // print the channel command (172-1811)
        Serial.print("\t");
    	
    	CH09 = analogRead(CH09); // read the analog input
        CH09Value = (uint16_t)(((float)CH09) * scaleFactor + bias); // linearly map the analog measurements (0-65535) to the SBUS commands (172-1811)
        Serial.print("CH09: ");
        Serial.print(CH09Value); // print the channel command (172-1811)
        Serial.print("\t");
    	
    	CH11 = analogRead(CH11); // read the analog input
        CH11Value = (uint16_t)(((float)CH11) * scaleFactor + bias); // linearly map the analog measurements (0-65535) to the SBUS commands (172-1811)
        Serial.print("CH11: ");
        Serial.print(CH11Value); // print the channel command (172-1811)
        Serial.print("\t");
    	
    	CH13 = analogRead(CH13); // read the analog input
        CH13Value = (uint16_t)(((float)CH13) * scaleFactor + bias); // linearly map the analog measurements (0-65535) to the SBUS commands (172-1811)
        Serial.print("CH13: ");
        Serial.print(CH13Value); // print the channel command (172-1811)
        Serial.print("\t");
    	
    	CH14 = analogRead(CH14); // read the analog input
        CH14Value = (uint16_t)(((float)CH14) * scaleFactor + bias); // linearly map the analog measurements (0-65535) to the SBUS commands (172-1811)
        Serial.print("CH14: ");
        Serial.print(CH14Value); // print the channel command (172-1811)
        Serial.print("\t");
    	
    	CH15 = analogRead(CH15); // read the analog input
        CH15Value = (uint16_t)(((float)CH15) * scaleFactor + bias); // linearly map the analog measurements (0-65535) to the SBUS commands (172-1811)
        Serial.print("CH15: ");
        Serial.print(CH15Value); // print the channel command (172-1811)
        Serial.print("\t");
    	
    	CH16 = analogRead(CH16); // read the analog input
        CH16Value = (uint16_t)(((float)CH16) * scaleFactor + bias); // linearly map the analog measurements (0-65535) to the SBUS commands (172-1811)
        Serial.print("CH16: ");
        Serial.print(CH16Value); // print the channel command (172-1811)
        Serial.print("\t");
          
        
        Serial.println();
    
      // write the SBUS packet to an SBUS compatible servo
        Transmit.write(&channels[0]);
    }

  2. #2
    Looks to me P1 to P4 are connectors. Did you try disconnecting them?

    Your loop() is mostly composed of delay(), [busy wait] and there are better ways to wait.
    See: https://www.makeuseof.com/tag/arduin...-shouldnt-use/

  3. #3
    Junior Member
    Join Date
    Oct 2016
    Posts
    9
    I see, pin 33 is connected. Look at this:

    https://forum.pjrc.com/threads/24823...freezes-teensy

  4. #4
    Senior Member pictographer's Avatar
    Join Date
    May 2013
    Location
    San Jose, CA
    Posts
    627
    The article provides good background. PJRC provides an even better library. See https://www.pjrc.com/teensy/td_timin...pedMillis.html and you won't have to worry about rollover.

  5. #5
    Quote Originally Posted by floating. View Post
    Looks to me P1 to P4 are connectors. Did you try disconnecting them?

    Your loop() is mostly composed of delay(), [busy wait] and there are better ways to wait.
    See: https://www.makeuseof.com/tag/arduin...-shouldnt-use/
    P1 - P4 are connectors for a ribbon cable to connect the IO boards to the central board. the left IO board is the one that takes the battery, so I disconnected the ribbon cable and just wired up the battery pins from IO board to the central board, to do some fault finding, which led me to discover something wrong with my LED output pins. I must have had something shorting them, but it's fixed now.

    The loop function where I have my LED heartbeat was only for me to ensure that something was happening when I applied 5V. the real code is below that, where Im creating an SBUS output. I'll likely be asking for more help on this code a bit later, to hopefully make it a bit more elegant.
    Thanks for the tip though, will definitely look into interrupts and millis in the future.


    Quote Originally Posted by josto View Post
    I see, pin 33 is connected. Look at this:

    https://forum.pjrc.com/threads/24823...freezes-teensy
    Very good information, turns out this was the actual problem, along with the shorted pin. I'm gonna have to rewire the switch that went to pin 33, probably to go to pin 2. Will make sure I remember this for the next revision of the board.

    Thanks all.

Posting Permissions

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