Subject Re: Auto weight
From Michael <michael@itntgroup.com.au>
Date Wed, 23 Dec 2020 21:21:11 -0500
Newsgroups dbase.getting-started

Hi Charlie,

Yes, I plug into scales all the time here. I am not sure where your located but there a re certification requirements you may need to look into.

Easiest way is get yourself a serial communication library from Marshallsoft. They have a wonderful library with sample code which is simple and easy to use and intergrate into your software. Heres the link,

http://marshallsoft.com/serial-communication-library.htm

Most scales talk through serial communications and as we do POS systems We plug in many types of scales. Your typical flatbed scales are general CAS PDII or if in England , we also use the Avery Berkel FX120 Scale. Make sure the provider of the scale sends you a serial cables as they are all custom.

Heres a simple routine I use to read a CAS scale,

        function ReadCas
        
           set decimals to 3

      #INCLUDE WSC32.CC
      #INCLUDE EVENTS.CC
      #define WSC_KEY_CODE XXXXXXXXXXXXX  && Marshallsoft will give you a key on purchase, place it here

      if x_dcrtare      && This is a valiable I set if I am going to apply a tare weight, for example a custom box used to carrry the weighted item.
         readtare()   && a routine I wrote to read the tare weight out of a table
      endif
        
      extern CLONG Sleep(CLONG) Kernel32.DLL

      LOCAL Code
      LOCAL Port
      LOCAL Baud
      * get the port
      Port = COM1
      xport = xxx_scaleread
                code = 0

           do case
              case xport = 0
                   port = COM1
              case xport = 1
                   port = COM2
              case xport = 2
                   port = COM3
              case xport = 3
                   port = COM4
              case xport = 4
                   port = COM5
              case xport = 5
                   port = COM6
              case xport = 6
                   port = COM7
              case xport = 7
                   port = COM8
                        case xport = 8
                                  port = COM9
                        case xport = 9
                                  port = COM10
                        case xport = 10
                             port = COM11
                        case xport = 11
              port = COM12
                        case xport = 12
              port = COM13
           endcase

      * pass the key code
      if SioKeyCode(WSC_KEY_CODE) < 0
        DISPLAYERROR("ERROR: Bad Key Code!")
        return
      endif

      if Code < 0
        DISPLAYERROR(str(abs(Code),5))
        retbuf = 0
        return retbuf
      endif

      * set parmameters for the port [edit baud rate as necessary]
      Code = SioReset(Port, 1024, 1024)
      Code = SioParms(Port,WSC_evenParity,WSC_OneStopBit,WSC_WordLength7)
      Code = SioBaud(Port, 9600)

      Code = SioPutc(Port, ASC("W"))
      Code = SioPutc(Port, asc(chr(13)))
                sleep .3
                
      * allow  time for reponse
      * get response
      Buffer = SPACE(20)
      Code = SioGets(Port,Buffer,20)

                retbuf = 0
      retbuf = stripweight2(rtrim(buffer)) - x_tare
                
                if retbuf < 0
                   retbuf = 0
                endif
                
      Code = SioDone(Port)
                x_tare = 0

        return retbuf

Charlie Wrote:

> Just curious..  Is there a possibility of having a scale hooked up to a computer somehow and have the weight of an item put on the scale show up in an entryfield in a form somehow possibly a pushbutton???  Has anyone else done something like this?  Thanks