Comments (12)
thank you for posting your issue.
i never tested negative coordinates.
could you replace your "send_f1675_gps" function in sbus2.cpp with following code:
void send_f1675_gps(uint8_t port, uint16_t speed, int16_t altitude, int16_t vario, int32_t latitude, int32_t longitude)
{
uint16_t value1 = 0;
int16_t value2 = 0;
uint32_t value3 = 0;
bool latitude_pos = false;
bool longitude_pos = false;
uint8_t bytes[SBUS2_TEL_DATA_SIZE] = {0x03, 0x40, 0x00 };
// SPEED -> Bit 14(bytes[1] bit7) -> GPS Valid or not
value1 = speed | 0x4000;
if ( value1 > 0x43E7 )
{
// max Speed is 999 km/h
value1 = 0x43E7;
}
bytes[1] = value1 >> 8;
bytes[2] = value1;
SBUS2_transmit_telemetry_data( port , bytes);
//HIGHT
value2 = altitude | 0x4000;
bytes[1] = value2 >> 8;
bytes[2] = value2;
SBUS2_transmit_telemetry_data( port+1 , bytes);
//TIME -> 12:34:56 Uhr = 126060 + 34*60 + 56 = 45296 = 0xB0F0
bytes[1] = 0xB0;
bytes[2] = 0xF0;
SBUS2_transmit_telemetry_data( port+2 , bytes);
// VARIO
value2 = vario * 10;
bytes[1] = value2 >> 8;
bytes[2] = value2;
SBUS2_transmit_telemetry_data( port+3 , bytes);
// LATITUDE
if(latitude >= 0){
latitude_pos = true;
}
else{
latitude_pos = false;
latitude = latitude * -1;
}
bytes[1] = (uint8_t)(latitude/1000000);
value3 = (uint32_t)(latitude%1000000);
if(latitude_pos){
bytes[2] = ((value3 >> 16) & 0x0f); // North
}
else{
bytes[2] = ((value3 >> 16) & 0x1f); // South
}
SBUS2_transmit_telemetry_data( port+4 , bytes);
bytes[1] = ((value3 >> 8) & 0xff);
bytes[2] = value3 & 0xff;
SBUS2_transmit_telemetry_data( port+5 , bytes);
// LONGITUDE
if(longitude >= 0){
longitude_pos = true;
}
else{
longitude_pos = false;
longitude = longitude * -1;
}
bytes[1] = (uint8_t)(longitude/1000000);
value3 = (uint32_t)(longitude%1000000);
if(longitude_pos){
bytes[2] = ((value3 >> 16) & 0x0f); // Eath
}
else{
bytes[2] = ((value3 >> 16) & 0x1f); // West
}
SBUS2_transmit_telemetry_data( port+6 , bytes);
bytes[1] = ((value3 >> 8) & 0xff);
bytes[2] = value3 & 0xff;
SBUS2_transmit_telemetry_data( port+7 , bytes);
}
from sbus2-telemetry.
if it's working i will change it in Git
from sbus2-telemetry.
Hi thanks for your answer,
The problem is different now, in both case (positive or negative coordinate) the radio always display
North for Latitude and East for longitude. The coordinate are good, there is just a problem of pole
Exemple
int32_t latitude = -52312499; // Display = N 52° 31.2499
int32_t longitude = -13245658; // Display = E 13° 24.5658
Thanks
Julien
from sbus2-telemetry.
Dear Julien,
i'am not sure why the Pole is wrong. At the Moment i have not the Time to Debug the Problem on my T14SG.
Maybe you have to wait until i have some more time.
please try the following code:
void send_f1675_gps(uint8_t port, uint16_t speed, int16_t altitude, int16_t vario, int32_t latitude, int32_t longitude)
{
uint16_t value1 = 0;
int16_t value2 = 0;
uint32_t value3 = 0;
bool latitude_pos = false;
bool longitude_pos = false;
int32_t _latitude = latitude;
int32_t _longitude = longitude;
uint8_t bytes[SBUS2_TEL_DATA_SIZE] = {0x03, 0x40, 0x00 };
// SPEED -> Bit 14(bytes[1] bit7) -> GPS Valid or not
value1 = speed | 0x4000;
if ( value1 > 0x43E7 )
{
// max Speed is 999 km/h
value1 = 0x43E7;
}
bytes[1] = value1 >> 8;
bytes[2] = value1;
SBUS2_transmit_telemetry_data( port , bytes);
//HIGHT
value2 = altitude | 0x4000;
bytes[1] = value2 >> 8;
bytes[2] = value2;
SBUS2_transmit_telemetry_data( port+1 , bytes);
//TIME -> 12:34:56 Uhr = 126060 + 34*60 + 56 = 45296 = 0xB0F0
bytes[1] = 0xB0;
bytes[2] = 0xF0;
SBUS2_transmit_telemetry_data( port+2 , bytes);
// VARIO
value2 = vario * 10;
bytes[1] = value2 >> 8;
bytes[2] = value2;
SBUS2_transmit_telemetry_data( port+3 , bytes);
// LATITUDE
if(latitude >= 0){
latitude_pos = true;
}
else{
latitude_pos = false;
latitude = latitude * -1;
}
bytes[1] = (uint8_t)(latitude/1000000);
value3 = (uint32_t)(latitude%1000000);
if(_latitude >= 0){
bytes[2] = ((value3 >> 16) & 0x0f); // North
}
else{
bytes[2] = ((value3 >> 16) & 0x1f); // South
}
SBUS2_transmit_telemetry_data( port+4 , bytes);
bytes[1] = ((value3 >> 8) & 0xff);
bytes[2] = value3 & 0xff;
SBUS2_transmit_telemetry_data( port+5 , bytes);
// LONGITUDE
if(longitude >= 0){
longitude_pos = true;
}
else{
longitude_pos = false;
longitude = longitude * -1;
}
bytes[1] = (uint8_t)(longitude/1000000);
value3 = (uint32_t)(longitude%1000000);
if(_longitude >= 0){
bytes[2] = ((value3 >> 16) & 0x0f); // Eath
}
else{
bytes[2] = ((value3 >> 16) & 0x1f); // West
}
SBUS2_transmit_telemetry_data( port+6 , bytes);
bytes[1] = ((value3 >> 8) & 0xff);
bytes[2] = value3 & 0xff;
SBUS2_transmit_telemetry_data( port+7 , bytes);
}
from sbus2-telemetry.
Hi,
Still the same problem with your code, i'll try to work on it too
Thanks a lot
Julien
from sbus2-telemetry.
the GPS Sensor is documented here:
https://sites.google.com/site/sbus2diy/home/sbus2protocol-part2/sbus2protocol-part3
please use google translation
North/south and East/West is just a single Bit set to 1 or set to zero.
you could try to send the Longitude value without calculation. It's just shifting some Bits
// LONGITUDE 13245658 -> 13° and 245658 = 0x 3 BF 9A
bytes[1] = 0x0D; -> 13 Degree
bytes[2] = 0x03; // East = 0
or
bytes[2] = 0x13; // West = 1
SBUS2_transmit_telemetry_data( port+6 , bytes);
bytes[1] = 0xBF;
bytes[2] = 0x9A;
SBUS2_transmit_telemetry_data( port+7 , bytes);
}
from sbus2-telemetry.
Yes it's working without calculation
bytes[2] = 0x13; // West = 1
I'll do some more test this afternoon
Thanks a lot
Julien
from sbus2-telemetry.
Hi,
I think i found the problem
For the calculation of negative we have to do a bitwise with a XOR and not a AND
bytes[2] = ((value3 >> 16) & 0x1f); => bytes[2] = ((value3 >> 16)^ 0x10);
It's working with
int32_t latitude = -52312499; // Display = S 52° 31.2499
int32_t longitude = -13245658; // Display = W 13° 24.5658
Thanks
Julien
from sbus2-telemetry.
on the first view it's sound wrong to me.
did you try it with OR?
245658 >> 16 = 0b0011 = 0x03
(0x03 & 0x1f) = 0001 0011
0x03 ^ 0x10 = 0001 0011
0x03 | 0x10 = 0001 0011
The Result's are the same
from sbus2-telemetry.
Hi
(0x03 & 0x1f) = 0000 0011 = 0x03
I'll try with OR
Thanks
Julien
from sbus2-telemetry.
yes, you are right...now i see the Problem.
for setting the E/W and the N/S Bit you have to use AND 0x1f for setting 0 and OR 0x10 for setting 1
bytes[2] = ((value3 >> 16) & 0x0f); // Eath
}
else{
bytes[2] = ((value3 >> 16) | 0x10); // West
}
from sbus2-telemetry.
solved in V1.0 Release
from sbus2-telemetry.
Related Issues (20)
- Telemetry not working with 3 sensor HOT 50
- [ESP32] Wrong Timing with ESP32 Arduino Core 1.0.5 HOT 1
- Frame loss HOT 13
- Reading SBUS2 sensor data to serial monitor HOT 34
- GPS Altitude not working
- [Feature Request] SBUS2 Frame Generation
- [BUG] UART_dropped_frame never cleared
- [ESP32][BUG] Not working with ESP32 Arduino V2.0.0 HOT 6
- GPS SBS-02G HOT 33
- [Feature] Add JetCat V10 Sensor HOT 3
- [Feature] Support ESP32-S2 & ESP32-C3 & ESP32-S3 HOT 23
- Examples don't actually compile for ESP-32: HOT 4
- How do you login your Arduino sbus2 for the remote controller?
- How do you login your Arduino as a sbus2 device to your remote controller? HOT 15
- too many arguments to function 'void SBUS2_Setup()' HOT 1
- It doesn't work with R7108SB HOT 9
- Atmega328P - jamming when processing sensors HOT 2
- Send RPM value to receiver HOT 13
- Why is there 2 voltages available for the SBS01T ? HOT 5
- SBUS Channel data HOT 27
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sbus2-telemetry.