Hi to all:
I have here a very strange problem that i can't find the razon to the code procceed in that way...
The code named 'SECTION CODE OF THE PROBLEM START HERE" is a code for moving a motor, and work like desired...
Now if i simple delete this lines of code:
The code named 'SECTION CODE OF THE PROBLEM START HERE" stop work,,,the motor don't move anymore:mad:
Can anyone tell me if encounter something of the code that could make this happen? Sincerelly i don't find nothing!
Below i send the code that contain the problem:
I have here a very strange problem that i can't find the razon to the code procceed in that way...
The code named 'SECTION CODE OF THE PROBLEM START HERE" is a code for moving a motor, and work like desired...
Now if i simple delete this lines of code:
Code:
Select Case trama_entrada_Swichts
Case "01"
Var_button.Value = 1
Case "00"
Var_button.Value = 1
End Select
Can anyone tell me if encounter something of the code that could make this happen? Sincerelly i don't find nothing!
Below i send the code that contain the problem:
Code:
Private Sub SerialPort1_DataReceived(ByVal sender As Object, ByVal e As System.IO.Ports.SerialDataReceivedEventArgs) Handles SerialPort1.DataReceived
Me.Invoke(New EventHandler(AddressOf receber_Tramas))
End Sub
Private Sub receber_Tramas()
Select Case trama_entrada_Swichts
Case "01"
Var_button.Value = 1
Case "00"
Var_button.Value = 1
End Select
'SECTION CODE OF THE PROBLEM START HERE
Dim Ler_trim As Integer = (Read_Trim.Value) / 65536
If Var_On_Ground.Value = 1 Then
Select Case Trama_Trim
Case (calibrar_meio_TRIM - 10) To (calibrar_meio_TRIM + 10)
Read_Trim.Value = 0 '-66
'Valores de 1Up a 13,5Up
Case Is > (calibrar_meio_TRIM + 20)
Read_Trim.Value = (calibrar_meio_TRIM - Trama_Trim) * 13
'Valores de 1Down a 4 Down
Case Is < (calibrar_meio_TRIM - 20)
Read_Trim.Value = (Trama_Trim - calibrar_meio_TRIM) * 13
End Select
End If
If Var_On_Ground.Value = 0 Then
Dim var_exp_Trim As Integer
var_exp_Trim = ((calibrar_meio_TRIM - Trama_Trim) * 11.2)
If var_primeira_vez = 0 Then
var_trim_anterior = Ler_trim
End If
Select Case Ler_trim
Case (var_trim_anterior - 174) To (var_trim_anterior + 174)
If var_primeira_vez = 0 Then
var_Valores_Diferentes_trim = 1 'Se for a 1ªvez a entrar então deixa entrar na rotina mesmo que esteja dentro dos limites
Else
var_Valores_Diferentes_trim = 0 'Se não for a 1ª vez e esteja dentro dos limites então não entra na rotina
End If
Case Else ' Caso os limites sejam acima dos indicados então tem que entrar na rotina para mover as rodas
var_Valores_Diferentes_trim = 1
End Select
If Trama_Trim > calibrar_maximo_TRIM Then
estado_motor = "00"
var_enviar_trama = "0080" & "04" & estado_backlight & estado_leds_sinalizacao & estado_motor
SerialPort1.Write(var_enviar_trama & vbCr)
End If
If Trama_Trim < calibrar_minimo_TRIM Then
estado_motor = "00"
var_enviar_trama = "0080" & "04" & estado_backlight & estado_leds_sinalizacao & estado_motor
SerialPort1.Write(var_enviar_trama & vbCr)
End If
''***************************************************************************************************
If var_Valores_Diferentes_trim = 1 Then
var_primeira_vez = 1
var_trim_anterior = Ler_trim
'Se o valor do trim no FS for positivo e o potenciómetro também FOR positivo então:
If (var_exp_Trim >= 0) And (Ler_trim >= 0) Then
Select Case var_exp_Trim
Case Is < Ler_trim
'MOTOR ANDA PARA O LADO DAS INSCRIÇÕES POSITIVAS, PORQUE O VALOR DO FS É SUPERIOR
'AO VALOR DO POTENCIÓMETRO
estado_motor = "11"
var_enviar_trama = "0080" & "04" & estado_backlight & estado_leds_sinalizacao & estado_motor
SerialPort1.Write(var_enviar_trama & vbCr)
Case Is > Ler_trim
'MOTOR ANDA PARA O LADO DAS INSCRIÇÕES NEGATIVAS, PORQUE O VALOR DO FS É INFERIOR
'AO VALOR DO POTENCIÓMETRO
estado_motor = "FF"
var_enviar_trama = "0080" & "04" & estado_backlight & estado_leds_sinalizacao & estado_motor
SerialPort1.Write(var_enviar_trama & vbCr)
End Select
End If
''************************************************************************************************
If (var_exp_Trim < 0) And (Ler_trim < 0) Then
Select Case var_exp_Trim
Case Is < Ler_trim
estado_motor = "11"
var_enviar_trama = "0080" & "04" & estado_backlight & estado_leds_sinalizacao & estado_motor
SerialPort1.Write(var_enviar_trama & vbCr)
Case Is > Ler_trim
estado_motor = "FF"
var_enviar_trama = "0080" & "04" & estado_backlight & estado_leds_sinalizacao & estado_motor
SerialPort1.Write(var_enviar_trama & vbCr)
End Select
End If
''************************************************************************************************
If (var_exp_Trim < 0) And (Ler_trim >= 0) Then
Select Case var_exp_Trim
Case Is < Ler_trim
estado_motor = "11"
var_enviar_trama = "0080" & "04" & estado_backlight & estado_leds_sinalizacao & estado_motor
SerialPort1.Write(var_enviar_trama & vbCr)
Case Is > Ler_trim
estado_motor = "FF"
var_enviar_trama = "0080" & "04" & estado_backlight & estado_leds_sinalizacao & estado_motor
SerialPort1.Write(var_enviar_trama & vbCr)
End Select
End If
''************************************************************************************************
If (var_exp_Trim >= 0) And (Ler_trim < 0) Then
Select Case var_exp_Trim
Case Is < Ler_trim
estado_motor = "11"
var_enviar_trama = "0080" & "04" & estado_backlight & estado_leds_sinalizacao & estado_motor
SerialPort1.Write(var_enviar_trama & vbCr)
Case Is > Ler_trim
estado_motor = "FF"
var_enviar_trama = "0080" & "04" & estado_backlight & estado_leds_sinalizacao & estado_motor
SerialPort1.Write(var_enviar_trama & vbCr)
End Select
End If
'************************************************************************************************
End If
'************************************************************************************************
'STOP THE MOTOR
If var_Valores_Diferentes_trim = 0 Then
estado_motor = "00"
var_enviar_trama = "0080" & "04" & estado_backlight & estado_leds_sinalizacao & estado_motor
SerialPort1.Write(var_enviar_trama & vbCr)
End If
End If
'************************************************************************************************
'=========================================================================================================
'=========================================================================================================
End Sub