problems with mesuring power

Hi,
Now i’m doing a program to measure voltage . I’m having hardware problem now “where should i connect the voltage source?” . I try to connect to one of the ADC “AUX/ADC” and it’s not working. Then we try to connect to the "CT103/TXD1 " , it’s also not working!! so if you know where to connect please help us!
best regards,
fonix
p.s i put some link to the photo how we connect .
i274.photobucket.com/albums/jj27 … MG2229.jpg
i274.photobucket.com/albums/jj27 … MG2221.jpg

Hi,
I’m friend of Fonix . We doing a school project about how to mesure voltage using Q2686 . This is the code we copy form some place and use it . We not sure if it’s correct or not . If we run the program run smoothly . But we don’t get the value we want . The code say it read from flash memory . But we not sure if ADC save the value in the flash memory or not . Even if it save into the flash memory we don’t the address to retrive . Please help us . We use both AUX/ADC ( ADC) and GPIO34 . both are not working . Please help us !!

s32 sLen;
static const ascii * tele_NameBuffer = "Wavecom Telemetry";

static const ascii * _TELE_STR_TL_CMD = "at+TEL";
static const ascii * _TELE_STR_IOSET_CMD = "at+IOSET";
static const ascii * TELE_STR_TELESTART_CMD = "at+TELESTART";
#define TELE_STR_TL_CMD         ( ascii * ) _TELE_STR_TL_CMD
#define TELE_STR_IOSET_CMD      ( ascii * ) _TELE_STR_IOSET_CMD

// Boundaries for Wireless CPU
static u8 TELE_IO_MIN;
static u8 TELE_IO_MAX;

// Label conversion macros
#define TELE_IO_VALUE2LABEL(_x) ( _x - TELE_IO_MIN + 1 )
#define TELE_IO_LABEL2VALUE(_x) ( _x - 1 + TELE_IO_MIN )

static adl_ioProductTypes_e telemetry_ProductType;
static u32 GpioPollingTime = 30; // in 1/10 of a second
static ascii reportnumber [ 20 ];
static s8 sms_telemetry_Handle_txt;
static s8 telemetry_internal_handle = ERROR;
static bool telemetry_appliState = FALSE;     // Application Main State 
static bool extSendSMS = FALSE;
static u8 TELE_TRACE_LEVEL;
static ascii * tele_PinCode;

// Features reserved GPIOs
static u8 tele_ReservedIoForFeaturesCount;
static u8 tele_ReservedIoForFeatures [ ADL_IO_MAX_NB ];

// Available GPIOs for subscription
static u8 tele_AvailableIoCount;
static u8 tele_AvailableIo [ ADL_IO_MAX_NB ];

// Currently subscribed GPIOs
static u8 tele_CurrentIoTableCount;
static u8* tele_CurrentIoTable;

// GPIO events handle
static s8 tele_GpioEventHandle;

// Last read inputs
static adl_ioRead_t * tele_ioLastReadInputs;

// Running retry timer structure
static adl_tmr_t * tele_tmrRetryHandle;
static u16 TELE_OBJECT_FLASH_IOSET;
//void tele_GpioSubscription ( void )
//{
    
//}
void adl_main ( adl_InitType_e InitType )
{
    
    TRACE (( 1, "Embedded Application : Main" ));
    tele_CurrentIoTable = adl_memGet ( sLen );
            
            // Read settings from flash
            adl_flhRead ( tele_NameBuffer, TELE_OBJECT_FLASH_IOSET, sLen, tele_CurrentIoTable );
            tele_CurrentIoTableCount = sLen;
            TRACE (( 1, "GPIO settings read from flash (%d GPIO)", tele_CurrentIoTableCount ));
}

Best regards,
Thia
ps. this is the trace we get .
i274.photobucket.com/albums/jj27 … screen.jpg

  1. ADC values are not stored in flash (unless you write them there yourself).
  2. The ADL library doesn’t seem to support reading the ADC directly. Yet another missing feature of ADL.

So, it looks like you have to use “AT+ADC?”. Since you’re writing an ADL application, you probably want something like:

adl_atCmdCreate("AT+ADC?", FALSE, YourResponseHandler, "+ADC: ", NULL);

Thank Matt Otto for your reply!
The code i write for the checking for voltage value from ADC is as shown below.

u8 ADC_Response_Handler (adl_atResponse_t *paras)
{
    /*none of the response of the ‘at+clcc’ command is subscribed but because
the 2nd argument is set to true, all will be sent to the external application*/

adl_atCmdCreate("AT+ADC?", TRUE, (adl_atRspHandler_t)ADC_Response_Handler, "+ADC: ", NULL);
return TRUE;
}

