Announcement

Collapse
No announcement yet.

Arduino sending data to serial monitor, not display

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

  • Arduino sending data to serial monitor, not display

    Hi all, I'm trying to run this code example with the matching 4d program that I downloaded from the website, slightly modified to work with my setup:


    ------------------------------------------------------------------------​​​​​​​------------------------------------​​​​​​​------------------------------------​​​​​​​------------------------------------
    #include <genieArduino.h>

    Genie genie;

    // Displaying Temperature Readings from a Host
    // 4D Systems
    // This Demo communicates with a 4D Systems Display, configured with ViSi-Genie.
    // The display has two LED digits objects for displaying temperature in degrees Celsius and Fahrenheit
    // This sketch comes with a documentation (4D-AN-P4015 ViSi-Genie - Displaying Temperature Values from a Host)
    // Download documentation here: http://www.4dsystems.com.au/appnotes/

    int tempC; //holds temperature readings in degrees Celsius
    int tempF; //holds temperature readings in degrees Fahrenheit
    int sensorPin = 23; //Vout of LM35 is connected to A0 of Arduino host

    void setup()
    {
    Serial.begin(9600);
    // a few options to talk to the Display, uncomment the preferred serial port and baud rate
    // make sure that the ViSi Genie program has the same baud rate
    genie.Begin(Serial); //Serial0
    //Reset the Display (change D4 to D2 if you have original 4D Arduino Adaptor)
    //See the app note 4D-AN-P4017-ViSi-Genie Connecting a 4D Display to an Arduino Host
    //for information if using jumper connecting wires
    pinMode(2, OUTPUT); // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
    digitalWrite(2, 0); // Reset the Display via D4
    delay(100);
    digitalWrite(2, 1); // unReset the Display via D4

    delay (5000); //let the display start up
    }

    void loop()
    {
    tempC = ((5.0 * analogRead(sensorPin) * 100.0) / 1024) + 2; //signal level sampled from sensorPin is converted to a temperature value. Do calibration if needed.
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x00, tempC); //Write to Leddigits0 the value of tempC
    delay(50);
    tempF = tempC * 9 / 5 + 32; //Convert temperature readings in degrees Celsius to degrees Fahrenheit
    genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x01, tempF); //Write to Leddigits1 the value of tempF
    delay(50);
    }
    ​​​​​​​------------------------------------​​​​​​​------------------------------------​​​​​​​------------------------------------​​​​​​​------------------------------------​​​​​​​------------------------------------



    However, the Arduino doesn't actually seem to be sending anything to the display--I checked on the scope to be sure. I am getting random garbage in two-character pairs onto the serial monitor, and I see the garbage no matter what baud rate I set the monitor to. Simply closing the monitor did not solve the problem either.

    I can get the GTX tool to communicate with the display just fine, and have run a few 4d sketches just fine as well. I am running both the 4d program and the Arduino program at a baud rate of 9600. My Arduino (a teensy 3.2) appears on my computer as Port 50, and the 4d display appears as Port 13. I am not having any problems with the 4d display other than communication issue, and am not having any problems running other programs on my teensy either.

  • #2
    Hello,

    You seem to be on the right track, however I would recommend using another Serial port for talking with the display and using a non- blocking delay on the mainloop. You could try modifying your code to make it look more like this:


    Code:
    #include <genieArduino.h>
    #include <SoftwareSerial.h>
    SoftwareSerial SoftSer(4,5);
    Genie genie;
    
    // Displaying Temperature Readings from a Host
    // 4D Systems
    // This Demo communicates with a 4D Systems Display, configured with ViSi-Genie.
    // The display has two LED digits objects for displaying temperature in degrees Celsius and Fahrenheit
    // This sketch comes with a documentation (4D-AN-P4015 ViSi-Genie - Displaying Temperature Values from a Host)
    // Download documentation here: http://www.4dsystems.com.au/appnotes/
    
      int tempC;           //holds temperature readings in degrees Celsius
      int tempF;           //holds temperature readings in degrees Fahrenheit
      int sensorPin = A9;  //Vout of LM35 is connected to A0 of Arduino host
      
    void setup()
    {
      Serial.begin(9600);
      // a few options to talk to the Display, uncomment the preferred serial port and baud rate
      // make sure that the ViSi Genie program has the same baud rate
      SoftSer.begin(9600);// this could also be another Serial port
      genie.Begin(SoftSer);  //Software Serial
      //Reset the Display (change D4 to D2 if you have original 4D Arduino Adaptor)
      //See the app note 4D-AN-P4017-ViSi-Genie Connecting a 4D Display to an Arduino Host
      //for information if using jumper connecting wires
      pinMode(2, OUTPUT);   // Set D4 on Arduino to Output (4D Arduino Adaptor V2 - Display Reset)
      digitalWrite(2, 0);   // Reset the Display via D4
      delay(100);
      digitalWrite(2, 1);   // unReset the Display via D4
      
      delay (3500);         //let the display start up
    }
    unsigned long Prevtime;
    void loop()
    {
      unsigned long Currtime = millis();
     if (Currtime - Prevtime >= 50 || Currtime - Prevtime <= 70){
      Serial.println("Printing celsius");
      tempC = ((5.0 * analogRead(sensorPin) * 100.0) / 1024) + 2;  //signal level sampled from sensorPin is converted to a temperature value. Do calibration  if needed.
      genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x00, tempC);         //Write to Leddigits0 the value of tempC
      }
      if (Currtime - Prevtime >= 100 || Currtime - Prevtime <= 120){
      Serial.println("Printing fren");
      tempF = tempC * 9 / 5 + 32;                                  //Convert temperature readings in degrees Celsius to degrees Fahrenheit
      genie.WriteObject(GENIE_OBJ_LED_DIGITS, 0x01, tempF);         //Write to Leddigits1 the value of tempF
      Currtime = Prevtime;
      }
    }
    Serial0 is usually used by the PC to communicate with the microcontroller, that's one of the reasons I choose to use another serial port to talk with the display. Another reason would be for debugging purposes. On the main loop I used a Serial print command to ensure that the program is entering the if conditionals.

    Could you check your wiring?

    I don't have a teensy 3.2 with me but I believe your circuit should look something like this:


    Click image for larger version  Name:	SAmple for teensy.png Views:	1 Size:	146.7 KB ID:	63862

    Note: Please rewire the Rx & Tx pins on the teensy if you're using a different Serial port


    You might also want to check this forum thread:

    Teensy 3.1 / 3.2 and 3.2" Picasso not communicating
    https://forum.4dsystems.com.au/forum...-communicating

    Best Regards,
    Michael
    Last edited by michael_4D; 6th June 2018, 06:47 PM.
    Michael

    Comment


    • #3
      Yep, that seems to have done the trick. Thanks!

      Comment


      • #4
        Good to hear that,

        If you have anymore inquiries, please don't hesitate to ask.

        Best Regards,
        Michael
        Michael

        Comment

        Working...
        X