About Visual Basic6 and RS232 ASCII communication

cyw1984

Sep 7, 2005
63
Joined
Sep 7, 2005
Messages
63
About Visual Basic6 and RS232 ASCII communication
zcQ40539.png


If I want to send the value (ASCII) to 8051 series port

VB block input:
0.01
0.02
0.03
0.04
0.05
0.06
0.07
0.08
0.09
0.1
0.11
0.12
0.13
0.14
0.15
0.16
0.17
0.18
.
.
.
.
.
.
.
29.93
29.94
29.95
29.96
29.97
29.98
29.99
30.00

RS232 transmit :

0000
0001
0002
0003
0004
0005
0006
.
.
.
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000


If i want display 0-30 with 0.00 (ACSII).....
How can I write the VB software , It need to write 3000 structure????

 

ECET0purdue

Jan 29, 2005
314
Joined
Jan 29, 2005
Messages
314
u can use an array. i have never used them in VB but i have in lots of other programming tools.

or use a varable. like this

x=.00
do(
      x=x+.01
MSComm1.Output = Chr(x)
)
while(x<3000)

%this will display it all... is that what you wanted? if you need the other part in it too do this.

t=1
x=.00
do(
      x=x+.01    %this will keep adding .01 to x
      t=t++        % this will keep adding 1 to t
Private Sub Command(t)_Click()      %this will sub t for what # it's at
MSComm1.Output = Chr(x)    %this will sub x for what ever # it's at.
End Sub
)
while(x<3000)          % it keeps doing this till x reaches 3000 or what ever
                                  % what ever number you put in here.

like i said i never programmed in VB but this is how i would guess to do it... and this ishow i would do it in all other programming i have done..
cheers,
glen

 

EdwardM

Apr 12, 2005
246
Joined
Apr 12, 2005
Messages
246
Hi cyw1984

first thoughts:

I presume you don't want to send all 3000 at once to the 8051 but just a current value?

You could do something like...

Public Sub Send5Chars(Value as string)
'The 5 characters have been previously made into a string which looks like "nnnn"

MSComm1.Output = Left(Value,1)
MSComm1.Output = Left(Value,2)
MSComm1.Output = "."
MSComm1.Output = Left(Value,3)
MSComm1.Output = Left(Value,4)
End Sub

...and would be invoked like this:

Send5Chars "0123"

Does that help?

Best of Luck

Ed

 

ECET0purdue

Jan 29, 2005
314
Joined
Jan 29, 2005
Messages
314
o ya add this .


int x;  to the top of mine and it should work?

and make sure
x=.00
do(
      x=x+.01
MSComm1.Output = Chr(x)
)
while(x<3000)
is between the privent sub  click() part and the  end sub part..

 
Top