HI ,i ve planed to build a controller for a old jd 990 ..i find this:
For example the following SysEx message turns off Tone 1 on the temporary patch on a JV-1080/JV-2080/XP-50 or XP-80. The checksum 6D is calculated as follows (all numbers are in Hex NOT decimal):
F0 41 10 6A 12 03 00 10 00 00 6D F7
^^ ^^^^^^^^^^^^^^ ^^ ^^
| | | |
| | | ±- End of SysEx message marker
| | ±- Checksum
| ±- Data portion of message
±- Command ID (12 = DT1 - Data Set)
(1) Add the data part of the message
03 + 00 + 10 + 00 + 00 = 13 (X)
(2) Divide (X) by 0x80 (128 in decimal) and save the reminder which is (Y)
13 / 80 = 0 with remainder of 13 =(Y)
(3) Subtract (Y) from 0x80 (128) to give us the checksum
80 - 13 = 6D (checksum)
i don’t understand the (2)..;some informations please…best regards and happy new years..
Yes, if you want to send SysEx messages, you have to understand what you are doing :). Look here for a more in-depth explanation of the concept. Also, you will need to understand the manufacturer’s (Roland) implementation of that concept.
It’s complex, but it’s not magic. With MIDIbox you are on the right platform for doing this!
void gen_chksum_and_send(void) {
unsigned char Y = 0;
unsigned char X = 0; // I assume it's meant to be overloaded
for (i=0; i < sysex_byte_count; i++){
X += sysex_buffer[i];
}
X %= 0x80; //There's the modulus
Y = 0x80 - X;
sysex_buffer[sysex_byte_count] = Y;
sysex_buffer_send();
}
Don’t go trying to do that frequently on the PIC though, a modulus is a divide operation so it’s slow.
There is a good explanation of the checksum at the end of This Page.
The add and mask concept is easier to implement in PIC than any divide type function.
I’d start with a dummy value of zero, then do a loop until the end of the sysex data, adding the next value and masking with 128 (AND 0x7F ) , to keep the numbers in the frame. You don’t need to worry about carry values, because the nominal overflow is going to be masked off anyway.
Note 0x7F = 0b01111111: the AND function effectively means “keep all the bits except the highest”.