/* atd callback function*/
void atADC_Handler(adl_atCmdPreParser_t *paras)
{
adl_atCmdUnSubscribe("AT+ADC?",
            (adl_atCmdHandler_t) atADC_Handler);

/*we unsubscribe the command so that when we resend the command
*it wont be received by the ADL parser anymore.*/
/*we resend the command( for the phone call to be made) and subscribe to some of its responses. We also set the 2nd argument to True so that the response not subscribed will be directly send to the external application */
/*adl_atCmdCreate("AT+ADC",
            FALSE,
            (adl_atRspHandler_t) ADC_Response_Handler,
            "OK",
            "OK",
            "OK",
            NULL);*/
}
/*main function*/
void adl_main ( adl_InitType_e InitType ){
    /*Subscribe to the ‘atd’ command.*/
    adl_atCmdSubscribe("AT+ADC?",(adl_atCmdHandler_t)atADC_Handler,ADL_CMD_TYPE_READ);
    TRACE (( 1," Send SMS: %d ",adl_atCmdSubscribe ));
    TRACE (( 1," Send SMS: %d ",adl_atCmdCreate ));
    TRACE (( 1," Send SMS: %d ",adl_atCmdUnSubscribe ));
    
}

but the trace i got is Trace
1851790399
1851795441
1851790488

is there smth wrong with my code?
Please tell me what wrong?
Thank for the help!!!

best regrad,
thia

So what else were you expecting from

TRACE (( 1, " Send SMS: %d ", adl_atCmdSubscribe   ));
    TRACE (( 1, " Send SMS: %d ", adl_atCmdCreate      ));
    TRACE (( 1, " Send SMS: %d ", adl_atCmdUnSubscribe ));

:question:

In ‘C’, when you give a function name - such as adl_atCmdSubscribe - without the parentheses, you are referring to its address

Thus your Trace does seem to be correctly displaying the addresses of those functions!

I guess that’s not what you actually wanted… :question:

thank anweii for your reply! i now manage to get the value 0 already.
now what we need is a program to read the voltage converted from ADC! anyone has any idea how we can start with!!
Thank You
best regrad,
thia

Your code is a bit of a mess - lots of the comments don’t match the code they accompany - it looks like you’ve been hacking about with it without much of a plan.

So start again, and go back to basics:

First, study the Product Technical Spec (PTS) for your module carefully to see how the hardware works;

Then, study the AT Commands manual to see how to use the AT commands - including AT+ADC;

Then, experiment with sending the AT+ADC command manually from Hypoterminal or the Wavecom terminal emulator.

Then, When you’ve got the hang of how it works, try sending the command and handling the responses in an Open-AT application.

Be sure to include plenty of tracing!

I agree with awneil. You now have enough information to make it work, but your programming skills need work. At this point your teacher will do a better job helping you put the pieces together than we will. (That’s what they’re there for!)

Hi,
We were able to find out the voltage value using the command AT+ADC?. But we are not sure how to use the command in the Open AT application.
Anyone have any sample program for sending command with the Open AT application or can i find any sample program about it anywhere? We hope to use it as reference for our program.Thank You.

Best Regard,
thia

Your Open-AT SDK includes a whole bundle of samples!

we were able to run the command using the program but i encounter some problems when i was trying to send out the results of the command. This is the progamming code that i had written

ascii a[20]="+6594868899"; 
ascii string[100]; 
ascii SmsTel[20]="+6581507582";
ascii SmsTimeorLength[20]="1000";
ascii SmsText[20]="hi";
u32 h,g,d,z;
u32 s;
s8 j,k;
bool SMS_TELE_Handler(ascii *SmsTel, ascii *SmsTimeOrLength, ascii *SmsText)
{
    return TRUE;
}
void SMS_TELE_ctrl_Handler ( u8 Event, u16 Nb )  
{ 
// Switch on event 
switch ( Event ) 
{ 
case ADL_SMS_EVENT_SENDING_OK : 
TRACE (( 1, "Report OK" )); 
break; 

case ADL_SMS_EVENT_SENDING_ERROR : 
TRACE (( 1, "Report sending error %d", Nb )); 
adl_atSendResponse ( ADL_AT_UNS, "\r\nFailed...\r\n" ); 

// Check for 512 
if ( Nb == 512 ) 
{ 
// Please Wait error... retry in 2 seconds 
TRACE (( 1, "Retry later..." )); 
//adl_tmrSubscribe ( FALSE, 20, ADL_TMR_TYPE_100MS, tele_tmrRetryHandler ); 
} 
break; 
} 
}


