Inputing an analogue voltage signal

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
me10kky
Posts: 4
Joined: Wed Mar 21, 2012 5:36 pm
Contact:

Inputing an analogue voltage signal

Post 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 4115 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 4115 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

me10kky
Posts: 4
Joined: Wed Mar 21, 2012 5:36 pm
Contact:

Re: Inputing an analogue voltage signal

Post by me10kky »

Working2.fcf
using flwocode 3
(6 KiB) Downloaded 299 times

GTF
Posts: 170
Joined: Sat Dec 10, 2011 7:21 pm
Location: Canada
Has thanked: 20 times
Been thanked: 52 times
Contact:

Re: Inputing an analogue voltage signal

Post 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
Attachments
ECIO40P Flash_using_ADC_loops.fcf
(8.5 KiB) Downloaded 270 times

me10kky
Posts: 4
Joined: Wed Mar 21, 2012 5:36 pm
Contact:

Re: Inputing an analogue voltage signal

Post by me10kky »

could you possibly make a screenshot of the change you made, as i cannot open your file for some strange reason.

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Inputing an analogue voltage signal

Post 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
Martin

GTF
Posts: 170
Joined: Sat Dec 10, 2011 7:21 pm
Location: Canada
Has thanked: 20 times
Been thanked: 52 times
Contact:

Re: Inputing an analogue voltage signal

Post by GTF »

Here you go.......
Attachments
FCscreenshot.png
(27.1 KiB) Downloaded 933 times

Post Reply