The offset used is 976 with the comment // Perhaps you may change the term "/2+976" -> center will be 1486
With my equipment the SBUS center is at 1488 which makes it difficult to arm the copter. I propose to change the 976 offset into 988 bringing the center spot on to 1500.
/******************************* SBUS RECIVER ************************************/ /* The following line apply only for Futaba S-Bus Receiver on MEGA boards at RX1 only (Serial 1). You have to invert the S-Bus-Serial Signal e.g. with a Hex-Inverter like IC SN74 LS 04 */ //#define SBUS //#define SBUS_SERIAL_PORT 1 //#define SBUS_MID_OFFSET 988
/* The following line apply only for Futaba S-Bus Receiver on MEGA or PROMICRO boards. You have to invert the S-Bus-Serial Signal e.g. with a Hex-Inverter like IC SN74 LS 04 */
/**************************************************************************************/ /*************** SBUS RX Data ********************/ /**************************************************************************************/ #if defined(SBUS) void readSBus(){ #if defined(SBUS_SOFT_INVERT) #define SBUS_SYNCBYTE 0xF0 // Not inverted #else #define SBUS_SYNCBYTE 0x0F // Hardware inverted #endif static uint16_t sbus[25]={0}; while(SerialAvailable(1)){ int val = SerialRead(1); if(sbusIndex==0 && val != SBUS_SYNCBYTE) continue; #if defined(SBUS_SOFT_INVERT) sbus[sbusIndex++] = (~val) & 0x00FF; #else sbus[sbusIndex++] = val; #endif if(sbusIndex==25){ sbusIndex=0; rcValue[0] = ((sbus[1]|sbus[2]<< 8) & 0x07FF)/2+SBUS_MID_OFFSET; // SBUS_MID_OFFSET defined and set in config.h rcValue[1] = ((sbus[2]>>3|sbus[3]<<5) & 0x07FF)/2+SBUS_MID_OFFSET; rcValue[2] = ((sbus[3]>>6|sbus[4]<<2|sbus[5]<<10) & 0x07FF)/2+SBUS_MID_OFFSET; rcValue[3] = ((sbus[5]>>1|sbus[6]<<7) & 0x07FF)/2+SBUS_MID_OFFSET; rcValue[4] = ((sbus[6]>>4|sbus[7]<<4) & 0x07FF)/2+SBUS_MID_OFFSET; rcValue[5] = ((sbus[7]>>7|sbus[8]<<1|sbus[9]<<9) & 0x07FF)/2+SBUS_MID_OFFSET; rcValue[6] = ((sbus[9]>>2|sbus[10]<<6) & 0x07FF)/2+SBUS_MID_OFFSET; rcValue[7] = ((sbus[10]>>5|sbus[11]<<3) & 0x07FF)/2+SBUS_MID_OFFSET; // & the other 8 + 2 channels if you need them //The following lines: If you need more than 8 channels, max 16 analog + 2 digital. Must comment the not needed channels! rcValue[8] = ((sbus[12]|sbus[13]<< 8) & 0x07FF)/2+SBUS_MID_OFFSET; rcValue[9] = ((sbus[13]>>3|sbus[14]<<5) & 0x07FF)/2+SBUS_MID_OFFSET; rcValue[10] = ((sbus[14]>>6|sbus[15]<<2|sbus[16]<<10) & 0x07FF)/2+SBUS_MID_OFFSET; rcValue[11] = ((sbus[16]>>1|sbus[17]<<7) & 0x07FF)/2+SBUS_MID_OFFSET; rcValue[12] = ((sbus[17]>>4|sbus[18]<<4) & 0x07FF)/2+SBUS_MID_OFFSET; rcValue[13] = ((sbus[18]>>7|sbus[19]<<1|sbus[20]<<9) & 0x07FF)/2+SBUS_MID_OFFSET; rcValue[14] = ((sbus[20]>>2|sbus[21]<<6) & 0x07FF)/2+SBUS_MID_OFFSET; rcValue[15] = ((sbus[21]>>5|sbus[22]<<3) & 0x07FF)/2+; // now the two Digital-Channels if ((sbus[23]) & 0x0001) rcValue[16] = 2000; else rcValue[16] = 1000; if ((sbus[23] >> 1) & 0x0001) rcValue[17] = 2000; else rcValue[17] = 1000;
// Failsafe: there is one Bit in the SBUS-protocol (Byte 25, Bit 4) whitch is the failsafe-indicator-bit #if defined(FAILSAFE) if (!((sbus[23] >> 3) & 0x0001)) {if(failsafeCnt > 20) failsafeCnt -= 20; else failsafeCnt = 0;} // clear FailSafe counter #endif } } } #endif
/******************************* SBUS RECIVER ************************************/ /* The following line apply only for Futaba S-Bus Receiver on MEGA boards at RX1 only (Serial 1). You have to invert the S-Bus-Serial Signal e.g. with a Hex-Inverter like IC SN74 LS 04 or use SBUS_SOFT_INVERT to invert via Software */ #define SBUS #define SBUS_SERIAL_PORT 1 #define SBUS_SOFT_INVERT #define SBUS_MID_OFFSET 988 //SBUS Mid-Point at 1500
This way not work. You inverting only data bits. Not the start and stop bits in serial transmision. In this case the serial receiver not work propertly.