How to get sample multi Analog Channel?

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
nhson
Posts: 2
Joined: Wed Oct 22, 2014 4:04 pm
Has thanked: 1 time
Contact:

How to get sample multi Analog Channel?

Post by nhson »

Hello everybody!

I'm new to flowscode V6. I feel this is a great tool for programming the processor. Despite watching all video tutorials but I still do not know how to build my apps with flowcode. Expect flowcode experts telling me how to do. My application is as follows:

There are 6 photo reflector connected to the dspic 30f2010 from AN0 - AN5
3 buttons SW1, SW2 and SW3 connected to pin RE0 - RE2
2 LEDs: LED1, LED2 connected to pin RE3 and RE4.

Press SW1 to enter the sampling program: the channel from AN0 - AN5 is sampled and then converted 100 times, the average value stored in the EEPROM memory (it called threshold). Press SW1 again to exit the sampling program.

The main program will continuously sampled and converted the channel from AN0 - AN5. Then compare with the results stored in the EEPROM. If there is any one channel is less than the threshold of 10%, the LED1 will on. If all channels are less than the threshold of 10%, the LED2 turn on. sample and converstion time must be as soon as possible and must be less than 100 micro second.

SW2 and SW3 button to increase or decrease sensitivity (default is 10%). If pressing SW2 will increase the sensitivity to 15, 20% ... Click the SW3 button to decrease sensitivity ...

Many thanks for help.

Son

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: How to get sample multi Analog Channel?

Post by QMESAR »

Hi

I am not an FC expert however in my opinion if you want to do simultaneous sampling then you will have to make your own macro and add the configuration of this in a .c file and call the macro in your FC flow diagram.
as I see now way to configure the ADC module for simultaneous or sequential sampling from the standard FC ADC macro

maybe one of the more experience people here can help us with a better solution :D

Regards

nhson
Posts: 2
Joined: Wed Oct 22, 2014 4:04 pm
Has thanked: 1 time
Contact:

Re: How to get sample multi Analog Channel?

Post by nhson »

Thank QMESAR for your kindly reply.

Could you explain more detail about where I can see standard FC ADC macro? How to add (or modify) configuration into macro in FC?

In FC 6, there some components connect with ADC pin of uC, such as potentiometer with some macro for ADC function. My app need connect with photo reflector via ADC pin but on the macro of photo reflector there is no ADC function. I mean I want to get analog value of the sensor but do not know how to do.

Thanks

Son

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: How to get sample multi Analog Channel?

Post by QMESAR »

Well you can use a simple potentiometer as it is only for simulation in FC in the real world it is a AN signal at a pin what you connect to the pin as a source does not matter for the code

(1)Go to inputs select >> place potentiometer on Dashboard you will see a potentiometer in the dashboards as in picture 1
(2) select the potentiometer in the dashboard as in picture 2 then go to the properties panel
(3) Now configure the properties for the AN signal give it a name as you would like and set up the sampling etc as in picture 3
Attachments
1.png
PIC 1
(2.86 KiB) Downloaded 2024 times
2.png
PIC 2
(3.54 KiB) Downloaded 2024 times
3.png
PIC 3
(30.64 KiB) Downloaded 2024 times

User avatar
QMESAR
Valued Contributor
Valued Contributor
Posts: 1287
Joined: Sun Oct 05, 2014 3:20 pm
Location: Russia
Has thanked: 384 times
Been thanked: 614 times
Contact:

Re: How to get sample multi Analog Channel?

Post by QMESAR »

(4)place a component macro in you flow diagram ,double click the component macro and you will see the property window open ,you will also see your signal
(5) Click the cross next to the signal name and you will see all the function you can use with the macro and your signal, select the function you want to use ,
you can use the macro now in your flow diagram you can also simulate your code (see help file on simulation)

Hope this helps you :D
Attachments
4.png
PIC 5
(21.84 KiB) Downloaded 2024 times
5.png
PIC 5
(23.86 KiB) Downloaded 2024 times

Post Reply