home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / pid_loop496371182002.psc / pid.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  2002-01-18  |  36.2 KB  |  1,288 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Simple PID Loop Simulator - Industrial Level Control ... mlseim@mmm.com"
  5.    ClientHeight    =   7020
  6.    ClientLeft      =   3090
  7.    ClientTop       =   2715
  8.    ClientWidth     =   9420
  9.    LinkTopic       =   "Form1"
  10.    ScaleHeight     =   7020
  11.    ScaleWidth      =   9420
  12.    Begin VB.CommandButton Command3 
  13.       Caption         =   "Create unstable water supply"
  14.       Height          =   435
  15.       Left            =   90
  16.       TabIndex        =   46
  17.       Top             =   5790
  18.       Width           =   1275
  19.    End
  20.    Begin VB.PictureBox Picture2 
  21.       BackColor       =   &H00000000&
  22.       FillColor       =   &H0000FFFF&
  23.       FillStyle       =   0  'Solid
  24.       Height          =   1125
  25.       Left            =   5190
  26.       ScaleHeight     =   71
  27.       ScaleMode       =   3  'Pixel
  28.       ScaleWidth      =   271
  29.       TabIndex        =   45
  30.       Top             =   5850
  31.       Width           =   4125
  32.    End
  33.    Begin VB.PictureBox Picture1 
  34.       BackColor       =   &H00000000&
  35.       Height          =   1305
  36.       Left            =   5160
  37.       ScaleHeight     =   83
  38.       ScaleMode       =   3  'Pixel
  39.       ScaleWidth      =   271
  40.       TabIndex        =   44
  41.       Top             =   4080
  42.       Width           =   4125
  43.    End
  44.    Begin VB.CommandButton Command2 
  45.       Caption         =   "Auto Control"
  46.       Height          =   315
  47.       Left            =   5100
  48.       TabIndex        =   27
  49.       Top             =   540
  50.       Width           =   1245
  51.    End
  52.    Begin VB.CommandButton Command1 
  53.       Caption         =   "Manual Control"
  54.       Height          =   315
  55.       Left            =   5100
  56.       TabIndex        =   26
  57.       Top             =   180
  58.       Width           =   1245
  59.    End
  60.    Begin VB.TextBox Text4 
  61.       BeginProperty Font 
  62.          Name            =   "Arial"
  63.          Size            =   9.75
  64.          Charset         =   0
  65.          Weight          =   700
  66.          Underline       =   0   'False
  67.          Italic          =   0   'False
  68.          Strikethrough   =   0   'False
  69.       EndProperty
  70.       Height          =   285
  71.       Left            =   6000
  72.       TabIndex        =   20
  73.       Text            =   "10"
  74.       Top             =   1800
  75.       Width           =   645
  76.    End
  77.    Begin VB.TextBox Text3 
  78.       BeginProperty Font 
  79.          Name            =   "Arial"
  80.          Size            =   9.75
  81.          Charset         =   0
  82.          Weight          =   700
  83.          Underline       =   0   'False
  84.          Italic          =   0   'False
  85.          Strikethrough   =   0   'False
  86.       EndProperty
  87.       Height          =   285
  88.       Left            =   6000
  89.       TabIndex        =   19
  90.       Text            =   "3"
  91.       Top             =   1410
  92.       Width           =   645
  93.    End
  94.    Begin VB.TextBox Text2 
  95.       BeginProperty Font 
  96.          Name            =   "Arial"
  97.          Size            =   9.75
  98.          Charset         =   0
  99.          Weight          =   700
  100.          Underline       =   0   'False
  101.          Italic          =   0   'False
  102.          Strikethrough   =   0   'False
  103.       EndProperty
  104.       Height          =   315
  105.       Left            =   6000
  106.       TabIndex        =   18
  107.       Text            =   "30"
  108.       Top             =   990
  109.       Width           =   615
  110.    End
  111.    Begin VB.Timer Timer1 
  112.       Interval        =   100
  113.       Left            =   90
  114.       Top             =   3810
  115.    End
  116.    Begin VB.TextBox Text1 
  117.       BeginProperty Font 
  118.          Name            =   "Arial"
  119.          Size            =   11.25
  120.          Charset         =   0
  121.          Weight          =   700
  122.          Underline       =   0   'False
  123.          Italic          =   0   'False
  124.          Strikethrough   =   0   'False
  125.       EndProperty
  126.       Height          =   285
  127.       Left            =   660
  128.       TabIndex        =   11
  129.       Top             =   2670
  130.       Width           =   675
  131.    End
  132.    Begin VB.VScrollBar VScroll1 
  133.       Height          =   3825
  134.       Left            =   4020
  135.       Max             =   0
  136.       Min             =   3100
  137.       TabIndex        =   7
  138.       Top             =   690
  139.       Width           =   255
  140.    End
  141.    Begin VB.HScrollBar HScroll2 
  142.       Height          =   255
  143.       Left            =   810
  144.       Max             =   100
  145.       TabIndex        =   4
  146.       Top             =   4650
  147.       Width           =   1365
  148.    End
  149.    Begin VB.HScrollBar HScroll1 
  150.       Height          =   255
  151.       Left            =   90
  152.       Max             =   100
  153.       TabIndex        =   1
  154.       Top             =   930
  155.       Width           =   1425
  156.    End
  157.    Begin VB.Label Label39 
  158.       Caption         =   $"pid.frx":0000
  159.       ForeColor       =   &H00808000&
  160.       Height          =   675
  161.       Left            =   120
  162.       TabIndex        =   54
  163.       Top             =   6360
  164.       Width           =   4545
  165.    End
  166.    Begin VB.Label Label15 
  167.       Caption         =   $"pid.frx":009F
  168.       ForeColor       =   &H00808000&
  169.       Height          =   795
  170.       Left            =   6840
  171.       TabIndex        =   53
  172.       Top             =   150
  173.       Width           =   2535
  174.    End
  175.    Begin VB.Line Line39 
  176.       BorderWidth     =   2
  177.       X1              =   30
  178.       X2              =   9330
  179.       Y1              =   30
  180.       Y2              =   30
  181.    End
  182.    Begin VB.Label Label43 
  183.       BackColor       =   &H00C0C0C0&
  184.       Caption         =   "Process Variable - PV"
  185.       BeginProperty Font 
  186.          Name            =   "Arial"
  187.          Size            =   8.25
  188.          Charset         =   0
  189.          Weight          =   700
  190.          Underline       =   0   'False
  191.          Italic          =   0   'False
  192.          Strikethrough   =   0   'False
  193.       EndProperty
  194.       Height          =   255
  195.       Left            =   6210
  196.       TabIndex        =   52
  197.       Top             =   3840
  198.       Width           =   1935
  199.    End
  200.    Begin VB.Label Label42 
  201.       Caption         =   "Output Valve Position"
  202.       BeginProperty Font 
  203.          Name            =   "Arial"
  204.          Size            =   8.25
  205.          Charset         =   0
  206.          Weight          =   700
  207.          Underline       =   0   'False
  208.          Italic          =   0   'False
  209.          Strikethrough   =   0   'False
  210.       EndProperty
  211.       Height          =   225
  212.       Left            =   6240
  213.       TabIndex        =   51
  214.       Top             =   5610
  215.       Width           =   1905
  216.    End
  217.    Begin VB.Label Label41 
  218.       Caption         =   "100%"
  219.       Height          =   285
  220.       Left            =   4740
  221.       TabIndex        =   50
  222.       Top             =   5850
  223.       Width           =   435
  224.    End
  225.    Begin VB.Label Label40 
  226.       Caption         =   "0%"
  227.       Height          =   315
  228.       Left            =   4890
  229.       TabIndex        =   49
  230.       Top             =   6750
  231.       Width           =   285
  232.    End
  233.    Begin VB.Label Label38 
  234.       ForeColor       =   &H00FF0000&
  235.       Height          =   225
  236.       Left            =   60
  237.       TabIndex        =   48
  238.       Top             =   1440
  239.       Width           =   435
  240.    End
  241.    Begin VB.Label Label37 
  242.       Caption         =   "% Valve Position"
  243.       Height          =   255
  244.       Left            =   2790
  245.       TabIndex        =   47
  246.       Top             =   5310
  247.       Width           =   1245
  248.    End
  249.    Begin VB.Shape Shape19 
  250.       FillColor       =   &H0000FF00&
  251.       Height          =   285
  252.       Left            =   1380
  253.       Shape           =   3  'Circle
  254.       Top             =   5880
  255.       Width           =   255
  256.    End
  257.    Begin VB.Label Label36 
  258.       Caption         =   "Rate"
  259.       Height          =   165
  260.       Left            =   6750
  261.       TabIndex        =   43
  262.       Top             =   3270
  263.       Width           =   375
  264.    End
  265.    Begin VB.Label Label35 
  266.       Caption         =   "d"
  267.       Height          =   195
  268.       Left            =   6540
  269.       TabIndex        =   42
  270.       Top             =   3150
  271.       Width           =   135
  272.    End
  273.    Begin VB.Line Line38 
  274.       X1              =   6570
  275.       X2              =   6570
  276.       Y1              =   3120
  277.       Y2              =   2880
  278.    End
  279.    Begin VB.Line Line37 
  280.       X1              =   6960
  281.       X2              =   7050
  282.       Y1              =   3120
  283.       Y2              =   3180
  284.    End
  285.    Begin VB.Line Line36 
  286.       X1              =   6960
  287.       X2              =   6870
  288.       Y1              =   3120
  289.       Y2              =   3180
  290.    End
  291.    Begin VB.Line Line35 
  292.       X1              =   6960
  293.       X2              =   6960
  294.       Y1              =   3240
  295.       Y2              =   3120
  296.    End
  297.    Begin VB.Line Line34 
  298.       X1              =   6720
  299.       X2              =   6960
  300.       Y1              =   3240
  301.       Y2              =   3240
  302.    End
  303.    Begin VB.Shape Shape18 
  304.       Height          =   255
  305.       Left            =   6510
  306.       Top             =   3120
  307.       Width           =   225
  308.    End
  309.    Begin VB.Label Label34 
  310.       Caption         =   "SP - PV"
  311.       Height          =   225
  312.       Left            =   6660
  313.       TabIndex        =   41
  314.       Top             =   2250
  315.       Width           =   585
  316.    End
  317.    Begin VB.Label Label33 
  318.       Caption         =   "0-120 Seconds"
  319.       Height          =   225
  320.       Left            =   6660
  321.       TabIndex        =   40
  322.       Top             =   1860
  323.       Width           =   1245
  324.    End
  325.    Begin VB.Label Label32 
  326.       Caption         =   "Reset"
  327.       Height          =   225
  328.       Left            =   7170
  329.       TabIndex        =   39
  330.       Top             =   2610
  331.       Width           =   465
  332.    End
  333.    Begin VB.Line Line33 
  334.       X1              =   6960
  335.       X2              =   6870
  336.       Y1              =   2880
  337.       Y2              =   2970
  338.    End
  339.    Begin VB.Line Line32 
  340.       X1              =   6870
  341.       X2              =   6960
  342.       Y1              =   2790
  343.       Y2              =   2880
  344.    End
  345.    Begin VB.Line Line31 
  346.       X1              =   6870
  347.       X2              =   7020
  348.       Y1              =   2970
  349.       Y2              =   2970
  350.    End
  351.    Begin VB.Line Line30 
  352.       X1              =   7020
  353.       X2              =   6870
  354.       Y1              =   2790
  355.       Y2              =   2790
  356.    End
  357.    Begin VB.Label Label31 
  358.       Caption         =   "OUT"
  359.       BeginProperty Font 
  360.          Name            =   "MS Sans Serif"
  361.          Size            =   8.25
  362.          Charset         =   0
  363.          Weight          =   700
  364.          Underline       =   0   'False
  365.          Italic          =   0   'False
  366.          Strikethrough   =   0   'False
  367.       EndProperty
  368.       Height          =   225
  369.       Left            =   7620
  370.       TabIndex        =   38
  371.       Top             =   3120
  372.       Width           =   405
  373.    End
  374.    Begin VB.Line Line29 
  375.       X1              =   6360
  376.       X2              =   6450
  377.       Y1              =   3540
  378.       Y2              =   3600
  379.    End
  380.    Begin VB.Line Line28 
  381.       X1              =   6360
  382.       X2              =   6450
  383.       Y1              =   3540
  384.       Y2              =   3480
  385.    End
  386.    Begin VB.Line Line27 
  387.       X1              =   6360
  388.       X2              =   7500
  389.       Y1              =   3540
  390.       Y2              =   3540
  391.    End
  392.    Begin VB.Line Line26 
  393.       X1              =   7500
  394.       X2              =   7500
  395.       Y1              =   2880
  396.       Y2              =   3540
  397.    End
  398.    Begin VB.Line Line25 
  399.       X1              =   7140
  400.       X2              =   7500
  401.       Y1              =   2880
  402.       Y2              =   2880
  403.    End
  404.    Begin VB.Label Label30 
  405.       BackColor       =   &H00FFFFFF&
  406.       Caption         =   "0"
  407.       BeginProperty Font 
  408.          Name            =   "Arial"
  409.          Size            =   9.75
  410.          Charset         =   0
  411.          Weight          =   700
  412.          Underline       =   0   'False
  413.          Italic          =   0   'False
  414.          Strikethrough   =   0   'False
  415.       EndProperty
  416.       Height          =   255
  417.       Left            =   6030
  418.       TabIndex        =   37
  419.       Top             =   2220
  420.       Width           =   585
  421.    End
  422.    Begin VB.Label Label29 
  423.       Caption         =   "e = error (difference)"
  424.       Height          =   225
  425.       Left            =   4560
  426.       TabIndex        =   36
  427.       Top             =   2220
  428.       Width           =   1425
  429.    End
  430.    Begin VB.Label Label28 
  431.       Caption         =   "e"
  432.       BeginProperty Font 
  433.          Name            =   "MS Sans Serif"
  434.          Size            =   8.25
  435.          Charset         =   0
  436.          Weight          =   700
  437.          Underline       =   0   'False
  438.          Italic          =   0   'False
  439.          Strikethrough   =   0   'False
  440.       EndProperty
  441.       Height          =   165
  442.       Left            =   5400
  443.       TabIndex        =   35
  444.       Top             =   2670
  445.       Width           =   195
  446.    End
  447.    Begin VB.Line Line22 
  448.       X1              =   5670
  449.       X2              =   5610
  450.       Y1              =   2880
  451.       Y2              =   2970
  452.    End
  453.    Begin VB.Line Line21 
  454.       X1              =   5670
  455.       X2              =   5610
  456.       Y1              =   2880
  457.       Y2              =   2820
  458.    End
  459.    Begin VB.Line Line24 
  460.       X1              =   6690
  461.       X2              =   6630
  462.       Y1              =   2880
  463.       Y2              =   2970
  464.    End
  465.    Begin VB.Line Line23 
  466.       X1              =   6690
  467.       X2              =   6630
  468.       Y1              =   2880
  469.       Y2              =   2790
  470.    End
  471.    Begin VB.Line Line20 
  472.       X1              =   5070
  473.       X2              =   5130
  474.       Y1              =   3120
  475.       Y2              =   3210
  476.    End
  477.    Begin VB.Line Line19 
  478.       X1              =   5070
  479.       X2              =   5010
  480.       Y1              =   3120
  481.       Y2              =   3210
  482.    End
  483.    Begin VB.Line Line18 
  484.       X1              =   4830
  485.       X2              =   4740
  486.       Y1              =   2880
  487.       Y2              =   2940
  488.    End
  489.    Begin VB.Line Line17 
  490.       X1              =   4830
  491.       X2              =   4740
  492.       Y1              =   2880
  493.       Y2              =   2820
  494.    End
  495.    Begin VB.Label Label27 
  496.       Caption         =   "SP"
  497.       BeginProperty Font 
  498.          Name            =   "MS Sans Serif"
  499.          Size            =   8.25
  500.          Charset         =   0
  501.          Weight          =   700
  502.          Underline       =   0   'False
  503.          Italic          =   0   'False
  504.          Strikethrough   =   0   'False
  505.       EndProperty
  506.       Height          =   225
  507.       Left            =   4440
  508.       TabIndex        =   34
  509.       Top             =   2640
  510.       Width           =   315
  511.    End
  512.    Begin VB.Label Label26 
  513.       Caption         =   "PV"
  514.       BeginProperty Font 
  515.          Name            =   "MS Sans Serif"
  516.          Size            =   8.25
  517.          Charset         =   0
  518.          Weight          =   700
  519.          Underline       =   0   'False
  520.          Italic          =   0   'False
  521.          Strikethrough   =   0   'False
  522.       EndProperty
  523.       Height          =   225
  524.       Left            =   5250
  525.       TabIndex        =   33
  526.       Top             =   3300
  527.       Width           =   315
  528.    End
  529.    Begin VB.Line Line16 
  530.       X1              =   5070
  531.       X2              =   5580
  532.       Y1              =   3540
  533.       Y2              =   3540
  534.    End
  535.    Begin VB.Line Line15 
  536.       X1              =   5070
  537.       X2              =   5070
  538.       Y1              =   3120
  539.       Y2              =   3540
  540.    End
  541.    Begin VB.Label Label25 
  542.       Caption         =   "Process"
  543.       Height          =   225
  544.       Left            =   5670
  545.       TabIndex        =   32
  546.       Top             =   3420
  547.       Width           =   645
  548.    End
  549.    Begin VB.Label Label24 
  550.       Caption         =   "X Gain"
  551.       Height          =   225
  552.       Left            =   5730
  553.       TabIndex        =   31
  554.       Top             =   2760
  555.       Width           =   525
  556.    End
  557.    Begin VB.Line Line14 
  558.       X1              =   6300
  559.       X2              =   6690
  560.       Y1              =   2880
  561.       Y2              =   2880
  562.    End
  563.    Begin VB.Line Line13 
  564.       X1              =   5310
  565.       X2              =   5670
  566.       Y1              =   2880
  567.       Y2              =   2880
  568.    End
  569.    Begin VB.Line Line12 
  570.       X1              =   4830
  571.       X2              =   4500
  572.       Y1              =   2880
  573.       Y2              =   2880
  574.    End
  575.    Begin VB.Line Line11 
  576.       X1              =   4950
  577.       X2              =   5160
  578.       Y1              =   2970
  579.       Y2              =   2970
  580.    End
  581.    Begin VB.Line Line10 
  582.       X1              =   5040
  583.       X2              =   5160
  584.       Y1              =   2760
  585.       Y2              =   2970
  586.    End
  587.    Begin VB.Line Line9 
  588.       X1              =   5040
  589.       X2              =   4950
  590.       Y1              =   2790
  591.       Y2              =   2970
  592.    End
  593.    Begin VB.Shape Shape17 
  594.       Height          =   405
  595.       Left            =   5580
  596.       Top             =   3330
  597.       Width           =   795
  598.    End
  599.    Begin VB.Shape Shape16 
  600.       Height          =   495
  601.       Left            =   6690
  602.       Shape           =   3  'Circle
  603.       Top             =   2640
  604.       Width           =   465
  605.    End
  606.    Begin VB.Shape Shape15 
  607.       Height          =   435
  608.       Left            =   5670
  609.       Top             =   2670
  610.       Width           =   645
  611.    End
  612.    Begin VB.Shape Shape14 
  613.       Height          =   495
  614.       Left            =   4830
  615.       Shape           =   3  'Circle
  616.       Top             =   2640
  617.       Width           =   465
  618.    End
  619.    Begin VB.Label Label23 
  620.       Caption         =   "OUT"
  621.       BeginProperty Font 
  622.          Name            =   "Arial"
  623.          Size            =   14.25
  624.          Charset         =   0
  625.          Weight          =   700
  626.          Underline       =   0   'False
  627.          Italic          =   0   'False
  628.          Strikethrough   =   0   'False
  629.       EndProperty
  630.       ForeColor       =   &H000000FF&
  631.       Height          =   375
  632.       Left            =   2790
  633.       TabIndex        =   30
  634.       Top             =   5010
  635.       Width           =   645
  636.    End
  637.    Begin VB.Label Label22 
  638.       Caption         =   "SP"
  639.       BeginProperty Font 
  640.          Name            =   "Arial"
  641.          Size            =   14.25
  642.          Charset         =   0
  643.          Weight          =   700
  644.          Underline       =   0   'False
  645.          Italic          =   0   'False
  646.          Strikethrough   =   0   'False
  647.       EndProperty
  648.       ForeColor       =   &H000000FF&
  649.       Height          =   345
  650.       Left            =   4320
  651.       TabIndex        =   29
  652.       Top             =   4170
  653.       Width           =   435
  654.    End
  655.    Begin VB.Label Label21 
  656.       Caption         =   "PV"
  657.       BeginProperty Font 
  658.          Name            =   "Arial"
  659.          Size            =   14.25
  660.          Charset         =   0
  661.          Weight          =   700
  662.          Underline       =   0   'False
  663.          Italic          =   0   'False
  664.          Strikethrough   =   0   'False
  665.       EndProperty
  666.       ForeColor       =   &H000000FF&
  667.       Height          =   345
  668.       Left            =   210
  669.       TabIndex        =   28
  670.       Top             =   2640
  671.       Width           =   435
  672.    End
  673.    Begin VB.Shape Shape13 
  674.       FillColor       =   &H0000FF00&
  675.       Height          =   285
  676.       Left            =   6390
  677.       Shape           =   3  'Circle
  678.       Top             =   570
  679.       Width           =   255
  680.    End
  681.    Begin VB.Shape Shape12 
  682.       FillColor       =   &H0000FF00&
  683.       FillStyle       =   0  'Solid
  684.       Height          =   285
  685.       Left            =   6390
  686.       Shape           =   3  'Circle
  687.       Top             =   210
  688.       Width           =   255
  689.    End
  690.    Begin VB.Label Label20 
  691.       Caption         =   "0-120 Seconds"
  692.       Height          =   225
  693.       Left            =   6660
  694.       TabIndex        =   25
  695.       Top             =   1470
  696.       Width           =   1275
  697.    End
  698.    Begin VB.Label Label19 
  699.       Caption         =   "0-100%"
  700.       Height          =   225
  701.       Left            =   6660
  702.       TabIndex        =   24
  703.       Top             =   1080
  704.       Width           =   585
  705.    End
  706.    Begin VB.Label Label18 
  707.       Caption         =   "Derivitave (RATE)"
  708.       Height          =   255
  709.       Left            =   4680
  710.       TabIndex        =   23
  711.       Top             =   1830
  712.       Width           =   1305
  713.    End
  714.    Begin VB.Label Label17 
  715.       Caption         =   "Integral (RESET)"
  716.       Height          =   285
  717.       Left            =   4740
  718.       TabIndex        =   22
  719.       Top             =   1440
  720.       Width           =   1245
  721.    End
  722.    Begin VB.Label Label16 
  723.       Caption         =   "Proportional (GAIN)"
  724.       Height          =   255
  725.       Left            =   4560
  726.       TabIndex        =   21
  727.       Top             =   1050
  728.       Width           =   1395
  729.    End
  730.    Begin VB.Shape Shape11 
  731.       FillColor       =   &H00FFFF00&
  732.       Height          =   405
  733.       Left            =   2460
  734.       Top             =   5010
  735.       Width           =   285
  736.    End
  737.    Begin VB.Shape Shape10 
  738.       FillColor       =   &H00FFFF00&
  739.       Height          =   225
  740.       Left            =   2460
  741.       Top             =   4170
  742.       Width           =   285
  743.    End
  744.    Begin VB.Shape Shape9 
  745.       BorderColor     =   &H00FFFF00&
  746.       BorderStyle     =   0  'Transparent
  747.       FillColor       =   &H00FFFF00&
  748.       Height          =   3075
  749.       Left            =   2190
  750.       Top             =   1050
  751.       Width           =   225
  752.    End
  753.    Begin VB.Shape Shape8 
  754.       FillColor       =   &H00FFFF00&
  755.       Height          =   435
  756.       Left            =   2190
  757.       Top             =   600
  758.       Width           =   195
  759.    End
  760.    Begin VB.Shape Shape7 
  761.       FillColor       =   &H00FFFF00&
  762.       Height          =   195
  763.       Left            =   1350
  764.       Top             =   420
  765.       Width           =   1035
  766.    End
  767.    Begin VB.Label Label14 
  768.       BeginProperty Font 
  769.          Name            =   "Arial"
  770.          Size            =   12
  771.          Charset         =   0
  772.          Weight          =   700
  773.          Underline       =   0   'False
  774.          Italic          =   0   'False
  775.          Strikethrough   =   0   'False
  776.       EndProperty
  777.       Height          =   285
  778.       Left            =   2370
  779.       TabIndex        =   17
  780.       Top             =   4560
  781.       Width           =   465
  782.    End
  783.    Begin VB.Label Label13 
  784.       BeginProperty Font 
  785.          Name            =   "Arial"
  786.          Size            =   12
  787.          Charset         =   0
  788.          Weight          =   700
  789.          Underline       =   0   'False
  790.          Italic          =   0   'False
  791.          Strikethrough   =   0   'False
  792.       EndProperty
  793.       Height          =   255
  794.       Left            =   750
  795.       TabIndex        =   16
  796.       Top             =   420
  797.       Width           =   465
  798.    End
  799.    Begin VB.Label Label12 
  800.       BeginProperty Font 
  801.          Name            =   "Arial"
  802.          Size            =   12
  803.          Charset         =   0
  804.          Weight          =   700
  805.          Underline       =   0   'False
  806.          Italic          =   0   'False
  807.          Strikethrough   =   0   'False
  808.       EndProperty
  809.       Height          =   225
  810.       Left            =   3810
  811.       TabIndex        =   15
  812.       Top             =   4530
  813.       Width           =   555
  814.    End
  815.    Begin VB.Label Label11 
  816.       Caption         =   "3000 Gal/Min Max."
  817.       ForeColor       =   &H00FF0000&
  818.       Height          =   255
  819.       Left            =   780
  820.       TabIndex        =   14
  821.       Top             =   5130
  822.       Width           =   1425
  823.    End
  824.    Begin VB.Label Label10 
  825.       Caption         =   " Gal/Min Max."
  826.       ForeColor       =   &H00FF0000&
  827.       Height          =   255
  828.       Left            =   480
  829.       TabIndex        =   13
  830.       Top             =   1440
  831.       Width           =   1005
  832.    End
  833.    Begin VB.Label Label9 
  834.       Caption         =   "Actual Level"
  835.       Height          =   405
  836.       Left            =   750
  837.       TabIndex        =   12
  838.       Top             =   2970
  839.       Width           =   525
  840.    End
  841.    Begin VB.Label Label8 
  842.       Caption         =   "Tank"
  843.       Height          =   225
  844.       Left            =   780
  845.       TabIndex        =   10
  846.       Top             =   2400
  847.       Width           =   435
  848.    End
  849.    Begin VB.Label Label7 
  850.       Caption         =   "3100 Gallon"
  851.       Height          =   255
  852.       Left            =   570
  853.       TabIndex        =   9
  854.       Top             =   2190
  855.       Width           =   945
  856.    End
  857.    Begin VB.Label Label6 
  858.       Caption         =   " Gallons"
  859.       Height          =   225
  860.       Left            =   4320
  861.       TabIndex        =   8
  862.       Top             =   4560
  863.       Width           =   645
  864.    End
  865.    Begin VB.Label Label5 
  866.       Caption         =   "Level Setpoint"
  867.       Height          =   225
  868.       Left            =   3630
  869.       TabIndex        =   6
  870.       Top             =   390
  871.       Width           =   1095
  872.    End
  873.    Begin VB.Shape Shape6 
  874.       BorderColor     =   &H000000C0&
  875.       BorderWidth     =   2
  876.       Height          =   3135
  877.       Left            =   3690
  878.       Top             =   1020
  879.       Width           =   195
  880.    End
  881.    Begin VB.Label Label4 
  882.       Caption         =   "Position 0-100%"
  883.       Height          =   225
  884.       Left            =   900
  885.       TabIndex        =   5
  886.       Top             =   4920
  887.       Width           =   1215
  888.    End
  889.    Begin VB.Label Label3 
  890.       Caption         =   "Valve"
  891.       Height          =   255
  892.       Left            =   1680
  893.       TabIndex        =   3
  894.       Top             =   4320
  895.       Width           =   465
  896.    End
  897.    Begin VB.Shape Shape5 
  898.       BorderWidth     =   2
  899.       Height          =   435
  900.       Left            =   2460
  901.       Top             =   5010
  902.       Width           =   315
  903.    End
  904.    Begin VB.Shape Shape4 
  905.       BorderWidth     =   2
  906.       Height          =   255
  907.       Left            =   2460
  908.       Top             =   4140
  909.       Width           =   315
  910.    End
  911.    Begin VB.Line Line8 
  912.       BorderWidth     =   2
  913.       X1              =   2400
  914.       X2              =   2400
  915.       Y1              =   990
  916.       Y2              =   420
  917.    End
  918.    Begin VB.Line Line7 
  919.       BorderWidth     =   2
  920.       X1              =   2190
  921.       X2              =   2190
  922.       Y1              =   630
  923.       Y2              =   1020
  924.    End
  925.    Begin VB.Line Line6 
  926.       BorderWidth     =   2
  927.       X1              =   1350
  928.       X2              =   2190
  929.       Y1              =   630
  930.       Y2              =   630
  931.    End
  932.    Begin VB.Line Line5 
  933.       BorderWidth     =   2
  934.       X1              =   1350
  935.       X2              =   2400
  936.       Y1              =   420
  937.       Y2              =   420
  938.    End
  939.    Begin VB.Shape Shape3 
  940.       BorderColor     =   &H00800000&
  941.       BorderWidth     =   3
  942.       Height          =   615
  943.       Index           =   1
  944.       Left            =   2220
  945.       Top             =   4380
  946.       Width           =   735
  947.    End
  948.    Begin VB.Label Label2 
  949.       Caption         =   "Position 0-100%"
  950.       Height          =   255
  951.       Left            =   210
  952.       TabIndex        =   2
  953.       Top             =   1200
  954.       Width           =   1185
  955.    End
  956.    Begin VB.Label Label1 
  957.       Caption         =   "Manual Valve"
  958.       Height          =   225
  959.       Left            =   1380
  960.       TabIndex        =   0
  961.       Top             =   150
  962.       Width           =   1065
  963.    End
  964.    Begin VB.Shape Shape3 
  965.       BorderColor     =   &H00800000&
  966.       BorderWidth     =   3
  967.       Height          =   615
  968.       Index           =   0
  969.       Left            =   600
  970.       Top             =   240
  971.       Width           =   735
  972.    End
  973.    Begin VB.Shape Shape2 
  974.       BorderWidth     =   2
  975.       FillColor       =   &H00FFFF00&
  976.       FillStyle       =   0  'Solid
  977.       Height          =   255
  978.       Left            =   0
  979.       Top             =   420
  980.       Width           =   585
  981.    End
  982.    Begin VB.Shape Shape1 
  983.       FillColor       =   &H0000FFFF&
  984.       FillStyle       =   0  'Solid
  985.       Height          =   3100
  986.       Index           =   1
  987.       Left            =   3690
  988.       Top             =   1020
  989.       Width           =   165
  990.    End
  991.    Begin VB.Shape Shape1 
  992.       BorderColor     =   &H00C0C000&
  993.       FillColor       =   &H00FFFF00&
  994.       FillStyle       =   0  'Solid
  995.       Height          =   3015
  996.       Index           =   0
  997.       Left            =   1620
  998.       Top             =   1080
  999.       Width           =   1995
  1000.    End
  1001.    Begin VB.Line Line4 
  1002.       BorderWidth     =   4
  1003.       X1              =   3660
  1004.       X2              =   1590
  1005.       Y1              =   4140
  1006.       Y2              =   4140
  1007.    End
  1008.    Begin VB.Line Line3 
  1009.       BorderWidth     =   4
  1010.       X1              =   3660
  1011.       X2              =   3660
  1012.       Y1              =   1050
  1013.       Y2              =   4140
  1014.    End
  1015.    Begin VB.Line Line2 
  1016.       BorderWidth     =   4
  1017.       X1              =   1590
  1018.       X2              =   3660
  1019.       Y1              =   1020
  1020.       Y2              =   1020
  1021.    End
  1022.    Begin VB.Line Line1 
  1023.       BorderWidth     =   4
  1024.       X1              =   1590
  1025.       X2              =   1590
  1026.       Y1              =   1020
  1027.       Y2              =   4140
  1028.    End
  1029.    Begin VB.Menu mnFile 
  1030.       Caption         =   "File"
  1031.       Begin VB.Menu mnExit 
  1032.          Caption         =   "Exit"
  1033.       End
  1034.    End
  1035.    Begin VB.Menu mnInstructions 
  1036.       Caption         =   "Instructions"
  1037.    End
  1038.    Begin VB.Menu mnAbout 
  1039.       Caption         =   "About"
  1040.       Begin VB.Menu mnLine1 
  1041.          Caption         =   "By Max Seim - mlseim@mmm.com"
  1042.       End
  1043.       Begin VB.Menu mnLine2 
  1044.          Caption         =   "Simple PID loop simulator - Version 01.18.02"
  1045.       End
  1046.    End
  1047. Attribute VB_Name = "Form1"
  1048. Attribute VB_GlobalNameSpace = False
  1049. Attribute VB_Creatable = False
  1050. Attribute VB_PredeclaredId = True
  1051. Attribute VB_Exposed = False
  1052. Option Explicit
  1053. '  Simple PID Loop Simulator ... for educational use.
  1054. '  By Max Seim,  mlseim@mmm.com
  1055. '     Systems Control Technician, 3M Company, Cottage Grove, Minnesota
  1056. Dim invalve As Integer
  1057. Dim outvalve As Integer
  1058. Dim mode As Integer '0=manual, 1=auto
  1059. Dim error As Integer
  1060. Dim stability As Integer '0=stable, 1=unstable
  1061. Dim supply As Integer
  1062. Dim x As Integer
  1063. Dim y As Integer
  1064. Dim gain As Long
  1065. Dim reset As Long
  1066. Dim rate As Long
  1067. Dim output As Integer
  1068. Dim pv As Long
  1069. Dim s1 As Integer
  1070. Dim s2 As Integer
  1071. Dim outgraph(100) As Integer
  1072. Dim pvgraph(100) As Integer
  1073. Dim inputd As Long
  1074. Dim inputdf As Long
  1075. Dim inputlast As Long
  1076. Dim feedback As Long
  1077. Dim dfilter As Long
  1078. Dim sp As Long
  1079. Private Sub Command1_Click() ' Go into MANUAL control
  1080. Shape12.FillStyle = 0
  1081. Shape13.FillStyle = 1
  1082. mode = 0
  1083. HScroll2.Enabled = True
  1084. End Sub
  1085. Private Sub Command2_Click() ' Go into AUTO control
  1086. Shape12.FillStyle = 1
  1087. Shape13.FillStyle = 0
  1088. mode = 1
  1089. HScroll2.Enabled = False
  1090. End Sub
  1091. Private Sub Command3_Click() ' Toggle the Unstable Water Supply
  1092. If stability = 0 Then
  1093.    Shape19.FillStyle = 0
  1094.    stability = 1
  1095.    Exit Sub
  1096. End If
  1097. If stability = 1 Then
  1098.    Shape19.FillStyle = 1
  1099.    stability = 0
  1100.    supply = 2000
  1101. End If
  1102. Label38.Caption = supply
  1103. End Sub
  1104. Private Sub Form_load()
  1105. ' center the form
  1106. Form1.Left = (Screen.Width / 2) - (Form1.Width / 2)
  1107. Form1.Top = (Screen.Height / 2) - (Form1.Height / 2)
  1108. ' Initialize the Sliders and other variables
  1109. VScroll1.Value = 0
  1110. Shape1(1).Top = (3100 - VScroll1.Value) + 1040
  1111. Shape1(1).Height = VScroll1.Value
  1112. Shape1(0).Top = (3100 - pv) + 1030
  1113. Shape1(0).Height = pv
  1114. Label12.Caption = VScroll1.Value
  1115. supply = 2000
  1116. Label38.Caption = supply
  1117. HScroll1.Value = 100
  1118. Label13.Caption = HScroll1.Value
  1119. invalve = (HScroll1.Value * (supply / 100)) / 60
  1120. outvalve = 0
  1121. Label14.Caption = 0
  1122. Text1.Text = pv
  1123.    Shape12.FillStyle = 1
  1124.    Shape13.FillStyle = 0
  1125.    mode = 1
  1126.    HScroll2.Enabled = False
  1127. gain = Text2.Text
  1128. reset = Text3.Text
  1129. rate = Text4.Text
  1130. VScroll1.Value = 1500
  1131. Shape1(1).Top = (3100 - VScroll1.Value) + 1040
  1132. Shape1(1).Height = VScroll1.Value
  1133. Label12.Caption = VScroll1.Value
  1134. sp = VScroll1.Value
  1135. Picture1.Cls
  1136. Picture1.ScaleMode = 3
  1137. Picture1.ScaleHeight = 3105
  1138. Picture1.ScaleWidth = 100
  1139. Picture1.AutoRedraw = True
  1140. Picture1.ForeColor = vbCyan
  1141. Picture1.DrawStyle = 0
  1142. Picture1.DrawWidth = 2
  1143. Picture2.Cls
  1144. Picture2.ScaleMode = 3
  1145. Picture2.ScaleHeight = 105
  1146. Picture2.ScaleWidth = 100
  1147. Picture2.AutoRedraw = True
  1148. Picture2.ForeColor = vbRed
  1149. Picture2.DrawStyle = 0
  1150. Picture2.DrawWidth = 2
  1151. End Sub
  1152. Private Sub HScroll1_Change() ' Slider control for INLET VALVE POSITION
  1153. Label13.Caption = HScroll1.Value
  1154. invalve = (HScroll1.Value * (supply / 100)) / 60
  1155. End Sub
  1156. Private Sub HScroll2_Change() ' Slider control for OUTLET VALVE POSITION
  1157. Label14.Caption = HScroll2.Value
  1158. outvalve = (HScroll2.Value * 30) / 60
  1159. End Sub
  1160. Private Sub mnExit_Click() ' Exit program
  1161. Erase outgraph
  1162. Erase pvgraph
  1163. Unload Me
  1164. End Sub
  1165. Private Sub mnInstructions_Click() ' Show instruction form
  1166. instructions.Show
  1167. End Sub
  1168. Private Sub Timer1_Timer()
  1169. On Error Resume Next
  1170.    If Text2 < 0 Then
  1171.    Text2 = 0
  1172.    End If
  1173.       If Text2 > 100 Then
  1174.       Text2 = 100
  1175.       End If
  1176. gain = Val(Text2)
  1177.    If Text3 < 0 Then
  1178.    Text3 = 0
  1179.    End If
  1180.       If Text3 > 120 Then
  1181.       Text3 = 120
  1182.       End If
  1183. reset = Val(Text3)
  1184.    If Text4 < 0 Then
  1185.    Text4 = 0
  1186.    End If
  1187.       If Text4 > 120 Then
  1188.       Text4 = 120
  1189.       End If
  1190. rate = Val(Text4)
  1191.   If pv < 3101 Then
  1192.      pv = pv + invalve
  1193.   End If
  1194.      If pv > 0 Then
  1195.        pv = pv - outvalve
  1196.      End If
  1197. Text1.Text = pv
  1198. error = sp - pv
  1199. Label30.Caption = error
  1200. Label38.Caption = supply
  1201. If stability = 1 Then
  1202. watersupply
  1203.    invalve = (HScroll1.Value * (supply / 100)) / 60
  1204. End If
  1205.   If mode = 1 Then
  1206.      pidloop
  1207.   End If
  1208. ' Graph the PV, Process Variable
  1209. Picture1.Cls
  1210. pvgraph(100) = pv
  1211. For x = 0 To 99
  1212. pvgraph(x) = pvgraph(x + 1)
  1213.   Picture1.PSet (x, 3000 - (pvgraph(x)))
  1214. Next x
  1215. ' Display the SP line (yellow)
  1216. Picture1.Line (0, 3000 - sp)-(100, 3000 - sp), vbYellow
  1217. ' Graph the OUTPUT VALVE position
  1218. Picture2.Cls
  1219. outgraph(100) = outvalve
  1220. For x = 0 To 99
  1221. outgraph(x) = outgraph(x + 1)
  1222.   Picture2.PSet (x, 100 - (outgraph(x) * 2))
  1223. Next x
  1224. End Sub
  1225. Private Sub VScroll1_Change() ' Slider control for SP (setpoint)
  1226. Shape1(1).Top = (3100 - VScroll1.Value) + 1040
  1227. Shape1(1).Height = VScroll1.Value
  1228. Label12.Caption = VScroll1.Value
  1229. sp = VScroll1.Value
  1230. End Sub
  1231. Private Sub tank() ' Draw the water tank animation
  1232. If HScroll1.Value > 0 Then
  1233.    Shape7.FillStyle = 0
  1234.    Shape8.FillStyle = 0
  1235.    Shape9.FillStyle = 0
  1236.   Else: Shape7.FillStyle = 1
  1237.         Shape8.FillStyle = 1
  1238.         Shape9.FillStyle = 1
  1239. End If
  1240. If pv > -1 Then
  1241.    Shape1(0).Top = (3100 - pv) + 1030
  1242.    Shape1(0).Height = pv
  1243. End If
  1244.   If (pv > 0) Or (HScroll1.Value > 0) Then
  1245.   Shape10.FillStyle = 0
  1246.     Else: Shape10.FillStyle = 1
  1247.   End If
  1248.      If (HScroll2.Value > 0) And (pv > 0) Then
  1249.      Shape11.FillStyle = 0
  1250.        Else: Shape11.FillStyle = 1
  1251.      End If
  1252. End Sub
  1253. Private Sub watersupply() ' Create an unstable water supply
  1254.   Randomize
  1255.   s1 = Int(Rnd(1) * 20 + 1)
  1256.      Randomize
  1257.      s2 = Int(Rnd(1) * 1000 + 1)
  1258. If s2 < 100 Then
  1259.   supply = supply + s1
  1260. End If
  1261. If s2 > 900 Then
  1262.   supply = supply - s1
  1263. End If
  1264.    If supply < 500 Then
  1265.    supply = 500
  1266.    End If
  1267.       If supply > 2500 Then
  1268.       supply = 2500
  1269.       End If
  1270.       
  1271. End Sub
  1272. Private Sub pidloop()
  1273. dfilter = 10 ' Filter value to scale down derivative effect.
  1274. inputd = pv + (inputlast - pv) * (rate / 60)
  1275. inputlast = pv
  1276. inputdf = inputdf + (inputd - inputdf) * dfilter / 60
  1277. output = (sp - inputdf) * (gain / 100) + feedback
  1278. If output > 100 Then ' clamp output valve between 0 and 100%
  1279.   output = 100
  1280. End If
  1281. If output < 0 Then
  1282.   output = 0
  1283. End If
  1284. HScroll2.Value = 100 - output ' Change slider value (AUTO MODE)
  1285. Label14.Caption = HScroll2.Value
  1286. feedback = feedback - (feedback - output) * reset / 60
  1287. End Sub
  1288.