I am new to the glouonpilot project (awesome job!) I want to adapt the EKF used in the Gluonpilot to work on my own autopilot system, but first I am trying to understand your implementation. I have a couple of questions regarding the ADC operations.
Firstly I will be using two dsPIC30F4011 MCUs interfaced to eachother via SPI. The dsPIC30F4011 does not have the DMA capabilities that the dsPic33FJ256MC71 has so I am unfamiliar with its functions.
1. Could you please explain qualitatively what is being done in the following lines of code (top of adc.c)?
- Code: Select all
// Number of locations for ADC buffer = 14 (AN0 to AN13) x 8 = 112 words
// Align the buffer to 128 words or 256 bytes. This is needed for peripheral indirect mode
unsigned int BufferA[MAX_CHNUM][SAMP_BUFF_SIZE]__attribute__((space(dma),aligned(256)));
unsigned int BufferB[MAX_CHNUM][SAMP_BUFF_SIZE]__attribute__((space(dma),aligned(256)));
In function ProcessADCSamples(unsigned int * AdcBuffer):
- Code: Select all
return (unsigned int) (((long)(AdcBuffer[0]/4 + AdcBuffer[1]/4 + AdcBuffer[2]/4 + AdcBuffer[3]/4) + (long)(AdcBuffer[4]/4 + AdcBuffer[5]/4 + AdcBuffer[6]/4 + AdcBuffer[7]/4)) / 2);
which is called in adc_get_channel(int i) and returns:
- Code: Select all
return ProcessADCSamples(&BufferA[i][0]) / 2 + ProcessADCSamples(&BufferB[i][0]) / 2;
what are the operations doing? Could you maybe explain using an example with a binary number?
2. You have acc_value_g = 6600, where is this value from? What does it represent?
3. Finally, the neutral values (ex. config.sensors.gyro_x_netural). Are they the bias values that are read when the sensors are being held still on a level surface?
Thank you and regards,
Tinus