s16 ADC_Response_Handler (adl_atResponse_t *paras)
{
    adl_atCmdCreate("at+adc?\x1A",  ADL_AT_PORT_TYPE( ADL_AT_UART1, TRUE ), (adl_atRspHandler_t)ADC_Response_Handler, "+ADC: ", NULL);
return TRUE;
//adl_strGetResponse (adl_atCmdCreate("at+adc?\x1A",  ADL_AT_PORT_TYPE( ADL_AT_UART1, TRUE ), (adl_atRspHandler_t)ADC_Response_Handler, "+ADC: ", NULL));
}
void atadc_Handler(adl_atCmdPreParser_t*paras)
{
    adl_atCmdUnSubscribe("at+adc?\x1A",(adl_atCmdHandler_t)atadc_Handler);
adl_atCmdCreate(paras->StrData,
            TRUE,
            (adl_atRspHandler_t) ADC_Response_Handler,
            ADL_AT_PORT_TYPE( ADL_AT_UART1, TRUE ),
            "OK",
            "OK",
            NULL);

}
void tele_tmrRetryHandler ( u8 ID )
{ 
h=adl_smsSubscribe( SMS_TELE_Handler, SMS_TELE_ctrl_Handler, ADL_SMS_MODE_TEXT ); //<------
s=adl_smsSend(h,a,adl_strGetResponse (adl_atCmdCreate("at+adc?\x1A",  ADL_AT_PORT_TYPE( ADL_AT_UART1, TRUE ), (adl_atRspHandler_t)ADC_Response_Handler, "+ADC: ", NULL)),ADL_SMS_MODE_TEXT); //<-----
j=adl_smsUnsubscribe(h);//<-----
TRACE ((1, " Send SMS: %d ", s));
TRACE ((1, " Send SMS: %d ", j)); 

}
void adl_main ( adl_InitType_e InitType ) 
{ 
adl_tmrSubscribe ( FALSE, 350, ADL_TMR_TYPE_100MS, tele_tmrRetryHandler );
g=adl_atCmdSubscribe("at+adc?\x1A",(adl_atCmdHandler_t)atadc_Handler,ADL_CMD_TYPE_READ|ADL_CMD_TYPE_TEST|ADL_CMD_TYPE_ACT|ADL_CMD_TYPE_PARA|0x0011);
k=adl_atCmdUnSubscribe("at+adc?\x1A",(adl_atCmdHandler_t)atadc_Handler);
z=adl_atCmdCreate("at+adc?\x1A", ADL_AT_PORT_TYPE( ADL_AT_UART1, TRUE ) , (adl_atRspHandler_t)ADC_Response_Handler, "*", NULL);
TRACE (( 1," Send SMS: %d ",g ));
TRACE (( 1," Send SMS: %d ",k ));
TRACE ((1, " Send SMS: %d ", h));
}

the trace i got for the adl_smsSend is -2, which mean parameter error
Can anyone help mi? Is there anything wrong with my code?
Best Regard
thia

Well, clearly there must be - otherwise you wouldn’t be getting an error, would you?!

But your code as presented is almost totally unreadable! :open_mouth:

Please take the time to reformat it so that it is legible;
Clear out all the junk that is no longer relevant;
Consider meaningfule names for your variables;
Comment it carefully - including the variable definitions;
Make sure it still compiles, and look at it carefully in the preview before you post it.

In doing this, you may well find the fault yourself!

i am sorry about the messy code. The code is still able to compile and i think the onli problem for the code is this line

s=adl_smsSend(h,a,adl_strGetResponse (adl_atCmdCreate("at+adc?\x1A",  ADL_AT_PORT_TYPE( ADL_AT_UART1, TRUE ), (adl_atRspHandler_t)ADC_Response_Handler, "+ADC: ", NULL)),ADL_SMS_MODE_TEXT);

Is the adl_strGetResponse used in the correct way?
if i just change the adl_strGetResponse to a normal ascii string it was able to work.
i wanted to get the results of the at command i use.

