Flowcode 6 - Need Help

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

Moderator: Benj

Post Reply
Th0ma$
Posts: 1
Joined: Thu Apr 28, 2016 5:49 pm
Contact:

Flowcode 6 - Need Help

Post by Th0ma$ »

hello all, so the following programs were done in Flowcode so I want you to help me has explained. Finally say, has what is this line etc ...
Thank you for your help

Here is the program hand (variable = b)
http://www.noelshack.com/2016-17-146186 ... e-main.png

Here under the program of the one above:
http://www.noelshack.com/2016-17-1461861566-dmx.png

Voila, Please explain me please (briefly even if you have no time)

kersing
Valued Contributor
Valued Contributor
Posts: 2010
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 552 times
Been thanked: 1079 times
Contact:

Re: Flowcode 6 - Need Help

Post by kersing »

Check this message, specifically the part about tutorial videos.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

JUZAR
Posts: 53
Joined: Wed Feb 25, 2015 1:31 pm
Has thanked: 15 times
Been thanked: 4 times
Contact:

Re: Flowcode 6 - Need Help

Post by JUZAR »

Hi All.

Can any one help me in writing a flow code for below.

1) I am using PIC 16F1824 device.
2) I want to generate a delay of 20 seconds using TIMER of PIC.
3) A input pin is used to start the timer. Once input pin goes HIGH the 20 seconds delay timer is initialized and on completion of 20 seconds a LED is to be turned ON.

Requested to kindly advice which TIMER/s is to be used in above mentioned PIC and how to initialize the timer and read the lapsed timer count to check completion of 20 seconds to turn ON the LED

Regards

Juzar.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9255
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2546 times
Been thanked: 3740 times
Contact:

Re: Flowcode 6 - Need Help

Post by medelec35 »

Hi JUZAR,
All the setting to do what you require is dependent on your hardware.
E.g. Type and frequency of oscillator.
Can you post a flowchart that has osc and configuration setting correct, then I can help you further.

Martin
Martin

JUZAR
Posts: 53
Joined: Wed Feb 25, 2015 1:31 pm
Has thanked: 15 times
Been thanked: 4 times
Contact:

Re: Flowcode 6 - Need Help

Post by JUZAR »

Hi Martin.

Kindly see attached flowcode which is not complete because I don't know how to initialize timer. The logic is as under.

1) C code initialized to set up oscillator frequency.
2) Potentiometer is used as component macro.
3) Flow code checks whether potentiometer values is > 0X88. If it is greater than 0X88 it will call a macro to initialize the TIMER1 to start the 20 seconds timer. I have used a toggle function so that timer not initialized repeatedly if value is >0X88 and further timer is not reset again and again.
4) If value is < 0X88, than timer1 will be disabled and toggled to 0. Or if in the middle of count, say 10 seconds are finished and potentiometer value goes <0x88 than controller will reset the timer count to 0.
5) Once 20 seconds are finished the LED will turn ON to indicate that 20 seconds are over.
6) Now I don't know how to read timer status using flowcode to check whether 20 seconds is completed or not. So kindly help me how to access the timer and read the status.

Exact requirement is to read the potentiometer status if it is >0x88 the timer will start and once 20 seconds are finished than interrupt is generated to call the main routine so that LED can be turned ON.

Awaiting your reply at the earliest.

Regards.

Juzar.
Attachments
Longdelaydemo.fcfx
(8.04 KiB) Downloaded 292 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9255
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2546 times
Been thanked: 3740 times
Contact:

Re: Flowcode 6 - Need Help

Post by medelec35 »

Hi Juzar,
Just one bit of confusion.
You have an osccon command which suggests your using internal oscillator.
However, the clock is set to 19660800Hz which suggests you are using external osc e.g crystal.
Configuration settings are set to an external clock rather than an internal or external oscillator.
Reason I asked you to explain about osc type and frequency is because it will have an effect on the timings.
Are you using internal oscillator,external crystal or resonator?
What is the clock frequency?

Martin
Martin

JUZAR
Posts: 53
Joined: Wed Feb 25, 2015 1:31 pm
Has thanked: 15 times
Been thanked: 4 times
Contact:

Re: Flowcode 6 - Need Help

Post by JUZAR »

Hi Martin.

Sorry, I missed to set the project options. Its now done in below attachment. I have used internal oscillator with clock speed of 16 MHz. While rest should be now OK.

