Más contenido relacionado
Mota central
- 1. MOTA CENTRAL<br />VarRx VAR BYTE' <br />varest var byte<br />ORA VAR BYTE<br />trisd=0<br /> <br />inicio0:<br />serin2 portc.7,813,50,no_data,[wait(quot;
estadoquot;
),dec1 varest]<br />pause 10<br />goto casos<br />inicio02:<br />serin2 portc.7,813,50,no_data2,[wait(quot;
estadoquot;
),dec2 varest]<br />pause 10<br />goto casos<br />casos:<br />select case varest<br />case 0<br />call pedir_dato<br />case 1<br />call pedir_dato<br />case 2<br />call pedir_dato<br />case 3<br />call pedir_dato<br />case 4<br />call pedir_dato<br />case 5<br />call pedir_dato2<br />case 6<br />call pedir_dato2<br />case 7<br />call pedir_dato2<br />case 8<br />call pedir_dato2<br />case 9<br />call pedir_dato2<br />case 10<br />call pedir_dato3<br />case 11<br />call pedir_dato3<br />case 12<br />call pedir_dato3<br />case 13<br />call pedir_dato3<br />case 14<br />call pedir_dato3<br />case 15<br />sleep 2<br />varest=0<br />goto casos<br />case else<br />goto inicio0<br />end select<br />pedir_dato:<br />serout2 portb.2,17197,[quot;
A_mandame_datoquot;
,dec3 varest]<br />goto inicio<br />pedir_dato2:<br />serout2 portb.2,17197,[quot;
B_mandame_datoquot;
,dec3 varest]<br />goto inicio2<br />pedir_dato3:<br />serout2 portb.2,17197,[quot;
C_mandame_datoquot;
,dec3 varest]<br />goto inicio3<br />Inicio:<br />SerIn2 PORTb.1, 17197,50,pedir_dato,[wait (quot;
#OKquot;
),dec3 VarRx]<br />Pause 1000<br />SerOut2 PORTc.6, 813,[DEC3 varrx,10,13]<br />GoTo Inicio0'<br />Inicio2:<br />SerIn2 PORTb.3, 17197,50,pedir_dato2,[wait (quot;
#OKquot;
),dec3 VarRx]<br />Pause 1000<br />SerOut2 PORTc.6, 813,[DEC3 varrx,10,13]<br />if varest=9 then goto inicio02<br />GoTo Inicio0' <br />Inicio3:<br />SerIn2 PORTb.4, 17197,50,pedir_dato3,[wait (quot;
#OKquot;
),dec3 VarRx]<br />Pause 1000<br />SerOut2 PORTc.6, 813,[DEC3 varrx,10,13]<br />if varest=14 then goto inicio0<br />GoTo Inicio02<br />no_data:<br />goto inicio0<br />no_data2:<br />goto inicio02<br />MOTA 1<br />define osc 4<br />define adc_bits 8<br />define adc_sampleus 50<br />trisb=0<br />adcon1=%00000000<br />VarTx VAR BYTE' Variable a transmitir<br />varest var byte<br />inicio0:<br />serin2 portc.7,17197,no_dato,[wait(quot;
A_mandame_datoquot;
),dec3 varest]<br />goto casos<br />casos:<br /> select case varest<br /> case 0<br /> portb=0<br /> goto inicio<br /> case 1<br /> portb=1<br /> goto inicio<br /> case 2<br /> portb=2<br /> goto inicio<br /> case 3<br /> portb=3<br /> goto inicio<br /> case 4<br /> portb=4<br /> goto inicio<br /> 'case 5<br /> 'portb=5<br /> 'pause 1000<br /> 'sleep 10<br /> 'varest=0<br /> 'goto casos<br /> case else <br /> goto inicio0<br /> end select<br /> <br />Inicio:<br />adcin 0,vartx<br />vartx=vartx*100/255<br />'PotPORTA.0, 255, VarTx' Leer la resistencia variable<br />' Transmitir los datos quot;
#OKquot;
y la variable VarTxa una velocidad de<br />' 1.200bps en modo invertido por la puerta A2<br />Pause 1000' Pausa de 10 milisegundos<br />SerOut2 PORTc.6, 17197, [quot;
#OKquot;
,dec3 VarTx]<br />if varest=4 then goto dormir<br />GoTo Inicio0' Volver a Inicio<br />no_dato:<br />goto inicio0<br />dormir:<br />sleep 30<br />goto inicio0<br />MOTA 2<br />define osc 4<br />define adc_bits 8<br />define adc_sampleus 50<br />trisb=0<br />adcon1=%00000000<br />VarTx VAR BYTE' Variable a transmitir<br />varest var byte<br />inicio0:<br />serin2 portc.7,17197,no_dato,[wait(quot;
B_mandame_datoquot;
),dec3 varest]<br />goto casos<br />casos:<br /> select case varest<br /> case 5<br /> portb=0<br /> goto inicio<br /> case 6<br /> portb=1<br /> goto inicio<br /> case 7<br /> portb=2<br /> goto inicio<br /> case 8<br /> portb=3<br /> goto inicio<br /> case 9<br /> portb=4<br /> goto inicio<br /> 'case 5<br /> 'portb=5<br /> 'pause 1000<br /> 'sleep 10<br /> 'varest=0<br /> 'goto casos<br /> case else <br /> goto inicio0<br /> end select<br /> <br />Inicio:<br />adcin 0,vartx<br />vartx=vartx*100/255<br />'PotPORTA.0, 255, VarTx' Leer la resistencia variable<br />' Transmitir los datos quot;
#OKquot;
y la variable VarTxa una velocidad de<br />' 1.200bps en modo invertido por la puerta A2<br />Pause 1000' Pausa de 10 milisegundos<br />SerOut2 PORTc.6, 17197, [quot;
#OKquot;
,dec3 VarTx]<br />if varest=9 then goto dormir<br />GoTo Inicio0' Volver a Inicio<br />no_dato:<br />goto inicio0<br />dormir:<br />sleep 30<br />goto inicio0<br />MOTA 3<br />define osc 4<br />define adc_bits 8<br />define adc_sampleus 50<br />trisb=0<br />adcon1=%00000000<br />VarTx VAR BYTE' Variable a transmitir<br />varest var byte<br />inicio0:<br />serin2 portc.7,17197,no_dato,[wait(quot;
C_mandame_datoquot;
),dec3 varest]<br />goto casos<br />casos:<br /> select case varest<br /> case 10<br /> portb=0<br /> goto inicio<br /> case 11<br /> portb=1<br /> goto inicio<br /> case 12<br /> portb=2<br /> goto inicio<br /> case 13<br /> portb=3<br /> goto inicio<br /> case 14<br /> portb=4<br /> goto inicio<br /> 'case 5<br /> 'portb=5<br /> 'pause 1000<br /> 'sleep 10<br /> 'varest=0<br /> 'goto casos<br /> case else <br /> goto inicio0<br /> end select<br /> <br />Inicio:<br />adcin 0,vartx<br />vartx=vartx*100/255<br />'PotPORTA.0, 255, VarTx' Leer la resistencia variable<br />' Transmitir los datos quot;
#OKquot;
y la variable VarTxa una velocidad de<br />' 1.200bps en modo invertido por la puerta A2<br />Pause 1000' Pausa de 10 milisegundos<br />SerOut2 PORTc.6, 17197, [quot;
#OKquot;
,dec3 VarTx]<br />if varest=14 then goto dormir<br />GoTo Inicio0' Volver a Inicio<br />no_dato:<br />goto inicio0<br />dormir:<br />sleep 30<br />goto inicio0<br />PROGRAMA EN VISUAL BASIC –EXCEL<br />Private Sub CommandButton1_Click()<br />'Dim ora As String<br />If MSComm1.PortOpen = False Then<br />MSComm1.PortOpen = True<br />End If<br />'CommandButton1.Enabled = False<br />End Sub<br />Private Sub CommandButton2_Click()<br />MSComm1.Output = quot;
estadoquot;
& Val(text_estado.Text)<br />End Sub<br />Private Sub MSComm1_OnComm()<br />Dim i, j As Byte<br />Dim dat, hoja, ora As String<br />dat = MSComm1.Input<br />For i = 1 To 100<br />Hoja1.Cells(i, 2) = Hoja1.Cells(i + 1, 2)<br />Hoja1.Cells(i, 1) = Hoja1.Cells(i + 1, 1)<br />Next<br />Hoja1.Cells(100, 2) = Mid(dat, 1, 3)<br />Hoja1.Cells(100, 1) = Hoja1.Cells(100, 3)<br />ScrollBar1.Value = ScrollBar1.Value + 1<br />text_estado.Text = ScrollBar1.Value<br />MSComm1.Output = quot;
estadoquot;
& Val(text_estado.Text)<br />If Val(text_estado.Text) = 15 Then<br />ScrollBar1.Value = 0<br />End If<br />End Sub<br />Private Sub ScrollBar1_Change()<br />text_estado.Text = ScrollBar1.Value<br />End Sub<br />