| Author |
Message |
|
|
Posted: Oct 08, 2009 - 01:14 PM |
|

Joined: Dec 04, 2007
Posts: 2382
Location: UK London
|
|
Hi All
Has any got the ADC working the bitcloud.
I am calling this hal function from the battery function in the bitcloud, so this way the result is displayed on the WSN monitor software.
Another issue is how do i clean the make files on hal directory, because if a edit the adc assocated file to aid me in debugging, it makes no differnce. Even if i make errors by purpose the bitcloud does not detect it.
Regards
DJ |
|
|
| |
|
|
|
|
|
Posted: Oct 08, 2009 - 03:11 PM |
|


Joined: Apr 15, 2009
Posts: 4869
Location: San Jose, CA
|
|
|
djoshi wrote:
Has any got the ADC working the bitcloud.
I am calling this hal function from the battery function in the bitcloud, so this way the result is displayed on the WSN monitor software.
A lot of people did. What the problem with it? Show your code.
djoshi wrote:
Another issue is how do i clean the make files on hal directory, because if a edit the adc assocated file to aid me in debugging, it makes no differnce. Even if i make errors by purpose the bitcloud does not detect it.
Go to HAL directory and run 'make clean all' there. After it rebuild your application. |
|
|
| |
|
|
|
|
|
Posted: Oct 09, 2009 - 10:22 PM |
|

Joined: Dec 04, 2007
Posts: 2382
Location: UK London
|
|
Sorry for the delay
Code:
int tu=0;
static void lightDataReady(bool result, int16_t light)
{
if (tu==0)
{
tu=1;
soil();
} if (result)
appMessage.data.meshbean.light =HAL_OpenAdc(&adc_soil);
else
appMessage.data.meshbean.light =HAL_OpenAdc(&adc_soil);
#ifdef _BATTERY_SENSOR_
assert(SUCCESS == BSP_ReadBatteryData(batteryDataReady), 0xf003);
#else
batteryDataReady(80);
#endif // _BATTERY_SENSOR_}
}
The reason why i do
Code:
appMessage.data.meshbean.light =HAL_OpenAdc(&adc_soil);
is for debug, i just want to see the return value which is always -1/
Code:
void soil(void)
{
adc_soil.resolution=RESOLUTION_8_BIT ;//8-bit
adc_soil.sampleRate=ADC_4800SPS;
adc_soil.voltageReference=INTERNAL_2d56V;
adc_soil.bufferPointer=&adc_soilvar;
adc_soil.selectionsAmount=1;
ptrfunc = retsoil;
adc_soil.callback=retsoil;
}
void retsoil(void)
{
}
I call soil() only once
DJ |
|
|
| |
|
|
|
|
|
Posted: Oct 10, 2009 - 07:44 AM |
|


Joined: Apr 15, 2009
Posts: 4869
Location: San Jose, CA
|
|
The only reasons to return -1 from HAL_OpenAdc() are following:
Code:
if (IDLE != halAdcState)
return -1;
if (NULL == param)
return -1;
if (NULL == param->bufferPointer)
return -1;
if (param->resolution > RESOLUTION_10_BIT)
return -1;
/* unsupported voltage reference */
if (param->voltageReference & 0x3F)
return -1;
/* adc speed must be only 9600 or 4800 SPS for 10 bit resolution */
if ((RESOLUTION_10_BIT == param->resolution) && (param->sampleRate < ADC_9600SPS))
return -1;
You may call soil() as many times as you want. HAL_OpenAdc() must be called only once (all other checks are passed). |
|
|
| |
|
|
|
|
|
Posted: Oct 18, 2009 - 01:51 PM |
|

Joined: Dec 04, 2007
Posts: 2382
Location: UK London
|
|
Dear Alex
Once all this is setup , i am executing HAL_ReadAdc , but where do i read the ADC reading?
DJ |
_________________ Thanks
Regads
DJ
|
| |
|
|
|
|
|
Posted: Oct 18, 2009 - 01:53 PM |
|


