{"id":13802019,"url":"https://github.com/redoxcode/micropython-ppm_reader","last_synced_at":"2025-08-23T18:07:48.076Z","repository":{"id":65011194,"uuid":"580709361","full_name":"redoxcode/micropython-ppm_reader","owner":"redoxcode","description":"A micropython library to decode PPM signals coming from a RC receiver","archived":false,"fork":false,"pushed_at":"2023-01-06T08:59:28.000Z","size":23,"stargazers_count":12,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-19T03:19:03.030Z","etag":null,"topics":["micropython","ppm","rc-receiver"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/redoxcode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-12-21T08:48:20.000Z","updated_at":"2025-04-10T20:57:42.000Z","dependencies_parsed_at":"2023-02-05T18:17:09.566Z","dependency_job_id":null,"html_url":"https://github.com/redoxcode/micropython-ppm_reader","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redoxcode%2Fmicropython-ppm_reader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redoxcode%2Fmicropython-ppm_reader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redoxcode%2Fmicropython-ppm_reader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/redoxcode%2Fmicropython-ppm_reader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/redoxcode","download_url":"https://codeload.github.com/redoxcode/micropython-ppm_reader/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250572177,"owners_count":21452326,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["micropython","ppm","rc-receiver"],"created_at":"2024-08-04T00:01:33.341Z","updated_at":"2025-04-24T05:30:53.420Z","avatar_url":"https://github.com/redoxcode.png","language":"Python","readme":"[![pypi version shield](https://img.shields.io/pypi/v/micropython-ppm_reader)](https://pypi.org/project/micropython-ppm_reader/) [![pypi downloads per month shield](https://img.shields.io/pypi/dm/micropython-ppm_reader?color=brightgreen)](https://pypi.org/project/micropython-ppm_reader/)\n## Description\nA micropython library to decode PPM signals coming from a RC receiver (as used for rc planes and drones).\n\nThis library is focused on savety and includes functions that can be used to detect a faulty or lost signal.\n**For this it is required to init the PpmReader class with the correct number of channels in the PPM signal. This might be a different number than the amount of servo connectors on the RC receiver hardware!**\n\nCreated for the use with pi pico, but should work on other boards as well.\nYou can find the [API documentation](https://github.com/redoxcode/micropython-ppm_reader/#API) and a few [examples](https://github.com/redoxcode/micropython-ppm_reader/#Examples) below.\n\n## Examples\n\n### Print the values of all channels\n```Python\nfrom ppm_reader import PpmReader\nppm_pin_id=28\nppm_channels=8\nppmReader=PpmReader(ppm_pin_id,ppm_channels)\nwhile True:\n    time.sleep(0.5)\n    print(ppmReader.get_values())\n```\n### Find the number of channels\n```Python\n#the number of channels should be known before you init PpmReader\n#if the channel number is incorrect only guess_channel_count will work\nfrom ppm_reader import PpmReader\nppm_pin_id=28\nppmReader=PpmReader(ppm_pin_id,channels=0)\nwhile True:\n    time.sleep(0.5)\n    print(ppmReader.guess_channel_count())\n```\n### Find values for min_value and max_value\n```Python\n#move the controls to the extreme positions and observe the values\nfrom ppm_reader import PpmReader\nppm_pin_id=28\nppm_channels=8\nppmReader=PpmReader(ppm_pin_id,ppm_channels)\nwhile True:\n    time.sleep(0.5)\n    print(ppmReader.get_raw_values())\n```\n### Check for a loss of signal\n```Python\nfrom ppm_reader import PpmReader\nppm_pin_id=28\nppm_channels=8\nppmReader=PpmReader(ppm_pin_id,ppm_channels)\n\n#wait initial connection with the remote\nwhile ppmReader.get_valid_packets() == 0:\n    print(\"waiting for connection ...\")\n    time.sleep(0.5)\nprint(\"connected.\")\n\n#got signal, continue to main loop\nwhile True:\n    last_packet_time=ppmReader.time_since_last_packet()\n    print(last_packet_time)\n    if last_packet_time\u003e25000: \n        #25ms without a new packet\n        #take security measures here (for example stop all motors)\n        print(\"connection lost\")\n        #wait for connection\n        while ppmReader.time_since_last_packet()\u003e25000:\n            pass\n        print(\"connected again\")\n    else:\n        #connection ok. Do something here\n        print(ppmReader.get_values())\n```\n\n## API\n### class PpmReader(pin_id,channels,min_value=1000,max_value=2000,packet_gap=4000)\n- pin_id: GPIO pin connected to the PPM signal comming from the RC receiver.\n- channels: Number of channels in the PPM signal. if the channel count is wrong the packts will be considered invalid.       \n- min_value: Minimum timeframe per channel in us (this should be around 1000us for standard equipment).\n- max_value: Minimum timeframe per channel in us (this should be around 2000us for standard equipment).   \n- packet_gap: Minimum time gap between packets in us (4000us should be used for standard equipment).\n\n```time_since_last_packet()```\n- returns the time passed since the last valid packet arrived in us. This will stay below about 5000us if every packet is received correctly. Missing 2 or 3 packets is usually not a problem.\n\n```get_valid_packets()```\n- returns the number of valid packets received\n\n```get_inalid_packets()```\n- returns the number of invalid packets received\n    \n```reset_packet_counters()```\n- resets counters for valid and invalid packets received\n    \n```get_raw_values()```\n- returns a list of all raw timeframes in us in the last valid packet received\n\n```get_raw_value(channel)```\n- returns the raw timeframe in us in the last valid packet received for a given channel\n- channel: channel to get the value from\n\n```get_values()```\n- returns a list of all values in the last valid packet maped to a range of 0.0 to 1.0 (values are not clipped)\n\n```get_value(channel)```\n- the value for a given channel in the last valid packet maped to a range of 0.0 to 1.0 (values are not clipped)\n- channel: channel to get the value from\n\n```get_values_bi()```\n- returns a list of all values in the last valid packet maped to a range of -1.0 to 1.0 (values are not clipped)\n\n```get_value_bi(channel)```\n- the value for a given channel in the last valid packet maped to a range of -1.0 to 1.0 (values are not clipped)\n- channel: channel to get the value fro\n\n\n```guess_channel_count()```\n- returns the number of channels in the last packet (incase you are not sure how many channels your signal has)\n","funding_links":[],"categories":["Libraries"],"sub_categories":["Communications"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredoxcode%2Fmicropython-ppm_reader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fredoxcode%2Fmicropython-ppm_reader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fredoxcode%2Fmicropython-ppm_reader/lists"}