Regards.

Juzar.
Attachments
Longdelaydemo.fcfx
(8.04 KiB) Downloaded 271 times

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9255
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2546 times
Been thanked: 3740 times
Contact:

Re: Flowcode 6 - Need Help

Post by medelec35 »

Hi Juzar,
Can you try the attached flowchart.
I have disabled watchdog timer, love voltage programming, PLL etc.
MCLR is still enabled as I don't know if pulling MCLR line up or not?


Martin

Edit. Attachment removed and added in a different post.
Last edited by medelec35 on Tue May 17, 2016 10:35 am, edited 1 time in total.
Reason: Removed attachment.
Martin

JUZAR
Posts: 53
Joined: Wed Feb 25, 2015 1:31 pm
Has thanked: 15 times
Been thanked: 4 times
Contact:

Re: Flowcode 6 - Need Help

Post by JUZAR »

Thanks Martin,

Will give you feedback soon

Regards.

Juzar

JUZAR
Posts: 53
Joined: Wed Feb 25, 2015 1:31 pm
Has thanked: 15 times
Been thanked: 4 times
Contact:

Re: Flowcode 6 - Need Help

Post by JUZAR »

Hi Martin.

Tested the flowcode on simulation and its working, also worked perfectly for all possible logic conditions.

I have one question on flowcode program and hardware of PIC, because I am new to this microcontroller programming I need your advise to clear this doubts, I would like to know whether the macro is repeatedly called by main routing on each over flow of timer or macro routine completes the 20 seconds and than returns to main routing for further processing. If main routing is intervened repeatedly by timer overflow than it there any way that main routine is called one 20 seconds are finished.

Awaiting your advise at the earliest.

Regards.

Juzar.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9255
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2546 times
Been thanked: 3740 times
Contact:

Re: Flowcode 6 - Need Help

Post by medelec35 »

Hi Juzar,
Sorry I posted wrong flowchart, attached is correct one.
How it works is as follows:
Timer0 is using a 8bit timer.
It has a register called tmr0.
Since interrupt is set at 61.035Hz (make a mental note of 61) then every

Code: Select all

1/61.035/256 = 64uS 
tmr0 is incremented by 1.
When register reaches 255, on the next increment it rolls-over to 0.
Its at that point the timer0 interrupt macro (sec20delay) is accessed.
Since only

Code: Select all

64us * 256 = 0.016384 secs
has elapsed we need to count each time interrupt macro has been accessed since interrupt has now been triggered.
For that we use a Count variable.
When macro has been accessed 61 times we know a fraction under a second has elapsed.
Therefore Seconds variable is incremented.
That is how timing is done.
The sec20delay is not called repeatedly by main, its automatically called by the timer0 interrupt when internal tmr0 register rolls over from 255 back to 0.
Timer interrupt macro is also known as Interrupt service Routine or ISR which has to be serviced and allowed to exit.

Martin
Attachments
Longdelaydemo 2.fcfx
(9.93 KiB) Downloaded 276 times
Martin

JUZAR
Posts: 53
Joined: Wed Feb 25, 2015 1:31 pm
Has thanked: 15 times
Been thanked: 4 times
Contact:

Re: Flowcode 6 - Need Help

Post by JUZAR »

Hi Martin.

Thanks very much for detailed information. I could now understand how this ISR is working. In case if any more information is required I shall contact you.

Good day.

Regards.

Juzar.

JUZAR
Posts: 53
Joined: Wed Feb 25, 2015 1:31 pm
Has thanked: 15 times
Been thanked: 4 times
Contact:

Re: Flowcode 6 - Need Help

Post by JUZAR »

Hi Martin.

Though the flowchart is working properly, but its giving error message as per attached file. Kindly help how to resolve this issue.

Regards.

Juzar.
Attachments
delaytimer.pdf
(315.71 KiB) Downloaded 256 times

User avatar
Benj
Matrix Staff
Posts: 15219
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4763 times
Been thanked: 4299 times
Contact:

Re: Flowcode 6 - Need Help

Post by Benj »

Hello Juzar,

The error is basically telling you that the variable toggle is read before it has been assigned a value.

Either give the variable an initial value via the variable manager or use a calculation icon to set the variable's value before you read the variable.

The simulation will always assume the value 0 for an uninitialised variable but the actual micro controller hardware will have a random value, hence the error/warning.

