Announcement

Collapse
No announcement yet.

Arduino and gen4d uLCD

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

  • Arduino and gen4d uLCD

    Has anyone successfully managed to interface any gen4 uLCD with an Arduino MKRzero, using the Visi-Genie libraries?
    .γνῶθι σαυτόν

  • #2
    Hi,

    Welcome to the forum.

    Sorry to hear you are having problems communicating with the Display.

    Could you please let me know how you have connected the display to the zero and what problems you are having.

    Best regards

    Paul

    Comment


    • #3
      Using RX and TX pins (13 and 14 on MKRzero board), placing a level translator (5 to 3.3 V) between gen4-PA or gen4-IB and connecting the HI level side to RX and TX pins on gen4 connected to display (gen4d uLCD 50DT). I have already made with the Arduino Mega and the adapter, the voltmeter presented in the AN and it is fully functional, but the same program compiled for MKRzero does not work.
      Best regards
      Maurizio
      .γνῶθι σαυτόν

      Comment


      • #4
        Hi Maurizio,

        Thanks for the information. I wouldn't expect it to work with the gen4-PA as it does tend to interfere with the USB converter on the PA. I would however expect it to work with the gen4-IB. The other issue may b e the reset logic. You mentioned the Mega and the adapter. If it is our adapter then the reset logic should be reversed if the reset is connected to a pin on the zero eg,


        digitalWrite(RESETLINE, 0); // Reset the Display
        delay(100);
        digitalWrite(RESETLINE, 1); // unReset the Display

        Comment


        • #5
          Already tested, but with the same results.I've changed also the gen4-PA with gen4-IB and viceversa but again no communication. I've powered the display with a different source: same no results. I'm a little bit confused and i'm thinking to a problem with a library. Could it possible?
          Maurizio
          .γνῶθι σαυτόν

          Comment


          • #7
            I'll try tomorrow. For the time being "mille grazie" (many thanks)
            Maurizio
            .γνῶθι σαυτόν

            Comment


            • #8
              Perfect. By replacing the gen4-IB with the gen4-PA, interposing the level shifter and feeding the display with a voltage source different from the Arduino MKRzero power supply, finally everything seems to work. I have not used the BETA library, I have continued to use the standard library. The AD conversion is not communicated to the display (Arduino and Display have the same baud rate 19200) and the port is COM0. The display sees the reset coming from the Arduino, but does not see the transmission of A1 data. Some idea?
              Thanks and best regards
              .γνῶθι σαυτόν

              Comment


              • #9
                Hi Maurizio,

                Thats great, thank you for the update.

                Is the analog reading a float variable. If this is the case it should be an integer that you send. It's the only thing that comes to mind. Could you please post your Arduino code here so I can take a look.

                Best regards

                Paul

                Comment


                • #10
                  Sorry but is not working at all.
                  The Arduino program is the following:

                  #include <genieArduino.h>
                  Genie genie;

                  // Voltmeter Demo
                  // 4D Systems
                  // This Demo communicates with a 4D Systems Display, configured with ViSi-Genie.
                  // The display has an angular meter, a LED digits, a rocker switch, and a static text.
                  // The program sends digital voltage readings to the LED digits and angular meter of the display module.
                  // The digital voltage readings are derived from pin A0 using ADC.Analog input voltage range is 0 to 5 volts only.
                  // The rocker switch of the display module is used for "turning on" the application.
                  // First, the program reads from the rocker switch manually using the Read Object function.
                  // If the rocker switch is on, the computed digital voltage readings are sent to the angular meter and LED digits.
                  // If the rocker switch is off, the angular meter and LED digits are made to display zero volts.

                  // This appication comes with a documentation: 4D-AN-P4019-ViSi-Genie A Simple Digital Voltmeter Application using an Arduino Host
                  // Download it here: http://www.4dsystems.com.au/appnotes/
                  /*
                  NOTE: Some Arduino boards such as the Due operate at 3.3 volts and tolerate analog input voltage levels from ground up to 3.3 V only.
                  Applying more than 3.3 V may damage the chip. If attempting to use 3.3V Arduino boards for this application, make sure to limit the
                  analog input voltage to 3.3 volts only and please read carefully your board’s datasheet.
                  */

                  int flag = 0; //holds the "power status" of the voltmeter. flag = 0 means voltmeter is "off", flag = 1 means the voltmeter is "on".
                  int sensorPin = A0; //the wiper of the trimmer potentiometer is connected to pin A0
                  int voltMeter; //holds the digital voltage value to be sent to the angular meter
                  int voltLED; //holds the digital voltage value to be sent to the LED digits

                  void setup()
                  {
                  Serial.begin(19200);
                  // a few options to talk to the Display, uncomment the one you want
                  // make sure that the ViSi Genie program has the same baud rate
                  genie.Begin(Serial); //Serial0
                  genie.AttachEventHandler(myGenieEventHandler);

                  //Reset the Display (change D4 to D2 if you have original 4D Arduino Adaptor)
                  pinMode(4, OUTPUT); // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
                  digitalWrite(4,LOW); // Reset the Display via D4
                  delay(100);
                  digitalWrite(4,HIGH); // unReset the Display via D4 The only thinks working well!!!

                  delay (3500); //let the display start up

                  }

                  void loop()
                  {
                  static long waitPeriod = millis();

                  genie.DoEvents(); //Genie events are received and queued here.

                  if (millis() >= waitPeriod)
                  {
                  if(flag == 1){
                  voltLED = ((3.3 * analogRead(sensorPin) * 1000.0) / 1023); // the only change!!!!!
                  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x00, voltLED); //write to Leddigits0 the value of voltLED
                  voltMeter = voltLED/100;
                  genie.WriteObject(GENIE_OBJ_ANGULAR_METER, 0x00, voltMeter); //write to Angularmeter0 the value of voltMeter
                  }

                  else if(flag == 0){
                  genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x00, 0);
                  genie.WriteObject(GENIE_OBJ_ANGULAR_METER, 0x00, 0);
                  }

                  // Do a manual read from Rockerswitch0. The results of this call will
                  // be available to myGenieEventHandler() after the display has responded
                  genie.ReadObject(GENIE_OBJ_ROCKERSW, 0x00);
                  waitPeriod = millis() + 50;
                  }
                  }


                  /////////////////////////////////////////////////////////////////////
                  //
                  // This is the user's event handler. It is called by genieDoEvents()
                  // when the following conditions are true
                  //
                  // The link is in an IDLE state, and
                  // There is an event to handle
                  //
                  // The event can be either a REPORT_EVENT frame sent asynchrounously
                  // from the display or a REPORT_OBJ frame sent by the display in
                  // response to a READ_OBJ request.
                  //

                  void myGenieEventHandler(void)
                  {
                  int rockersw_val; //holds the status of Rockerswitch0
                  genieFrame Event;
                  genie.DequeueEvent(&Event);
                  //Evaluate the event
                  if (genie.EventIs(&Event, GENIE_REPORT_OBJ, GENIE_OBJ_ROCKERSW, 0x00)){ //if the event is a REPORT_OBJ from Rockerswitch0
                  rockersw_val = genie.GetEventData(&Event); //extract the MSB and LSB values and pass them to rockersw_val
                  if (rockersw_val == 0) //if Rockerswitch0 is off
                  flag = 0; //"turn off" the voltmeter
                  else if (rockersw_val == 1) //if Rockerswitch0 is on
                  flag = 1; //"turn on" the voltmeter
                  }
                  }

                  As you can see is the same I've used with Arduino Mega, I've changed only the rows in red.
                  Best regards
                  Maurizio
                  .γνῶθι σαυτόν

                  Comment


                  • #11
                    Hi Maurizio

                    Could you please try using this code instead.

                    float tvolt = analogRead(sensorPin) * 0.0322;
                    voltLED = (int)tvolt;

                    Best regards

                    Paul

                    Comment


                    • #12
                      like this:
                      {
                      if(flag == 1){

                      float tvolt = analogRead(sensorPin) * 0.0322;
                      voltLED = (int)tvolt;

                      //voltLED = ((5.0 * analogRead(sensorPin) * 1000.0) / 1023); // the only change!!!!!
                      //Serial.println(voltLED);

                      genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x00, voltLED); //write to Leddigits0 the value of voltLED
                      voltMeter = voltLED/100;
                      genie.WriteObject(GENIE_OBJ_ANGULAR_METER, 0x00, voltMeter); //write to Angularmeter0 the value of voltMeter
                      }

                      Nothing change.
                      Best regards
                      Maurizio
                      .γνῶθι σαυτόν

                      Comment


                      • #13
                        Could you please try the Beta version. If there is no communication at all then there still may be a comms issue. I noticed that you have replaced the gen4-IB with the gen4-PA so is your setup now using the gen4-PA ? If this is the case, could you please switch back to the gen4-IB

                        Comment


                        • #14
                          I have tested the BETA version with both gen4-PA and gen4-IB but to no avail.
                          I do not know what to do! Now I prepare a schematic of the connection and then send it to you hoping to get to the bottom of the problem.
                          Best regards
                          Maurizio
                          .γνῶθι σαυτόν

                          Comment


                          • #15
                            The strange thing is that the configuration with Arduino Mega worked immediately and this makes me think that the libraries are optimized for an 8-bit or 16-bit processor and these do not fit with a 32-bit micro like SAMD21 Cortex-M0 + 32bit low power ARM MCU like the Arduino MKR zero.
                            Again thank you for your time, best regards
                            Maurizio
                            (Sorry for my English, but it's not my mother tongue as you can imagine!)
                            .γνῶθι σαυτόν

                            Comment

                            Working...
                            X