
It doesn't matter which serial port I connect the receiver to ?
For 16 channels I have to have Taranis

haydent wrote:been playing around with this a little more in gui, and i notice i only get travel from 1090 to 1909 yet without sbus i get 1000-2000
do others get the same ? wordering if this is deliberate, or possibly the signal not being translated accurately ?
haydent wrote:someone else was asking about this too. im not sure how close it currently is to doing this but its totally possible.
sounds like a good excuse for you to learn the basics of arduino and mwc ?
Plüschi wrote:I did receive my taranis today and yes, sbus range on the X8R is quite a bit less that ppmsum range on the DR4. Upping throw does fix it nicely. You get finer control with bigger throw, so im totally OK with that.
BUT my center is way off at 1486 instead of 1500. Did you change "#define offset" or did you change the transmitter setting?
OT: does your taranis also scream "telemnetry lost - telemetry recovered" when receiver is near to transmitter? I hate that.
Code: Select all
void readSBus(){
#define SBUS_SYNCBYTE 0x0F // Not 100% sure: at the beginning of coding it was 0xF0 !!!
static uint16_t sbus[25]={0};
while(SerialAvailable(1)){
int val = SerialRead(1);
if(sbusIndex==0 && val != SBUS_SYNCBYTE)
continue;
sbus[sbusIndex++] = val;
if(sbusIndex==25){
sbusIndex=0;
rcValue[0] = ((sbus[1]|sbus[2]<< 8) & 0x07FF)/2+SBUS_MID_OFFSET;
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+SBUS_MID_OFFSET;
// 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
//jrb SBUS adjust
// For some reason the SBUS data provides only about 75% of the actual RX output pulse width
// Adjust the actual value by +/-25%. Sign determined by pulse width above or below center
uint8_t adj_index;
for(adj_index=0; adj_index<16; adj_index++)
{
if (rcValue[adj_index] < MIDRC)
rcValue[adj_index] -= (MIDRC - rcValue[adj_index]) >> 2;
else
rcValue[adj_index] += (rcValue[adj_index] - MIDRC) >> 2;
}
}
}
}
haydent wrote:thank you very much or your detailed investigation and submission. I hope this can be integrated as promptly as possible.
edit, and i noticed you signed up just to post this, double thanks !!! and welcome
haydent wrote:bringing this back up again, anybody else ? (im using x8r too)haydent wrote:been playing around with this a little more in gui, and i notice i only get travel from 1090 to 1909 yet without sbus i get 1000-2000
do others get the same ? wordering if this is deliberate, or possibly the signal not being translated accurately ?
JohnB wrote:Happy to help.
John
-ralf- wrote:
Yes, works perfekt ..... or better![]()
Bind the X8R as second receiver ..... and you can use channel 9 to 16 direkt at
the receiver and channel 1 to 8 via s.bus.
Code: Select all
uint16_t val;
val = (sbus[1]|sbus[2]<< 8) & 0x07FF;
rcValue[0] = (val >> 1) + (val >> 3) + SBUS_OFFSET;
val = (sbus[2]>>3|sbus[3]<<5) & 0x07FF;
rcValue[1] = (val >> 1) + (val >> 3) + SBUS_OFFSET;
val = (sbus[3]>>6|sbus[4]<<2|sbus[5]<<10) & 0x07FF;
rcValue[2] = (val >> 1) + (val >> 3) + SBUS_OFFSET;
val = (sbus[5]>>1|sbus[6]<<7) & 0x07FF;
rcValue[3] = (val >> 1) + (val >> 3) + SBUS_OFFSET;
val = (sbus[6]>>4|sbus[7]<<4) & 0x07FF;
rcValue[4] = (val >> 1) + (val >> 3) + SBUS_OFFSET;
val = (sbus[7]>>7|sbus[8]<<1|sbus[9]<<9) & 0x07FF;
rcValue[5] = (val >> 1) + (val >> 3) + SBUS_OFFSET;
val = (sbus[9]>>2|sbus[10]<<6) & 0x07FF;
rcValue[6] = (val >> 1) + (val >> 3) + SBUS_OFFSET;
val = (sbus[10]>>5|sbus[11]<<3) & 0x07FF;
rcValue[7] = (val >> 1) + (val >> 3) + SBUS_OFFSET;
Plüschi wrote:JohnB why dont you put that into a simpler format without the if ?
Plüschi wrote:And same thing for spektrum?
Then bug alex a lot ... the idea is good
JohnB wrote:It is not clear to me that your code will work
JohnB wrote:No changed required for Spektrum.
Plüschi wrote:JohnB wrote:It is not clear to me that your code will work
Sbus values are from 0 to 2000 OR 0 to 2048 , cant remember.
Sbus total range is 0 to 2000.
Sbus useful range is 200 to 1800.
New SbusOffset will be 875
Calculation: sbus/2 + sbus/8 + offset = servo value
Low pos = 200 -> 100 + 25 + 875 = 1000 us
Mid pos = 1000 -> 500 + 125 + 875 = 1500 us
High pos = 1800 -> 900 + 225 + 875 = 2000 us
Sbus total range is 0 to 2048.
Sbus useful range is 224 to 1824.
New SbusOffset will be 860
Calculation: sbus/2 + sbus/8 + offset = servo value
Low pos = 224 -> 112 + 28 + 860 = 1000 us
Mid pos = 1024 -> 512 + 128 + 860 = 1500 us
High pos = 1824 -> 912 + 228 + 860 = 2000 usJohnB wrote:No changed required for Spektrum.
Speksat has the same issue needing 125% throws.
Alexinparis wrote:So what is the consensus ?
Plüschi : are you convinced spektrum does not need this because the scaling here is not at the same place ?
JohnB: I don't see any reason to make it optional via #define
Plüschi wrote:I think consensus is "do it for sbus".
I also say "do it for speksat", while john says "dont do for speksat".
Resoning behind doing that for speksat is the copter will NOT arm if you dont UP the throws, whis IS a problem for newbies. Same as for SBUS.
Plüschi wrote:I think consensus is "do it for sbus".
I
Plüschi wrote:@John
> Spektrum ... the pulse widths being decoded by MultiWii already match the transmitted pulse widths
How can you know this if the transmitter does not tell you the " transmitted pulse width" ?
I remember back in ver 2.2 days GregEgan already used spek scaling in his pocketquad fork. There must be a reason.
haydent wrote:i can see the need for both, but personally only need sbus as well. how about 2 seperate patches with seperate config options in their respective rx sections ?
Code: Select all
uint16_t readRawRC(uint8_t chan) {
uint16_t data;
#if defined(SPEKTRUM)
readSpektrum();
if (chan < RC_CHANS) {
data = rcValue[rcChannel[chan]];
} else data = 1500;
#elif defined(SBUS)
readSBus();
if (chan < RC_CHANS) {
data = rcValue[rcChannel[chan]];
} else data = 1500;
#else
uint8_t oldSREG;
oldSREG = SREG; cli(); // Let's disable interrupts
data = rcValue[rcChannel[chan]]; // Let's copy the data Atomically
SREG = oldSREG; // Let's restore interrupt state
#endif
return data; // We return the value correctly copied when the IRQ's where disabled
}
Code: Select all
#if defined(SPEKTRUM)
readRawRC(1); delay(44); // For digital receivers like Spektrum, SBUS, and Serial, to ensure that an "old" frame does not cause immediate exit at startup.
#endif
Code: Select all
#if defined(SPEKTRUM) || defined(SBUS)
readRawRC(1); delay(44); // For digital receivers like Spektrum, SBUS, and Serial, to ensure that an "old" frame does not cause immediate exit at startup.
#endif
haydent wrote:Tested out your sbus code again John and seems fine still. I have corrected an unrelated sbus + lcd conf bug.
JohnB wrote:haydent wrote:Tested out your sbus code again John and seems fine still. I have corrected an unrelated sbus + lcd conf bug.
Do you have the ability to test sbus with 15 or 16 channels? There is some sort of problem doing that with the current firmware, see my previous post. I tried it with the original 2.3 release code and the problem did not exist there.
No problems detected with 14 channels or less. I don't think this will bother many people but I am curious if this problem is unique to me using a Taranis and X8R.
John
haydent wrote:yes i have taranis/x8r and rigol dso if needed. ill have a go, never tried > 8
Code: Select all
debug[0] = rcValue[12];
debug[1] = rcValue[13];
debug[2] = rcValue[14];
debug[3] = rcValue[15];
haydent wrote:so how do i test 16 channels in MW when the gui only shows 8 ? or did you have some other method in mind ?
Alexinparis wrote:Hi,
I've just committed the mod suggested by JohnB.
With no option (permanent mod)
I think current SBUS users will have to look carefully at the change mod in next version.
From what I understand, I see no reason to make post scale treatment on spektrum system.
The fact users have to increase the travel range in the tx to reach [1000-2000] us is common for every system and spektrum is in the same case as standard or ppm rx on this point.
Plüschi wrote:Code: Select all
debug[0] = rcValue[12];
debug[1] = rcValue[13];
debug[2] = rcValue[14];
debug[3] = rcValue[15];
JohnB wrote:
The failure can be seen in the GUI. Something is happening to the decode of the sbus channels. Channel 1 is moving to channel 3, channel 2 is moving to channel 4 etc. The good news is this was found with ground testing. This would have been a disaster in the air.
John