first i would like to thank you for sharing your work!
I am using the PPMOut with success and a eurgle 2.4 GHz transmitter module. PPM is working fine. Now i try to understand the ArduinoRCLib examples but get stuck because my programming skills are limited. I want to add to the PPMOut example some Expo to the poti connected on A0 but don't know to do this.
I understand, that g_PPMOut.update(); takes care about new values available in the input buffer. But i don't understand how to apply the Expo value to the input buffer :(
Unfortunately i could not find any working coding example that covers my needs. It would be very kind if you could give me a short coding example.
thanks in advance
Michael
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
First of all, sorry for the late reply, I was on vacation when you asked the question and didn't get to reading all of my email since I got back :)
The Expo class works on normalized values (-256 - 256), you'll need to convert your stick input from 0 - 1024 to -256 - 256 first. Then you apply expo, and then you convert it to microseconds and pass it to PPMOut. If you look at the PPMOut example, you will have to replace the body of the input loop with the following:
As you can see, first the analog input is mapped to the range -256 to 256. Then expo is applied (with one Expo object named g_expo, you can use one object per channel if that's what you need of course). The result is still in the -256 to 256 range, that is mapped to microseconds (1000 - 2000) and put in the input buffer. A more decent way is to set up a chain of AIPin, Expo and Channel objects instead (see the TX example).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2013-08-17
Hi,
thanks for your kind help, but i am still stuck with the code :(
the following code gives me an error: "void value not ignored as it ought to be"
Below is the complete code i use. It would be very kind if you could give me a helping hand by correcting the code.
thanks in advance for your help!
Michael
/* --------------------------------------------------------------------------- ** 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>#include<Expo.h>#define CHANNELS 4uint8_tg_pins[CHANNELS]={A0,A1,A2,A3};// Input pinsuint16_tg_input[CHANNELS];// Input buffer in microsecondsuint8_tg_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::PPMOutg_PPMOut(CHANNELS,g_input,g_work,CHANNELS);rc::Expog_expo;voidsetup(){// Initialize timer1, this is required for all features that use Timer1// (PPMIn/PPMOut/ServoIn/ServoOut)rc::Timer1::init();for(uint8_ti=0;i<CHANNELS;++i){// set up input pinspinMode(g_pins[i],INPUT);// fill input buffer, convert raw values to microsecondsg_input[i]=map(analogRead(g_pins[i]),0,1024,1000,2000);}// initialize PPMOut with some settingsg_PPMOut.setPulseLength(448);// pulse length in microsecondsg_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);}voidloop(){// update the input bufferfor(uint8_ti=0;i<CHANNELS;++i){// fill input buffer, convert raw values normalized, apply expo, convert to microsecondsint16_tnorm=map(analogRead(g_pins[i]),0,1024,-256,256);norm=g_expo.apply(norm);g_input[i]=map(exp,-256,256,1000,2000);}// tell PPMOut there are new values available in the input bufferg_PPMOut.update();}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, I made a mistake in my initial response... This line:
g_input[i] = map(exp, -256, 256, 1000, 2000);
should be
g_input[i] = map(norm, -256, 256, 1000, 2000);
When I wrote my initial response I had named the variable 'norm' 'exp', I renamed it halfway through, but forgot to update that line. Normally you'd get an "Unknown identifier 'exp'" error, but 'exp' already exists as a function (double exp(double)) which explains the error (it's trying to cast a function pointer to a long int).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2013-08-21
Hi,
great, now it runs fine :) i am starting to understand step by step the concept and allready spend smore and more time to understand the code and read the documentation.
thanks for your help!
Michael
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
first i would like to thank you for sharing your work!
I am using the PPMOut with success and a eurgle 2.4 GHz transmitter module. PPM is working fine. Now i try to understand the ArduinoRCLib examples but get stuck because my programming skills are limited. I want to add to the PPMOut example some Expo to the poti connected on A0 but don't know to do this.
I understand, that g_PPMOut.update(); takes care about new values available in the input buffer. But i don't understand how to apply the Expo value to the input buffer :(
Unfortunately i could not find any working coding example that covers my needs. It would be very kind if you could give me a short coding example.
thanks in advance
Michael
First of all, sorry for the late reply, I was on vacation when you asked the question and didn't get to reading all of my email since I got back :)
The Expo class works on normalized values (-256 - 256), you'll need to convert your stick input from 0 - 1024 to -256 - 256 first. Then you apply expo, and then you convert it to microseconds and pass it to PPMOut. If you look at the PPMOut example, you will have to replace the body of the input loop with the following:
As you can see, first the analog input is mapped to the range -256 to 256. Then expo is applied (with one Expo object named g_expo, you can use one object per channel if that's what you need of course). The result is still in the -256 to 256 range, that is mapped to microseconds (1000 - 2000) and put in the input buffer. A more decent way is to set up a chain of AIPin, Expo and Channel objects instead (see the TX example).
Hi,
thanks for your kind help, but i am still stuck with the code :(
the following code gives me an error: "void value not ignored as it ought to be"
norm = g_expo.apply();
g_input[i] = map(exp, -256, 256, 1000, 2000);
changing it to the following gives me an other error: "invalid conversion from 'double (*)(double)' to 'long int'"
norm = g_expo.apply(norm);
g_input[i] = map(exp, -256, 256, 1000, 2000);
Below is the complete code i use. It would be very kind if you could give me a helping hand by correcting the code.
thanks in advance for your help!
Michael
Sorry, I made a mistake in my initial response... This line:
should be
When I wrote my initial response I had named the variable 'norm' 'exp', I renamed it halfway through, but forgot to update that line. Normally you'd get an "Unknown identifier 'exp'" error, but 'exp' already exists as a function (double exp(double)) which explains the error (it's trying to cast a function pointer to a long int).
Hi,
great, now it runs fine :) i am starting to understand step by step the concept and allready spend smore and more time to understand the code and read the documentation.
thanks for your help!
Michael