• Announcements

Archived

This topic is now archived and is closed to further replies.

LRC check

Recommended Posts

I am programming a program which will talk to a plc. I use the modbus protocol to communicate with it in C. But you have to do a LRC check and send that with the data. Does someone know how you do a LRC check? And if perhaps someone knows something more about the modbus protocol(how it works, where i can find more info)let me know. Thanx in advance

anyone?

Share on other sites
We use modbus PLCs here, but I didn''t write the code for them. Are you sure it isn''t a CRC ?

Magmai Kai Holmlor
- Not For Rent

Share on other sites
No i am sure it is LRC check. Do you know anything about that. And do you know some documentation about modbus protocol?

Share on other sites
We probably have some documentation around here somewhere... I peeked at our modbus code and it uses a CRC. And as I understand it, Modbus is an industry standard - so I'm about 99% certain it's a CRC. Perhaps cyclic begins with an L in another language??

And, oddly enough, there' a www.modbus.org

Edited by - Magmai Kai Holmlor on October 23, 2001 12:08:36 AM

Share on other sites
CRC = Cyclical Redundancy Check
LRC = Longitudinal Redundancy Check

LRC's tend to crop up in serial data communications. (Mixed memories from many many moons ago of getting a Nippondenso barcode reader to talk to an Archimedes ;-)

unsigned char get_lrc( unsigned char* data, int size ){    int i;    unsigned char sum = 0,    unsigned char checksum = 0xff;    for (i=0; i < size; ++i)    {        sum = sum + buf[ i ];    }    for (i=0; i<8; i++)     {        if ((sum & (1 << i)) > 0)        {            checksum = checksum & (0xff ^ (1 << i));        }    }    ++checksum;    return checksum;}

--
Simon O'Connor
Creative Asylum Ltd
www.creative-asylum.com

Edited by - S1CA on October 24, 2001 9:25:23 AM

Edited by - S1CA on October 24, 2001 9:26:23 AM

• Partner Spotlight

• Forum Statistics

• Total Topics
627662
• Total Posts
2978516

• 10
• 10
• 12
• 22
• 13