Coder Social home page Coder Social logo

Comments (12)

BrushlessPower avatar BrushlessPower commented on June 16, 2024

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.

BrushlessPower avatar BrushlessPower commented on June 16, 2024

if it's working i will change it in Git

from sbus2-telemetry.

magnum3131 avatar magnum3131 commented on June 16, 2024

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.

ericlangel avatar ericlangel commented on June 16, 2024

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.

magnum3131 avatar magnum3131 commented on June 16, 2024

Hi,
Still the same problem with your code, i'll try to work on it too
Thanks a lot
Julien

from sbus2-telemetry.

ericlangel avatar ericlangel commented on June 16, 2024

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.

magnum3131 avatar magnum3131 commented on June 16, 2024

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.

magnum3131 avatar magnum3131 commented on June 16, 2024

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.

ericlangel avatar ericlangel commented on June 16, 2024

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.

magnum3131 avatar magnum3131 commented on June 16, 2024

Hi
(0x03 & 0x1f) = 0000 0011 = 0x03
I'll try with OR
Thanks
Julien

from sbus2-telemetry.

ericlangel avatar ericlangel commented on June 16, 2024

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.

BrushlessPower avatar BrushlessPower commented on June 16, 2024

solved in V1.0 Release

from sbus2-telemetry.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.