Olimex Support Forum

OLinuXino Android / Linux boards and System On Modules => A20 => Topic started by: NewBieGermany on February 10, 2015, 07:28:53 PM

Title: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: NewBieGermany on February 10, 2015, 07:28:53 PM
Hello,

I would like to use the LRADC of the A20 to sample a sensor output. I guess I figured out how to do the C programming, just write or right to the registers via the base address and the offsets, then using e.g. memcpy or pointer arithmetic directly. Maybe somehow could confirm that?

But I can't find the corresponding pin LRADC1. LRADC0 seems to be at position 39 ...

The output voltage of the sensor could be as high as 3,2 V but the LRADC can sample up to 2V. Will it be destroyed by applying 3,2 V?
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: JohnS on February 10, 2015, 08:19:15 PM
See the datasheet, for the "pin" (ball) at least.

John
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: dave-at-axon on February 11, 2015, 06:45:39 AM
Actually John, the A20 datasheets are very poor in respect to the information needed. There is no information in any of the A20 docs I could find that show the LRADC input voltage tolerance.

With that in mind, NewBieGermany, I suggest you limit the input to max 2V just to be safe. I've fried two A20's already with accidental 5V input to a GPIO as it is.

You can use a 100R resistor and a 2V or a 2.2V zener diode to protect the input if your signal will could be more than 2V. 2.2 is likely to be safe if you need the full 2V input range.

By the way, the resolution is only 6 bit (total of 64 bits) so your sensor output is going to be very poor resolution depending on the range of the sensor output. What is the sensor you wish to monitor? Might be better to use an external higher resolution ADC?
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: JohnS on February 11, 2015, 11:44:31 AM
I believe you but as I put it has the "pin" (ball) details.

I just tried google and even that found it!

John
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: dave-at-axon on February 11, 2015, 05:31:59 PM
Hey John, no amount of Googling for me is giving any results on max voltage input for the LRADC 0 and 1 inputs. I've tried with the A20 balls or AB23 and AB22 and nothing. The only reference I can find is for 0-2V with the ADC VCC pins being 3.0V to 3.3V max.

Do me a favour will you, post one of the links you seem to have found. I'd be curious to your search terms. Use LMGTFY if you want to?  ;)
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: JohnS on February 11, 2015, 07:09:19 PM
You're not understanding English :(

"it" means the last thing mentioned, which is the "pin" (ball) details

John
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: dave-at-axon on February 12, 2015, 06:00:49 AM
I use Google for everything first before asking a question and in this case, I couldn't find what you said you found. AllWinner docs are very poor and they won't reply to emails on the subject so if you or someone knows the answer, it would be appreciated to what that is. If you want to keep it to yourself, fine and maybe you can just stay quiet on the forums for the sake of others who wish to learn and don't want cryptic answers.
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: JohnS on February 12, 2015, 10:01:07 AM
The question was about A20's LRADC0/1 so into google I stuck
A20 LRADC0
or
A20 LRADC1

and it got me results.  Is that what you tried?  Didn't it work?

The docs are so poor that I expect some projects might not be wise.  I think AW put up an engineer or the like at some point on the linux-sunxi list but I'm not sure whether he (her?) will get doc improvements done if asked.

John
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: dave-at-axon on February 12, 2015, 11:01:59 AM
Hey John,

Your Google must be different to mine. ;)

I put in your search terms and all I got was stuff from others use of the LRADC but nothing that suggests anything about the max voltage limits other than the 0-2V mentioned in the A20 docs.

Based on this, and without concrete data, I would still exercise caution buy the OP to limit the input to max 2.1 to 2.2V at the very least.
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: JohnS on February 12, 2015, 01:58:17 PM
As I've posted, this was to find the "pin" details.  I didn't look for voltages but being cautious would be a good idea!

Someone on linux-sunxi may be collecting questions for AW re datasheets - maybe?

John
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: dave-at-axon on February 12, 2015, 02:33:08 PM
The point is that the OP was looking for advice on the voltage input where he could apply 3.2V from his sensor and wanted to know if this would damage the sensor.

He wasn't asking about the pins to use. :)
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: JohnS on February 12, 2015, 05:58:55 PM
The point is:

I quote from his post "But I can't find the corresponding pin LRADC1"

That is what I answered.

John
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: dave-at-axon on February 13, 2015, 04:15:11 AM
Ah, I see your point now John and apologise. Saying that, it might have been clearer if you had quoted the part you responded too, just to clarify your answer  :)

The LRADC1 is on GPIO1 pin 39 and the OP noted that connection (without reference to the GPIO connector) but he mistook it for LRADC0 which is used internally for the buttons.
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: JohnS on February 13, 2015, 01:00:11 PM
No worries.

OK, you got me wondering, though...  Did some more google stuff, figured A20 & A10 are almost alike and found with:
A10 lradc V
a Chinese (?) post that reads the 6-bit value from the lradc data register then uses
(data + 1) / 64 * 2 as the volts

Which looks like max 2V.  Suspect the formula because it can't return 0.

Not exactly the ideal source!!  It's at http://www.eeboard.com/bbs/thread-38057-1-1.html

John
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: dave-at-axon on February 13, 2015, 06:17:42 PM
I often wonder why some folks use complex formula to get the result.

A simple data * 0.003125 would get the same result.

:)
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: jmyreen on February 13, 2015, 07:02:12 PM
Well, some people may find an increment and a shift less complex than a floating point multiply. Especially if you don't want a floating point result.  :)
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: JohnS on February 13, 2015, 07:56:16 PM
Quote from: dave-at-axon on February 13, 2015, 06:17:42 PM
I often wonder why some folks use complex formula to get the result.

A simple data * 0.003125 would get the same result.

:)
Magic numbers are usually bad, however they're written.

The compiler will sort it all out, so best write it clearly.

John
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: dave-at-axon on February 14, 2015, 05:07:32 AM
True, the compiler can sort it out. I was just making comment about the complex one shown as a sample  :P

In my own defence :) and as you said John, I usually create a #define for the calculation and let the compiler sort out the final value.
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: JohnS on February 14, 2015, 09:13:53 AM
I figured as much!

John
Title: Re: A20 LRADC - Where are the pins? To much input voltage! How much to destroy it?
Post by: NewBieGermany on February 22, 2015, 07:34:18 PM
Thanks a lot for all the comments!  :)

Well, I use two resistors to do a voltage devider so the voltage level is ok.

I figured out that LRADC1 is on PIN 39 of GPIO1 and LRADC0 is connected to several buttons not used with a the debian system (if android is used). I used the LRADC1.

With the register base adress LRADC and the offsets of the LRADC_CTRL and LRADC_DATA1 I could configure them using:

void *memcpy(void* addressDest, const void* addressSource, size_t n)

Unfortunately I can't make any sense on the data read on LRADC_DATA1.
Maybe someone has an idea what to check? Do I have to export the the port?

The resolution of the sensor is ok for me.

Thanks to all!