Announcement

Collapse
No announcement yet.

uLCD-32PTU with Feather M0

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

  • uLCD-32PTU with Feather M0

    Greetings,

    I seem to be having some sort of lockup issue after writing a command. I'm using the Genie demo program (genieArduino_Demo, with only the reset line modified) and on boot, the display resets (I'm using pin 5 and not the shield so the logic is inverted correctly), and the widgets from the demo show up and I know communication is happening because I can set the "Cool Gauge" to a value (it's default at 50, and that gets set, but if I say, change it to 90, it sets correctly to 90), but then nothing else happens. I put some dummy blinky lights code all over the place, and that works, but only before the cool gauge is updated. Once that object gets written to, it looks like the MCU freezes.

    Any ideas? When I switched over to serial only and tried the serial write demo (Display Print), I get the freezing issue when the serial object (Picaso_Serial_4DLib Display(&DisplaySerial); ) is called. No reset of the display at all.

    The display works fine with an Arduino UNO.

    Thanks in advance.


  • #2
    Hi,

    Can you detail us to which baud rate you are using it with. Also, can you confirm if the host is getting the ACK or NAK reply back from the display.

    Best Regards,

    Comment


    • #3
      I have made some progress.... The serial seems to be working (I started with 9600, now at the 200000 setting). The below code on the genie side works no problem.

      /**********************************************************************************
      * Write String Test - Demo application
      * This demo simply illustrates the various ways you can now send data to a String
      * object in ViSi-Genie, from an Arduino.
      *
      * Demo uses Hardware Serial0 to communicate with the 4D Systems display module.
      * Simply create a Workshop4 Genie application for your 4D Systems display module,
      * and place a single 'Strings' object on the display, and download it to your module.
      * It will have the ID Strings0. This is then populated with data in the demo code below.
      *
      * PLEASE NOTE: If you are using a non-AVR Arduino, such as a Due, or other variants
      * such as a Chipkit or Teensy, then you will need to comment out the Flash String
      * line below - Line 60, as it will prevent the demo from compiling.
      */

      #include <genieArduino.h>

      Genie genie;

      #define RESETLINE 5 // Change this if you are not using an Arduino Adaptor Shield Version 2 (see code below)

      // Setup function
      void setup()
      {
      // Use a Serial Begin and serial port of your choice in your code and use the genie.Begin function to send
      // it to the Genie library (see this example below)
      // max of 200K Baud is good for most Arduinos. Galileo should use 115200 or below.
      // Some Arduino variants use Serial1 for the TX/RX pins, as Serial0 is for USB.
      Serial.begin(200000); // Serial0 @ 9600 Baud
      genie.Begin(Serial1); // Use Serial0 for talking to the Genie Library, and to the 4D Systems display

      // Reset the Display (change D4 to D2 if you have original 4D Arduino Adaptor)
      // THIS IS IMPORTANT AND CAN PREVENT OUT OF SYNC ISSUES, SLOW SPEED RESPONSE ETC
      // If NOT using a 4D Arduino Adaptor, digitalWrites must be reversed as Display Reset is Active Low, and
      // the 4D Arduino Adaptors invert this signal so must be Active High.
      pinMode(RESETLINE, OUTPUT); // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
      digitalWrite(RESETLINE, 0); // Reset the Display via D4
      delay(100);
      digitalWrite(RESETLINE, 1); // unReset the Display via D4

      delay (3500); //let the display start up after the reset (This is important)
      }

      // Main loop
      void loop()
      {
      //An optional third parameter specifies the base (format) to use; permitted values are BIN (binary, or base 2), OCT (octal, or base 8), DEC (decimal, or base 10), HEX (hexadecimal, or base 16).
      //For floating point numbers, this parameter specifies the number of decimal places to use.
      int x = -78;
      long y = 171;
      double z = 175.3456;
      int digits = 3;
      String Str = "This is string class";
      genie.WriteStr(0, "TEST"); // Write to String0 Object, with the string "TEST"
      delay(1000);
      genie.WriteStr(0, z, digits); //3 decimal places
      delay(1000);
      genie.WriteStr(0, 123.45678, 5); // 5 decimal places
      delay(1000);
      genie.WriteStr(0, 123.45678); // 2 decimal places by default if no value is given to decimal place.
      delay(1000);
      genie.WriteStr(0, " "); // Clear
      delay(10);
      genie.WriteStr(0, x); //prints negative integer
      delay(1000);
      genie.WriteStr(0, y);
      delay(1000);
      genie.WriteStr(0, -x, BIN); //base 2 of 78
      delay(1000);
      genie.WriteStr(0, y,16); //base 16
      delay(1000);
      genie.WriteStr(0, 10); //base 10 by default
      delay(1000);
      genie.WriteStr(0, 10,8); //base 8
      delay(1000);
      genie.WriteStr(0, Str); //prints String Class
      delay(1000);
      unsigned int zc = 123 ;
      genie.WriteStr(0, zc); //prints unsigned ints
      delay(1000);
      unsigned long e = 1234 ;
      genie.WriteStr(0, e); //prints unsigned long
      delay(1000);
      }


      However, if I add an object, I can get a single command to work, then the process seems to not execute any more code. Example, I added a user led, and added the command

      genie.WriteObject(GENIE_OBJ_USER_LED, 0, 1);
      delay(100);

      This works, but if I add a follow on genie command like so:

      genie.WriteObject(GENIE_OBJ_USER_LED, 0, 1);
      delay(100);
      genie.WriteObject(GENIE_OBJ_USER_LED, 0, 0);
      delay(100);

      No other command executes. I put a blink on the board LED after this command as well and can confirm that no code executes after that single genie command (I have done the same with forms; created two forms and I can get it to switch forms but then no code executes so i can't switch it back; I put a cool gauge and can write position once, then no code excutes).

      I will look into the ACK/NAK, as I don't have that error callback function included in what I have tried so far (although I did scope the TX line on the display and saw serial data, but only the once).

      Once again, this is a Feather M0 with the display connected to Serial1.

      Comment


      • #4
        Latest update: I edited the "WriteStrDemo" to create the program below and loaded it to the Feather M0 in my project. Using Feather Serial 1 (and have tried both Com0 and Com1 on the LCD)

        Confirmed ACK (x06) is received back from the display when writing to the String0 object. (also confirmed on the RX line of the M0 on an oscilloscope for good measure).

        If the command "genie.WriteObject(GENIE_OBJ_USER_LED, 0, 1)" is enabled in the code below, the USERLED0 object turns on, then no other code executes.

        I included both a check serial function (to read the ack response) and a blinkLED function just to confirm that nothing else happens after the USERLED0 object write command.

        I found an old Feather 32u4 lying around which is pin-compatible (at least for D5 and TX/RX); swapped MCUs out, loaded this code onto the 32u4 (enabling the USERLED0 commands) and get ACK for all genie commands. Code runs exactly as written (millis is currently on 1506652 and rolling....)

        Any ideas on what might be going on???? I also pulled USB power and ran it off a 5V line, no difference. Runs fine on 32u4, not on the M0.


        /**********************************************************************************
        * Write String Test - Demo application
        * This demo simply illustrates the various ways you can now send data to a String
        * object in ViSi-Genie, from an Arduino.
        *
        * Edited Demo uses Hardware Serial1 to communicate with the 4D Systems display module.
        * Simply create a Workshop4 Genie application for your 4D Systems display module,
        * and place a single 'Strings' object on the display, and download it to your module.
        * It will have the ID Strings0. This is then populated with data in the demo code below.
        *
        */

        #include <genieArduino.h> // using library version=1.5.1

        Genie genie;

        #define RESETLINE 5 // Changed; not using the adaptor shield

        //
        // Setup function
        void setup()
        {
        pinMode(LED_BUILTIN, OUTPUT);
        // Use a Serial Begin and serial port of your choice in your code and use the genie.Begin function to send
        // it to the Genie library (see this example below)
        // max of 200K Baud is good for most Arduinos. Galileo should use 115200 or below.
        // Some Arduino variants use Serial1 for the TX/RX pins, as Serial0 is for USB.
        Serial.begin(115200); // For debugging back to PC
        Serial1.begin(200000); // Serial1 @ 200000 Baud
        genie.Begin(Serial1); // Use Serial1 for talking to the Genie Library, and to the 4D Systems display

        // Logic below inverted to reflect that the shield is not being used
        pinMode(RESETLINE, OUTPUT);
        digitalWrite(RESETLINE, 0); // Reset the Display via D5
        delay(100);
        digitalWrite(RESETLINE, 1); // unReset the Display via D5

        delay(3500); //let the display start up after the reset (This is important!!!!!)
        }

        // Main loop
        void loop()
        {
        Serial.println("Writing millis");
        genie.WriteStr(0, millis()); // prints millis to String0 Object

        checkSerial(); // enable to see ACK/NAK response on Serial (PC serial port)
        //flashLED(); // optional to see if MCU is still alive after genie command

        if ((millis() % 3) == 0){ // just a simple method of flashing the LCD LED periodically based on millis() value
        //genie.WriteObject(GENIE_OBJ_USER_LED, 0, 1); // WORKS on Feather 32u4 - LOCKS up Feather M0
        //checkSerial(); // enable to see ACK/NAK response on Serial (PC serial port)
        //flashLED(); // optional to see if host is still alive after genie command
        }
        else {
        //genie.WriteObject(GENIE_OBJ_USER_LED, 0, 0); // WORKS on Feather 32u4 - LOCKS up Feather M0
        //checkSerial();
        //flashLED(); // optional to see if MCU is still alive after genie command
        }

        delay(100);
        }

        void checkSerial(){ // function to check incoming response from display
        Serial.println("Checking serial....");
        delay(10); // this delay is necessary to give the display time to respond back to host
        if (Serial1.available() > 0) {
        int incomingByte = Serial1.read();
        if (incomingByte > 0){
        Serial.print("Serial data is ");
        Serial.println(incomingByte); // prints ack (x06) or nak (x15)
        }
        else {
        Serial.println("No serial data returned.");
        }
        }
        }

        void flashLED() {
        Serial.println("LED set high");
        digitalWrite(LED_BUILTIN, HIGH); // turn the host LED on
        delay(500); // hold on time
        Serial.println("LED set low");
        digitalWrite(LED_BUILTIN, LOW); // turn the host LED off
        //delay(500); // optional post flash delay
        }

        Comment


        • #5
          I neglected to mention above that Serial communication to the display from the M0 is working with no problems (I've tried baud rates from 9600 to 200000 and all work).

          Any help out there???

          Comment


          • #6
            Good day,

            If you are using the library for this, you should at least follow the event handling for ViSi-genie to properly communicate with the display module like handling the responses coming back from the displays. To start with, you need to have genie.AttachEventHandler(myGenieEventHandler); in the setup and genie.DoEvents(); in the main loop. Also when implementing this, your main loop should be devoid of blocking functions like delay(). You can refer on thisapplication note on how the library should handle events with the display module: https://docs.4dsystems.com.au/app-note/4D-AN-00017

            Best Regards,

            Comment


            • #7
              I've just built the test app above from the "WriteString_demo.ino" file that is included in the library. There's no event handling function in that example. I'll add the genie.AttachEventHandler(myGenieEventHandler); and genie.DoEvents(); and see what happens. But the code above runs fine on a Feather 32u4, just not a Feather M0. And the code above checks for serial command coming back; the delays are added because the M0 is such a fast processor compared to AVR devices, I thought slowing it down might solve the problem.

              Comment


              • #8
                Same effect (display seems to lock up; no code executes post genie command), both with the event handler added to the code and using the Gen4 device....

                Comment


                • #9
                  Hi,

                  Have you also tried with the other example projects just to check if the M0 serial handling is working properly with the genie library? Maybe go simple on the next project with just one or two objects just to check if it transacts correctly.

                  Best Regards,

                  Comment


                  • #10
                    Not sure if you ever resolved this, but I had a similar problem recently with an Adafruit M0 Express and the Genie library. It turned out to be the Adafruit SAMD board library. Any version of the library 1.6.0 or newer causes the lockup. I reverted back to version 1.5.14 (the last of the 1.5.x line) and the problem stopped.

                    Here's my post on the Adafruit forum on it: https://forums.adafruit.com/viewtopic.php?f=62&t=169530

                    Unfortunately, they haven't offered an actual solution so I'm just sticking with the older library.

                    -K

                    Comment

                    Working...
                    X