Joined: Apr 15, 2009
Posts: 4869
Location: San Jose, CA
|
|
|
djoshi wrote:
Once all this is setup , i am executing HAL_ReadAdc , but where do i read the ADC reading?
After all the data acquired callback function will be called. (retsoil() in your case) |
|
|
| |
|
|
|
|
|
Posted: Oct 18, 2009 - 02:09 PM |
|

Joined: Dec 04, 2007
Posts: 2382
Location: UK London
|
|
I do not understand i first set all parameters, and then call open_adc.
I preumsed at this time the function void retsoil would be called.
Now i am running open_adc, so where does the adc reading get stored.
Should i be modifying my retsoil, so it takes int agrument as an input.
Regards
DJ |
_________________ Thanks
Regads
DJ
|
| |
|
|
|
|
|
Posted: Oct 18, 2009 - 02:17 PM |
|


Joined: Apr 15, 2009
Posts: 4869
Location: San Jose, CA
|
|
1. Setup parameters. Including buffer pointer to store data (bufferPointer) and function to call after all data has been read (callback).
2. Call HAL_OpenADC()
3. Do anything else (or just wait). When data will be available callback function will be called. That means that readings at bufferPointer[] are valid
4. Use data at bufferPointer[]. |
|
|
| |
|
|
|
|
|
Posted: Oct 18, 2009 - 10:35 PM |
|

Joined: Dec 04, 2007
Posts: 2382
Location: UK London
|
|
Thanks i just got it working.
Ok what i am doing is using power regulator to test ADC. I have set my internal ref to 2.56.
I am now inputing another 2.5V into pin1 which is ADC channel 1.
The reading i am getting is 202. Does this sound correct?
One of the device that i am using the ADC requires a wait of 300ms once the sensor is powered up. What is the best way to implment the delay.
Only way i can think of is power the device, go to sleep , wake up, read the voltage and then power off.
By the way, the max voltage my sensor outputs is 3V, so my ref voltage will be 3.3V, which is my reg, so where would i connect this, is it AVCC or AREF.
Regards
DJ |
|
|
| |
|
|
|
|
|
Posted: Oct 19, 2009 - 06:40 AM |
|


Joined: Apr 15, 2009
Posts: 4869
Location: San Jose, CA
|
|
|
djoshi wrote:
The reading i am getting is 202. Does this sound correct?
It depends on ADC settings but looks incorrect for me. Try shorting ref.voltage to input pin to see if you get full scale value. And then short ground to input to see if you get something about 0.
djoshi wrote:
One of the device that i am using the ADC requires a wait of 300ms once the sensor is powered up. What is the best way to implment the delay.
Use HAL_AppTimerStart()
djoshi wrote:
Only way i can think of is power the device, go to sleep , wake up, read the voltage and then power off.
If you need to lower power consumption then you may try this.
djoshi wrote:
By the way, the max voltage my sensor outputs is 3V, so my ref voltage will be 3.3V, which is my reg, so where would i connect this, is it AVCC or AREF.
Read the datasheet. |
|
|
| |
|
|
|
|
|
Posted: Oct 19, 2009 - 07:19 PM |
|

Joined: Dec 04, 2007
Posts: 2382
Location: UK London
|
|
Hi Alex
Just checked the REF voltage, it is 3.3V even though i have set it to 2.56V.
I have also set my reading to be 8-bit, so i presume that what i am reading which is about 200 is correct.
e.g. if 3.3V = 255, this mean 1V=77.27
So 2.56V=198
But why doesnt the 2.56V become my ref voltage?
These are my settings.
Code:
adc_soil.resolution=RESOLUTION_8_BIT ;//8-bit
adc_soil.sampleRate=ADC_4800SPS;
adc_soil.voltageReference=INTERNAL_2d56V;
adc_soil.bufferPointer=&adc_soilvar;
adc_soil.selectionsAmount=1;
ptrfunc = retsoil;
adc_soil.callback=retsoil;
DJ |
|
|
| |
|
|
|
|
|
Posted: Oct 19, 2009 - 07:28 PM |
|


Joined: Apr 15, 2009
Posts: 4869
Location: San Jose, CA
|
|
|
djoshi wrote:
I have also set my reading to be 8-bit, so i presume that what i am reading which is about 200 is correct.
e.g. if 3.3V = 255, this mean 1V=77.27
So 2.56V=198
But why doesnt the 2.56V become my ref voltage?
Your calculations are correct. I'll check tomorrow what is the thing with ref. voltage. |
|
|
| |
|
|
|
|
|
Posted: Oct 19, 2009 - 07:51 PM |
|

