Motorola and Intel microprocessors are generally incompatible (cannot share the same memory) because of the byte-order problem.For a better experience, please enable JavaScript in your browser before proceeding.Ive carefully studied the Modicon documentation (ref: PI-MBUS-300 Rev.
When it comes to CRC transmission, the document clearly states that the CRC needs to be sent low order byte first. Modbus Crc Polynomial Code Is VirtuallyMy code is virtually a straight shameless rip off of the code example in the manual. Yet when I test my product with 3rd party Modbus masters I found that I had to reverse the order of my transmitted CRC in order to get successful connections to the master. My first thought was that the 3rd party product I was using had some bugs. But when I got the same results from 3 different products I concluded that those developers knew something that I did not. Has anyone else run into this Can anyone confirm (or dispute) my conclusion that the byte order must be HILO and not LOHI as the manual states Do I need to by an official Modbus capable product PLC to test my protocol implementation rather than using downloaded shareware Any thoughts comments help is greatly appreciated. Ive read through some other postings here regarding this issue. The replies generally focused on byte order issues with respect to platforms on which the code is run AND on the notion that the Modicon example code is already doing a byte order swap, etc. My point: When it says to send the low byte first, that means to me from the perspective of the UART, meaning that the low byte is sent out of the UART first, followed by the high byte. I dont need to care how 16 bit variables are stored on any particular platform (little endian, big endian). Period. So low byte first should mean low byte first. Its up to you, the programmer, to figure out which 8 bit memory location of your 16 bit variable, corresponds to low and high respectively. However, in the Modicon example code, the CRC is calculated and split between two separate 8-bit variables clearly labeled Hi and Lo. Only at the end of the routine do those two 8-bit pieces get merged into a 16-bit variable and returned to the caller. So one doesnt have to even deal with platform specific byte ordering issues. Just keep the CRC as two separate 8-bit bytes and send them one at a time in the proper order, right Well guess which of those two variables I think should be sent first The one labeled Lo. So thats the issue and I think the other poster (back in October 2002) was finding the same thing. Attached is a link which includes data bus for several popular software products. Different computer architectures use memory in these different ways to store data. Do you start with the least significant byte first (Little-endian), or the most significant byte first (Big-endian).
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |