Go Down

Topic: analogRead not working.. (Read 1 time) previous topic - next topic

KeithRB

Does it work if you undefine FASTADC?

Faye_V

I'll try that.

I think I've solved it! Without using the FASTADC though, it seems to be a problem with the SD card setup, without it, it runs and takes the data (random values, different from those on the voltmeter) so I'll see if there's another way to get the correct data.

Thanks!

KeithRB

Also, incremento will be 0, since 5/1024 will be done in integer math before being converted to a float. try 5.0/1024.0

Faye_V

Thanks a lot, that explains it! Now it gives the value I want :)

The problem I had wasn't with the SD card code, it was an RTC issue, it reseted itself, so it was 1am for my circuit, and the program entered into the "dormir" routine, putting low the USART0.. Could it be that the FASTADC caused this to the RTC?

Faye_V

I'm still having trouble with the analogRead in my program, I'm no longer using the FASTADC routine, because I've changed my load so the voltage increase will become slower.This way the 100┬Ás per sample are enough, since I have 20ms from 0 to the top voltage, this allows me to have 200 samples and I only require 100.

BUT, the analogRead gives me random values! I keep getting 5V (1023) when I actually have 3.7V maximum.. What can be wrong? I'll appreciate any thoughts on this! Thanks!

Go Up