Shop OBEX P1 Docs P2 Docs Learn Events
Serial protocol - How to detect frame start/end - Modbus — Parallax Forums

Serial protocol - How to detect frame start/end - Modbus

pacmanpacman Posts: 327
edited 2010-11-01 14:13 in Propeller 1
I've been dabbling with Modbus recently, but have hit a bit of a problem with detecting the 3.5 character silence at the start/end of a modbus RTU packet.

I was thinking that as I know the baud rate, I could use something like the Extended_FDSerial object and the rxDecTime function within it to get fairly accurate timing..

I'm not convinced that this is the best (or even if this is a good/mediocre) way of detecting the silence.

Can anyone suggest an alternative? {sample code would be appreciated...}

Thanks in advance..

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
=================
The future is in our hands.
Which way to the future?
=================

Comments

  • Bill HenningBill Henning Posts: 6,445
    edited 2009-12-22 03:21
    Keep a "last start bit cnt value" register, initialized to cnt when you start your serial object

    then check to see if last cnt > 3.5 character intervals, if so, new packet... regardless, save cnt to last cnt/

    pacman said...
    I've been dabbling with Modbus recently, but have hit a bit of a problem with detecting the 3.5 character silence at the start/end of a modbus RTU packet.

    I was thinking that as I know the baud rate, I could use something like the Extended_FDSerial object and the rxDecTime function within it to get fairly accurate timing..

    I'm not convinced that this is the best (or even if this is a good/mediocre) way of detecting the silence.

    Can anyone suggest an alternative? {sample code would be appreciated...}

    Thanks in advance..
    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    www.mikronauts.com Please use mikronauts _at_ gmail _dot_ com to contact me off-forum, my PM is almost totally full
    Morpheusdual Prop SBC w/ 512KB kit $119.95, Mem+2MB memory IO board kit $89.95, both kits $189.95
    Propteus and Proteus for Propeller prototyping 6.250MHz custom Crystals run Propellers at 100MHz
    Las - Large model assembler for the Propeller Largos - a feature full nano operating system for the Propeller
  • Reset_VectorReset_Vector Posts: 55
    edited 2009-12-22 15:18
    Hi Pacman,
    As previous said, here is my MODBUS protocol handler.
    If you have any questions, you can ask me.

    Best regards from France
  • Dave MatthewsDave Matthews Posts: 93
    edited 2010-11-01 14:13
    I very much appreciate the code Olivier, any recent updates? I am just beginning to work on a version of the protocol relying heavily upon your work so generously posted. This week is the big push for me, so I hope you are still out there and perhaps available for questions.

    Thanks again for publishing your creation,
    Dave KI4PSR
Sign In or Register to comment.