Gauge for Sensor

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • ADVANCETOM
    Member
    • Oct 2012
    • 91

    Gauge for Sensor

    Hello at my current project im wanna use this levelsensor with an 128g1 or an g2 oled


    http://www.sensortechnics.com/cms/upload/datasheets/DS_Standard-CLC_E_11663.pdf

    This sensor uses 5Volt TTL levels
    im wanna use an 4,7k pullup

    But im not sure how to communicate with the sensor?

    should i use OW read?
    Cant find an example for this one?

    Need Help pls
  • ESPsupport
    4D Staff
    • Jan 2009
    • 9841

    #2


    It's just straight serial at 9600 baud (see top of Page 3), but since it's RS232 levels it will need converting to TTL levels.

    Might be better to use the Analog, you will probably need to scale it using a couple of resistors, but once you have done that you will be able to use Goldelox's 10bit A2D converter, which should be better than the 8bit converter which you will end up with from the serial interface.
    Mark

    Comment

    • ADVANCETOM
      Member
      • Oct 2012
      • 91

      #3


      Can you help me with the resistor 4,5 v - 3,3 v= 1,2 V

      I would Take 1,2 kohm right?

      Comment

      • ESPsupport
        4D Staff
        • Jan 2009
        • 9841

        #4


        No, you'd need 2 resistors to create a divider, but scratch that idea.

        Just use Serial, as although the datasheet says RS232, it isn't really RS232.

        Just note that that device must be disconnected when you program the display
        Mark

        Comment

        • ADVANCETOM
          Member
          • Oct 2012
          • 91

          #5


          Okay
          And use OW read to read the sensor?
          May you have an example script ?

          Comment

          • ESPsupport
            4D Staff
            • Jan 2009
            • 9841

            #6


            It's just standard serial at 9600 baud, the datasheet is quite misleading, see top of page 3.

            You do two serin()s after setting the baud rate to 9600, I guess it streams data continuously, so one read will be 0x00 and the other will be the value
            Mark

            Comment

            • ADVANCETOM
              Member
              • Oct 2012
              • 91

              #7


              Pls Need a example !

              Comment

              • ESPsupport
                4D Staff
                • Jan 2009
                • 9841

                #8

                Pretty hard to make a sample for something you don't even have, a fair bit of experimentation would probably be needed.

                Anyway, this might be a starting point


                func main()
                var i, j ;
                setbaud(BAUD_9600);
                repeat
                while( (i := serin()) < 0) ; // read one value
                while( (j := serin()) < 0) ; // read another
                i := MAX(i,j) ; // one will be 0, take the other
                print([UDEC3ZB] i, "\r") ; // print it
                pause(100) ; // pause a while before repeating
                forever

                endfunc

                Mark

                Comment

                • ADVANCETOM
                  Member
                  • Oct 2012
                  • 91

                  #9


                  nice i will give a try later
                  And many Thanks for your fast reply this will help me very well !!

                  Comment

                  • ADVANCETOM
                    Member
                    • Oct 2012
                    • 91

                    #10
                    This works very well im used the serial console works fine.
                    But can you help me to integrate this now in a visi gauge code?
                    This is my existing gauge code i have.
                    Sorry i cant put this two pieces together working need help here!
                    i new at programming Sorry maybe for an noob question

                    Code:
                    #platform "GOLDELOX"
                    
                    /****************************************************************************************
                    *                                                                                       *
                    *  4D Visi Sample                                                                       *
                    *                                                                                       *
                    *  Date:        30 March 2012                                                           *
                    *                                                                                       *
                    *  Description: Demonstrates the visual placement of Meter and Led digits               *
                    *                                                                                       *
                    *  Prologue: 1. A new program was created by clicking the new button and the '4d Visi'  *
                    *               option was selected.                                                    *
                    *            2. The basic uOLED-128-G1 display was selected with Landscape orientation  *
                    *               and OK was presed.                                                      *
                    *            3. The meter and gauge have been created by clicking on them in            *
                    *               the relevant tabs above and then clicking on their top left location in *
                    *               the image display, on your right.                                       *
                    *            4. They moved around, resized and modified to produce what you see         *
                    *            5. This comment block was added                                            *
                    *            6. This was then saved                                                     *
                    *                                                                                       *
                    *  Getting it                                                                           *
                    *  running:  1. Select the Com port your display is attached to and click Comp'nLoad.   *
                    *               When prompted to, select the uSD card to allow the RAW data to be       *
                    *               copied, then insert the uSD card into your display before clicking OK.  *
                    *                                                                                       *
                    *                                                                                       *
                    ****************************************************************************************/
                    
                    #inherit "4DGL_16bitColours.fnc"
                    
                    #inherit "VisualConst.inc"
                    
                    #inherit "PMC1.0aaktuellConst.inc"
                    
                    func main()
                        var numx ;
                        print("Starting\n") ;
                        while(!media_Init())
                            putstr("Drive not mounted...");
                            pause(200);
                            gfx_Cls();
                            pause(200);
                        wend
                    
                    
                        gfx_Set(SCREEN_MODE,LANDSCAPE) ;
                        repeat
                            numx := ABS ( RAND() % 100) ;
                    
                    
                    
                    
                          // Meter1 1.0 generated 02.11.2012 21:31:05
                          media_SetAdd(iMeter1H, iMeter1L) ;      // point to the Meter1 image
                          media_VideoFrame(0, 0, numx) ;          // where numx is 0 to 100 (for a displayed 0 to 100)
                    
                          // Gauge1 1.0 generated 01.11.2012 15:38:50
                          media_SetAdd(iGauge1H, iGauge1L) ;      // point to the Gauge1 image
                          media_VideoFrame(0, 104, numx) ;          // where numx is 0 to 100 (for a displayed 0 to 100)
                    
                    
                    
                    
                        // Label1 1.0 generated 01.11.2012 15:43:40
                        txt_FGcolour(TURQUOISE) ;
                        txt_BGcolour(BLACK) ;
                        gfx_MoveTo(0, 92) ;
                        putstr("PMC V1.0a") ;
                    
                        // Led1 1.0 generated 01.11.2012 15:47:00
                        media_SetAdd(iLed1H, iLed1L) ;      // point to the Led1 image
                        media_VideoFrame(84, 92, numx) ;      // where numx is 0 (Off) or 1 (On)
                    
                    
                    
                    
                    
                    
                            pause(250) ;
                        forever
                    endfunc



                    Code:
                    #platform "GOLDELOX"
                    
                    #inherit "4DGL_16bitColours.fnc"
                    
                    func main()
                        var i, j ;
                        setbaud(BAUD_9600);
                    
                        repeat
                            while( (i := serin()) < 0)  ; // read one value
                            while( (j := serin()) < 0)  ; // read another
                            i := MAX(i,j) ;                    // one will be 0, take the other
                            print([UDEC3ZB] i, "\r") ;   // print it
                            pause(100) ;                     // pause a while before repeating
                        forever
                    
                    endfunc



                    Comment

                    • ESPsupport
                      4D Staff
                      • Jan 2009
                      • 9841

                      #11


                      Put the vars with the other vars, put the "setbaud(BAUD_9600);" before the repeat.

                      Then replace the "numx := ABS ( RAND() % 100) ;" with

                      while( (i := serin()) < 0) ; // read one value
                      while( (j := serin()) < 0) ; // read another
                      numx := MAX(i,j) ; // one will be 0, take the other
                      numx-- ; // start at 0

                      This will result in values between 0 and 253, which should ultimately be the scale of your gauges, etc.

                      For now you could rescale it a bit by using
                      numx := numx * 100 / 253 ; // scale to 0-100
                      Mark

                      Comment

                      • ADVANCETOM
                        Member
                        • Oct 2012
                        • 91

                        #12
                        Hello and Ty for fast reply
                        Here is my code now but display only presents "Starting" and nothing else only black ?
                        Maybe i do a failure?


                        Code:
                        #platform "GOLDELOX"
                        
                        /****************************************************************************************
                        *                                                                                       *
                        *  4D Visi Sample                                                                       *
                        *                                                                                       *
                        *  Date:        30 March 2012                                                           *
                        *                                                                                       *
                        *  Description: Demonstrates the visual placement of Meter and Led digits               *
                        *                                                                                       *
                        *  Prologue: 1. A new program was created by clicking the new button and the '4d Visi'  *
                        *               option was selected.                                                    *
                        *            2. The basic uOLED-128-G1 display was selected with Landscape orientation  *
                        *               and OK was presed.                                                      *
                        *            3. The meter and gauge have been created by clicking on them in            *
                        *               the relevant tabs above and then clicking on their top left location in *
                        *               the image display, on your right.                                       *
                        *            4. They moved around, resized and modified to produce what you see         *
                        *            5. This comment block was added                                            *
                        *            6. This was then saved                                                     *
                        *                                                                                       *
                        *  Getting it                                                                           *
                        *  running:  1. Select the Com port your display is attached to and click Comp'nLoad.   *
                        *               When prompted to, select the uSD card to allow the RAW data to be       *
                        *               copied, then insert the uSD card into your display before clicking OK.  *
                        *                                                                                       *
                        *                                                                                       *
                        ****************************************************************************************/
                        
                        #inherit "4DGL_16bitColours.fnc"
                        
                        #inherit "VisualConst.inc"
                        
                        #inherit "PMC1.0aaktuell+serinConst.inc"
                        
                        func main()
                            var i, j ;
                            var numx ;
                            print("Starting\n") ;
                            while(!media_Init())
                                putstr("Drive not mounted...");
                                pause(200);
                                gfx_Cls();
                                pause(200);
                            wend
                        
                        
                            gfx_Set(SCREEN_MODE,LANDSCAPE) ;
                            setbaud(BAUD_9600);
                            repeat
                                while( (i := serin()) < 0)  ; // read one value
                                while( (j := serin()) < 0)  ; // read another
                                numx := MAX(i,j) ;            // one will be 0, take the other
                                numx-- ;                           // start at 0
                        
                        
                        
                        
                        
                        
                              // Meter1 1.0 generated 02.11.2012 21:31:05
                              media_SetAdd(iMeter1H, iMeter1L) ;      // point to the Meter1 image
                              media_VideoFrame(0, 0, numx) ;          // where numx is 0 to 100 (for a displayed 0 to 100)
                        
                              // Gauge1 1.0 generated 01.11.2012 15:38:50
                              media_SetAdd(iGauge1H, iGauge1L) ;      // point to the Gauge1 image
                              media_VideoFrame(0, 104, numx) ;          // where numx is 0 to 100 (for a displayed 0 to 100)
                        
                        
                        
                        
                            // Label1 1.0 generated 01.11.2012 15:43:40
                            txt_FGcolour(TURQUOISE) ;
                            txt_BGcolour(BLACK) ;
                            gfx_MoveTo(0, 92) ;
                            putstr("PMC V1.0a") ;
                        
                            // Led1 1.0 generated 01.11.2012 15:47:00
                            media_SetAdd(iLed1H, iLed1L) ;      // point to the Led1 image
                            media_VideoFrame(84, 92, numx) ;      // where numx is 0 (Off) or 1 (On)
                        
                        
                        
                        
                        
                        
                                pause(250) ;
                             forever
                        endfunc

                        Comment

                        • ESPsupport
                          4D Staff
                          • Jan 2009
                          • 9841

                          #13


                          As it is the code will not display anything until the first value comes through from the sensor, so maybe that isn't connected?
                          Mark

                          Comment

                          • ADVANCETOM
                            Member
                            • Oct 2012
                            • 91

                            #14


                            Yeah sorry im tested wit serial terminal 9600
                            send 0001 and the display works Awesome!!!
                            Im so lucky it works now!
                            next step i will connect the sensor on it and do some tests with it.


                            added

                            numx := numx * 100 / 253 ; // scale to 0-100


                            and the scale is awesome working fine with ser terminal



                            Merry Christmas Mark and many Thanks

                            Comment

                            • ADVANCETOM
                              Member
                              • Oct 2012
                              • 91

                              #15


                              Hello here is my setup video with working Display and Sensor simply tested with a waterglass


                              https://&#91;video=youtube_share;ytYoyS6...yS6e1TQhttp://[/video]

                              Comment

                              Working...
                              X