Forum Menu




 


Log in Problems?
New User? Sign Up!
AVR Freaks Forum Index

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
Qbo_electronics
PostPosted: Aug 20, 2011 - 01:15 PM
Newbie


Joined: Jun 14, 2009
Posts: 15


Hi there,
I started again play with modules. I uploaded LowPower from BitCloud_ZIGBIT_1_12_0. And there is comunication via air. I changed short adres and CS_UID. Network joins but end device doesn't go sleeps(GreenLed always is on) and doesn't send sensor measurment.Either coordinator doesn't send data by USART. Could you tell me what i do wrong?

Regards,
Qbo
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Aug 20, 2011 - 04:32 PM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA

What hardware do you have?

_________________
The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Qbo_electronics
PostPosted: Aug 20, 2011 - 05:58 PM
Newbie


Joined: Jun 14, 2009
Posts: 15


That was the problem.I don't have light and temperature sensors. I've changed application in the way it starts from battery and stays in this measurement. I don't use channel 0 for this measurement but channel 1 that why battery.c was modified(HAL_ReadAdc(HAL_ADC_CHANNEL1)). In this channel I have voltage divider but the reading which i get is wrong. I changed reference voltage to AVCC because i use it. I fight with this ADC more then week and i thought i do something wrong but now i don't really understand why the readings are different while I'm using battery code. For example i will give some code of ADC init and measurement which i made before.
Code:

static HAL_AdcParams_t PotentiometrADC=               //descriptor adc
{
    .resolution        = RESOLUTION_8_BIT,
    .sampleRate        = ADC_4800SPS,
    .voltageReference  = AVCC,
    .bufferPointer     = &Buffer.ADCData,
    .selectionsAmount  = 1,
};

and measurement

void ADCmeasurement(void){
   HAL_OpenAdc(&PotentiometrADC);
   HAL_ReadAdc(HAL_ADC_CHANNEL1);
   voltADC = ((Buffer.ADCData *3300ul*2ul)/256ul); 
   
}


Thanks Alex for answer.


Last edited by Qbo_electronics on Aug 20, 2011 - 06:05 PM; edited 1 time in total
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Aug 20, 2011 - 06:04 PM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA

What is "wrong"? Give more information: real AVcc voltage, value of Buffer.ADCData after the measurement.

Battery code applies some scaling after measurement is taken to convert acquired to mV units. Do you take this into account?

_________________
The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Qbo_electronics
PostPosted: Aug 20, 2011 - 06:06 PM
Newbie


Joined: Jun 14, 2009
Posts: 15


I've updated. It looks like that the divider is resistor with termistor. The measurement don't change at all with temperature.
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Aug 20, 2011 - 06:10 PM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA

After HAL_ReadAdc() you need to wait for confirmation callback.

LE: which you don't even fill:
Code:
adcParam.callback = batteryCallback;
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Qbo_electronics
PostPosted: Aug 20, 2011 - 06:15 PM
Newbie


Joined: Jun 14, 2009
Posts: 15


Ok, I thought about it. But if I changed the battery.c code (in LowPower application) only measurement channel from 0 to 1 the callback stay this same. Am I wrong?
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Aug 20, 2011 - 06:26 PM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA

If you change battery.c code, then yes, it will be the same, but this code:
Code:

   HAL_ReadAdc(HAL_ADC_CHANNEL1);
   voltADC = ((Buffer.ADCData *3300ul*2ul)/256ul); 
is just wrong, Buffer.ADCData at this point contains garbage.

Also, conversion formula is different for different reference voltages.

What voltage do you have for AVcc and what is the input voltage?

_________________
The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Qbo_electronics
PostPosted: Aug 20, 2011 - 06:32 PM
Newbie


Joined: Jun 14, 2009
Posts: 15


In ADC1 pin i've have 2.2 V but it's no problem of conversion formula(I will change it). Now i just won't to make a measurement. Because if i have thermistor and i put near lighted match the voltage which I get should change (in Low power application). I add that I've checked all connections and voltages in hardware and with temperature voltage is changing on adc pin.
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Aug 20, 2011 - 06:37 PM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA

I'm asking for the last time, what voltage do you have on the AVcc pin? What reading do you get? How much it is changing? Can you put there potentiometer to get consistent readings?

_________________
The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Qbo_electronics
PostPosted: Aug 20, 2011 - 06:46 PM
Newbie


Joined: Jun 14, 2009
Posts: 15


I have digital VDD 3.3V thus AVCC I think is filtered digital supply. Voltage is changing 1.5V to 2.2V because its NTC thermistor. It's in 0603 package. But If I short pin to GND reading is this same. Reading which I get via USART is 206 mV.
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Aug 20, 2011 - 06:50 PM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA

Try without conversion to mV first, to see real ADC value.

_________________
The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Qbo_electronics
PostPosted: Aug 20, 2011 - 07:01 PM
Newbie


Joined: Jun 14, 2009
Posts: 15


Code:

  value = (batteryControl.batteryData);

I made it and reading is 13. Short to 3.3V or GND has no effect.
 
 View user's profile Send private message  
Reply with quote Back to top
Qbo_electronics
PostPosted: Aug 20, 2011 - 07:41 PM
Newbie


Joined: Jun 14, 2009
Posts: 15


I'm confused because I was curious and checked what tells other ADCs channels. At second was reference (253 almost 3.3V) and my multimetr says 0V .Then I back to channel 1 and it was no 13 just 253. Still no response for short to GND. It looks like that it is non volatile value or something wrong with adresses. I'm using IAR.Could it be something with ESD? I play around the hardware for a while. Have you got any other idea?
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Aug 21, 2011 - 06:05 PM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA

Well, I don't know, it is hard to say without having the hardware. You may try to use direct AVR registers access instead of BitClout API, just to make sure.

_________________
The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Qbo_electronics
PostPosted: Aug 21, 2011 - 07:10 PM
Newbie


Joined: Jun 14, 2009
Posts: 15


I tried today. No effect. Tomorrow I will buy new modules because also must make more nodes. We will see. Thanks Alex for help,have a nice end of sunday.
 
 View user's profile Send private message  
Reply with quote Back to top
Qbo_electronics
PostPosted: Aug 23, 2011 - 07:52 PM
Newbie


Joined: Jun 14, 2009
Posts: 15


Hi there, i desoldered old module ad put in this place now one. Everthing works good. I dont know what was the reason. Alex i have a question. When the node goes in the sleep mode(power-down,power-save etc.). I won't to set/clear pin(0,1) and stay in this state(0 or 1) for time when it sleeps or . It is possible?If yes where I can look for it?
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Aug 23, 2011 - 08:00 PM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA

Sleep modes preserve pins state, set them to whatever value you like, just remember that I/O pins may also drain your battery.

_________________
The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Qbo_electronics
PostPosted: Aug 27, 2011 - 09:12 PM
Newbie


Joined: Jun 14, 2009
Posts: 15


Hi,
I don't understand something. I play with the lowpower application and want to get in all sensor type this same reading. For example I have BSP task handler.
Code:
void BSP_TaskHandler(void)
{
  if (bspTaskFlags & BSP_BUTTONS)
  {
    bspTaskFlags &= (~BSP_BUTTONS);
    bspButtonsHandler();
  }
  if (bspTaskFlags & BSP_TEMPERATURE)
  {
    bspTaskFlags &= (~BSP_TEMPERATURE);
    //bspLM73Handler();
    bspBatteryHandler();
  }
  if (bspTaskFlags & BSP_BATTERY)
  {
    bspTaskFlags &= (~BSP_BATTERY);
    bspBatteryHandler();
  }
  if (bspTaskFlags)
  {
    SYS_PostTask(BSP_TASK_ID);
  }
}

And I have identical read sensor funcitions
Code:

void boardAbstractionReadSensor(AppSensorType_t t, AppSensorCallback_t cb)
{
  if (APP_SENSOR_TYPE_TEMPERATURE == t)
  {
    batteryCallback = cb;
    BSP_ReadBatteryData(batterySensorHandler);
  }
  if (APP_SENSOR_TYPE_BATTERY == t)
  {
    batteryCallback = cb;
    BSP_ReadBatteryData(batterySensorHandler);
    return;
  }
  cb(false, 0);
}

When the network is working reading for battery is right but for temperature sensor is 0. This looks like the buffer(appMessageBuffer.msg.report.value) when reading temp task have result false. Even if I modify in battery.c task -> bspPostTask(BSP_TEMPERATURE); has no reasponse. Could You tell me what I do wrong?
 
 View user's profile Send private message  
Reply with quote Back to top
alexru
PostPosted: Aug 28, 2011 - 09:24 AM
Raving lunatic


Joined: Apr 15, 2009
Posts: 4857
Location: San Jose, CA

You've forgot to copy "return" statement in the first "if", so it calls callback right away.

_________________
The opinions and views expressed by me on this forum are my own and do not represent my employer or anyone else that I’m affiliated with.
 
 View user's profile Send private message Send e-mail Visit poster's website 
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT + 1 Hour
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2006 The PNphpBB Group
Credits