Announcement

Collapse
No announcement yet.

MKR1000 genie.WriteObject() isn't working - The program worked fine for a UNO board

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

  • MKR1000 genie.WriteObject() isn't working - The program worked fine for a UNO board

    Hello all,

    I've created a new Topic as the first was solved.
    For our project we're trying tho minimize our PCB footprint and therefore we replaced the arduino UNO board for a MKR1000 board (with WiFi option). Some side info we're using a Gen4-ulcd-32DCT-CLB display and I've included the project files also (display project in workshop4 and the arduino file)

    No we're struggling with having the genie.WriteObject(); write something to our display. Reading commands from the display is working fine as I can switch my debug LED on and of.
    With a UNO board everything worked fine, we changed the Serial to Serial1 as needed.

    What we've already tried is:
    • Changed the bautrate without success
    • Changed the delay from 3500 to 5000 without success
    • We used a LED to debug our code and there we noticed that the coding is working fine, especially as the program was working fine for a UNO board
    Anyone who can help us with suggestions?
    Thank you

    Code:
    //Test Screen MKR1000
    
    #include "genieArduino.h"
    #include <SPI.h>
    
    Genie genie;
    #define RESETLINE 4
    
    //program definitions
    bool buttonLive;        //Definition button on screen
    bool buttonCalibration;   //Definition button on screen
    bool buttonScope;      //Definition button on screen
    bool firstReading;
    float OffsetLive;
    
    void setup() {
      Serial1.begin(115200);  // Serial0 @ 200000 (200K) Baud
      genie.Begin(Serial1);   // Use Serial0 for talking to the Genie Library, and to the 4D Systems display. Serial for uno, Serila1 for mkr
    
      genie.AttachEventHandler(myGenieEventHandler); // Attach the user function Event Handler for processing events
    
      // 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, 1);  // Reset the Display via D4
      delay(100);
      digitalWrite(RESETLINE, 0);  // unReset the Display via D4
    
      delay (5000); //let the display start up after the reset (This is important) was before 3500
    
      // Set the brightness/Contrast of the Display - (Not needed but illustrates how)
      // Most Displays, 1 = Display ON, 0 = Display OFF. See below for exceptions and for DIABLO16 displays.
      // For uLCD-43, uLCD-220RD, uLCD-70DT, and uLCD-35DT, use 0-15 for Brightness Control, where 0 = Display OFF, though to 15 = Max Brightness ON.
      genie.WriteContrast(15);
    
      //program settings
      buttonLive = 0; // Initialise buttonLive in 0 mode
      buttonCalibration = 0; // Initialise buttonCalibration in 0 mode
      buttonScope = 0;  // Initialise buttonScoop in 0 mode
    
      //Debug led
      pinMode(11, OUTPUT);
     
      digitalWrite(11, LOW);
    }
    
    void loop() {
      genie.DoEvents(); // This calls the library each loop to process the queued responses from the display
      if (buttonLive == 1) // If button "live meting" is "active" then start liveMeasure
      {
        liveMeasure();
        digitalWrite(11, HIGH);               //Debug led to see if the code is working
      }
      if (buttonCalibration == 1) // If button "Calibration" op "on" then start Calibration
      {
        Calibration();
      }
      if (buttonScope == 1) //If button "Scope" op "Active" then start Scope
      {
        Scope();
      }
    
    }
    
    void myGenieEventHandler(void)
    {
      genieFrame Event;
      genie.DequeueEvent(&Event); // Remove the next queued event from the buffer, and process it below
    
      //If the cmd received is from a Reported Event (Events triggered from the Events tab of Workshop4 objects)
      if (Event.reportObject.cmd == GENIE_REPORT_EVENT)
      {
        if (Event.reportObject.object == GENIE_OBJ_WINBUTTON)
        {
          if (Event.reportObject.index == 4)    // Live measure 4 due to winbutton6 in 4workshop
          {
            buttonLive = !buttonLive;           // switch state buttonLive with each press between 1 and 0
          }
          if (Event.reportObject.index == 3)      //When pressing on main menu in live screen we go back to main menu and reinitialise the start state
          {
            genie.WriteObject(GENIE_OBJ_FORM, 0, 0);
            buttonLive = 0;                       //Set state of winbutton4 to start state and buttonLive to 0
            genie.WriteObject(GENIE_OBJ_WINBUTTON, 4, 0);
            firstReading = true;                  //firstReading reinitaliseto True for next measurement
            digitalWrite(11, HIGH);               //Debug led to see if the code is working
          }
          if (Event.reportObject.index == 8)    // Calibration mode active 8 because of  winbutton8 in 4workshop
          {
            buttonCalibration = !buttonCalibration;           // switch state buttonCalibration with each press between 1 and 0
          }
          if (Event.reportObject.index == 7)      //When pressing on main menu in live screen we go back to main menu and reinitialise the start state
          {
            genie.WriteObject(GENIE_OBJ_FORM, 0, 0);
            buttonCalibration = 0;                       //Set winbutton8 state back to start and buttonCalibration to 0
            genie.WriteObject(GENIE_OBJ_WINBUTTON, 8, 0);
          }
          if (Event.reportObject.index == 5)      //When pressing on main menu in fft screen we go back to main menu and reinitialise the start state
          {
            genie.WriteObject(GENIE_OBJ_FORM, 0, 0);
            //buttonFFT = 0;                       //en zetten we winbutton8 terug naar de beginstatus alsook buttonLive to 0
            genie.WriteObject(GENIE_OBJ_WINBUTTON, 6, 0);
          }
          if (Event.reportObject.index == 10)    // Calibration mode actief 8 omwille van winbutton8 in 4workshop
          {
            buttonScope = !buttonScope;           // switch state  buttonScope  with each press between 1 and 0
          }
          if (Event.reportObject.index == 9)      //When pressing on main menu in Scope screen we go back to main menu and reinitialise the start state
          {
            genie.WriteObject(GENIE_OBJ_FORM, 0, 0);
            buttonScope = 0;                       //Set state winbutton10 back to the start and buttonScope to 0
            genie.WriteObject(GENIE_OBJ_WINBUTTON, 10, 0);
          }
        }
      }
    }
    
    void liveMeasure()
    {
      genie.WriteObject(GENIE_OBJ_METER, 0, 25);
    }
    void Calibration()
    {
      genie.WriteObject(GENIE_OBJ_METER, 1, 100);
    }
    void Scope()
    {
      genie.WriteObject(GENIE_OBJ_SCOPE, 0, 1236.5);
    }
    Attached Files

  • #2
    Hello Vannue,

    Can I confirm that you are using Pins 13 and 14 as your RX/TX since you are using Serial1? If you are, then I don't see why the program does not work correctly on MKR1000 but works fine on Arduino Uno.

    I suggest that you try using a logic analyzer or a USB to UART adaptor (RX pin) to monitor what your board is sending and receiving. You can try observing the serial data received by the RX line of the display. If you are going to use a USB to UART adaptor, you can use the Workshop4 Terminal to check the data.

    Best Regards,
    Kimberly

    Comment


    • #3
      I just found out that the gen4PA shied was causing problems as this has also a usb to uart communication to program the display.

      This interfere with the MKR1000 USB to serial on-board chip and for the UNO board it doesn't seem to interfere.

      When I used the normal flatcable to serial shield everything was more or less working

      Maybe a heads up for other members in the future.

      Comment


      • #4
        Hello Vannue,

        For Visi-Genie projects, you can actually change the communication port. Try going to Workshop4 > File > Options > Genie > Comms Port. Change the selected Comms Port from 0 to 1 and select which pins you want to use as Rx/Tx. Select the ok button to save the changes you made.

        See image below:

        Click image for larger version

Name:	ChangingCOM.png
Views:	1
Size:	40.4 KB
ID:	64258

        Best Regards,
        Kimberly

        Comment

        Working...
        X