Joined: Dec 04, 2007
Posts: 2382
Location: UK London
|
|
Ok Thanks You
According to the Raven sechmatic there is 0ohms from AVCC to AREF.
DJ |
_________________ Thanks
Regads
DJ
|
| |
|
|
|
|
|
Posted: Oct 20, 2009 - 07:12 AM |
|


Joined: Apr 15, 2009
Posts: 4869
Location: San Jose, CA
|
|
|
djoshi wrote:
According to the Raven sechmatic there is 0ohms from AVCC to AREF.
Yes, you need to remove R201. Otherwise you must select AVCC only. |
|
|
| |
|
|
|
|
|
Posted: Oct 22, 2009 - 01:52 PM |
|

Joined: Dec 04, 2007
Posts: 2382
Location: UK London
|
|
| Thanks i think i can do with a 3.3V REF |
_________________ Thanks
Regads
DJ
|
| |
|
|
|
|
|
Posted: Oct 26, 2009 - 10:28 AM |
|

Joined: Dec 04, 2007
Posts: 2382
Location: UK London
|
|
Now that its working.
I normally lets ADC run 10 times and i take the average of the 10 readings.
This is better then taking the first reading
How does the HAL do this, or do i start and stop the ADC 10 times, as there is no conintious mode?
Regards
DJ |
_________________ Thanks
Regads
DJ
|
| |
|
|
|
|
|
Posted: Oct 26, 2009 - 11:20 AM |
|


Joined: Apr 15, 2009
Posts: 4869
Location: San Jose, CA
|
|
|
djoshi wrote:
How does the HAL do this, or do i start and stop the ADC 10 times, as there is no conintious mode?
adc_soil.selectionsAmount=10; And provide enough space in buffer. |
|
|
| |
|
|
|
|
|
Posted: Nov 13, 2009 - 06:25 PM |
|

Joined: Oct 07, 2009
Posts: 37
|
|
I´m having problems with the same function.
Let me show my code:
HAL_AdcParams_t ADCParametros;
int mirehal_read_universal_inputs(channel canal, unsigned short int *result)
{
ADCParametros.resolution = RESOLUTION_10_BIT;
ADCParametros.voltageReference = AREF;
ADCParametros.selectionsAmount = 1;
ADCParametros.bufferPointer = result;
ADCParametros.sampleRate = ADC_9600SPS;
ADCParametros.callback = NULL;
if( HAL_CloseAdc () == -1 ) {
boardAbstractionShowString("ADC its already closed");
//return 1; //unsupported parameter or ADC is busy
} else {
boardAbstractionShowString("ADC its already open");
}
if( HAL_OpenAdc(&ADCParametros) == -1 ) {
boardAbstractionShowString("Error -1 on ADC");
//return 1; //unsupported parameter or ADC is busy
} else {
boardAbstractionShowString("Sucess on ADC");
}
What is happen is that: First i check i the adc is already open and i´m receiving the answer that was not. But when try to open it, i just receive the "-1" error. Could anyone help me?
*I´m making my code above the blink.c sample.
Another with is the i don´t understand, what do you mean with "make clean all there". Because i try to chance the return error to identify why of the mistake but i´m unsucessfull.
Thanks |
|
|
| |
|
|
|
|
|
Posted: Nov 13, 2009 - 07:15 PM |
|


Joined: Apr 15, 2009
Posts: 4869
Location: San Jose, CA
|
|
|
oximer wrote:
What is happen is that: First i check i the adc is already open and i´m receiving the answer that was not. But when try to open it, i just receive the "-1" error. Could anyone help me?
I see no problems with above code.
oximer wrote:
Another with is the i don´t understand, what do you mean with "make clean all there". Because i try to chance the return error to identify why of the mistake but i´m unsucessfull.
After you made changes go to HAL/ directory and invoke 'make clean all' from command line. This will actually rebuild HAL library. After this build your own application as always. |
|
|
| |
|
|
|
|
|