Adc

From Paparazzi

Jump to: navigation, search

check your schematics, see which pin you have a free ADC ig. pin27 at he arm7


see sw/airborne/arm7/adc_hw.c


pin27 AD0.6  P0.4    PINSEL0 3 <<  8


add to : conf/autopilot/tiny_sense.h


// ONBOARDCAM
#define ADC_3 AdcBank0(6)
#ifdef USE_ADC_3
#ifndef USE_AD0
#define USE_AD0
#endif
#define USE_AD0_6
#endif</p>


now you can use it in your airframe file an gif it a name:


conf/airframes/TUDelft/EasyStarSense.xml

 <section name="adc" prefix="ADC_CHANNEL_">
   <define name="ONBOARDCAMA" value="ADC_3"/>
   <define name="ONBOARDCAMA_NB_SAMPLES" value="32"/>
 </section>


add this to the bottom of your airframe file


ap.CFLAGS += -DADC -DUSE_ADC_3


and use it for instance in a modulle: sw/airborne/modules/onboardcam/onboardcam.c


#include "adc.h"


#ifndef ADC_CHANNEL_ONBOARDCAMA 
#error "ON BOARD CAM needs ADC_CHANNEL_ONBOARDCAMA or ADC_CHANNEL_ONBOARDCAMB"
#endif


static struct adc_buf buf_onboardcama;


void init_onboardcam(void)
{
  adc_buf_channel(ADC_CHANNEL_ONBOARDCAMA, &buf_onboardcama, ADC_CHANNEL_ONBOARDCAMA_NB_SAMPLES);
}
Personal tools