Announcement

Collapse
No announcement yet.

SPI communication with ADS7813 and uLCD-35DT

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

  • SPI communication with ADS7813 and uLCD-35DT

    hello, I have to do a project storage analog signals, i use the analog-digital converter ADS7813 it has output type SPI, but i dont know how connect and set the uLCD-35DT screen, I can not find any tutorial where the operation is explained the SPI ports of the screen, any suggestions?

  • #2
    Hi Davidmx4,

    For now there are no application notes for SPI communication on Diablo16 displays. There are examples, however, in Workshop (File - Samples -Diablo Designer):

    SPIflashBuild.4DG
    SPIflashDemo.4dg


    These projects demonstrate the use of an external flash memory thru SPI communication. I trust that you will be able to use these projects as a reference for your application.

    In addition to being SPI-comms-capable and having other numerous features, the Diablo16 processor can also do ADC. For more info, kindly refer to section 4.12 Analog Inputs of the datasheet for the uLCD-35DT.

    http://www.4dsystems.com.au/productp...heet_R_1_1.pdf

    In File - Samples -Diablo Designer you can find Analogue.4dg.

    The application note

    D-AN-D2005 Designer Analog Input

    may also help.

    Regards.
    Doff

    Comment


    • #3
      Doff thanks, but I need to use the ADC to have a range of 0 to 10V mandatory. I tried to make a code in VISI but when I try to run the program all black screen appears and does nothing to me. I think I must be missing a line of code, compile because I do not check any errors. My code is as follows, I hope you can help me, thanks.



      #platform "uLCD-35DT"

      // Program Skeleton 1.1 generated 03/07/2014 18:21:54

      #inherit "4DGL_16bitColours.fnc"

      #inherit "VisualConst.inc"

      #inherit "P1Const.inc"

      func main()
      // var hstrings ; // Handle to access uSD strings, uncomment if required
      // var hFontx ; // Handle to access uSD fonts, uncomment if required and change n to font number
      // Uncomment the following if uSD images, fonts or strings used.
      /*
      putstr("Mounting...\n");
      if (!(disk:=file_Mount()))
      while(!(disk :=file_Mount()))
      putstr("Drive not mounted...");
      pause(200);
      gfx_Cls();
      pause(200);
      wend
      endif
      // gfx_TransparentColour(0x0020); // uncomment if transparency required
      // gfx_Transparency(ON); // uncomment if transparency required

      // hFontn := file_LoadImageControl("P1.dan", "P1.gcn", 1); // Open handle to access uSD fonts, uncomment if required and change n to font number dropping a and c if > 9
      // hstrings := file_Open("P1.txf", 'r') ; // Open handle to access uSD strings, uncomment if required
      hndl := file_LoadImageControl("P1.dat", "P1.gci", 1);
      */

      pause(100);


      var DATBIN[16];
      var j,c,VALDEC,VOLT,VALORDECIMAL,V10,V32767,DIVOLT,Result;

      SPI1_Init(SPI_SPEED11, SPI16_MODE_1); //Configuration SP1
      SPI1_SCK_pin(PA3);
      SPI1_SDI_pin(PA2);
      SPI1_SDO_pin(PA1);

      repeat

      spi1_ReadBlock(str_Ptr(DATBIN), 16); //Read 16 bit for the ADC7813


      for(j:=1, c:=16384; j<16; j++, c:=c/2) //Convert Binary to Decimal
      VALDEC+=DATBIN[j]*c;
      next

      flt_ITOF(VALORDECIMAL, VALDEC); //Convert Decimal to Voltage 0-10
      flt_VAL(V10, "10");
      flt_ITOF(V32767, 32767);
      flt_DIV(DIVOLT, V10, V32767);
      flt_MUL(Result, VALORDECIMAL, DIVOLT);

      VOLT:=10*VALDEC/32767;

      // Coolgauge1 1.0 generated 03/07/2014 20:53:58
      img_SetWord(hndl, iCoolgauge1, IMAGE_INDEX, Result) ; // where frame is 0 to 10 (for a displayed -1 to -1)
      img_Show(hndl,iCoolgauge1) ;



      // Meter1 1.0 generated 03/07/2014 21:04:06
      img_SetWord(hndl, iMeter1, IMAGE_INDEX, VOLT) ; // where frame is 0 to 10 (for a displayed 0 to 10)
      img_Show(hndl,iMeter1) ;

      gfx_Set(SCREEN_MODE,LANDSCAPE) ;

      forever
      endfunc




      I Used two gauges for visualization, here's an image and my code in rar.
      Attached Files
      Last edited by davidmx4; 4 July 2014, 02:03 PM.

      Comment


      • #4
        Hi Davidmx4,

        In your code remove the block comment symbols at lines 15 and 31. This will allow the uSD card mounting routine and file_LoadImageControl() command to be compiled. The objects will now show on the display when you run the program. This application note may help you:

        4D-AN-P3005 ViSi Adding Image and Video

        app notes are found here: http://www.4dsystems.com.au/appnotes

        Regards.
        Last edited by Doff; 5 July 2014, 10:34 AM.
        Doff

        Comment


        • #5
          Now, always appears the message "Mointing..." and never go to the gauges.

          Comment


          • #6
            Hello Davidmx4,

            Were you able to follow the instructions on page 9 of the application note? It seems that the display module is waiting for the uSD card to be mounted.

            From the last paragraph on page 9,

            Remove the μSD card and insert it into the μSD card slot of the display
            module. The program will now run. The image should be shown on the
            display module screen as configured in the WYSIWYG screen. Below is the
            code at this point, with the unnecessary lines excluded.
            Hope this helps.
            Doff

            Comment


            • #7
              Hi, i'm trying to advance for my project with the ADS7813, i have a question, How can i convert a Binary number of 16 bits to a Decimal value?
              I'm use this code but i think doesn't work:


              //This is only a part of my code

              var DATBIN[15]; //Declared the BUS
              spi1_ReadBlock(DATBIN, 16); //Read the 16 Bit BUS and save in var DATBIN, is this correct???

              for(j:=1, c:=16384; j<16; j++, c:=c/2)
              VALDEC+=DATBIN[j]*c;

              I don't know if the 4d Workshop support loops for with two variables, or exist some function for convert BIN to DEC.
              And i don't know if the spi1_ReadBlock support a BUS of 16 bits.
              Last edited by davidmx4; 9 July 2014, 01:59 PM.

              Comment


              • #8
                A 16bit binary number is a decimal number if you print it that way.

                A simple test will show you that for(j:=1, c:=16384; j<16; j++, c:=c/2) is indeed supported and works

                But really, I should think your code could simply be

                var DATBIN;
                spi1_ReadBlock(&DATBIN, 2); //Read the 16 Bit BUS and save in var DATBIN
                print(DATBIN) ;

                Of course, the endianness might not be correct, but that's easily fixed (eg DATBIN := BYTESWAP(DATBIN) )
                Mark

                Comment

                Working...
                X