Jump to content
Electronics-Lab.com Community

About Visual Basic6 and RS232 ASCII communication


Recommended Posts

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????

Link to comment
Share on other sites


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



Link to comment
Share on other sites

  • 3 weeks later...

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
  • Create New...