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

pio_ppm - RC PPM protocol example works on GPIO 3 #414

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

elmot
Copy link

@elmot elmot commented Aug 20, 2023

An example of RC PPM protocol encoder using PIO
Resolves #197

pio/ppm/ppm.pio Outdated Show resolved Hide resolved
pio/ppm/ppm.c Outdated Show resolved Hide resolved
@elmot
Copy link
Author

elmot commented Aug 22, 2023

Needs to be fixed after testing with real hardware

pio/ppm/ppm.c Outdated Show resolved Hide resolved
pio/ppm/ppm.pio Outdated Show resolved Hide resolved
@lurch
Copy link
Contributor

lurch commented Aug 28, 2023

Oh, this should be targeted at the develop branch of pico-examples, rather than the master branch.

@elmot elmot changed the base branch from master to develop August 28, 2023 11:47
@elmot
Copy link
Author

elmot commented Aug 28, 2023

Redirected

@elmot
Copy link
Author

elmot commented Oct 5, 2023

@lurch any progress here?

@lurch
Copy link
Contributor

lurch commented Oct 5, 2023

I don't have commit / merge rights on this repo, that's up to somebody else 🙂

@jschwob
Copy link

jschwob commented Nov 20, 2023

Today I tested your code and found an issue. Using the ToolkitRC M6 Smart charger which includes a ppm monitor I found that the output could not be read. Since the device can also generate a PPM output I simply compared the waveforms and determined that that the signal was inverted. (This is common in the RC world. Blame futuba - Sbus is also inverted)
Here is the update I made to invert the signal.

.program ppm
.side_set 1

    set pindirs, 1  side 0; Set pin to output
.wrap_target
    out x, 16 side 1
delay0:
    jmp x-- delay0 side 1
    out x, 16 side 0
delay1:
    jmp x-- delay1 side 0
    .wrap

I'm working on a project that will use this code to interface on the trainer port of RC Transmitters. I haven't performed any value tests yet. Will post an update if I find any timing issues which would cause an incorrect value to be returned to the rc transmitter.

@lurch
Copy link
Contributor

lurch commented Nov 21, 2023

determined that that the signal was inverted.

It might be easier to use gpio_set_outover with GPIO_OVERRIDE_INVERT, than to rewrite the PIO code? 🤷

@jschwob
Copy link

jschwob commented Nov 21, 2023

That sounds like a great suggestion. I haven't had time to test it yet - my changes simply flipped the output bits. I also need to generate an inverted uart for Sbus so I'll give GPIO_Override_invert a shot and report my findings.

@jschwob
Copy link

jschwob commented Nov 22, 2023

I added this to the init portion:
gpio_set_outover(pin, GPIO_OVERRIDE_INVERT); //Invert output as rc transmitters expect inverted signal.

worked as expected and my tester read the signal w/o issue. No changes are required to the assembly code. Just need to add this to the init portion.

Testing: Initial tests show values requested were output +2 high. I have only tested it on one device so far. I don't have an accurate oscilloscope to validate the signal properly however I do have multiple flight controllers and other rc transmitters to read the values to validate the ppm signal with. I'll post more as I continue testing. So far this is working great and +2 seems reasonable all things considered.

@elmot
Copy link
Author

elmot commented Nov 23, 2023

@jschwob that story with inverted signals looks a bit strange. Existing code works well with Ardupilot flight controller, and I never seen any articles where PPM signal looks inverted. Can you, please, provide the any?

@jschwob
Copy link

jschwob commented Nov 23, 2023

Please see above for my testing methodology. I'm using a standard hobby charger and signal tester. ToolkitRC M6 Smart charger which includes a ppm monitor. The tester can also generate a standard ppm signal that works with rc receivers. I used this output signal to determine that the signal 'appeared' to be inverted on a hobby grade scope. Most of this stuff goes back to the 60's and 70's where parts counts had to be at an absolute minimum for cost on rc electronics. Was before my time. I don't think there is an 'official' spec for ppm. Its down to what each manufacture used back in the day and is still in use today.

I checked the Ardupilot documentation and it appears that they use an auto detect routine. My guess is that part of the auto detect routine is to check the signal inverted and un-inverted.

@jschwob
Copy link

jschwob commented Nov 23, 2023

I'm still testing it and will post results when I connect it to a transmitter trainer port on one of my transmitters. For my application I will add a setting to allow the user to choose inverted as default or non inverted.

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.

Pulse Position Modulation (PPM)
3 participants