Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FSK DAC: 1200bps telemetry over audio (similar to Bel202 encoding) #2202

Merged
merged 35 commits into from
Feb 26, 2016

Conversation

peabody124
Copy link
Contributor

This creates a PIOS_COM interace to the DAC output that creates
a 1200bps audio modem. The stream is modulated similarly to V.23
encoding using 1 start and 1 stop bits, 1 parity bit. The two symbols
are centered at 1200 and 2200 Hz.

The data source tested with this is the light telemetry module that was
developed for this purpose of low bandwidth telemetry, previously using
a hardware serial stream to audio modem chip.

This will be a pios_com interface that generates
Bell202 encoded data on the DAC DMA channel.
Because MARK is 1200Hz and SPACE is 2200Hz at 1200bps
there will not be an integer number of cycles for a
space. Thus we have to work out the phase we end each
symbol at and make sure to start the next one at that
phase.

This also drops the code that sends a mid-voltage
between symbols and it constantly outputs MARK when
awaiting a new byte.
This is required for FSKDAC since we use the middle of a
DMA to schedule what the next symbol should be, rather than
waiting to the end.
This makes sure we are prepared to send the next symbol when
the buffer swaps.
For some reason, disabling the DMA HT flag, which should
reduce the CPU utilization, ultimately results in some of
the start symbols being dropped. There doesn't appear to
be a clear software bug, so perhaps this is some kind of
hardware erata when rapidly toggling IRQ enables.
This is enough to hold the largest packet but too
small to hold two packets. This prevents them stacking
up in the COM buffer and introducing latency.
};

struct pios_fskdac_dev {
enum pios_fskdac_dev_magic magic;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra whitespace.

This provides the smoothed altitude and climb rate
For such a low bandwidth link we should send the smoothed
altitude rather than raw baro samples to reduce noise.
#include "manualcontrolcommand.h"
#include "flightstatus.h"
#include "positionactual.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alphabetization, my favorite!

@kubark42
Copy link
Contributor

Good stuff. I'm trusting that the modem math works, I haven't vetted it very closely. The only remaining question before merging is whether you'd like to move the #include modulesettings.h line down with the other UAVObjects.

@peabody124
Copy link
Contributor Author

Yeah the math works. If you have a clever thought about converting the phase alignment calculation
https://github.com/TauLabs/TauLabs/pull/2202/files#diff-66ff64856df7b2196f418ca7a9ebd111R221
to integer math I'd be happy to hear it, although would probably defer to another PR for improvement.

@peabody124
Copy link
Contributor Author

PS comments from review should be addressed now.

@kubark42
Copy link
Contributor

If you have a clever thought about converting the phase alignment calculation
https://github.com/TauLabs/TauLabs/pull/2202/files#diff-66ff64856df7b2196f418ca7a9ebd111R221
to integer math I'd be happy to hear it

Nothing instantly occurs to me, but I'm not sure the fmodf() function is that expensive since it is basically an FPU division followed by an FPU multiplication and subtraction. How much precision do you need?

kubark42 added a commit that referenced this pull request Feb 26, 2016
FSK DAC: 1200bps telemetry over audio
@kubark42 kubark42 merged commit 00c034a into TauLabs:next Feb 26, 2016
@mlyle
Copy link
Contributor

mlyle commented Feb 26, 2016

There's a bit more to it than that-- you burn significant precision with those operations.

https://github.com/eblot/newlib/blob/master/newlib/libm/math/ef_fmod.c

@peabody124
Copy link
Contributor Author

@kubark42 not much precision since it just determines an integer offset into the next buffer

@peabody124 peabody124 deleted the fskdac branch February 26, 2016 23:18
@kubark42 kubark42 changed the title FSK DAC: 1200bps telemetry over audio FSK DAC: 1200bps telemetry over audio (using Bel202 encoding) Feb 27, 2016
@kubark42 kubark42 changed the title FSK DAC: 1200bps telemetry over audio (using Bel202 encoding) FSK DAC: 1200bps telemetry over audio (similar to Bel202 encoding) Feb 27, 2016
* Schedule the next bit to be written by setting the address of the
* double buffer
*/
static void pios_fskdac_set_symbol(struct pios_fskdac_dev * fskdac_dev, uint8_t sym)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just looked at this section a little more. If you have a moment, a future PR which expanded the theoretic justification for this section would be most welcome. Perhaps just links to the documents you used to develop this would be enough to maintain it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Probably best for me to just explain here since I created this based on just tying to achieve continuous phase while transitioning between symbols.

Unfortunately good sources on Bell 202 are lacking, so I can't be sure this is fully compatible with hardware implementations. That would be reflected in the state system below as it reflects more on how you map a byte into a sequence of mark/space symbols.

@peabody124
Copy link
Contributor Author

BTW @kubark42 check out https://www.instagram.com/p/BCRgrnjFquF/ so now any FPV recording has a data log (slow).

@peabody124
Copy link
Contributor Author

Also @KipK not sure if you are still active but thought you might like this. I'd love to know if this is actually compatible with the chip you use in ghettostation.

@peabody124
Copy link
Contributor Author

screen shot 2016-02-27 at 12 07 27 pm

@kubark42
Copy link
Contributor

That's pretty neat stuff. Are you exporting it to KML?

@peabody124
Copy link
Contributor Author

@kubark42 yeah. And there is a neat gx:Track type that Google earth supports animates the flight path too, which is kind of fun

}

#if defined(PIOS_INCLUDE_FREERTOS)
portEND_SWITCHING_ISR((rx_need_yield || tx_need_yield) ? pdTRUE : pdFALSE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When compiling with FreeRTOS, this fails with unknown variables.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants