Analog Input

View: New views
13 Messages — Rating Filter:   Alert me  

Analog Input

by Daniel-378 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

Sadly I have to bother you again with ADC issues. I am not able to get a
signal on the ADC inputs. I've uploaded an image of the simple circuit
I'm using: (http://www.darthziu.de/Bilder/Circuit.jpg).

I bridged Pin 1&2 on the ADC connector as Harald wrote on 2009/09/02.

Code is as follows (as the example at NutWiki):

int main(void)
{
    // UART registrieren
    u_long baud = 115200;
    NutRegisterDevice(&DEV_UART, 0, 0);
    freopen(DEV_DEBUG_NAME, "w", stdout);
    _ioctl(_fileno(stdout), UART_SETSPEED, &baud);

    puts("\nADC example");
 
    ADCInit();
    uint16_t adc_value = 0;
   
    for (;;) {
       
    ADCStartConversion();  
 
        while (ADCRead(&adc_value))
        {
            NutThreadYield();
        }
 
       printf("Value: %u\n", adc_value);
               NutSleep(1000);
    }
   
    return 0;
}

Get always the same values on the ADC (eg. ADC0==255, ADC7==1023), even
if I play with the poti. With an external voltage meter I get different
voltages as expected.

Where is my error? I'm getting insane here. Just tried with 2 Ethernuts,
every ADC Pin and nearly every ADC software configuration.

Thanks in advance
Daniel
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: Analog Input

by Andre Riesberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Daniel wrote:

>Hi all,
>
>Sadly I have to bother you again with ADC issues. I am not able to get a
>signal on the ADC inputs. I've uploaded an image of the simple circuit
>I'm using: (http://www.darthziu.de/Bilder/Circuit.jpg).
>
>I bridged Pin 1&2 on the ADC connector as Harald wrote on 2009/09/02.
>
>Code is as follows (as the example at NutWiki):
>
>int main(void)
>{
>    // UART registrieren
>    u_long baud = 115200;
>    NutRegisterDevice(&DEV_UART, 0, 0);
>    freopen(DEV_DEBUG_NAME, "w", stdout);
>    _ioctl(_fileno(stdout), UART_SETSPEED, &baud);
>
>    puts("\nADC example");
>
>    ADCInit();
>    uint16_t adc_value = 0;
>  
>    for (;;) {
>      
>    ADCStartConversion();  
>
>        while (ADCRead(&adc_value))
>        {
>            NutThreadYield();
>        }
>
>       printf("Value: %u\n", adc_value);
>               NutSleep(1000);
>    }
>  
>    return 0;
>}
>
>Get always the same values on the ADC (eg. ADC0==255, ADC7==1023), even
>if I play with the poti. With an external voltage meter I get different
>voltages as expected.
>
>Where is my error? I'm getting insane here. Just tried with 2 Ethernuts,
>every ADC Pin and nearly every ADC software configuration.
>
>Thanks in advance
>Daniel
>_______________________________________________
>http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>
>  
>
Hallo Daniel,

I  missed the previous discussions. What kind of board do you use? CPU type?

Greetings
Andre
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: Analog Input

by Daniel-378 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andre Riesberg schrieb:

> Daniel wrote:
>
>  
>> Hi all,
>>
>> Sadly I have to bother you again with ADC issues. I am not able to get a
>> signal on the ADC inputs. I've uploaded an image of the simple circuit
>> I'm using: (http://www.darthziu.de/Bilder/Circuit.jpg).
>>
>> I bridged Pin 1&2 on the ADC connector as Harald wrote on 2009/09/02.
>>
>> Code is as follows (as the example at NutWiki):
>>
>> int main(void)
>> {
>>    // UART registrieren
>>    u_long baud = 115200;
>>    NutRegisterDevice(&DEV_UART, 0, 0);
>>    freopen(DEV_DEBUG_NAME, "w", stdout);
>>    _ioctl(_fileno(stdout), UART_SETSPEED, &baud);
>>
>>    puts("\nADC example");
>>
>>    ADCInit();
>>    uint16_t adc_value = 0;
>>  
>>    for (;;) {
>>      
>>    ADCStartConversion();  
>>
>>        while (ADCRead(&adc_value))
>>        {
>>            NutThreadYield();
>>        }
>>
>>       printf("Value: %u\n", adc_value);
>>               NutSleep(1000);
>>    }
>>  
>>    return 0;
>> }
>>
>> Get always the same values on the ADC (eg. ADC0==255, ADC7==1023), even
>> if I play with the poti. With an external voltage meter I get different
>> voltages as expected.
>>
>> Where is my error? I'm getting insane here. Just tried with 2 Ethernuts,
>> every ADC Pin and nearly every ADC software configuration.
>>
>> Thanks in advance
>> Daniel
>> _______________________________________________
>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>
>>
>>  
>>
>>    
> Hallo Daniel,
>
> I  missed the previous discussions. What kind of board do you use? CPU type?
>
> Greetings
> Andre
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>  
It's an Ethernut 1.3 H.

Daniel
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: Analog Input

by Andre Riesberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Daniel wrote:

>Andre Riesberg schrieb:
>  
>
>>Daniel wrote:
>>
>>  
>>    
>>
>>>Hi all,
>>>
>>>Sadly I have to bother you again with ADC issues. I am not able to get a
>>>signal on the ADC inputs. I've uploaded an image of the simple circuit
>>>I'm using: (http://www.darthziu.de/Bilder/Circuit.jpg).
>>>
>>>I bridged Pin 1&2 on the ADC connector as Harald wrote on 2009/09/02.
>>>
>>>Code is as follows (as the example at NutWiki):
>>>
>>>int main(void)
>>>{
>>>   // UART registrieren
>>>   u_long baud = 115200;
>>>   NutRegisterDevice(&DEV_UART, 0, 0);
>>>   freopen(DEV_DEBUG_NAME, "w", stdout);
>>>   _ioctl(_fileno(stdout), UART_SETSPEED, &baud);
>>>
>>>   puts("\nADC example");
>>>
>>>   ADCInit();
>>>   uint16_t adc_value = 0;
>>>  
>>>   for (;;) {
>>>      
>>>   ADCStartConversion();  
>>>
>>>       while (ADCRead(&adc_value))
>>>       {
>>>           NutThreadYield();
>>>       }
>>>
>>>      printf("Value: %u\n", adc_value);
>>>              NutSleep(1000);
>>>   }
>>>  
>>>   return 0;
>>>}
>>>
>>>Get always the same values on the ADC (eg. ADC0==255, ADC7==1023), even
>>>if I play with the poti. With an external voltage meter I get different
>>>voltages as expected.
>>>
>>>Where is my error? I'm getting insane here. Just tried with 2 Ethernuts,
>>>every ADC Pin and nearly every ADC software configuration.
>>>
>>>Thanks in advance
>>>Daniel
>>>_______________________________________________
>>>http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>>
>>>
>>>
>>>
>>>    
>>>      
>>>
>>Hallo Daniel,
>>
>>I  missed the previous discussions. What kind of board do you use? CPU type?
>>
>>Greetings
>>Andre
>>_______________________________________________
>>http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>
>>  
>>    
>>
>It's an Ethernut 1.3 H.
>
>Daniel
>_______________________________________________
>http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>
>  
>
Hi Daniel,

ok, ATmega128. I have a similar hardware here with correct working ADC's
(tested without Nut/OS). I will check this with Nut/OS tomorrow morning
(I am an early morning worker :-) )

Greetings
André
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: Analog Input

by Andre Riesberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Daniel wrote:

