PROGRAM DISPLAY HMI ( ATMEGA 2560)
$regfile = "[Link]"
$crystal = 16000000
$hwstack = 40
$swstack = 16
$framesize = 32
$baud = 9600
$baud1 = 9600
'===============================================================================
Dim In_adc0 As Long , In_adc1 As Long , In_adc2 As Long
'----------------------------------------------------------
Dim In_s1 As String * 25 , Vir_in As Long
Dim In_s2 As Integer
Dim Kv As Long , Ma As Long , Sc As Long
Dim Vir_kv As Long , Vir_ma As Long , Vir_sc As Long
'--------------------------------------------
Config Portd = Output
Config Adc = Single , Prescaler = Auto
'--------------------------------------------
Open "COM1:" For Binary As #1
Open "COM2:" For Binary As #2
'--------------------------------------------
Enable Interrupts
Start Adc
'===============================================================================
main1
Main1:
Do
Vir_in = Ischarwaiting(#2)
If Vir_in = 1 Then
In_s1 = Waitkey(#2)
Print #1 , In_s1
End If
'===============================================================================
'------------------------------------------------------------ Kv +/- -----------
If In_s1 = "K" And Vir_in = 1 Then : Goto Kv_in : End If
If Kv < 40 Then : Kv = 40 : End If
If Kv > 125 Then : Kv = 125 : End If
'-------------------------------------------------------------------------------
'------------------------------------------------------------ mA +/- -----------
If In_s1 = "M" And Vir_in = 1 Then : Goto Ma_in : End If
If Ma < 40 Then : Ma = 40 : End If
If Ma > 200 Then : Ma = 200 : End If
'-------------------------------------------------------------------------------
'------------------------------------------------------------ Sec +/- -----------
If In_s1 = "S" And Vir_in = 1 Then : Goto Sec_in : End If
If Sc < 1 Then : Sc = 1 : End If
If Sc > 200 Then : Sc = 200 : End If
'-------------------------------------------------------------------------------
Print #2 , "[Link]=" ; Sc ; : Printbin #2 , 255 ; 255 ; 255
Print #2 , "[Link]=" ; Ma ; : Printbin #2 , 255 ; 255 ; 255
Print #2 , "[Link]=" ; Kv ; : Printbin #2 , 255 ; 255 ; 255
'Print #1 , "in=" ; In_s1 ; "=" ; Vir_in ; " "
Loop Until Vir_in = 27
Return
'=============================================================================== kv
in
Kv_in:
Do
'-------------------------------------
Vir_in = Ischarwaiting(#2)
If Vir_in = 1 Then
In_s1 = Waitkey(#2)
Print #1 , In_s1
End If
'------------------------------------
If In_s1 = "1" And Vir_in = 1 Then
Decr Kv
Goto Main1
End If
'---------------------------------------
If In_s1 = "2" And Vir_in = 1 Then
Incr Kv
Goto Main1
End If
Loop
Return
'===============================================================================
ma in
Ma_in:
Do
'-------------------------------------
Vir_in = Ischarwaiting(#2)
If Vir_in = 1 Then
In_s1 = Waitkey(#2)
Print #1 , In_s1
End If
'------------------------------------
If In_s1 = "1" And Vir_in = 1 Then
Decr Ma
Goto Main1
End If
'---------------------------------------
If In_s1 = "2" And Vir_in = 1 Then
Incr Ma
Goto Main1
End If
Loop
Return
'===============================================================================
sec in
Sec_in:
Do
'-------------------------------------
Vir_in = Ischarwaiting(#2)
If Vir_in = 1 Then
In_s1 = Waitkey(#2)
Print #1 , In_s1
End If
'------------------------------------
If In_s1 = "1" And Vir_in = 1 Then
Decr Sc
Goto Main1
End If
'---------------------------------------
If In_s1 = "2" And Vir_in = 1 Then
Incr Sc
Goto Main1
End If
Loop
Return