![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
chingB
Joined: 29 Dec 2003 Posts: 81
|
PICmicro Serial Com with VB - Inquiry and Help |
Posted: Sun Jan 23, 2005 7:07 am |
|
|
Hi,
I have a setup with a VB program that can sends command to my PICmicro!
My problem:
When I send a command to my PIC then it reply by sending 16byte character... when I debug my VB code I found out that the last three(4) character were not received.
With this I made an experiment... that my PIC will only send 8byte character once a command is receive and I found-out that it receive the 8byte character?
Does anybody in the community who can help me with this problem? Do I miss something especially the MSComm Object setup in VB. Is there an alternative Com object that is freeware which is better than the built-in MSComm object.
BTW, my setting is 115200, 8, N, 1
Thanx |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
Re: PICmicro Serial Com with VB - Inquiry and Help |
Posted: Sun Jan 23, 2005 8:23 am |
|
|
chingB wrote: | Hi,
I have a setup with a VB program that can sends command to my PICmicro!
My problem:
When I send a command to my PIC then it reply by sending 16byte character... when I debug my VB code I found out that the last three(4) character were not received.
With this I made an experiment... that my PIC will only send 8byte character once a command is receive and I found-out that it receive the 8byte character?
Does anybody in the community who can help me with this problem? Do I miss something especially the MSComm Object setup in VB. Is there an alternative Com object that is freeware which is better than the built-in MSComm object.
BTW, my setting is 115200, 8, N, 1
Thanx |
MSCOMM, can a a bit of a pain. However given the loss of just the 'last' characters (I hope you mean that you send '16 characters', and '8 characters', an '8 byte character', would be sending 64bits at once...), it is possible that you are just running into the 'sleep' problem.
This is a commonly hit one on the PIC, where you must realise, that code like:
printf("Some text");
If using the hardware UART, will return to the caller, with three bytes still to send (this is because of the hardware buffering in the UART chip), and the code must ensure that the processor remains running to send these. If the instruction is placed at the end of 'main', because there is a hidden 'sleep' here, the processor will execute this, and not send the last three characters.
MSCOMM, lacks any ability to control the comm timeouts, and for some applications, this can be necessary, but generally for all it's problems, I'd suspect the fault is elsewhere.
Are you sure your crystal gives reasonable baud rate timings at 115200?. Unless you are using a crystal that is a nice even multiple of this rate, the bit rate error may be unacceptably high, and cause problems.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sun Jan 23, 2005 9:44 am |
|
|
Post a small test program (PIC) the demonstrates the problem. |
|
![](templates/subSilver/images/spacer.gif) |
seegoon
Joined: 19 Jan 2005 Posts: 8
|
Re: PICmicro Serial Com with VB - Inquiry and Help |
Posted: Tue Jan 25, 2005 1:15 am |
|
|
Hi there. I had a similar problem before. I was a buffer overflow problem in the PIC.
Check that you have the ,errors option in the use rs232(....) . This solved my problem. You can also manually check for errors and then clear.
Cheers
rob |
|
![](templates/subSilver/images/spacer.gif) |
Bill Boucher
Joined: 04 Feb 2005 Posts: 34 Location: Chatham,ON,CA
|
|
Posted: Fri Feb 04, 2005 3:17 pm |
|
|
In VB's mscomm, you can make sure there's no character in the "parity replace" property and set "NullDiscard" to none. Also, turn the handshaking off, set DTR & RTS & EOF to false.
From the PIC, you might want to try using only "putch" to send bytes instead of printf. Several other's on this forum had mentioned that although I can't say from experience myself if that matters.
Also, in VB, try using mscomm's "binary" mode. I find it works a lot smoother although you have to mess with arrays because you can't tx/rx strings. In "binary" mode, you can send any byte value from 0 to 255 as in text mode but there seems to be far fewer errors than in text mode. |
|
![](templates/subSilver/images/spacer.gif) |
jma_1
Joined: 08 Feb 2005 Posts: 147 Location: Wisconsin
|
another pc com solution |
Posted: Tue Feb 08, 2005 2:41 pm |
|
|
Greetings,
There are other alternatives to VB that are relatively straight forward to use. My choices would be java (javax.comm package) or labview / labwindows. Labview / Labwindows can be downloaded from National Instruments (trial version). Labwindows might be a better choice -> directly create an executable. The java package is available directly from Sun and is free to use. If you want a java example, try the 'SimpleWrite' or 'SimpleRead' that comes with the javax.comm package. Both Windows & Linux version of the javax.comm package are available. |
|
![](templates/subSilver/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|