Page 1 of 1

Inputing an analogue voltage signal

Posted: Wed Mar 21, 2012 6:16 pm
by me10kky
Basically im using flowcode and the ecio40p . Im using a voltage signal of range 1.3 volts to 4.1 volts into Port A pin 0 and the converting it into a digital value.
With flowcode 4, my analogue voltage signal reads as a digital one as in pic1
Using flowcode 4
Using flowcode 4
1.jpg (55.59 KiB) Viewed 4112 times
(low below 3 volts and high above 3 volts). However using flowcode 3, theres a sample ADC macro that does indeed help convert this value
Using flowcode 3
Using flowcode 3
2.jpg (74 KiB) Viewed 4112 times
. When i simulate with flowcode 4, the conversion works properly, but in actual practice it doesn't. Is there anay way to remedy this?
What im basically doing is using the analogue signal from an LDR (connected at the top of a voltage divider) to give me a larger voltage when there is bright light shone upon it. I will then move the light source and reread the analogue voltage signal, compare it with the first, and check whether the light source is closer or further away, and then have a motor rotate in a certain direction. Ive also noticed that when making this comparison in flowcode(between the first analogue voltage signal and the second), say is V1>V2, the program makes the right decision when the two values are further away( say 1.6v for V1 and 3.4v for V2), but when the two values are about .5 apart, the microcontoller take a few seconds before it sends an output to my motor, and sometimes it even make the wrong decision.
Does anyone have a clue as to any of these problems?
Just a note ive connected both VDD in and VDD out pins on my ecio40p chip to 5 volts.
Here are my two files, the first in flowcode 4, and the second in flowcode 3.
ECIO40P Flash_using_ADC.fcf
using flowcode 4
(5.5 KiB) Downloaded 303 times

Re: Inputing an analogue voltage signal

Posted: Wed Mar 21, 2012 6:17 pm
by me10kky
Working2.fcf
using flwocode 3
(6 KiB) Downloaded 299 times

Re: Inputing an analogue voltage signal

Posted: Wed Mar 21, 2012 11:03 pm
by GTF
It appears that you are nudging the motor in 1 direction or the other for 1 sec and then reading the analog input. If during this 1 sec period the target(200) is overshot it will not equal 200 and the motor will continue to nudge in the same direction. Perhaps while loops that end when the target is reached might work better. See the attached example. It may be better to use > and < in place of the = 200, but I wasn't sure which direction you are going in each case.

> or < rather than = may also work in your existing code, but there will be overshoot with the 1 sec delays. :)

Grant

Re: Inputing an analogue voltage signal

Posted: Wed Mar 21, 2012 11:09 pm
by me10kky
could you possibly make a screenshot of the change you made, as i cannot open your file for some strange reason.

Re: Inputing an analogue voltage signal

Posted: Wed Mar 21, 2012 11:11 pm
by medelec35
Hi me10kky,
Have you had a look here:
http://www.matrixmultimedia.com/article.php?a=361
?
Ben has posted a flowchart which moves to motor towards the strongest light source.

Even if your not using a servo motor, the way in which the strongest light is found maybe useful for you.

Martin

Re: Inputing an analogue voltage signal

Posted: Thu Mar 22, 2012 4:18 am
by GTF
Here you go.......