2 questions


Closed Thread
Results 1 to 14 of 14

Thread: 2 questions

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Solved question 2

    Thanks Henrik,
    that is the way!
    JS

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    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

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default Actually I do

    Quote Originally Posted by skimask
    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,
    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

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    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

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default hmmmm

    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 now Nevertheless . . 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.

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S.
    I will give that a try
    JS

    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

  7. #7
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    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.

  8. #8
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S.
    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 now Nevertheless . . the hardest part is figuring out what to do, then you can work out how!
    JS

    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

  9. #9
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default No project at hand

    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

Similar Threads

  1. ICSP (2) questions
    By Ramonetnet in forum mel PIC BASIC Pro
    Replies: 28
    Last Post: - 28th April 2008, 10:03
  2. LOTS of questions....
    By reaper0995 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd March 2008, 17:00
  3. USB-FTDI[UM232R] with PIC16f877a
    By bjox in forum USB
    Replies: 1
    Last Post: - 23rd February 2008, 22:40
  4. PicKit 2 Questions
    By dmairspotter in forum General
    Replies: 3
    Last Post: - 11th November 2007, 21:10
  5. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts