pjago / CEE0099

Laboratório de Controle Digital
MIT License
2 stars 0 forks source link

PIC responds in Big Endian #11

Open pjago opened 6 years ago

pjago commented 6 years ago

The tachometer response is of 16 bits, and currently is sent by PIC in the Big Endian format (most significant byte first). This is an issue since x86-64 processors, and therefore MATLAB, store data in the Little Endian format. At the moment it is solved by swaping the bytes after doing a fread.

I can't really clean this until we decide to refactor previous MATLAB code, especially those where fread is used in multiple lines. Only worth doing if we decide to join an existing protocol, like Modbus.

pjago commented 6 years ago

Another thing that would benefit from changing protocol is that atm writing a duty cycle of 10 has no effect, since in the current protocol the value 10 is recognized as a '\n'.