Page 1 of 1

ADC help!

Posted: Sun Nov 22, 2009 4:46 pm
by Gaz
Hi folks

Could anyone give me any pointers on how to use the ADC in Flowcode V4?

Ive got 2 LED's flashing flip flop style but would now like to use the ADC facility to control the flash rate.

I aint got a clue where to start! :roll:

cheers

Gaz

Re: ADC help!

Posted: Sun Nov 22, 2009 11:06 pm
by medelec35
have a look here:
http://www.matrixmultimedia.com/mmforum ... 12&p=14003
It was created when V4 was new to me, so its not the most advanced in the word, but it works well to alter led brightness, hence flash rate.

Also to learn more about flowcode 4 you can find a link to V4 examples here:
http://www.matrixmultimedia.com/Flowcode3a-X.php
Scroll down to flowcode extras, then you will see 'Flowcode V4 Examples'
What I do to learn is just load a flowcode example, then press F8, to run single step, then in variable windows, right click and select 'Add variable...'
If you want to add all variables then highlight top one, hold shift key, then left click on lowest variable, then click 'use variable'
You could either run simulation by holding down F8, or you can go to View, project options and change simulation speed from 'As fat as possible' to 1000. If left on 'As fast as possible' variables will not be displayed in variables window.

You could just read adc value, convert to a delay period. then a continuous loop of: led on, read ADC Calculate delay led on,delay, led off, delay
Also included a couple of very basic programs to get you started.
First one (LED Delay1) using reading 8 bit ADC
Second one (LED Delay2) using 10bit ADC and delay variable from 0 to 1023 ms . You don't have to stick with max 1023 ms Delay, using a formula you can go up to something like 32767 ms. Or Change delay form ms to Seconds.
Hope it helps.

Re: ADC help!

Posted: Mon Nov 23, 2009 1:24 pm
by Gaz
Thanks for that fella.

I will have a look and see if I can digest it all! :lol:

Re: ADC help!

Posted: Mon Nov 23, 2009 2:06 pm
by medelec35
Your welcome.

Since there is quiet a bit to digest, If I were you I would just save and run the two attached files, and just see how they work. There probably won’t be a need to read the rest.

Re: ADC help!

Posted: Mon Nov 23, 2009 4:13 pm
by Gaz
I downloaded the first file and V4 says its an unexpected format? are V3 files not compatable with V4?
Seems a bit odd?

Re: ADC help!

Posted: Mon Nov 23, 2009 4:29 pm
by medelec35
Yes that’s odd!
Files were created with V4. Just downloaded file and opened it. Opens fine with my V4.

Re: ADC help!

Posted: Mon Nov 23, 2009 5:15 pm
by Gaz
Im running V4 pro. Do any of the mods know why this could be?

Re: ADC help!

Posted: Mon Nov 23, 2009 7:37 pm
by medelec35
Within flowcode, go to help, and check for updates. Are you using latest .. V4.2?

Re: ADC help!

Posted: Mon Nov 23, 2009 7:57 pm
by Gaz
Cheers again fella

I did the update and it loads up now.

Right, I'm off for a play! :lol:

Re: ADC help!

Posted: Mon Nov 23, 2009 8:49 pm
by medelec35
Glad you have got V4 working now 8)
Sorry mate, I slightly misread :oops: .
You wanted to flash two LEDS like flip flop style.

Here you go. You will like this one much better.
Connect pot to RA1.
LED1 to B0 and LED2 to B1

f you want specific times in which they change rate e.g. from 100ms to 1 second, then let me know and I will work out correct formula for you.

This was tested on 16F872. You will need to change target, configuration and perhaps port settings to suit.

Re: ADC help!

Posted: Mon Nov 23, 2009 9:59 pm
by Gaz
Thats exactly what I wanted mate, top stuff 8)

I have a play around with that now and try and understand how various parts work.

Thanks again fella

Gaz