CONTROLLO DI LIVELLO CON SENSORE DI POSIZIONE

 

E’ costituito da una pompa che manda acqua ad un serbatoio in cui č posizionato un sensore di posizione che ha una uscita in tensione legata alla distanza fra il sensore ed il galleggiante nel serbatoio. Fissato con un potenziometro il livello di acqua che deve essere raggiunto la pompa varia la propria tensione al 75% a distanza inferiore a 3 cm e poi al 50% a 2 cm fino a fermarsi al raggiungimento del livello di setpoint.

 

 

 

Il sistema:la pompa ed il sensore di posizione, il serbatoio e il galleggiante(disco in compensato).

 

 

 

 

Il sensore

 

 

 

Legge del sensore

valore letto

tensione

 

dal micro

 

 

N

V

Distanza

200

0,98

15,6

250

1,22

12,2

300

1,47

10,0

350

1,71

8,3

400

1,96

7,1

450

2,20

6,2

500

2,44

5,4

550

2,69

4,8

600

2,93

4,3

 

 

 

Grafico

La pompa

 

 

 

 

 

L’uscita sul monitor del cubloc

 

 

 

 

 

 

 

L’uscita sul PC

 

 

 

L’uscita sul PC

 

 

Il listato del programma

 

 

Const Device = CB280

Dim sp1 As String

Dim n As Integer

Dim bandap As Single

Dim setpoint As Single

Dim liv As Single

Dim nn As Integer

Dim a As Single

Dim b As Single

Dim c As Single

Dim r As Single

Dim start As Integer

Dim push As Integer

Dim old As Single

Dim q As Single

Low 5

Set Debug Off

Set Debug Off

Debug clr

setpoint=15

bandap=2

start=0

Pwmoff 0

old=0

Do

nn=Adin(3)

a=26

a=a/10000

b=268

b=b/1000000

b=b*nn

c=193

c=c/1000000

c=c/1000

c=c*nn*nn

r=a+b+c

r=1/r

c=5

c=c/10

liv=23-r

If old=0 Then old=liv

q=0

If old<>0 Then

q=(liv-old)

q=q*471

q=q/1000

old=liv

End If

sp1="altezza="

scrivi 3,sp1,liv,2

nn=Adin(4)

sp1="setpoint="

a=18

b=nn*137

b=b/10000

r=a-b

setpoint=r

scrivi 4,sp1,r,2

n=1000

If setpoint-liv>4 Then n=1000

If setpoint-liv<3 Then n=750

If setpoint-liv<2 Then n=500

If setpoint-liv<0 Then n=0

sp1="scostamento="

r=setpoint-liv

scrivi 6,sp1,r,2

sp1="PWM="

scrivi 7,sp1,n,1

push=In(0)

If push=1 Then start=1

If start=1 Then Pwm 0,n,1000

If n=0 Then start=0

 

sp1="portata l/min="

scrivi 8,sp1,q,2

sp1="Erogazione  on "

If start=1 Then

scrivist 9,sp1

End If

If start=0 Then

sp1="Erogazione off"

scrivist 9,sp1

End If

'Delay 1000

seriale

Loop

Sub scrivi(riga As Integer,s As String,num As Single,decim As Integer)

                Debug Goxy,1,riga

        Debug s

        Debug Fp(num,8,decim)

        Debug Goxy,1,riga

        End Sub

        Sub scrivist(riga As Integer,s As String)

                Debug Goxy,1,riga

        Debug s

                End Sub

                Sub seriale()

Dim i As Byte

Dim st As String

Bclr 0,1

Opencom 0,9600,18,9,54

Bclr 1,2

For i=1 To 9

If i=8 Then r=88888

If i=9 Then r=99999

If i=7 Then r=88888

If i=6 Then r=99999

If i=5 Then r=88888

If i=4 Then r=n*10

If i=3 Then r=setpoint*100

If i=2 Then r=liv*100

If i=1 Then r=start*100

st=Fp(r,5,0)

Putstr 0,st

Next

Delay 300

End Sub