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>#defineCHANNELS4uint8_tg_pins[CHANNELS]={A0,A1,A2,A3};//Inputpinsuint16_tg_input[CHANNELS];//Inputbufferinmicrosecondsuint8_tg_work[PPMOUT_WORK_SIZE(CHANNELS)];//weneedtohaveaworkbufferforthePPMOutclass//PPMOutrequirestwobuffers://Inputbuffercontaininginputsamplesinmicroseconds//Workbufferof((channels+1)*2)elementsforinternalcalculationsandframebuffering//Thissetupremovesanylimitonthenumberofchannelsyouwant,andmakessurethelibrarydoesn'tusemore//memorythanitreallyneeds,sincetheclientcodesuppliesthebuffers.rc::PPMOutg_PPMOut(CHANNELS,g_input,g_work,CHANNELS);rc::Expog_expo;voidsetup(){//Initializetimer1,thisisrequiredforallfeaturesthatuseTimer1//(PPMIn/PPMOut/ServoIn/ServoOut)rc::Timer1::init();for(uint8_ti=0;i<CHANNELS;++i){//setupinputpinspinMode(g_pins[i],INPUT);//fillinputbuffer,convertrawvaluestomicrosecondsg_input[i]=map(analogRead(g_pins[i]),0,1024,1000,2000);}//initializePPMOutwithsomesettingsg_PPMOut.setPulseLength(448);//pulselengthinmicrosecondsg_PPMOut.setPauseLength(10448);//lengthofpauseafterlastchannelinmicroseconds//note:thisisalsocalledtheendofframe,orstartofframe,andisusuallyaround10ms//startPPMOut,usepin9(pins9and10arepreferred)g_PPMOut.start(9);}voidloop(){//updatetheinputbufferfor(uint8_ti=0;i<CHANNELS;++i){//fillinputbuffer,convertrawvaluesnormalized,applyexpo,converttomicrosecondsint16_tnorm=map(analogRead(g_pins[i]),0,1024,-256,256);norm=g_expo.apply(norm);g_input[i]=map(exp,-256,256,1000,2000);}//tellPPMOuttherearenewvaluesavailableintheinputbufferg_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