RS232 Serial I/O Creating my own protocol/commands


+ Reply to Thread
Results 1 to 12 of 12
  1. #1
    t0pP8uZz
    Guest t0pP8uZz's Avatar

    0 Not allowed!

    Default RS232 Serial I/O Creating my own protocol/commands

    Okay so my main logic board is controller via a host computer connected via rs232 serial. Now everything is working great.

    Since i have alot of commands i want to issue the PIC, i want to create me own protocol/commands.. the problem im having is mixing hex codes with decimals.

    For instance.. i want to be able to do the following..

    Create a command header like: FF0B
    Then the next byte or 2 would be the command IE: 0F
    then the next bytes would be the decimal or text to send to the command.

    Whats the best way of achieving this?

    Of course my pic would need to read the serial hex, make sure the header is correct (FF0B) then check the if statements for command 0F, then pass the next bytes as decimals or text.

    Sorry if i didnt explain clearly.
    -Jay

  2. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  3. #2
    t0pP8uZz
    Guest t0pP8uZz's Avatar

    0 Not allowed!

    Default Re: RS232 Serial I/O Creating my own protocol/commands

    So basically a way to check data integrity as I know some bytes are lost due to noise etc.

  4. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  5. #3
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,367
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default Re: RS232 Serial I/O Creating my own protocol/commands

    Hi,
    I am probably wrong on this bit but my take on it is, you can only send 8 bits at a time so the controller does not care if it recieves FF or 255, they are both the same. The only thing would be if you were sending ASCII.

    This is the bit that concernes me
    So basically a way to check data integrity as I know some bytes are lost due to noise etc.
    Why do you think you would be losing bytes to noise, if this is the case then it might be worth looking at RS485 which is a differential bus and more resiliant to noise but where is the noise coming from in the first place. The other thing if you can control it is the baud rate, slower should be more tolerant.

    Regards,
    Bob

  6. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  7. #4
    t0pP8uZz
    Guest t0pP8uZz's Avatar

    0 Not allowed!

    Default Re: RS232 Serial I/O Creating my own protocol/commands

    Thanks for the reply.

    Okay well i just reading about serial communication and it seems that its almost a must to have some kind of crc checksum to make sure the data didnt change as bits cant be flipped a number of ways (noise etc) as far as i know there isnt any noise in my system, but these particula commands are controlling a money coin payout hopper... so as you could imagine any kind of change to the sent packet/data could be dangerous in financial terms.

    Also how do we work directly with hex in Proton? Lets say i sent the hex bytes FF FF via serial. can i check them in the pic like if Var1 = FF

  8. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  9. #5
    Prolific Poster RGV250's Avatar
    Join Date
    Aug 2005
    Posts
    2,367
    Thumbs Up
    Received: 29
    Given: 7
    Total Downloaded
    1.16 GB

    0 Not allowed!

    Default Re: RS232 Serial I/O Creating my own protocol/commands

    Hi,
    Look under Numeric representation in the compiler manual, for decimal you do not need to do anything, for hex you put the $ sign in front IE $FF.
    As for errors, you could try looking for parity checking, someone might have done it.

    Regards,
    Bob
    Last edited by RGV250; 2nd February 2014 at 19:26.

  10. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  11. #6
    t0pP8uZz
    Guest t0pP8uZz's Avatar

    0 Not allowed!

    Default Re: RS232 Serial I/O Creating my own protocol/commands

    Cheers Bob, that helps alot.

    -Jay

  12. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  13. #7
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,415
    Thumbs Up
    Received: 48
    Given: 40
    Total Downloaded
    3.45 GB

    0 Not allowed!

    Default Re: RS232 Serial I/O Creating my own protocol/commands

    Jay

    I wrote an article for the Wiki about creating a protocol for exactly the thing you are doing. But I can't now find it! It's in there somewhere. I'll keep looking and let you know if I find it.

    Charlie

  14. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  15. #8
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,415
    Thumbs Up
    Received: 48
    Given: 40
    Total Downloaded
    3.45 GB

    0 Not allowed!

    Default Re: RS232 Serial I/O Creating my own protocol/commands

    Last edited by joesaliba; 5th February 2014 at 06:19.

  16. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  17. #9
    t0pP8uZz
    Guest t0pP8uZz's Avatar

    0 Not allowed!

    Default Re: RS232 Serial I/O Creating my own protocol/commands

    I haven't taken a look yet. But... That's great! So excited to have a read

    Thanks a lot!
    Jay

  18. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  19. #10
    t0pP8uZz
    Guest t0pP8uZz's Avatar

    0 Not allowed!

    Default Re: RS232 Serial I/O Creating my own protocol/commands

    Quote Originally Posted by charliecoultas View Post
    Jay

    I wrote an article for the Wiki about creating a protocol for exactly the thing you are doing. But I can't now find it! It's in there somewhere. I'll keep looking and let you know if I find it.

    Charlie
    Hey thanks for linking me to your article on the transmission protocol.

    How come you recive each byte one by one in the interrupt? Im using a RS232 Serial com, would it not be better to recieve the packet data all at once using RSIn?

    Then decipher the packet and check the integrity from there. Could use an interrupt to detect only when data is coming in.

  20. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  21. #11
    Prolific Poster charliecoultas's Avatar
    Join Date
    Sep 2010
    Posts
    1,415
    Thumbs Up
    Received: 48
    Given: 40
    Total Downloaded
    3.45 GB

    0 Not allowed!

    Default Re: RS232 Serial I/O Creating my own protocol/commands

    I found it easier that way. I did try receiving lots of bytes into a buffer then try to sort it out, but doing it as each byte comes in seemed simpler. You can do it any way you like of course. Are you nearer a solution to your problem?

    Charlie

  22. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

  23. #12
    t0pP8uZz
    Guest t0pP8uZz's Avatar

    0 Not allowed!

    Default Re: RS232 Serial I/O Creating my own protocol/commands

    Quote Originally Posted by charliecoultas View Post
    I found it easier that way. I did try receiving lots of bytes into a buffer then try to sort it out, but doing it as each byte comes in seemed simpler. You can do it any way you like of course. Are you nearer a solution to your problem?

    Charlie
    Ah right, Yeah that article really helped out. I think i was overthinking the situation.

    Cheers

    Jay

  24. Attention

    This valuable resource relies upon the very small amount of revenue generated by displaying online advertisements to our visitors.

    The advertisements we display are relevant to this web site and your browsing history

    Please consider supporting us by disabling your ad blocker.


    Note: Some users have reported issues related to ad-blockers rendering parts of this wesite unusable,
    where possible we will rectify the issues to enable you to use this resource with adblocking enabled.

    If you can, please report issues in the forum area WebSite / Forum Issues


    Thank you for your attention.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Looking for a serial protocol
    By towlerg in forum Serial / Ethernet
    Replies: 6
    Last Post: 25th July 2016, 13:30
  2. Creating a Serial GUI
    By pic-ignorant in forum The Lounge
    Replies: 21
    Last Post: 2nd September 2013, 17:54
  3. [SOLVED !] Serial Timeout Protocol
    By Mark Rodgers in forum Proton Plus Compiler v3
    Replies: 5
    Last Post: 20th August 2010, 04:53
  4. Re-define for serial commands
    By bill9399 in forum Wish List / Product Feedback
    Replies: 7
    Last Post: 19th March 2006, 23:37
  5. [SOLVED !] Serial commands - why so many?
    By simonl in forum Proton Plus Compiler v3
    Replies: 2
    Last Post: 31st May 2005, 17:50

Tags for this Thread

Posting Permissions

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