>Andre Riesberg schrieb:
>  
>
>>Daniel wrote:
>>
>>  
>>    
>>
>>>Hi all,
>>>
>>>Sadly I have to bother you again with ADC issues. I am not able to get a
>>>signal on the ADC inputs. I've uploaded an image of the simple circuit
>>>I'm using: (http://www.darthziu.de/Bilder/Circuit.jpg).
>>>
>>>I bridged Pin 1&2 on the ADC connector as Harald wrote on 2009/09/02.
>>>
>>>Code is as follows (as the example at NutWiki):
>>>
>>>int main(void)
>>>{
>>>   // UART registrieren
>>>   u_long baud = 115200;
>>>   NutRegisterDevice(&DEV_UART, 0, 0);
>>>   freopen(DEV_DEBUG_NAME, "w", stdout);
>>>   _ioctl(_fileno(stdout), UART_SETSPEED, &baud);
>>>
>>>   puts("\nADC example");
>>>
>>>   ADCInit();
>>>   uint16_t adc_value = 0;
>>>  
>>>   for (;;) {
>>>      
>>>   ADCStartConversion();  
>>>
>>>       while (ADCRead(&adc_value))
>>>       {
>>>           NutThreadYield();
>>>       }
>>>
>>>      printf("Value: %u\n", adc_value);
>>>              NutSleep(1000);
>>>   }
>>>  
>>>   return 0;
>>>}
>>>
>>>Get always the same values on the ADC (eg. ADC0==255, ADC7==1023), even
>>>if I play with the poti. With an external voltage meter I get different
>>>voltages as expected.
>>>
>>>Where is my error? I'm getting insane here. Just tried with 2 Ethernuts,
>>>every ADC Pin and nearly every ADC software configuration.
>>>
>>>Thanks in advance
>>>Daniel
>>>_______________________________________________
>>>http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>>
>>>
>>>
>>>
>>>    
>>>      
>>>
>>Hallo Daniel,
>>
>>I  missed the previous discussions. What kind of board do you use? CPU type?
>>
>>Greetings
>>Andre
>>_______________________________________________
>>http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>
>>  
>>    
>>
>It's an Ethernut 1.3 H.
>
>Daniel
>_______________________________________________
>http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>
>  
>
Hi Daniel,

another qestion:
What are the settings in the "Nut/OS Configurator" in parameters
"Architecture->AVR->ADC Driver" ?

Greetings
André



_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: Analog Input

by Daniel-378 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andre Riesberg schrieb:

> Daniel wrote:
>
>  
>> Andre Riesberg schrieb:
>>  
>>
>>    
>>> Daniel wrote:
>>>
>>>  
>>>    
>>>
>>>      
>>>> Hi all,
>>>>
>>>> Sadly I have to bother you again with ADC issues. I am not able to get a
>>>> signal on the ADC inputs. I've uploaded an image of the simple circuit
>>>> I'm using: (http://www.darthziu.de/Bilder/Circuit.jpg).
>>>>
>>>> I bridged Pin 1&2 on the ADC connector as Harald wrote on 2009/09/02.
>>>>
>>>> Code is as follows (as the example at NutWiki):
>>>>
>>>> int main(void)
>>>> {
>>>>   // UART registrieren
>>>>   u_long baud = 115200;
>>>>   NutRegisterDevice(&DEV_UART, 0, 0);
>>>>   freopen(DEV_DEBUG_NAME, "w", stdout);
>>>>   _ioctl(_fileno(stdout), UART_SETSPEED, &baud);
>>>>
>>>>   puts("\nADC example");
>>>>
>>>>   ADCInit();
>>>>   uint16_t adc_value = 0;
>>>>  
>>>>   for (;;) {
>>>>      
>>>>   ADCStartConversion();  
>>>>
>>>>       while (ADCRead(&adc_value))
>>>>       {
>>>>           NutThreadYield();
>>>>       }
>>>>
>>>>      printf("Value: %u\n", adc_value);
>>>>              NutSleep(1000);
>>>>   }
>>>>  
>>>>   return 0;
>>>> }
>>>>
>>>> Get always the same values on the ADC (eg. ADC0==255, ADC7==1023), even
>>>> if I play with the poti. With an external voltage meter I get different
>>>> voltages as expected.
>>>>
>>>> Where is my error? I'm getting insane here. Just tried with 2 Ethernuts,
>>>> every ADC Pin and nearly every ADC software configuration.
>>>>
>>>> Thanks in advance
>>>> Daniel
>>>> _______________________________________________
>>>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>>>
>>>>
>>>>
>>>>
>>>>    
>>>>      
>>>>
>>>>        
>>> Hallo Daniel,
>>>
>>> I  missed the previous discussions. What kind of board do you use? CPU type?
>>>
>>> Greetings
>>> Andre
>>> _______________________________________________
>>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>>
>>>  
>>>    
>>>
>>>      
>> It's an Ethernut 1.3 H.
>>
>> Daniel
>> _______________________________________________
>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>
>>
>>  
>>
>>    
> Hi Daniel,
>
> another qestion:
> What are the settings in the "Nut/OS Configurator" in parameters
> "Architecture->AVR->ADC Driver" ?
>
> Greetings
> André
>
>
>
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>  
Hi André,

Each of the values under "ADC Driver" and "ADC Driver" itself are enabled.

Daniel
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: Analog Input

by Daniel-378 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Okay,

I've managed it. Seems that I tried with the false pins. I'm confused,
because if i look at the datasheet of ethernut and compare it with the
board, the Expansion Port is connected in the same direction. But Analog
Port is flipped around.

Thanks for the answers,
Daniel
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: Analog Input

by Andre Riesberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

[Snap]

>Hi André,
>
>Each of the values under "ADC Driver" and "ADC Driver" itself are enabled.
>
>Daniel
>_______________________________________________
>http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>
>  
>
Hi Daniel,

I have set:
Buffer Size = 16
Inital Channel = ADC0
Initial Reference = AVCC
Initial  Mode = FREE_RUNNING
Initial Prescale = ADC_PRESCALE_DIV128

and it works fine. (I use your sample program)

I use AT90CAN128, but I think this is not a big difference.

So, try my settings first.
I know you have shorten pin 1 and 2 of connector J6. Please check the
AREF Pin (62) at the CPU. Here you must have +5V.
Next check PortF is define as input.
Doublecheck the generated code form Nut/OS Configurtator: Up to date?
correct CPU?

Greeting
Andre


_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: Analog Input

by Daniel-378 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andre Riesberg schrieb:

> [Snap]
>
>  
>> Hi André,
>>
>> Each of the values under "ADC Driver" and "ADC Driver" itself are enabled.
>>
>> Daniel
>> _______________________________________________
>> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>
>>
>>  
>>
>>    
> Hi Daniel,
>
> I have set:
> Buffer Size = 16
> Inital Channel = ADC0
> Initial Reference = AVCC
> Initial  Mode = FREE_RUNNING
> Initial Prescale = ADC_PRESCALE_DIV128
>
> and it works fine. (I use your sample program)
>
> I use AT90CAN128, but I think this is not a big difference.
>
> So, try my settings first.
> I know you have shorten pin 1 and 2 of connector J6. Please check the
> AREF Pin (62) at the CPU. Here you must have +5V.
> Next check PortF is define as input.
> Doublecheck the generated code form Nut/OS Configurtator: Up to date?
> correct CPU?
>
> Greeting
> Andre
>
>
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>  
Hi Andre,

Thanks for the info. As I wrote in the last mail I made it work fine
with the default settings.
I only used the false pins at the onboard-connector due to the datasheet
is a little bit confusing to me.

Daniel
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: Analog Input

by Andre Riesberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Daniel wrote:

