EROGATORE AUTOMATICO

 

L’applicazione  è basata sulla simulazione del riempimento di un contenitore di liquido. Su una  base circolare viene appoggiato un bicchiere con un fondo opaco. La base poggia su 3 miscroswitch disposti elettricamente in serie e geometricamente a 120° che scattano al raggiungimento di circa 300 grammi complessivi di peso del bicchiere.

Premendo il pulsante di START la pompa situata in un serbatoio adiacente manda acqua fino al riempimento, attraverso una tubazione, al bicchiere se:

 

BASE

 

Lo schema

 

 

 

La base dell’erogatore

 

 

 

COLLEGAMENTI

Dalla base dell’erogatore escono 3 coppie di fili corrispondenti a:

 

  1. pulsante di start
  2. fotocellula
  3. microswitch

 

questi vanno collegati ai morsetti della apparecchiatura 2 con il CUBLOC 220

Questi ingressi su questa scheda sono già collegati a :

 

La pompa viene comandata da una scheda a relay.

 

 

 

 

 

 

 

La pompa

 

Collegamento POMPA

 

 

GND e +12 VDC possono essere prelevati sulla scheda

In alternativa può essere utilizzata una pompa 12 VDC,come in figura:

 

 

In tal caso:

 

 

Nel programma variare :

If start=1 Then Out 15,1

If start=0 Then Out 15,0

Con

If start=1 Then Out 19,1

If start=0 Then Out 19,0

 

Accertarsi che U1 sia collegata a P19

 

 

 

IL PROGRAMMA SU CUBLOC

VERSIONE 1

Questo programma  visualizza sul monitor i testi direttamente dal microcontrollore

 

Const Device = CB220

Dim a As Byte

Dim b As Byte

Dim c As Byte

Dim d As Integer

Dim start As Integer

Dim st As String

Debug clr

Debug "programma erogatore"

Do

Delay 1000

b=In(10)

a=In(11)

d=Adin(1)

If b=1 Then st="pulsante start =ON "

If b=0 Then st="pulsante start =OFF"

scrivist 2,st

If a=1 Then st="peso           =ON "

If a=0 Then st="peso           =OFF"

scrivist 3,st

st="fotocellula="

scrivi 5,st,d,0

If b=1 Then start=1

If a=1 Then start=0

If d>50 Then start=0

If start=1 Then Out 15,1

If start=0 Then Out 15,0

If start=1 Then st="pompa  ON "

If start=0 Then st="pompa  OFF"

scrivist 7,st

Loop

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

                Debug Goxy,1,riga

        Debug s

        Debug Fp(num,10,decim)

        Debug Goxy,1,riga

        End Sub

        Sub scrivist(riga As Integer,s As String)

                Debug Goxy,1,riga

        Debug s

                End Sub

 

VERSIONE 2

Questa versione invia i dati al PC tramite porta seriale(COM1, che deve essere collegata)

 

Const Device = CB220

'collaudo seconda scheda

Dim a As Byte

Dim b As Byte

Dim c As Byte

Dim d As Integer

Dim start As Integer

Dim st As String

Dim i As Integer

Dim r As Single

Dim liv As Byte

Set Debug Off

Debug clr

Debug "programma erogatore"

Do

b=In(10)

a=In(11)

liv=In(12)

d=Adin(1)

If b=1 Then st="pulsante start =ON "

If b=0 Then st="pulsante start =OFF"

scrivist 2,st

If a=1 Then st="peso           =ON "

If a=0 Then st="peso           =OFF"

scrivist 3,st

st="fotocellula="

scrivi 5,st,d,0

If b=1 Then start=1

If a=1 Then start=0

If d>50 Then start=0

If start=1 Then Out 15,1

If start=0 Then Out 15,0

If start=1 Then st="pompa  ON "

If start=0 Then st="pompa  OFF"

scrivist 7,st

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,10,decim)

        Debug Goxy,1,riga

        End Sub

        Sub scrivist(riga As Integer,s As String)

                Debug Goxy,1,riga

        Debug s

                End Sub

                'provaseriale

Sub seriale()

Bclr 0,1

Opencom 0,9600,18,9,54

Bclr 1,2

For i=1 To 9

If i=1 Then r=11111

If i=2 Then r=22222

If i=3 Then r=33333

If i=4 Then r=44444

If i=5 Then r=55555

If i=6 Then r=66666

If i=7 Then r=77777

If i=8 Then r=88888

If i=9 Then r=99999

If i=1 Then r=b

If i=2 Then r=a

If i=3 Then r=d

If i=4 Then r=liv

If i=5 Then r=start

st=Fp(r,5,0)

Putstr 0,st

Next

Delay 300

End Sub

 

 

Con il collegamento con il PC alimentare prima il CUBLOC ed inserire il cavo seriale. Poi lanciare il programma.

 

 

 

 

Il programma che “colloquia” con il microcontrollore