JUZAR
Posts: 53
Joined: Wed Feb 25, 2015 1:31 pm
Has thanked: 15 times
Been thanked: 4 times
Contact:

Re: Flowcode 6 - Need Help

Post by JUZAR »

Thanks Benj.

After assigning initial value, its not giving any error. Flowcode6 is now becoming more and more interesting because of valuable advise from all experts.

Thanks again.

Regards.

Juzar.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9255
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2546 times
Been thanked: 3740 times
Contact:

Re: Flowcode 6 - Need Help

Post by medelec35 »

Hi Juzar,
I only preassigned new variables I added and did not check variables you added.
Sorry about that.

Glad you are nor more familiar with interrupts though.
Martin
Martin

JUZAR
Posts: 53
Joined: Wed Feb 25, 2015 1:31 pm
Has thanked: 15 times
Been thanked: 4 times
Contact:

Re: Flowcode 6 - Need Help

Post by JUZAR »

Hi Experts,

Though with your help I have gained some knowledge on interrupt and timers, but I am again stuck up in writing a flowcode. Can any of the expert help me to make a flowchart for below.

1) There is a variable input frequency from 45 Hz to 50 Hz.
2) I want to turn ON an LED when frequency reaches 47 Hz.
3) PIC16F1824 running at 16 MHz clock frequency is to be used to detect 47 Hz
4) Kindly guide me how can we detect 47 Hz using interrupt / timer to measure 21.276 milli seconds ( 47 Hz ) and turn on LED.
5) If possible the software should run independently in background without intervening main routing and generate an interrupt when 21.276 milli seconds is measured to tick main routine to turn ON LED.

Awaiting your reply at the earliest.

Regards.

Juzar.

kersing
Valued Contributor
Valued Contributor
Posts: 2010
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 552 times
Been thanked: 1079 times
Contact:

Re: Flowcode 6 - Need Help

Post by kersing »

Juzar,

We don't mind helping, however it would be nice if you at least attempt to solve this yourself. Search the forum to check if there is anything that might help and create a flowchart that attempts to solve the problem. Or describe how you would like solve the problem and explain what issues you are facing when creating the flowchart.

Best regards,

Jac
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

JUZAR
Posts: 53
Joined: Wed Feb 25, 2015 1:31 pm
Has thanked: 15 times
Been thanked: 4 times
Contact:

Re: Flowcode 6 - Need Help

Post by JUZAR »

Hi Jac

Ok, I will first try and apply efforts to solve it. By this way it will be possible learn many things and understand various experiences of forum members.

Regards

Juzar

JUZAR
Posts: 53
Joined: Wed Feb 25, 2015 1:31 pm
Has thanked: 15 times
Been thanked: 4 times
Contact:

Re: Flowcode 6 - Need Help

Post by JUZAR »

Hi
I need an advise on lookup table.

I want to read an analog signal through A/D and get 8 bit equivalent, since the input is non linear, I wanted to make a LUT and compare the incoming analog signal with LUT and use that compared LUT data to display a seven segment LED display. Since I have never used this feature, need help how to use it. Couldn't find detailed information of LUT on net, it will helpful with an example on how its implemented in V6. This will help in better understanding.

Regards.

JUZAR
Posts: 53
Joined: Wed Feb 25, 2015 1:31 pm
Has thanked: 15 times
Been thanked: 4 times
Contact:

Re: Flowcode 6 - Need Help

Post by JUZAR »

Hi,

I need help in configuring internal frequency of PIC12F1822 using Flowcode6. I want to know what should be written in C code icon to configure internal frequency to 8 MHz.

Awaiting your reply at the earliest.

Thanks

Juzar

User avatar
AbhijitR
Posts: 216
Joined: Fri Nov 07, 2014 12:48 pm
Location: Pune, India
Has thanked: 215 times
Been thanked: 52 times
Contact:

Re: Flowcode 6 - Need Help

Post by AbhijitR »

Hello! Juzar

May be you should try to insert as below in the "C" block in lowercase, as the first block in MAIN loop, V8 has got a very nice function (IntOscHelper1).

osccon=0x70;

Abhi

JUZAR
Posts: 53
Joined: Wed Feb 25, 2015 1:31 pm
Has thanked: 15 times
Been thanked: 4 times
Contact:

Re: Flowcode 6 - Need Help

Post by JUZAR »

Thanks Abhi,

I shall implement and check it

Regards.

Juzar

Post Reply