>Andre Riesberg schrieb:
>  
>
>>[Snap]
>>
>>  
>>    
>>
>>>Hi André,
>>>
>>>Each of the values under "ADC Driver" and "ADC Driver" itself are enabled.
>>>
>>>Daniel
>>>_______________________________________________
>>>http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>>
>>>
>>>
>>>
>>>    
>>>      
>>>
>>Hi Daniel,
>>
>>I have set:
>>Buffer Size = 16
>>Inital Channel = ADC0
>>Initial Reference = AVCC
>>Initial  Mode = FREE_RUNNING
>>Initial Prescale = ADC_PRESCALE_DIV128
>>
>>and it works fine. (I use your sample program)
>>
>>I use AT90CAN128, but I think this is not a big difference.
>>
>>So, try my settings first.
>>I know you have shorten pin 1 and 2 of connector J6. Please check the
>>AREF Pin (62) at the CPU. Here you must have +5V.
>>Next check PortF is define as input.
>>Doublecheck the generated code form Nut/OS Configurtator: Up to date?
>>correct CPU?
>>
>>Greeting
>>Andre
>>
>>
>>_______________________________________________
>>http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>>
>>  
>>    
>>
>Hi Andre,
>
>Thanks for the info. As I wrote in the last mail I made it work fine
>with the default settings.
>I only used the false pins at the onboard-connector due to the datasheet
>is a little bit confusing to me.
>
>Daniel
>_______________________________________________
>http://lists.egnite.de/mailman/listinfo/en-nut-discussion
>
>
>  
>
Hi Daniel,

perfect!

Greetings
André
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: Analog Input

by Ole Reinhardt-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Daniel,

> I've managed it. Seems that I tried with the false pins. I'm confused,
> because if i look at the datasheet of ethernut and compare it with the
> board, the Expansion Port is connected in the same direction. But Analog
> Port is flipped around.

Just another hint: One of the most common errors is not to switch of the
JTAG port by setting the fuse bit correctly. If the JTAG port is enabled
ADC conversion will not work on all channels.

Bye,

Ole Reinhardt


--
 _____________________________________________________________
|                                                             |
| Embedded-IT                                                 |
|                                                             |
| Ole Reinhardt        Tel. / Fax:        +49 (0)271  7420433 |
| Luisenstraße 29      Mobil:             +49 (0)177  7420433 |
| 57076 Siegen         eMail:    ole.reinhardt@... |
| Germany              Web:         http://www.embedded-it.de |
|_____________________________________________________________|

_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: Analog Input

by Ethernut :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Ole Reinhardt wrote:

> Just another hint: One of the most common errors is not to switch of the
> JTAG port by setting the fuse bit correctly. If the JTAG port is enabled
> ADC conversion will not work on all channels.

Easy talk for you. As you are not selling AVR boards, you don't need to
deal with customers who misprogrammed their fuses. ;-)

When starting with AVR, I killed several chips by setting wrong fuse
bits. As long as there is an alternative, better do not change the fuse
settings.

uint8_t mcucsr;
/*
 * The JTAG disable bit must be written twice within four cycles.
 * Thus we have to disable interrupts.
 */
mcucsr = inb(MCUCSR) | _BV(JTD);
NutEnterCritical();
outb(MCUCSR, val);
outb(MCUCSR, val);
NutExitCritical();


Reprogramming via JTAG requires to keep the reset button pressed when
calling avrdude (or any other programming tool of your choice).

Harald
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion

Re: Analog Input

by Uwe Bonnes :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>>>>> "Ole" == Ole Reinhardt <ole.reinhardt@...> writes:

    Ole> Hi Daniel,
    >> I've managed it. Seems that I tried with the false pins. I'm
    >> confused, because if i look at the datasheet of ethernut and compare
    >> it with the board, the Expansion Port is connected in the same
    >> direction. But Analog Port is flipped around.

    Ole> Just another hint: One of the most common errors is not to switch
    Ole> of the JTAG port by setting the fuse bit correctly. If the JTAG
    Ole> port is enabled ADC conversion will not work on all channels.

The AT90CAN datasheet also tells about the JTD bit in the MCUCR controll
register. With the JTAG fuse programmed (default) and the JTD bit set in the
application program (write twice within four clock cycles), application
access to all ADC channels is possible, but also JTAG access whith the CPU
hold in reset.

--
Uwe Bonnes                bon@...

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
_______________________________________________
http://lists.egnite.de/mailman/listinfo/en-nut-discussion