parallel command of AnalogRead?

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
mtbf0
 
Posts: 1645
Joined: Sat Nov 10, 2007 12:59 am

Re: parallel command of AnalogRead?

Post by mtbf0 »

dragonuv wrote:and the 0.7 * vcc doesn't make sense,
if you don't believe me, (by the way, i got it wrong, at 5V it's 0.6 * Vcc), you could always read the f*cking data sheet. it appears that you have switched back to the arduino. in my copy of the megax8 data sheet, which dates from sept '07, the relevant information is on page 304.

even if the avr senses a high on the input as it zips past 3v, isn't it reasonable that the cap should eventually charge all the way to 5v?

since it appears that i have exited the realm of civilized discourse, perhaps i should ignore this thread in the future.

ta-ta.

dragonuv
 
Posts: 235
Joined: Tue Dec 04, 2007 1:22 pm

Re: parallel command of AnalogRead?

Post by dragonuv »

mtbf0 wrote:
dragonuv wrote:and the 0.7 * vcc doesn't make sense,
if you don't believe me, (by the way, i got it wrong, at 5V it's 0.6 * Vcc), you could always read the f*cking data sheet. it appears that you have switched back to the arduino. in my copy of the megax8 data sheet, which dates from sept '07, the relevant information is on page 304.

even if the avr senses a high on the input as it zips past 3v, isn't it reasonable that the cap should eventually charge all the way to 5v?

since it appears that i have exited the realm of civilized discourse, perhaps i should ignore this thread in the future.

ta-ta.
I did read the datasheet, i just said it doesnt make sense, not blaming anyone.
and yes you were right and this is where my mistake is, it charges all the way up to 5v

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: parallel command of AnalogRead?

Post by adafruit »

hey0, lets keep this forum happy.
dragonuv: please do more research before posting. it can be very frustrating when i spend a half hour helping someone and they dont spend 5 minutes trying to help themselves. if you have a question that can be solved by -trying it out- and observing, or drawing a diagram and talking it through, please do that first before depending on the kindness of stranges
mtbf0: some people here are n00bs but you shouldn't run yerself into the ground teaching them 4 years worth of electronics knowledge in a thread. sometimes -not responding- will actually be more helpful since then they gotta do some work on their own, yknow? :)

dragonuv
 
Posts: 235
Joined: Tue Dec 04, 2007 1:22 pm

Re: parallel command of AnalogRead?

Post by dragonuv »

i got a problem, when i try to measure the voltage of 2 AA batteries (2.86 volts together) it reads a HIGH signal after 3 milliseconds, i thought there is something i did wrong so i took 1 battery out, so i had 1 battery that has 1.4 volt and then it couldnt get a high signal. which means the minimum voltage it takes to read a high signal is from 1.4 to 2.86. so why isnt it what the datasheet says?

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: parallel command of AnalogRead?

Post by adafruit »

RC time methods are only good for measuring resistive sensors. you cant use it to measure batteries, IR distance sensors, accellerometers, etc.

you should just get an arduino

dragonuv
 
Posts: 235
Joined: Tue Dec 04, 2007 1:22 pm

Re: parallel command of AnalogRead?

Post by dragonuv »

i do have arduino, when i talked about the volage of the batteries i meant the voltage across a resistor, same schematic as you had in the tutorial page, but instead of 5v i connected one end to the resistor and the minus to the ground of the arduino.

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: parallel command of AnalogRead?

Post by adafruit »

you need to spend a lot more time experimenting and understanding how this stuff works. try different stuff. i suggest starting with things you KNOW work before heading into things you dont know at all
perhaps do some online tutorials, etc.
if you can't get it working by wednesday you can post again

dragonuv
 
Posts: 235
Joined: Tue Dec 04, 2007 1:22 pm

Re: parallel command of AnalogRead?

Post by dragonuv »

dragonuv wrote:...which means the minimum voltage it takes to read a high signal is from 1.4 to 2.86. so why isnt it what the datasheet says?
I have made a test that apparently approved my theory (im beginning to think there is something wrong with my arduino).

I have connected the 5v and the ground into 2 edges of a potentiometer, and to the middle I've connected the digital 2 pin and the analog 2 pin

here is the schematic:
voltage2.png
voltage2.png (2.43 KiB) Viewed 2807 times
and then wrote this code:

void setup()
{
Serial.begin(9600);
pinMode(2, INPUT);
}

void loop()
{
int reading;
double voltage;
reading = analogRead(2);
voltage = (double)reading*5/1023;

Serial.println(voltage);
Serial.println(digitalRead(2));
}
I rotated slowly the potentiometer to see when I am reaching a point where the 1's and 0's start to mix together
From the Serial monitor it can be seen that the minimum voltage it takes to turn a digital pin HIGH is about 2.43
voltage.PNG
voltage.PNG (1.39 KiB) Viewed 2804 times
Is there anything wrong with my arduino? according to the datasheet it should be somewhere between 3.5v-3v

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: parallel command of AnalogRead?

Post by adafruit »

good work experimenting! now you have some information to think about.
it looks like its around vcc/2 which is pretty reasonable. note that each chip will be a little different and that they may very well completely change that voltage. but my experience is that the trigger point is around 1/2 between 0 and whatever voltage is powering the CHIP (which for arduinos is 5V)

which you can see by examining the scope shot from my tutorial:
http://www.ladyada.net/images/sensors/RCtimecapture.jpg

dragonuv
 
Posts: 235
Joined: Tue Dec 04, 2007 1:22 pm

Re: parallel command of AnalogRead?

Post by dragonuv »

Thanks verymuch Ladyada,
now that I have the minimum voltage it takes to turn a pin HIGH ive gone 1 step further. But im still having problem with the timing, Ive been trying to get the exact time it takes the capacitor to reach 2.5v, I tried to take a bunch of capacitors from (0.1 micro farad to 100 micro farad) and resistors to see which combination gives me the exact voltage (I've tested their exact values with a multimeter) but no luck, the most precise result i got was 6.3 volts, and I've tested it with the 5v of the arduino.

Is there anything wrong with the code?

int photocellPin = 2;
long photocellReading;

void setup(void) {
Serial.begin(9600);
}

void loop(void)
{
photocellReading = RCtime(photocellPin);
Serial.print("RCtime reading = ");
Serial.println(photocellReading);
}

int RCtime(int RCpin) {
long reading = 0; // start with 0

pinMode(RCpin, OUTPUT);
digitalWrite(RCpin, LOW);
delay(2000); //let the voltage across the capacitor to go down

pinMode(RCpin, INPUT);
while (digitalRead(RCpin) == LOW )
{
reading++;
delayMicroseconds(1);
}
return reading;
}
the code was adapted from the tutorial, Ive deleted lines that I didnt need.

woody1189
 
Posts: 85
Joined: Sat Jun 21, 2008 11:19 pm

Re: parallel command of AnalogRead?

Post by woody1189 »

heres a really good tutorial for adc of the avr's if you end up getting one with an adc:

http://www.avrfreaks.net/index.php?name ... ic&t=56429

also, i believe the technical analogue to digitalRead would be PINX where x is the specific avr port and the analogue for analogRead would just be to set the ADC to sample and send to an integer value. check out this tutorial to see how the basic i/o registers of the avrs work:

http://iamsuhasm.BANNED.com/tutsproj ... -tutorial/

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”