![]() |
![]() |
![]() |
|
|
|||||||
| Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc. |
|
|
Thread Tools | Display Modes |
|
|
(permalink) |
|
Hey,
I'd like to write a Visual Basic 6 program that can send information to a PIC and receive information from the PIC. We are talkin as simple as possible here... bare minimum.. once I am able to make connection .. the possibilities are endless. I would use the MAX 232 chip.. Dont know exactly how to use the chip though.. Dont know what API Id use with VB6 either.. Any links or code would be very much appreciated. Thanks
__________________
"Stick around" - Arnold Schwarzenegger in The Predator after impaling a soldier to a wood post 9vDC Guitar Pedal PSU PIC16F84a Game Module |
|
|
|
|
|
|
(permalink) |
|
Goto
http://www.winpicprog.co.uk/pic_tutorial7.htm Then use HyperTerminal to check out your PIC project before writing your own 232 routines in VB6. As for VB6, it's not my area of expertise, but I'm sure there are built in routines for acessing the serial ports. Search the help files for COM PORT. A quick Google turned up this: http://www.thaiio.com/prog-cgi/0002_serial.htm
__________________
--- The days of the digital watch are numbered. --- |
|
|
|
|
|
|
(permalink) |
|
You can use MSCOMM ActiveX control for RS232 communications.
Place one MSCOMM control named MSComm1 and two Textboxes named txtTx and txtRx on a form. Paste the following lines in the forms code. txtRX will display all the characters received from serial port and whatever you type in txtTX will be sent to your PIC. Code:
Private Sub Form_Load() With MSComm1 .Settings = "9600,n,8,1" ' Baud=9600, Parity=None, Data-Bits=8, Stop-Bits=1 .CommPort = 1 ' COM1 .PortOpen = True ' Open the port End With End Sub Private Sub Form_Unload() If MSComm1.PortOpen = True then MSComm1.PortOpen = False End Sub Private Sub MSComm1_OnComm() If MSComm1.CommEvent = comEvReceive Then txtRX.Text = txtRX.Text & MSComm1.Input End If End Sub Private Sub txtTX_KeyPress(KeyAscii As Integer) Mscomm1.Output = Chr(KeyAscii) End Sub
__________________
"There is no way to peace, peace is the way!" |
|
|
|
|
|
|
(permalink) |
|
Hey,
So is the MAXIM 232 the best chip to use? How would I hook it up? Ive set up VB6 as you've stated. So If I were to type 'ABC' into the textbox.. Would the PIC recieve: 100 0001 for A 100 0010 for B and 100 0011 for C ?
__________________
"Stick around" - Arnold Schwarzenegger in The Predator after impaling a soldier to a wood post 9vDC Guitar Pedal PSU PIC16F84a Game Module |
|
|
|
|
|
|
(permalink) | |
|
Quote:
http://www.winpicprog.co.uk/pic_tuto...s232_board.htm As the whether it is the best, that is a matter of opinion. The MAX232A uses smaller capacitors but if you have a MAX232 in the junk box, then you can't beat the price.
__________________
--- The days of the digital watch are numbered. --- |
||
|
|
|
|
|
(permalink) |
|
Here's a link to the cap free MAX233 and some additional info
http://www.compsys1.com/workbench/On...3_adapter.html I've also found RealTerm recently, looks like a nice open source terminal and oddly has some I2C and 1wire (iButton) support http://realterm.sourceforge.net/ Last edited by blueroomelectronics; 31st July 2007 at 04:42 AM. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
Assuming you set the VB RS232 comms for say, 9600,n,8,1 [baud rate 9600, no parity, 8 bit data, 1 stop bit] The bit stream for the "A" character would be 1 Start bit 8 data bits ,,,, ASCII "A" is 0x41 == 01000001 1 Stop bit ASCII "B" is 0x41,,, "C" is 0x42 You may, on some strings to a terminal also have to send the code for CRLF [carriage return line, line feed] after the ie: "ABC" 0x0D, 0x0A This depends upon the program in the receiving PC, some programs look for the CRLF in the string as a line terminator. Use the ON COMM event in VB, there are examples in the online help files within the VB program. Use the error trapping routines shown in the help files. The MAX232 has 2 line drivers[transmitters] and 2 line receivers, usually you just use one transmitter on the TXD output from the PIC to PC and one line receiver to the RXD input of the PIC from the PC. Eric |
||
|
|
|
|
|
(permalink) | |
|
Quote:
I forgot to mention, set the Multiline property of txtRx to True.
__________________
"There is no way to peace, peace is the way!" |
||
|
|
|
|
|
(permalink) |
|
if you will also be sending numerical data, remember mscomm sends ascii codes a byte at a time, so you could use chr$(n) where n is a byte of data to send.
this may be obvious, but shift work can make you a bit dense at times! |
|
|
|
|
|
|
(permalink) | |
|
Quote:
__________________
"There is no way to peace, peace is the way!" |
||
|
|
|
|
|
(permalink) |
|
if i want to send 8 then i have to output chr$(8). your code won't do that.
what i meant was sending numeric data from the pc, rather than echoing keypresses. perhaps i should have been more specific. |
|
|
|
|
|
|
(permalink) | |
|
Quote:
__________________
"There is no way to peace, peace is the way!" |
||
|
|
|
|
|
(permalink) |
|
Ok,
So ive got the max 232 set up as Nigels has.. The program like kinjalgp, THANK YOU! So.. Is PIN 9 on the MAX the TX and PIN 10 is the RX? When I type in the TX box pin 10 drops about . 05 V.. so Im assuming that its the TX.. Im going to now try to program a 16f84a.. all i have right now.. so that it will talk to VB.. Can someone explain the purpose of the CAPS on the 232? If this works out I think Im going going to have to automate my entire home Basically, from what i understand.. is when I type a character.. The first bit, which lasts 104us is a 0. This will get the pic into the INT or subroutine.. Then I will capture and place each bit into a variable.. then the stop bit will be a 1.. I would I send.. say an A to VB? Sorry if this post is jumbled Im in a hurry.. Hope someone can answers these questions! Thank you!
__________________
"Stick around" - Arnold Schwarzenegger in The Predator after impaling a soldier to a wood post 9vDC Guitar Pedal PSU PIC16F84a Game Module |
|
|
|
|
|
|
(permalink) | |
|
Quote:
For the pin layout, check the datasheet. The figures can help you better understand the configuration of the receivers and transmitters. |
||
|
|
|
|
|
(permalink) |
|
hmm..
well ive gotten key presses in the TX box to trigger the MICRO.. I cant seem to get the MICRO to send characters to the RX txt box. I think it might be the caps im using for the 232.. I dont have 10uf caps so I exchanged with 4.7uf.. could this be the problem? When I send the byte out the voltage on the TX (RS232) line is changing.. so it is doing something.. VB isnt displaying the characters though.. will keep trouble shooting.
__________________
"Stick around" - Arnold Schwarzenegger in The Predator after impaling a soldier to a wood post 9vDC Guitar Pedal PSU PIC16F84a Game Module |
|
|
|
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Latest |
| Visual Basic for Electronics Engineering Applications | ThermalRunaway | Electronic Books | 22 | 27th August 2008 07:40 PM |
| Serial Communication Interrupt in PIC Basic Pro | TheMaccabee | Robotics Chat | 5 | 12th April 2007 07:52 AM |
| K8055 USB Interface Visual Basic Help | Sudonon | General Electronics Chat | 6 | 11th September 2006 12:24 AM |
| visual basic program for parallel port interface | group_x3m | Micro Controllers | 5 | 26th May 2006 01:48 AM |
| Newcomers, please read! (PIC regarded) Upd. 0xD | Jay.slovak | Micro Controllers | 0 | 17th April 2005 01:04 PM |