2 questions


Closed Thread
Results 1 to 14 of 14

Thread: 2 questions

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

    Default 2 questions

    Hi Everyone,
    I have 2 serial related data questions.
    1.How, do I make PIC Basic Pro, interpret a string sent Serially from a P/C or another PIC as a command? Using Hserin and the variable called Char I tried something like this:
    Code:
    While char = value
    PortA.1 = 1
    wend
    Question 2:
    I hooked my serial backpack up to my P/C.
    The backpack uses the hserin protocol in and the lcdout protocol to output data to the LCD. It is equipped with a max232 to interface with the P/C. When I send data to it from the P/C it prints strings of text on screen in this order, Line 1, line 3, line 2, line 4. it completely ignores the commands $FE, $C0 and so on, rather printing them onscreen as part or the text string, so in many ways this question is related to question 1. When I send the data to it from a PIC it properly formats the screen with the normal LCDOUT commands.
    Thank You,
    JS

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default

    Hi Joe,
    What software are you using send the data from the PC to the LCD? If it's a terminal program you need to figure out how to send the ASCII representation of $FE. You can't just type "$FE" because that will send the three characters $,F,E and not the LCD's "command identifier".

    If you are using Hyperterminal it MAY work by doing this:
    Hold down the left ALT key on you keyboard, then, on the numerical keyboard type 254 and let go of the ALT key. Then do the same but type 192 instead. This should be the same as sending $FE,$C0

    If you're using the Serial communicator in MCS look for "Parse Control Characters" in the help file.

    /Henrik Olsson.

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


    Did you find this post helpful? Yes | No

    Default Serial Sender

    Quote Originally Posted by HenrikOlsson
    Hi Joe,
    What software are you using send the data from the PC to the LCD? If it's a terminal program you need to figure out how to send the ASCII representation of $FE. You can't just type "$FE" because that will send the three characters $,F,E and not the LCD's "command identifier".

    If you are using Hyperterminal it MAY work by doing this:
    Hold down the left ALT key on you keyboard, then, on the numerical keyboard type 254 and let go of the ALT key. Then do the same but type 192 instead. This should be the same as sending $FE,$C0

    If you're using the Serial communicator in MCS look for "Parse Control Characters" in the help file.

    /Henrik Olsson.
    Hi Henrik,
    I am using something I found SOMEWHERE called serial sender, I was unable to get hyperterminal to work. Thanks, JS

  4. #4
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,516


    Did you find this post helpful? Yes | No

    Default

    Hi,
    I found SerialSender here:
    http://www.seetron.com/vfdmnl/mnl.htm

    If that is what you got it looks like this is the way to send ASCII:
    Try typing <254><192>LCDTest and then hit Send.

    /Henrik Olsson.

  5. #5
    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

  6. #6
    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

  7. #7
    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

  8. #8
    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

  9. #9
    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 06:58.

  10. #10
    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

  11. #11
    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.

  12. #12
    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

  13. #13
    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

  14. #14
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S.
    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

    Well, heck, that should be simple enough for ya.
    Set up the receiver PIC to read the serial port.
    Receive an 'a', Portb.0 goes high, led goes on, echo back 'PB0=1' if you want,
    receive a 'b', Portb.0 goes low, led goes off, echo back 'PB0=0',
    get a 'c', portb.1 goes high, led goes on,
    get a 'd', portb.1 goes low, led goes off....

    And so on and so on.
    It all goes back to JCP (remember Joe's Communications Protocol?). It's all about what you want to do. In the end, it doesn't matter what I or anybody else thinks....it's all about what you want.

    So design the thing, write the firmware, and make it work!!!
    The problem is, once you get that working, ideas start flooding forth, and then you start spending big money on pieces/parts...

    JDG

Similar Threads

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

Members who have read this thread : 1

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