Announcement

Collapse
No announcement yet.

Serial comunication from Arduino to display uLCD-70-DT

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

  • Serial comunication from Arduino to display uLCD-70-DT

    Hi everybody.....
    I need some advice from my project with uLCD Diablo16

    First question:
    Basically i have to send String to display by Arduino. Comunication between the two devices is serial. Strings sending that I would like to write them all 'inside of the string object. The project is in VISI environment and not GENIE.
    I tried to use the serin() command but i can't read the strings that i send by arduino. i think that serin() isn't the correct instruction for my pourpose.
    Any advice?

    Second question:
    For the reason mentioneted above i tried to write the strings directly inside the VISI environment but in this case i need to send flags to display by Arduino, always to enable the strings inside the strings object in VISI environment, but the problem it's always the same: i don't know how implement the serial comunication to sending data from arduino to display.
    Instead the serial comunication from display to arduino it's ok

    To conclude the library that i used inside the Arduino IDE it's SerialSoftware.h


    Thank you


  • #2
    Serin() is the correct function, maybe you are just getting -1 (character not available) and need to loop/wait? Maybe you need to set up a comms buffer?

    If you still can't work it out try posting your code.
    Mark

    Comment


    • #3
      correct.....i have always -1......serin() don't read the character from Arduino......

      Comment


      • #4
        I think you need to post your code, on both sides. And also some photos of how everything is connected
        Mark

        Comment


        • #5
          Everything it's connected with shield for serial comunication......
          I need to write some strings to the display.....
          For the comunication into the Arduino IDE i used the softwareserial library, where i used pin 2 and 3 for the TX and RX comuication between the two devices.
          I have a keyboard designed with VISI for the display. With serout('char') [where char it's every alphanumeric character that i send to Arduino], i send the data to Arduino IDE, data that i read with the follow istructions:

          Arduino IDE:

          SoftwareSerial Display(2,3);

          .....

          If(Display.available())

          char c = Display.read();

          Workshop IDE

          if(savekey == 41)
          putch('a') // for examples the HEX code ASCII for the charcter 'a' it's 0x41
          serout('a') //when i touch the character 'a' i print it to the display and send to Arduino the letter 'a'

          in this manner i'm capable to read every char send by the display to Arduino

          Now i have this problem....

          Inside the Arduino IDE i have strings that i wrote in this manner:

          Serial.print(F("hiii"));

          ecc...

          if' want see this string to the display i need to change Serial with Display

          Display.print(F("hii"));

          the problem it's that inside the worshop IDE, serin() it's different then serout, because read only a char , and if don't read a char, return -1....for this reason i need to change my program, enabling flag that i will send to the display........this flag, when they will be received by the Display, will enable the string that i won't display....

          Examples:

          Workshop IDE

          char := serin();

          if(char > 0) // flag recevied by arduino......show the string

          putstr("hii");

          else
          pustr(" no hii"); // serin return - 1, whereby

          endif



          Arduino IDE

          if(Display.available())

          char character = 'a';

          Display.print('a'); // i send a flag to display...in this manner serin() read a char and return a number >0
          else




          byte number = 01010101;

          Display.print('number')'; // in send a flag to display...in this manner serin() don't read a char but a byte and return -1




          Any advice for this case??

          Sorry for the length of the post


          Comment


          • #6
            See post below.
            Last edited by Doff; 18th August 2014, 08:53 PM.
            Doff

            Comment


            • #7
              Hi Tntsei,

              Bytes sent to an Arduino controller are actually buffered in the background.

              http://arduino.cc/en/Serial/available

              Such that when you do a Serial.read(), you have to check if the there are bytes available in the buffer first.


              Code:
              If(Display.available())
                   char c = Display.read();
              If you do a read without checking if the receive buffer contains something, most likely what you will get is garbage data or 0xFF or -1 if I remember correctly.


              In 4DGL you can also do buffered comms, similar to that done in the Arduino IDE. Then you will also have to check if the receive buffer contains something before you do a read. Otherwise, you will get a "-1", which means that the buffer is empty. To illustrate,

              Code:
              if(com_Count())            // check if there are bytes available in the receive buffer for COM0
                   char x = serin();      // read a byte off the buffer. char now holds a valid byte.
              endif

              In the Arduino IDE, the receive buffer is 64 bytes long. In 4DGL, you have the freedom to set the size of the buffer because you have to setup the comms buffer yourself using the command,

              Code:
              com_Init(buffer, bufsize, qualifier);
              In Worskhop there are demo programs for serial comms. File - Samples - Picaso Designer - PICASO SERIAL COMMS. The codes are for Picaso, so just change the target screen to uLCD-70DT. Put the cursor on any of the serial comms functions and press "F1" to bring out the Diablo16 Internal Reference Manual.


              If you do not wish to use buffered comms, you can also do a continuous read until you get a valid character.

              Code:
              while ((i := serin()) < 0) ;
              char x = i; // i holds a valid byte

              I trust that you can figure things out by playing with the sample codes in Workshop and by reading the internal functions manual. You can also send your project files to doff at 4dsystems dot com dot au if you need further assistance.

              Hope this helps somehow and regards.
              Doff

              Comment


              • #8
                ok Doff...but if i want send strings to the display?.....serin() it's capable to read always char.......
                With Visi Genie inside the Arduino IDE, it's possible use genie.WriteStr.....but if my project (like in my case) it's VISI and not Genie?

                Comment


                • #9
                  Hi Tntsei,

                  A string is essentially composed of a stream of bytes. The controller sending the string has to do a serial send repetitively. On the other hand, the host receiving the string will have to do a serial read repetitively. These concurrent processes will depend on the length of the string of course. You will also have to store the read bytes somewhere. That is how strings are sent and received by controllers, AFAIK. Since you are doing your project in ViSi, you will have to handle all these on your display and on your Arduino. You will find some of the sample programs in Workshop helpful, I believe.

                  Regards.
                  Doff

                  Comment


                  • #10
                    If i try to use the library genieArduino inside the Arduino IDE and i try to write string inside a String Object inside a Visi project without introduce code 4DGL for the String Objcet?

                    Comment


                    • #11
                      Hi Tntsei,

                      The string object in ViSi will not "do anything" if you send it a string. You will have to write the 4DGL code for it to print the string received from the host. Hence the need to look at the sample programs in Workshop for basic serial comms. Why not use ViSi-Genie by the way?

                      Regards.
                      Doff

                      Comment


                      • #12
                        Because I need to program the display in VISI....i need to send every char that i push to Arduino in Real Time.

                        Can you give me some examples in code 4DGL to show strings inside a string object in VISI?
                        it's possible that it's so difficult write string on the display?

                        For examples if i use serin() i can read always char and not strings!

                        Comment


                        • #13
                          Hi Tntsei,

                          Attached is a zip file containing the ff:

                          Arduino sketch - just for sending a string to Serial0

                          ViSi project file 1 - illustrates how to receive a string (non-buffered comms style)

                          ViSi project file 2 - illustrates how to receive a string (buffered comms style)

                          They are based on the sample programs in Workshop. Hopefully you can use them as a reference and successfully integrate them to your project/s.

                          I used a uLCD-35DT for testing, so just change the target screen to a uLCD-70DT.

                          Regards.
                          Attached Files
                          Doff

                          Comment


                          • #14
                            Thanks Doff!!!!!

                            i'll let you know!!

                            Comment


                            • #15
                              Perfect Doff...the program it's unable to show the string on the display...

                              Now i have another question....

                              IF i want send an ACK message to the display how can i do with Arduino?

                              Comment

                              Working...
                              X