Visual Basic - Ondas de modulación 4-ask

Life is soft - evento anual de software empresarial
 
Vista:
sin imagen de perfil

Ondas de modulación 4-ask

Publicado por Christian (2 intervenciones) el 21/04/2014 22:27:29
Tengo un problema con el Picture1 y es que cuando gráfico las ondas no abarcan todo el Picture1 como tiene que realizarse y cuando coloco cierta cantidad de numeros binarios en el txtData tampoco el Picture se acomoda...Esto es lo que tengo:

Necesito una ayuda urgente gracias


Option Explicit
Dim eje As Integer
Dim h As Integer
Dim ejemen As Integer
Dim pi As Double
Dim x As Single, y As Single, Z As Single
Const Xmin = 0
Const Ymax = 4
Const Ymin = -4
Const xmax = 0
Const Xpaso = 0.0001
Dim OldPx, OldPy As Double 'Para unir las ondas

Private Sub Command1_Click()

If (txtData = "") Then
MsgBox "***| No has ingresado datos,Por favor deja la maricada y madura |***", vbQuestion, "***| Datos binarios no ingresados |***"
End
End If

Dim i, ask, fsk, psk, tiempo As Integer
Dim num(600 * 2) As String
Picture1.Cls
Picture1.ForeColor = vbWhite
Picture1.BackColor = vbBlack
Picture1.Line (10, Picture1.Height / 2)-(Picture1.Width, Picture1.Height / 2), vbRed
'Picture1.Line (10, (Picture1.Height / 2) + 1)-(Picture1.Width, (Picture1.Height / 2) + 1)

'Dibuja los puntos en el picture
For h = 0 To 30
Picture1.PSet (h * 500, Picture1.Height / 9.5)
Picture1.PSet (h * 500, Picture1.Height / 5)
Picture1.PSet (h * 500, Picture1.Width / 10.7)
Picture1.PSet (h * 500, Picture1.Height / 2.5)
Picture1.PSet (h * 500, Picture1.Height / 1.43)
Picture1.PSet (h * 500, Picture1.Height / 1.65)
Picture1.PSet (h * 500, Picture1.Height / 1.25)
Picture1.PSet (h * 500, Picture1.Height / 1.11)
Next h
ask = 1

For i = 1 To Len(txtData) Step 2
num(i - 1) = Mid(txtData, i, 2)
If (Mid(txtData, i, 1) = 0) And (Mid(txtData, i + 1, 1) = 0) Then ask = 1
If (Mid(txtData, i, 1) = 0) And (Mid(txtData, i + 1, 1) = 1) Then ask = 2
If (Mid(txtData, i, 1) = 1) And (Mid(txtData, i + 1, 1) = 0) Then ask = 3
If (Mid(txtData, i, 1) = 1) And (Mid(txtData, i + 1, 1) = 1) Then ask = 4
Picture1.ForeColor = vbYellow

onda ask, fsk, psk, tiempo
tiempo = tiempo + 1
If num(i - 1) = "1" Or num(i - 1) = "0" Then
MsgBox " Faltan numeros para generar el grafico 4Ask ", , "Information"
tiempo = tiempo - 1
End If
Next
End Sub
Function onda(ByVal Amplitud As Integer, ByVal Frecuencia As Integer, ByVal Fase As Integer, tiempo As Integer)
Dim x, i, f, Ini, Ancho As Double
If Fase = 0 Then
Frecuencia = 1
Ancho = 6.3 / Frecuencia
Ini = (Ancho * Fase / 180)
i = (1900 * tiempo)
f = 1
Amplitud = Amplitud * 360
If (tiempo <> 0) Then
Dim save As Variant
save = Picture1.ForeColor
Picture1.ForeColor = vbRed
Picture1.Line (OldPx, OldPy)-(i, -Sin(Ini * Frecuencia) * Amplitud + Picture1.Height / 60), vbWhite 'Dibuja una línea
Picture1.Line (OldPx, OldPy)-(i, -Sin(Ini * Frecuencia) * Amplitud + Picture1.Height / 1), vbWhite 'Dibuja una línea
Picture1.ForeColor = save
End If

While f <= Frecuencia
x = Ini
While x <= (Ini + (6.3 / Frecuencia))
Picture1.PSet (i, -Sin(x * Frecuencia) * Amplitud + Picture1.Height / 2)
x = x + 0.001
i = i + 0.3
Wend
f = f + 1
i = i + 1
Wend
pi = 3.1416
OldPx = i
End If
End Function
Private Sub Command2_Click()
End
End Sub

Private Sub txtData_keypress(KeyAscii As Integer)
If InStr("10", Chr(KeyAscii)) = 0 Then
If KeyAscii <> 8 Then KeyAscii = 0
End If
End Sub

Private Sub form_load()
Picture1.ScaleLeft = Xmin
Picture1.ScaleTop = Ymax
Picture1.ScaleHeight = -(Ymax - Ymin)
End Sub
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder