Inputing an analogue voltage signal
Posted: Wed Mar 21, 2012 6:16 pm
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 (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 . 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.
With flowcode 4, my analogue voltage signal reads as a digital one as in pic1 (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 . 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.