Thanks Henrik,
that is the way!
JS
Joe,
Do you have VB5 or any sort of programming language for the PC? If not, I could probably whip you up a simple program this weekend to do those types of things for you with a click instead of all the extra characters, and just for the serial backpack type of thing.
Heck, I may just whip one up for myself anyways...might come in handy...
JDG
Hi Skimask,Originally Posted by skimask
Actually I do have VB3, 4,5,6 - Aint eBay greatcommunicating 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
Originally Posted by Joe S.
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
I will give that a try, <h3>yesiree, I sure will,YEP, I believe you are talkin' a couple of light years ahead of my experience level,</h3> what I think you are saying is send a string $FF, $10, $E0, $FF and receive it, then subtract $FF from it repeatedly to extract data which does not equal 0 after the subtraction process. I'm sure I can do this . . . a year from nowNevertheless . . the hardest part is figuring out what to do, then you can work out how!
JS
Last edited by Archangel; - 30th November 2006 at 05:58.
Originally Posted by Joe S.
Well, that was just an example, limited info on what you really got going and a zillion different ways a guy could go about it all.
Let me know what you come up with. It's always interesting to see different methods of doing the same thing...
JDG
Good ol' VB is still really easy to work with. Bruce have a short tutorial on that.
http://rentron.com/VisualBasic.htm
a piece of something to play around... posted here awhile back... when i had a good day
http://www.picbasic.co.uk/forum/atta...3&d=1117969258
Steve
It's not a bug, it's a random feature.
There's no problem, only learning opportunities.
Originally Posted by Joe S.
Ya know, I think I got this posted confused with another that was talking about using RF modules.
If you're hardwired, then, heck, I wouldn't worry about all that packet stuff.
And from the sounds of it, it sounds like you've got a good handle on what to do and when to do it.
What are you trying to do anyways? What's the end result going to be?
JDG
Hi Skimask,
I have no particular project at hand, I am trying to learn how to control a PIC via a serial connection, you know turn on some LEDs . . .
JS
Bookmarks