OpenxGPS?

Development & General Chat for the superb openxvario project.

Moderator: rainer

mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: OpenxGPS?

Post by mstrens »

I think SPORT is fast enough to send all data every 500 ms.
Just take care that 24 ms is the enlapsed time to send ONE data (in fact 4 bytes of data).
Longitude, Latitude, Speed are each different data.

nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: OpenxGPS?

Post by nigelsheffield »

OK I will look into it more, I don't have the GPS unit, neither do I have the skills to program it as I only just started with arduino, all I have done so far is run the blink program lol!
When I have the openxsensor built and working I will study up on the code and see what the GPS needs to work.
If I feel I might be able to do it I will get a GPS and try it out.
Would anyone else be interested in this?
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: OpenxGPS?

Post by mstrens »

Connecting a GPS sensor to oXs would require some changes to oXs. Those are perhaps not so easy for a beginner with programming.
But there is no obligation to connect the GPS sensor to OXS.
If you accept to connect it to an independant Arduino pro mini, you can use the code that cshunt provided in this thread on Jan 31.
Note: as you know probably, you can connect on the SPORT bus several devices (e.g. an oXs and an arduino/GPS). Just take take care to assign them different device ID.
nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: OpenxGPS?

Post by nigelsheffield »

That sounds easier for now!
It would be a nice addition to the openxsensor too.
Perhaps once I get it all working I will see how it might be pos to add it to openxsensor.
Incorporating it into openxconfig would be a challenge!
Thanks for your help.
I will get a GPS then and try cshunt program and go from there.
Nigel.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: OpenxGPS?

Post by mstrens »

I had a short look at the code provided by cshunt.
I noticed a small error: when a byte is sent to Tx on SPORT interface, the program should check that the byte is not 0x7E and not 0x7D.
If the byte is one of those 2 values, the code must send 2 bytes instead of 1. The first byte to send must be 0x7D and the second must be the original byte XOR with 0x20.
This is request because the SPORT protocol foresee that the value 0x7E is reserved for the master (the Receiver) to send a pooling command. So slaves (sensors) may not use this code.

nigelsheffield
Posts: 308
Joined: Fri Nov 08, 2013 9:56 pm
Country: -

Re: OpenxGPS?

Post by nigelsheffield »

Thanks, can you please point me to the code, is it easily fixed?
I think I would just add the GPS with its own arduino rather then trying to combine it on one arduino.
mstrens
Posts: 1435
Joined: Fri Dec 27, 2013 7:49 pm
Country: -

Re: OpenxGPS?

Post by mstrens »

In the file FrskySport.ino there is a function to send a byte (and calculate CRC).
You could add there the logic I explained.
Still you should also add it in the function that send the CRC (it is just after in the code)

Here the function that send a byte.

Code: Select all

// ***********************************************************************
void FrSkySPort_SendByte(uint8_t byte) {

  _FrSkySPort_Serial.write(byte);

  // CRC update
  crc += byte;         //0-1FF
  crc += crc >> 8;   //0-100
  crc &= 0x00ff;
  crc += crc >> 8;   //0-0FF
  crc &= 0x00ff;
}


Here for information the code being used in oXs ( in file Aserial.cpp); SwUartTXData contains the byte that is really transmit.

Code: Select all

          case TRANSMIT_STOP_BIT: //************************************* We send a stop bit
		if ( ByteStuffByte || (++TxCount < 8 ) )		// Have we sent 8 bytes?
		{
			if ( ByteStuffByte )
			{
				SwUartTXData = ByteStuffByte ;
				ByteStuffByte = 0 ;
			}
			else
                        {
		            if ( TxCount < 7 )		// Data (or crc)?
		            {
			        SwUartTXData = TxSportData[TxCount] ;
			        Crc += SwUartTXData ; //0-1FF
			        Crc += Crc >> 8 ; //0-100
			        Crc &= 0x00ff ;
		            }
		            else
		            {
			        SwUartTXData = 0xFF-Crc ; // prepare sending check digit
		            }
                            if ( ( SwUartTXData == 0x7E ) || ( SwUartTXData == 0x7D ) )
                  	        {
				  ByteStuffByte = SwUartTXData ^ 0x20 ;
				  SwUartTXData = 0x7D ;					
			    }
			}


Post Reply

Return to “OpenXVario - an open source vario supported by the open source firmwares!!”