PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Feb 18, 2007 1:49 pm |
|
|
It could be that the data is different, or it could be the inter-character
spacing that is different. (i.e., the time interval between transmission
of characters).
You need to capture the serial data and compare the characters
that are sent by the PIC or by VB6. You need a terminal program
that can display data in hex. Then you can see the control characters.
Or, to see the PIC's output, you can use sprintf() and then display
the buffer contents. The program below shows how to do this.
Here's the output:
Quote: |
FE 03 31 32 33 34 35 36 FF 00 00 00 00 00 00 00 00 00 00 00
|
Code: |
#include <16F877.H>
#fuses XT, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
//=======================
void main(void)
{
int8 buffer[20];
int8 i;
sprintf(buffer, "%c%c%s%c",254,3,"123456",255);
for(i = 0; i < sizeof(buffer); i++)
printf("%X ", buffer[i]);
while(1);
} |
If you can't get a terminal program that will display the VB6 data in hex,
then you could write a PIC program to read the VB6 output (from Com1)
and then send it to the PC as Ascii Hex bytes (as shown in the program
above).
To test if the problem is caused by inter-character spacing, you could
modify the PIC program to send one character at a time and put a
100 ms delay between each character, as it's sent to the 7-segment
display. (Use 100ms for an initial test). |
|