parallel command of AnalogRead?

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Re: parallel command of AnalogRead?

Postby mtbf0 » Mon Jun 08, 2009 11:42 am

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 want to lead a dissipate existence, play scratchy records and enjoy my decline" - iggy pop, i need more
User avatar
mtbf0
 
Posts: 1642
Joined: Fri Nov 09, 2007 11:59 pm
Location: oakland ca

Re: parallel command of AnalogRead?

Postby dragonuv » Mon Jun 08, 2009 11:49 am

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
dragonuv
 
Posts: 234
Joined: Tue Dec 04, 2007 12:22 pm

Re: parallel command of AnalogRead?

Postby adafruit » Mon Jun 08, 2009 11:56 am

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? :)
User avatar
adafruit
 
Posts: 10490
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: parallel command of AnalogRead?

Postby dragonuv » Mon Jun 08, 2009 5:31 pm

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?
dragonuv
 
Posts: 234
Joined: Tue Dec 04, 2007 12:22 pm

Re: parallel command of AnalogRead?

Postby adafruit » Mon Jun 08, 2009 6:07 pm

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
User avatar
adafruit
 
Posts: 10490
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: parallel command of AnalogRead?

Postby dragonuv » Mon Jun 08, 2009 6:39 pm

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.
dragonuv
 
Posts: 234
Joined: Tue Dec 04, 2007 12:22 pm

Re: parallel command of AnalogRead?

Postby adafruit » Mon Jun 08, 2009 6:49 pm

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
User avatar
adafruit
 
Posts: 10490
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: parallel command of AnalogRead?

Postby dragonuv » Wed Jun 10, 2009 6:01 pm

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 2031 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 2028 times


Is there anything wrong with my arduino? according to the datasheet it should be somewhere between 3.5v-3v
dragonuv
 
Posts: 234
Joined: Tue Dec 04, 2007 12:22 pm

Re: parallel command of AnalogRead?

Postby adafruit » Wed Jun 10, 2009 11:06 pm

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
User avatar
adafruit
 
Posts: 10490
Joined: Thu Apr 06, 2006 3:21 pm
Location: nyc

Re: parallel command of AnalogRead?

Postby dragonuv » Thu Jun 11, 2009 6:12 pm

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.
dragonuv
 
Posts: 234
Joined: Tue Dec 04, 2007 12:22 pm

Re: parallel command of AnalogRead?

Postby woody1189 » Fri Jun 19, 2009 9:44 pm

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.wordpress.com/tutsproj ... -tutorial/
woody1189
 
Posts: 85
Joined: Sat Jun 21, 2008 10:19 pm

Previous

Return to Microcontrollers

Who is online

Users browsing this forum: mibignistinly and 0 guests

Stuff to buy from the Adafruit store and links to product documentation!


New Products [102]

Raspberry Pi[80]
 
FLORA[23]
 
Bunnie Studios[9]
 
FPGA[1]
 
mbed[11]
Arduino[60]
 
NETduino[14]
 
BeagleBone[24]
 
Android[6]
 
XBee[10]
More Dev Boards[30]


 
BoArduino[8]
 
SpokePOV[4]
 
TV-B-Gone[4]
 
MiniPOV[3]
 
SIM reader[3]
 
Microtouch[5]
 
Clocks & Watches[18]
 
Drawdio[4]
 
Brain Machine[1]
 
Game of Life[2]
 
MintyBoost[2]
More DIY Kits[16]


 
MaKey MaKey[3]
 
Tweet-a-Watt[5]
 
Young Engineers[33]
 
Discover Electronics[2]
 
Snap Circuits[4]
 
littleBits[3]
 
Project packs[8]


 
Breakout Boards[33]
LCDs & Displays[48]
Components & Parts[69]
Batteries & Power[49]
EL Wire/Tape/Panel[52]
LEDs[109]
 
Wireless[14]
Cables[60]
 
Lasers[6]
Sensors/Parts[145]
 
Enclosures/Cases[11]
 
Solar[11]
 
RFID / NFC[13]
Prototyping[70]
 
iDevices[13]
Tools[71]
 
Wearables[39]
 
CNC[37]
 
Robotics[29]
 
3D printing[1]
 
Materials[24]


 
Stickers[41]
 
Skill badges[55]
 
Books[25]
 
Circuit Playground[7]
 
Gift Certificates[4]