Librairie RC pour générer signal PPM

Bonsoir à tous,

Actuellement je bosse sur un projet qui consiste à actionner des servos moteur sur 8 channel à la sortie d’un récepteur en envoyant un signal ppm via un émetteur à l’aide d’une carte Nano.

J’ai trouvé un exemple de programme appelé “PPM-OUT” pour 4 channel dans la librairie RC que j’aimerais modifié:

/* ---------------------------------------------------------------------------
** This software is in the public domain, furnished “as is”, without technical
** support, and with no warranty, express or implied, as to its usefulness for
** any purpose.
**
** ppmout_example.pde
** Demonstrate Pulse Position Modulation Output functionality
**
** Author: Daniel van den Ouden
** Project: ArduinoRCLib
** Website: http://sourceforge.net/p/arduinorclib/
** -------------------------------------------------------------------------*/

#include <PPMOut.h>
#include <Timer1.h>

#define CHANNELS 4

uint8_t g_pins[CHANNELS] = {A0, A1, A2, A3}; // Input pins
uint16_t g_input[CHANNELS]; // Input buffer in microseconds
uint8_t g_work[PPMOUT_WORK_SIZE(CHANNELS)]; // we need to have a work buffer for the PPMOut class

// PPMOut requires two buffers:
// Input buffer containing input samples in microseconds
// Work buffer of ((channels + 1) * 2) elements for internal calculations and frame buffering
// This setup removes any limit on the number of channels you want, and makes sure the library doesn’t use more
// memory than it really needs, since the client code supplies the buffers.
rc::PPMOut g_PPMOut(CHANNELS, g_input, g_work, CHANNELS);

void setup()
{
// Initialize timer1, this is required for all features that use Timer1
// (PPMIn/PPMOut/ServoIn/ServoOut)
rc::Timer1::init();

for (uint8_t i = 0; i < CHANNELS; ++i)
{
// set up input pins
pinMode(g_pins*, INPUT);*

  • // fill input buffer, convert raw values to microseconds*
    g_input = map(analogRead(g_pins*), 0, 1024, 1000, 2000);
    _ }*_

* // initialize PPMOut with some settings*
* g_PPMOut.setPulseLength(448); // pulse length in microseconds*
* g_PPMOut.setPauseLength(10448); // length of pause after last channel in microseconds*
* // note: this is also called the end of frame, or start of frame, and is usually around 10ms*

* // start PPMOut, use pin 9 (pins 9 and 10 are preferred)*
* g_PPMOut.start(9);
_}
void loop()
{
// update the input buffer*
* for (uint8_t i = 0; i < CHANNELS; ++i)*
* {
// fill input buffer, convert raw values to microseconds*
g_input = map(analogRead(g_pins*), 0, 1024, 1000, 2000);*
* }*_

* // tell PPMOut there are new values available in the input buffer*
* g_PPMOut.update();
_}
Voici ce que j’ai codé pour régler les fins de course des servos à l’aide de potentiomètre et qui ne fonctionne pas j’ai besoin de votre merci d’avance :
#include <PPMOut.h>
#include <Timer1.h>
#define CHANNELS 4*

int etat;
int inter = 7;
int tempo;
int pot1 = A0;
int pot2 = A1;
uint16_t g_input[CHANNELS]; // Input buffer in microseconds
uint8_t g_work[PPMOUT_WORK_SIZE(CHANNELS)]; // we need to have a work buffer for the PPMOut class
rc::PPMOut g_PPMOut(CHANNELS, g_input, g_work, CHANNELS);
void setup()
{
* pinMode(inter, INPUT);
pinMode(pot1, INPUT);
pinMode(pot2,INPUT);
digitalWrite(inter,LOW);
Serial.begin(9600);
// Initialize timer1, this is required for all features that use Timer1*

* // (PPMIn/PPMOut/ServoIn/ServoOut)
rc::Timer1::init();
etat = digitalRead(inter);
if (etat == HIGH)
{_

g_input[0]= 1900;
g_input[1]= 1900;
g_input[2]= 1000;
g_input[3] = map(analogRead(pot1), 0, 1024, 1000, 1500);*

* }*
* else*
* {*
* g_input[0]= 1000;
g_input[1]= 1000;
g_input[2]= 1000;
g_input[3]= map(analogRead(pot2), 0, 1024, 1500, 2000);*

* }*
* // initialize PPMOut with some settings*
* g_PPMOut.setPulseLength(448); // pulse length in microseconds*
* g_PPMOut.setPauseLength(10448); // length of pause after last channel in microseconds*
* // note: this is also called the end of frame, or start of frame, and is usually around 10ms*

* // start PPMOut, use pin 9 (pins 9 and 10 are preferred)*
* g_PPMOut.start(10);
_}
void loop()
{
etat = digitalRead(inter);
// update the input buffer*

* if (etat == HIGH)
{_

g_input[0]= 1900;
g_input[1]= 1900;
g_input[2]= 1000;
g_input[3] = map(analogRead(pot1), 0, 1024, 1000, 1500);*

* }*
* else*
* {*
* g_input[0]= 1000;
g_input[1]= 1000;
g_input[2]= 1000;
g_input[3]= map(analogRead(pot2), 0, 1024, 1500, 2000);
_ }
Serial.print(“Valeur”);
Serial.print(etat);_

g_PPMOut.update();
_}*_