Announcement

Collapse
No announcement yet.

uLCD 32PT GPIO bug for SPI and 1 Wire

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

  • #16
    Hi Guys,

    I am trying to connect a one-wire temp sensor DS18B20 directly to a "Gen4-uLCD-43DCT-CLB". The code is from the app note: 4D-AN-P3006. When I try to compile it, these are the error messages that I get:

    Error: name 'OW_Reset' is already used as a 'PmmC function' in line 4936 (line 26 file:1-Wire-TEMP.inc)
    Error: name 'OW_Write' is already used as a 'PmmC function' in line 4962 (line 50 file:1-Wire-TEMP.inc)
    Error: name 'OW_Read' is already used as a 'PmmC function' in line 4944 (line 78 file:1-Wire-TEMP.inc)
    Error: undefined symbol 'IO5_PIN' (line 38 column 18 file:1-Wire-Discovery.4dg)
    Error: could not resolve a integer value for constant OW_PIN (line 39 file:1-Wire-Discovery.4dg)
    Fatal error: errors in first pass(1), can't continue (line 151 file:1-Wire-Discovery.4dg)

    I would appreciate any help to get this running.

    Thank you,

    Mark

    Comment


    • #17
      Hello Mark,

      The example was written for a Picaso, 1 Wire functions are already present in the PmmC of your device. You need to remove #include for the 1-Wire library and also set it up to use PA pin numbers for a Diablo instead of IO numbers eg PA5 instead of IO5 etc.page 49 onwards of this datasheet may help with pin numbers.

      https://www.4dsystems.com.au/product...ions_R_2_0.pdf

      Best regards

      Paul

      Comment


      • #18
        Thank you pauleilio for your reply. I found this bit of code that works fine on its own but locks up my Visi-Genie code when I try to use it as a separate function:


        var temp_buf ;

        txt_MoveCursor(0,0);
        if(OW_Reset(PA2)) // initialise and test
        print("No device detected");
        while(1);
        endif
        // repeat
        txt_MoveCursor(0, 0);
        print ("result=", OW_Reset(PA2));
        OW_Write(PA2, 0xcc); // skip ROM
        OW_Write(PA2, 0x44); // start conversion
        OW_Reset(PA2); // reset
        OW_Write(PA2, 0xcc); // skip ROM
        OW_Write(PA2, 0xBE); // get temperature
        temp_buf := OW_Read(PA2);
        temp_buf += (OW_Read(PA2) << 8);
        txt_MoveCursor(1, 0);
        print ("temp_buf=0x", [DEC4] temp_buf);
        // forever

        I know that if I have a function that repeats "forever" in the main loop that it will slow everything down, so I took the repeat and forever out. However what happens is that it reads the temp once and blocks my other functions. It doesn't lock the screen up, but it stops every other sensor from displaying. Where can I insert this in the visi genie code so it will not affect everything else?
        I was connecting it to an Arduino, but it was slowing everything down there as well. I have code that only asks it to update once per second, but that didn't help either.
        Any ideas?

        Thanks for your help,

        Mark

        Comment


        • #19
          Hi Mark,

          I think it is this bit of code that will cause it to block your program.

          if(OW_Reset(PA2)) // initialise and test
          print("No device detected");
          while(1);
          endif

          You could just use

          var deviceOk;
          if(OW_Reset(PA2)) deviceOk := 1;

          Or you could remove that completely as a reset is called within a print statement.

          Another way you could do this is to put the code in a function with an insertion point Globals/Data eg

          func GetOneWire()

          OW_Reset(PA2);
          OW_Write(PA2, 0xcc); // skip ROM
          OW_Write(PA2, 0x44); // start conversion
          OW_Reset(PA2); // reset
          OW_Write(PA2, 0xcc); // skip ROM
          OW_Write(PA2, 0xBE); // get temperature
          temp_buf := OW_Read(PA2);
          temp_buf += (OW_Read(PA2) << 8);

          return temp_buf;

          endfunc

          You can then use this function in you mainloop code eg,

          txt_MoveCursor(1, 0);
          print (GetOneWire());

          I hope this helps

          Best regards

          Paul






          Comment


          • #20
            Paul,
            Thanks again, that seems to work fine. I did have another question. If I want the temp checked every few seconds instead of every time through the loop, how would you do it?

            Thanks for your help,

            Mark

            Comment


            • #21
              Hi Mark,

              You could use the system rolling timer sys_T() like this

              in Constant/Globals/Data,

              var timeNow;

              in PostGenieInit

              timeNow := sys_T();

              and in your Mainloop

              if((sys_T() - timeNow) > 3000) // 3000 milliseconds
              txt_MoveCursor(1, 0);
              print (GetOneWire());
              timeNow := sys_T();
              endif

              I hope this helps

              Best regards

              Paul

              Comment


              • #22
                thanks again, that does what I needed

                Comment


                • #23
                  Well, I thought I had this project done, but the readings that I’m getting are about 10 degrees too high. I have tried changing the sensors but the result is the same. Do you know what could be going on here ? I’m not talking about conversion error to Fahrenheit, I’m talking about the Celsius value that’s reported. Is there some function that could be influencing the result? Any help would be appreciated.
                  regards,
                  Mark

                  Comment


                  • #24
                    Hi Mark,

                    You code looks right so I don't think it is a function that is causing the 10 degrees higher. there have been reports of reading higher but not as much as 10 degrees. Are they Dallas sensors ?
                    You could try printing out the MSB and LSB to make sure that the LSB is changing as expected.

                    Best regards

                    Paul

                    Comment

                    Working...
                    X