Quote Originally Posted by Joe S.
Hi Skimask,
Actually I do have VB3, 4,5,6 - Aint eBay great communicating with PIC through PC is something I just wanted to try, it works, good. I really need to find out how to communicate commands through the serial port, say toggle an LED on another PIC from serial port, either sent by PC or PIC., and it's late and I am going to bed, even later in SD huh?
Regards
JS

It's about 4am right now. I gotta work at 6am, had to put the snowthrower on tractor tonight, big problems, kinks to work out, stuff got broken over the summer, blah blah blah. At least I got to break out the big tools, hammers, welders, etc.etc.

Anyways, communicating commands from the PC to the PIC....
You use JCP....that is Joe's Communications Protocol (or in my case Jeremy's Communications Protocol.
In my case, I usually use a 4 byte packet:
1st byte : $FF - leader byte, must be an $FF
2nd byte : data byte for function to be used
3rd byte : inverse of the data byte
4th byte : $FF - trailer byte, must be a $FF

For a bit of checking at the receiving end, the 2nd and 3rd byte must add up to $FF, and the 1st and 4th bytes must be $FF. When I'm using wireless, this will differentiate the end of the preamble for the modules (which are $55's) and the start of the packet.

So, I send a packet like:
$FF , $10, $E0, $FF
The receiver saves the last 4 bytes received (which I save by using a sort of shifting buffer, receive a byte, shift the rest over, receive another byte, shift the rest over, and so on).
If the 1st and 4th byte are $FF, the I check if the 2nd and 3rd add up to $FF. If all that is good, I do whatever is in the 2nd byte, and at the same time clear the last 4 bytes received in whatever variables I save them in. For example, in this case, $10 might turn on the LED on portb.0, $11 might turn it off. And so on, and so on.

That's the nice thing about JCP (or whatever you want to call it). Whatever you want, you make. In my case, if my leader and trailer are $FF, it's a one byte control (4 bytes per packet), if the leader/trailer are $FE, it's a 2 byte control packet (6 bytes per packet), and so on. It's always worked for me. The problem with this simple method is when I'm intermixing 4 byte and 6 byte packets in the same system. The fix for that is, just don't do it! Easy enough.
Just come up with a method that's easy for you to remember, that's the big thing. Maybe make the bits or characters in the packet match the pins of the PIC as you go around the PIC itself, something, anything....
JDG