Announcement

Collapse
No announcement yet.

uOLED-128-g2 and Teensy 3.1 : a never ending nightmare

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • uOLED-128-g2 and Teensy 3.1 : a never ending nightmare

    For two months now, I try to get the Oled working with my our teensy's 3.1.
    My Configuration:
    Teensy Pin 0(RX1) = uOLED Pin Tx
    Teensy Pin 1(TX1) = uOLED Pin Rx
    Teensy Pin 2 = uOLED Pin RES

    Resetting works so far. But the code hangs as soon as I call a Function related to that display. My Code so far:

    #include "Goldelox_Serial_4DLib.h"
    #include "GoldeloxBigDemo.h"
    #include "Goldelox_Const4D.h"

    //Goldelox_Serial_4DLib Display(&DisplaySerial); // Obviously unusable.
    HardwareSerial Uart = HardwareSerial(); // Suggested in the pjrc forum
    Goldelox_Serial_4DLib Display(&Uart);

    void setup()
    {
    delay(1000) ;
    Serial.begin(38600);
    Serial.println("Resetting Display...");
    //Reset the display
    pinMode(2, OUTPUT); // define Pin2 as an output pin . The Display's reset pin is connected to pin 2 of the teensy.
    digitalWrite(2, HIGH); // Reset the display
    delay(100);
    digitalWrite(2, LOW); // Clear Reset
    delay(2000);
    Serial.println("Display Reset Done.");
    }

    void loop()
    {
    Serial.print("Loop\n") ;
    Uart.begin(9600);

    Serial.print("LOOP: Clear Display\n") ;
    Display.gfx_Cls() ; // PROGRAM HANGS HERE
    Serial.print("LOOP: Text Test\n") ;
    Display.putstr("Text Tests") ;
    delay(2000);
    }

    If I use the original GoldeloxBigDemo Demo, it hangs in on the line:
    Goldelox_Serial_4DLib Display(&DisplaySerial);

    Oh, and forget about softwareserial. That does not compile, since it supports one up to 20 mhz microcontrollers or so. (Teensy 40-96mhz)

    So, send the Display back?

  • #2


    Hello Unibonn

    Welcome to the forum.

    To start with, I would doubt anything is 'wrong' with the display to warrant returning it. It is likely your code/wiring.

    Please start by explaining how you have wired up your system. I assume you have it directly connected rather than via any sort of adaptor. So your Reset pin 2 is directly to the displays reset pin, right?

    If that is the case, then your reset logic is backwards. Reset is active low, as per the datasheet. It is activated high when using the Arduino Adaptor Shield as that has a transistor based reset circuit, whereas yours is directly connected it seems.

    What serial port are you connecting the display to? Likewise, what display are you outputting to your serial monitor with debug messages? They cannot be the same.

    Start with that, and let us know. Someone will help you through this.

    Regards
    James

    Comment


    • #3


      Hello,

      As James said, try reversing the logic of your reset routine.

      1) To check if your program is sending out the correct command:
      1.A) Connect the Tx and Rx pins of the Teensy 3.1 to the corresponding pins of the USB-PA5 or 4D USB programming able.

      Teensy Tx pin ---> Rx pin of 4D programming module
      Teensy Rx pin ---> Tx pin of 4D programming module
      Teensy Gnd pin ---> Gnd pin of 4D programming module

      1.B) Plug the 4D programming module to your PC and open the Terminal 9600 utility in Workshop.
      1.C) Power on the Teensy 3.1. You should be able to receive the hex bytes "FF D7", which are the command bytes for clearing the screen. Attached is a sample image of this experiment.


      1.D) If the Teensy 3.1 sends out this command, then the display should be able to understand and execute it. See the Goldexlox SPE Reference Manual for more info.
      http://www.4dsystems.com.au/downloads/Software/4D-Workshop4-IDE/Docs/Serial/GOLDELOX-SPE-COMMAND-SET-REV1.4.pdf

      2) Also, try increasing the delay duration after the display reset routine.

      delay(2000); -->> try changing this to delay(5000) Serial.println("Display Reset Done.");
      This is to ensure that the display has started up properly before the Teensy starts sending commands (although the minimum start up delay for Goldelox displays is 2 seconds). Kindly try this and see what happens.

      3) To check if your Goldelox display is working, read the application note

      4D-AN-G5003 Serial Getting Started - The Serial Platform Environment Application

      App notes are here: http://www.4dsystems.com.au/appnotes/


      4) Also under the heading "Uart Object Names" on this page, https://www.pjrc.com/teensy/td_uart.html , it says:

      Uart Object Names On Teensy 2.0, "Serial1" accesses the Uart serial port.On Teensy 3.0, "Serial1", "Serail2", and "Serial3" access the 3 Uart serial ports. If you wish to use a different name, you copy this line to the beginning of your program, before any place you use Uart. // This line defines a "Uart" object to access the serial port HardwareSerial Uart = HardwareSerial();
      Aren't you supposed to replace "Uart" with "Serial1" like:
      // This line defines a "Uart" object to access the serial portHardwareSerial Serial1 = HardwareSerial(); void setup() { Serial.begin(9600); Serial1.begin(38400);}
      I saw this sample code but the programmer did it quite differently:

      https://bitbucket.org/bomadsen/arduino/src/f5082d0816192e423e2910c774d4a8bef91476d3/serial_test/serial_test.ino?at=master

      If the above is all wrong, just ignore item 4 of this post. I'm not really sure as I've never used a Teensy board. But as what James said, the display must have a dedicated serial port.

      Hope this helps.
      Doff

      Comment


      • #4
        Wow! Thanks.

        James_4DSystems was right. The wiring was completely correct. Reversing the reset solved the problem. So the solution is:

        #include "Goldelox_Serial_4DLib.h"
        #include "GoldeloxBigDemo.h"
        #include "Goldelox_Const4D.h"

        //Goldelox_Serial_4DLib Display(&DisplaySerial); // Obviously unusable.
        HardwareSerial Uart = HardwareSerial(); // Suggested in the pjrc forum
        Goldelox_Serial_4DLib Display(&Uart);

        void setup()
        {
        delay(1000) ;
        Serial.begin(38600);
        Serial.println("Resetting Display...");
        //Reset the display
        pinMode(2, OUTPUT); // define Pin2 as an output pin . The Display's reset pin is connected to pin 2 of the teensy.
        // ############ Solution: ###########
        digitalWrite(2, LOW); // Reset the display
        delay(100);
        digitalWrite(2, HIGH); // Clear Reset
        // #######################
        delay(2000);
        Serial.println("Display Reset Done.");
        }

        void loop()
        {
        Serial.print("Loop\n") ;
        Uart.begin(9600);

        Serial.print("LOOP: Clear Display\n") ;
        Display.gfx_Cls() ; // PROGRAM HANGS HERE
        Serial.print("LOOP: Text Test\n") ;
        Display.putstr("Text Tests") ;
        delay(2000);
        }

        Comment


        • #5
          Sorry to drag up an old post but I've been trying for 3 days to get my uOLED-128G2 working.
          Even with the above, all I get is a reset and then the welcome scrolling text on the display but I do get serial output to my monitor, so I know it's not hung.

          My configuration is the same as the OP and I'm going directly from the Teensy to the display:-
          Teensy Pin 0(RX1) = uOLED Pin Tx
          Teensy Pin 1(TX1) = uOLED Pin Rx
          Teensy Pin 2 = uOLED Pin RES

          I've tested it on a Due and it works OK with the 4D shield.

          Please help, I'm determined to get it working with the Teensy

          Comment


          • #6
            Hello Vortecks

            Welcome to the forum.

            So you have RX to TX, TX to RX and Reset to a GPIO.
            What program are you running on it?
            How was it wired on your Due? Via the 4D Shield it seems.
            Did you swap the reset logic, as wiring it directly is not the same as wiring it via a 4D Shield. One is active low, the other is active high. As per post #2 above.

            Please explain some more.

            Regards
            James

            Comment


            • #7
              Hi James and thank you for your quick reply.

              My mistake, it was an Uno that it was working on with your 4D shield - I'd had a very long day and I was rather tired. I was determined to sort it out by myself before I do a very un-bloke thing and ask for help.

              On my Teensy, I'm now using the same sketch as above because it's the only thing that runs and doesn't lock the Teensy,
              I'm using it as you described (RX to TX, TX to RX and Reset to pin 2.

              Code:
              #include "Goldelox_Serial_4DLib.h"
              #include "GoldeloxBigDemo.h"
              #include "Goldelox_Const4D.h"
              
              //Goldelox_Serial_4DLib Display(DisplaySerial); // Obviously unusable.
              HardwareSerial Uart = HardwareSerial(); // Suggested in the pjrc forum
              Goldelox_Serial_4DLib Display(&Uart);
              
              void setup()
              {
              delay(1000) ;
              Serial.begin(38600);
              Serial.println("Resetting Display...");
              //Reset the display
              pinMode(2, OUTPUT); // define Pin2 as an output pin . The Display's reset pin is connected to pin 2 of the teensy.
              // ############ Solution: ###########
              digitalWrite(2, LOW); // Reset the display
              delay(100);
              digitalWrite(2, HIGH); // Clear Reset
              // #######################
              delay(2000);
              Serial.println("Display Reset Done.");
              }
              
              void loop()
              {
              Serial.print("Loop\n") ;
              Uart.begin(9600);
              
              Serial.print("LOOP: Clear Display\n") ;
              Display.gfx_Cls() ; // PROGRAM HANGS HERE
              Serial.print("LOOP: Text Test\n") ;
              Display.putstr("Text Tests") ;
              delay(2000);
              }
              When I run it on the Teensy, I do get a reset but I can't get it to display anything. All I get (about 5 seconds after reset) is your default splash screen.

              I've tried countless variants and every suggestion from PJRC but to no avail.

              Code:
              #include "Goldelox_Serial_4DLib.h"
              #include "GoldeloxBigDemo.h"
              #include "Goldelox_Const4D.h"
              
              HardwareSerial Uart = Serial1;
              Goldelox_Serial_4DLib Display(&Uart);
              
              void setup()
              {
                delay(10000); // 10 second delay to make sure reset is working
                Serial.begin(9600);
                Uart.begin(9600);
                Serial.println("Resetting Display...");
                //Reset the display
                pinMode(2, OUTPUT); // define Pin2 as an output pin . The Display's reset pin is connected to pin 2 of the teensy.
              
                digitalWrite(2, LOW); // Reset the display
                delay(100);
                digitalWrite(2, HIGH); // Clear Reset
                delay(3000);
                Serial.println("Display Reset Done.");
              }
              
              void loop()
              {
                Serial.print("Loop\n") ;
                Serial.print("LOOP: Clear Display\n") ;
                Display.gfx_Cls();
                Serial.print("LOOP: Text Test\n") ;
                Display.putstr("Text Tests") ;
                delay(2000);
              }
              Thanks for your help,

              Tony

              Comment


              • #8
                Hi Tony

                I dont have a Teensy so its a little hard for me to debug and know for sure.
                So obviously over and above TX, RX and RESET, you have GND and 5V too right? I assume if you are powering the display off a seperate 5V to what the Teensy is using, you have a common GND between the display and the Teensy so they have the same reference.

                What is the Baud Rate you have set on your Display SPE by default?
                It will say on the splash screen when it loads up after 5 seconds of no serial activity.
                Assuming its 9600, like what you have set in your Teensy code.

                What PmmC are you running on your display?
                Have you tried updating it at all, and reloading SPE?
                What Arduino IDE version are you using?
                What Goldelox Serial Library are you using? The latest on Github?

                Can you take a photo of your setup?

                AT the start you have "HardwareSerial Uart = Serial1;" and the other guy had "HardwareSerial Uart = HardwareSerial();" - unsure which is right for the Teensy, given I dont have one.

                Can you try this demo below:

                Code:
                #include "Goldelox_Serial_4DLib.h"
                #include "Goldelox_Const4D.h"
                
                #define DisplaySerial Serial1
                Goldelox_Serial_4DLib Display(&DisplaySerial);
                
                void setup()
                {
                  Serial.begin(9600);    // Teensy USB Port Serial @ 9600baud - Terminal in IDE
                  DisplaySerial.begin(9600);   // Serial1 UART @ 9600baud to Goldelox Display
                  
                  //For handling errors
                  Display.Callback4D = mycallback ;
                
                  //5 second timeout on all commands
                  Display.TimeLimit4D = 5000 ;
                  
                  //Set display orientation and screensaver details
                  Display.gfx_ScreenMode(LANDSCAPE);
                  Display.SSTimeout(0);
                  Display.SSSpeed(0);
                  Display.SSMode(0);
                
                  Serial.println("Resetting Display..."); // Status to Terminal
                  
                  pinMode(2, OUTPUT); // define Pin2 as an output pin . The Display's reset pin is connected to pin 2 of the teensy.  
                  digitalWrite(2, LOW); // Reset the display
                  delay(100);
                  digitalWrite(2, HIGH); // Clear Reset
                  delay(5000);  
                  
                  Serial.println("Display Reset Done."); // Status to Terminal
                }
                
                void loop()
                {
                  Serial.println("Loop"); // Status to Terminal
                  Serial.println("LOOP: Clear Display"); // Status to Terminal
                  Display.gfx_Cls();
                  Serial.println("LOOP: Text Test"); // Status to Terminal
                  Display.putstr("Text Tests");
                  delay(2000);
                }
                
                void mycallback(int ErrCode, unsigned char Errorbyte)
                {
                  // Pin 13 has an LED connected on most Arduino boards.
                  int led = 13;
                  pinMode(led, OUTPUT);
                  while(1)
                  {
                    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
                    delay(200);                // wait for 200 ms
                    digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
                    delay(200);                // wait for 200 ms
                  }
                }
                See if that works at all.

                Regards
                James

                Comment


                • #9
                  Hi James and thanks for the reply. Sorry for the delay in replying, things are rather hectic at present.

                  Sadly, your code doesn't work and gives and Error code 1 and Error byte 0.

                  The PmmC is 2.5, SPE is 1.2 and I'm using Arduino IDE 1.6.5. with the latest library from Github.
                  It works perfectly with the Arduino Uno + 4D shield but not the Teensy wired directly.
                  I haven't updated it with the USB-PA5 because I didn't want to fork out money on something that potentially doesn't fix the problem. If you say it probably will, I'll buy one.

                  Best regards,

                  Tony

                  Comment


                  • #10
                    Hi Tony

                    Sadly, your code doesn't work and gives and Error code 1 and Error byte 0.
                    Where are you seeing these? I have no idea what that means.

                    PmmC 2.5, SPE 1.2 are the latest, so no issues there.
                    Arduino IDE 1.6.5 should be fine.

                    I will download this PJRC installer and try and compile it here. ill come back to you shortly.

                    Oh and what teensy do you have?

                    Regards
                    James

                    Comment


                    • #11
                      Hmm, compiles fine here for Teensy 3.1/3.2

                      Sketch uses 17,820 bytes (6%) of program storage space. Maximum is 262,144 bytes.
                      Global variables use 4,668 bytes (7%) of dynamic memory, leaving 60,868 bytes for local variables. Maximum is 65,536 bytes.
                      .... Please provide more info as to what these errors are.
                      James

                      Comment


                      • #12
                        I'm using a Teensy 3.2

                        I don't think I explained it correctly......

                        Your code does compile, the error codes I was referring to, was for:

                        Code:
                        void mycallback(int ErrCode, unsigned char Errorbyte)

                        Comment


                        • #13
                          Sorry still doesnt make sense. What do you mean the error codes are for that function.
                          Are you meaning, the Teensy is going into that function and getting stuck in the while(1) loop, indicating there is an error, and the Teensy is getting stuck and throwing an error somehow?

                          Having never used a Teensy you are going to have to give me some more info I am sorry.
                          Where are you seeing this error?
                          How about you comment out that whole function, as well as this line in setup()
                          Display.Callback4D = mycallback ;

                          Please take a photo of your setup showing all the wiring so I can see.

                          Regards
                          James

                          Comment


                          • #14
                            Sorry just realised what you were saying.

                            Error code 1 means Timeout.

                            #define Err4D_OK 0
                            #define Err4D_Timeout 1
                            #define Err4D_NAK 2 // other than ACK received

                            Sure you have RX and TX around the right way?

                            Regards
                            James

                            Comment


                            • #15
                              Hi James,

                              After spending countless hours trying to get it working, I gave up and passed it to someone else. He spent a few days but couldn't get it working.
                              He checked the pinout on the shield and it turns out we had it wired backwards - On the supplied cable, it says RX and TX but these aren't connected to TX and RX respectively, they're supposed to be connected RX to RX and TX to TX.
                              We've tried it on a Due and Teensy this way and it works perfectly!

                              Have I got a unique one, or are they all the same?

                              Tony

                              Comment

                              Working...
                              X