ascii phonenumber[20]="+6594868899"; 
ascii SmsTel[20]="+6581507582";
ascii SmsTimeorLength[20]="1000";
ascii SmsText[20]="hi";
u32 smsSu,CmdSu,CmdCreate;
u32 smsSend;
s8 smsUn,CmdUn;
bool SMS_TELE_Handler(ascii *SmsTel, ascii *SmsTimeOrLength, ascii *SmsText)
{
    return TRUE;
}
void SMS_TELE_ctrl_Handler ( u8 Event, u16 Nb )  
{ 
switch ( Event ) 
{ 
    case ADL_SMS_EVENT_SENDING_OK : 
    TRACE (( 1, "Report OK" )); 
    break; 

    case ADL_SMS_EVENT_SENDING_ERROR : 
    TRACE (( 1, "Report sending error %d", Nb )); 
    adl_atSendResponse ( ADL_AT_UNS, "\r\nFailed...\r\n" ); 

if ( Nb == 512 ) 
{ 
    TRACE (( 1, "Retry later..." )); 
} 
break; 
} 
}
s16 ADC_Response_Handler (adl_atResponse_t *paras)
{
    adl_atCmdCreate("at+adc?\x1A",  ADL_AT_PORT_TYPE( ADL_AT_UART1, TRUE ), (adl_atRspHandler_t)ADC_Response_Handler, "+ADC: ", NULL);
return TRUE;
}
void atadc_Handler(adl_atCmdPreParser_t*paras)
{
    adl_atCmdUnSubscribe("at+adc?\x1A",(adl_atCmdHandler_t)atadc_Handler);
    adl_atCmdCreate(paras->StrData,
            TRUE,
            (adl_atRspHandler_t) ADC_Response_Handler,
            ADL_AT_PORT_TYPE( ADL_AT_UART1, TRUE ),
            "OK",
            "OK",
            NULL);
}
void tele_tmrRetryHandler ( u8 ID )
{ 
    smsSu=adl_smsSubscribe( SMS_TELE_Handler, SMS_TELE_ctrl_Handler, ADL_SMS_MODE_TEXT ); 
    smsSend=adl_smsSend(smsSu,phonenumber,adl_strGetResponse (adl_atCmdCreate("at+adc?\x1A",  ADL_AT_PORT_TYPE( ADL_AT_UART1, TRUE ), (adl_atRspHandler_t)ADC_Response_Handler, "+ADC: ", NULL)),ADL_SMS_MODE_TEXT); 
    smsUn=adl_smsUnsubscribe(smsSu);
    TRACE ((1, " Send SMS: %d ", smsSend));
    TRACE ((1, " Send SMS: %d ", smsUn)); 

}
void adl_main ( adl_InitType_e InitType ) 
{ 
    adl_tmrSubscribe ( FALSE, 350, ADL_TMR_TYPE_100MS, tele_tmrRetryHandler );
    CmdSu=adl_atCmdSubscribe("at+adc?\x1A",(adl_atCmdHandler_t)atadc_Handler,ADL_CMD_TYPE_READ);
    CmdUn=adl_atCmdUnSubscribe("at+adc?\x1A",(adl_atCmdHandler_t)atadc_Handler);
    CmdCreate=adl_atCmdCreate("at+adc?\x1A", ADL_AT_PORT_TYPE( ADL_AT_UART1, TRUE ) , (adl_atRspHandler_t)ADC_Response_Handler, "*", NULL);
    TRACE (( 1," Send SMS: %d ",CmdSu ));
    TRACE (( 1," Send SMS: %d ",CmdUn ));
    TRACE ((1, " Send SMS: %d ", CmdCreate));
}

So why don’t you tidy it up?

If the code is messy and hard to read, how can you expect to uderstand it?
How can you expect to spot the errors.

Again, the effort you put into making your code clear and easy to ready will be repaid many times when you need to debug and maintain it!

What does the manual say?

Again, if you lay it out clearly, and comment it carefully, it will be clearly obvious whether the way you are using it is correct!

the manual say

adl_strGetResponse(adl_strID_e RspID);

where the RspId is the response ID from which to get the string.
But mine, the results is shown in the terminal emulator.
when i run the program i would get +ADC:(4145,1389,1377) followed by a OK
can i use adl_strGetResponse to get the +ADC:(4145,1389,1377) from the terminal emulator?

Yes, that is what adl_strGetResponse requires as its parameter - so what are you actually passing in that parameter…?

the parameter that i pass in is

adl_atCmdCreate("at+adc?\x1A",  ADL_AT_PORT_TYPE( ADL_AT_UART1, TRUE ), (adl_atRspHandler_t)ADC_Response_Handler, "+ADC: ", NULL);

but is it correct?
i am not sure what to pass in if i want to get the results from the terminal emulator.

Again, look it up in the manual:

You already know what adl_strGetResponse requires as its parameter - so does the return value from adl_atCmdCreate make sense here…?

What does the manual tell you that adl_atCmdCreate actually does…?