-
October 24th, 2006, 10:50 AM
#1
sending and reciving signals via rs232....
hi
I am new @ forum and vb
I need to do something for school with vb
(it is like a big test at the end of the school jear...)
I need to send and recive signals via rs232 ( com-gate = rs232)
( I need to recive signals with an ic and work with the signal to activate a electric engine and stop it back again...)
does some 1 know a good tutorial so I kan lurn a little bit of vb?
thx, sry for my bad english...
(if here are dutch people pleas add my msn I need you ;P)
p.s.: I got vb 6.0 (never saw it never worked with it...)
-
October 24th, 2006, 10:58 AM
#2
Re: sending and reciving signals via rs232....
Hello and welcome at the forum.
You should search the forum for "MSComm". We had quite a few interesting threads about that just recently, also with examples.
-
October 24th, 2006, 11:15 AM
#3
Re: sending and reciving signals via rs232....
You should use the MSComm control. You can send commands out the serial port . Add an MSComm control to your form and put this code in your form load event. Make sur e you have a the proper DB-9 connection on the back of your CPU. You may need to buy a cable or solder pins 2,3, and 5 yourself on an RS-232 connector from Radio Shack, etc.
Private Sub Form_Load()
With MSComm1
.Commport =1 ' Check out available
' COM ports in Device Manager if this one
'is invalid
.PortOpen = True 'Physically switch your comm
'port on. You will most likely have a male
'DB-9 connection on back of the CPU
.Output = "Your IC Command" 'Send a string in
'the protocol your IC demands
.PortOpen=False 'Make sure to close the port
End With
End Sub
Last edited by machaeroguy; October 24th, 2006 at 11:22 AM.
-
October 24th, 2006, 11:34 AM
#4
Re: sending and reciving signals via rs232....
great forum!!!!
(I love the fast replays ;P)
Serial (RS232) port interface pinout and signals
Transmit Data pin 3
Receive Data pin 2
Signal Ground pin 5
do I need to select for a new project standard exe?
(never programmed anithing only html...)
very thx
-
October 24th, 2006, 11:40 AM
#5
Re: sending and reciving signals via rs232....
I only need to recive 1 signal and if he recived it the pc need to send via com a singnal...
sample:
like the ic sends 0001 to the pc
and the pc send 0010 to the other ic
can you send bits?
or what els do you need to type in output= ?
-
October 24th, 2006, 11:49 AM
#6
Re: sending and reciving signals via rs232....
For a great intro to VB 6.0 in this type of setting, I HIGHLY recommend the book, "Automating Science and Engineering Laboratories with Visual Basic". It will get you up and running with the beginner VB questions and COMPLETLEY explain various ways to communicate with other computers, microcontrollers, etc. Very user friendly. It has been my bible at my factory automation job.
-
October 24th, 2006, 11:50 AM
#7
Re: sending and reciving signals via rs232....
You send characters which are also bit patterns of 8 bit.
To send a pattern you look at it as a hex code and transmit it as a character.
Example:
Want to send 00000001: that's &H01 in VB hex notation
Sending it: MSComm1.Output = chr$(&H01)
BTW if you only have 3 lines you have to set the Handshake property of MSComm control to 0 (none).
I repeat: search the forum for RS232 or MSComm. We had good posts recently, explaining some footfalls and also showing sample code.
-
October 24th, 2006, 12:09 PM
#8
Re: sending and reciving signals via rs232....
Originally Posted by WoF
You send characters which are also bit patterns of 8 bit.
To send a pattern you look at it as a hex code and transmit it as a character.
Example:
Want to send 00000001: that's &H01 in VB hex notation
Sending it: MSComm1.Output = chr$(&H01)
BTW if you only have 3 lines you have to set the Handshake property of MSComm control to 0 (none).
I repeat: search the forum for RS232 or MSComm. We had good posts recently, explaining some footfalls and also showing sample code.
ok I will search thx ;P
MSComm1.Output = chr$(&H01)
I don't get wy you canged &H01 in chr$ I understand that &H01 is hex but what is chr$ then?
and does some 1 know what mhz 9600 bound is?
I don't know what cristal I need to put there...
Last edited by de fre; October 24th, 2006 at 12:17 PM.
-
October 24th, 2006, 12:10 PM
#9
Re: sending and reciving signals via rs232....
Originally Posted by machaeroguy
For a great intro to VB 6.0 in this type of setting, I HIGHLY recommend the book, "Automating Science and Engineering Laboratories with Visual Basic". It will get you up and running with the beginner VB questions and COMPLETLEY explain various ways to communicate with other computers, microcontrollers, etc. Very user friendly. It has been my bible at my factory automation job.
I need to wait for the book ( 1 month probl.) and it costs money
but thx for the advise
-
October 24th, 2006, 01:14 PM
#10
Re: sending and reciving signals via rs232....
1) do I need to select for a new project standard exe?
2) MSComm1.Output = chr$(&H01)(255)
I don't get wy you canged &H01 in chr$ I understand that &H01 is hex but what is chr$ then?
3) and does some 1 know what mhz 9600 bound is?
I don't know what cristal I need to put @ my ic...
thx
-
October 25th, 2006, 06:14 AM
#11
Re: sending and reciving signals via rs232....
where can I find this?
Add an MSCOMM control to the form.
(or do this ;p)
I got this tutorial from this site:
http://support.microsoft.com/default...b;en-us;194922
Private Sub Form_Load()
Form1.Caption = "App1"
With MSCOMM1
.Handshaking = 2 - comRTS
.RThreshold = 1
.RTSEnable = True
.Settings = "9600,n,8,1"
.SThreshold = 1
.PortOpen = True
' Leave all other settings as default values.
End With
Command1.Caption = "&Send"
Text1.Text = "Test string from App1 "
End Sub
Private Sub Command1_Click()
MSComm1.Output = Text1.Text
End Sub
Private Sub Form_Unload(Cancel As Integer)
MSComm1.PortOpen = False
End Sub
when I set teh settings like they said I put this text in
he marks some text in yellow....
SOME 1 HELP PLEAS!!!!!!!!!!!!!!!!!!!!!!!!!!!
Last edited by de fre; October 25th, 2006 at 06:27 AM.
-
October 25th, 2006, 06:30 AM
#12
Re: sending and reciving signals via rs232....
1) Yes, open a standard exe.
To add the MSComm control:
Go to the 'Project' menu,
select 'Components' to get an (enormous) list of additional components. Select and check the entry 'Microsoft Comm Control 6.0'
This gives you the MSComm control in your components toolbar (left side)
Click it and create one in your form.
You have now an MSComm control in your form which allows communication via an RS232 serial port.
Click on the control and view it's properties in the property list (right side)
2) Why the Chr$()? Easy. &H01 is a numeric value. Serial communication is built to send string data. So chr$(NumericValue) gives you a single character string representation of the numeric value. The range is 0 to 255 since a character is only derived from a byte value.
3) 9600 baud is the bitrate with which the bytes are sent over the serial lines. There is no direct relation to the MHz of your IC, I suppose.
Some microcontroller may be equipped with a serial interface, consisting of what is called a UART section. Internally there will be a baud rate generator which must be set somehow by the control program you will write, I guess.
Since there are such a lot of different chips and boards on the market, you should tell us, what type of microcontroller you are using.
-
October 25th, 2006, 06:32 AM
#13
Re: sending and reciving signals via rs232....
Sorry, you edited while I was writing.
Put the MSComm control in first, before you run the code.
Also there must be an error message if some text is marked yellow. You must supply that too to allow us a useful reply.
-
October 25th, 2006, 07:13 AM
#14
Re: sending and reciving signals via rs232....
Originally Posted by WoF
Sorry, you edited while I was writing.
Put the MSComm control in first, before you run the code.
Also there must be an error message if some text is marked yellow. You must supply that too to allow us a useful reply.
how can I set the mscomm conrol?
-
October 25th, 2006, 07:26 AM
#15
Re: sending and reciving signals via rs232....
Read my post.
Well, ok. Here it is again:
To add the MSComm control:
Go to the 'Project' menu,
select 'Components' to get an (enormous) list of additional components. Select and check the entry 'Microsoft Comm Control 6.0'
This gives you the MSComm control in your components toolbar (left side)
Click it and create one in your form.
You have now an MSComm control in your form which allows communication via an RS232 serial port.
Click on the control and view it's properties in the property list (right side)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|