Macros...

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

Moderator: Benj

Post Reply
saakis
Posts: 44
Joined: Sat Dec 11, 2010 8:50 pm
Has thanked: 8 times
Been thanked: 3 times
Contact:

Macros...

Post by saakis »

Hi Matrix people!
I feel a bit frustated trying to make a makro in a v6 program but I can't manage to do that so far. What am I doing wrong? I was a happy v4 and v5 user and so I bought the newer version hopping that some issues I had sould be solved. So far I have a lot of problems not doing the quite simple projects I want to make but with the "bells and whistles" the new program offers. I am a service engineer and I want simple things that works perfect. I don't care so much about colors, shapes and 3D's that make my life harder. Can you make a flow code that give me access to the counter of TMR1? That would be very good and helpfull, but trying to resize the buttons and accidentaly tilting them and trying to put them back it is a bit annoying as time consumming as well. I believe upgrade means "make you life easier" but for instance incompatibility between the older version and new does not help. Can you imagine that with windows? I have to keep and running three different programs...The Flowcode is a good chance for people like me who want to bend over to the word of microcontrollers but have not the time and the patience to do that.So please make our lives easier. :?
Please take a look to the flowcode below of what is going wrong and the programm denies to simulate because of the macro. I want just to clear the lcd. One more...can I jumb from an Interrupt to a point in the main programm? If not how I can go from an interrupt to a certain point in the programm?
Best regards
[attachment=0]Multi-Pulse_gen/attachment.fcfx
Attachments
Multi-Pulse_gen.fcfx
(11.61 KiB) Downloaded 254 times

Spanish_dude
Posts: 594
Joined: Thu Sep 17, 2009 7:52 am
Location: Belgium
Has thanked: 63 times
Been thanked: 102 times
Contact:

Re: Macros...

Post by Spanish_dude »

Moved to V6 forum.

- Nicolas

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: Macros...

Post by medelec35 »

Hi saakis,
I can help you with your flowchart so you can get your project running.
The reason why you have a syntax error is because unlike previous versions of Flowcode, with V6 string is a keyword so you cant use keywords for variables or calling macros.


All you will need to do is make sure Project Explorer is open (View menu).
Click on the macros tab, Right click on STRING macro, select Edit.
Rename, E.g StringMacro
Then your Flowchart simulation should run.
saakis wrote: I don't care so much about colors, shapes and 3D's that make my life harde
That is being addressed in the latest update that's due to be released.
Components will no longer default to the 3D panel (System Panel) but there will be an option to default to the 2D panel (Dashboard Panel).
So no more funny angles if your not use to 3D

What hardware have you got (e'g internal osc, external cryatal, osc speed etc) as we may need to check your configuration settings are correct before running on hardware.

Martin
Martin

saakis
Posts: 44
Joined: Sat Dec 11, 2010 8:50 pm
Has thanked: 8 times
Been thanked: 3 times
Contact:

Re: Macros...

Post by saakis »

Thank you very much Martin, now it works! I dont' understand why I had to do it, but it works... I dont' understant also why must spoil somthing it works fine. Could you also answer to me please if from an interrupt can go in a specific point in the main program, because I tried with a connection point but I could't. Is there a solution to that in order to get out of an endless loop without make hard reset.
Thank you again!
Sakis

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: Macros...

Post by medelec35 »

Hi saakis ,
Your welcome.
saakis wrote: I dont' understand why I had to do it, but it works.
For any macro name or variable name, you will not be able to use the following reserved keywords:
Keywords.png
(7.02 KiB) Downloaded 3439 times
saakis wrote:Could you also answer to me please if from an interrupt can go in a specific point in the main program, because I tried with a connection point but I could't. Is there a solution to that in order to get out of an endless loop without make hard reset.
If you can explain in a bit more detail what you want to happen e.g using timer 1 interrupt to count in seconds and after x seconds displayed is cleared for x seconds.
Or then pressing a switch connected to INT0 the display is cleared etc.

Then I can modify your flowchart for you.

The simplest way If you wanted to have a go yourself is add a variable called UpdateTimerInt.
You can then have a decision icon in main:

Code: Select all

If UpdateTimerInt: Clear LCD etc: UpdateTimerInt=0
Within a decision macro, If you don't have an equals sign after a variable e.g if UpdateTimerInt
instead of If UpdateTimerInt = 1
then the decision is true if UpdateTimerInt is any value higher than 0

Then within your interrupt macro you just have:

Code: Select all

UpdateTimerInt=1
Martin
Martin

saakis
Posts: 44
Joined: Sat Dec 11, 2010 8:50 pm
Has thanked: 8 times
Been thanked: 3 times
Contact:

Re: Macros...

Post by saakis »

Thanks again Martin. So it was bad luck by giving the name string to my makro...Where is this keywords written at? Because in the help file wasn't.Better help files and videos will be wellcome. I want to do a pulse genarator with three modes. One to be as a normal gen, the second as a single pulse gen with variable pulse length and the third as a string pulse in which I can vary the number of pulses I want and the period of them and maybe a variable space and repeat. In the first mode at least I want to have the oppurtunity to get out of the loop by having an INT0 with a switch.
Sakis

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: Macros...

Post by medelec35 »

saakis wrote:Where is this keywords written at?
What I did to get the keywords is add a variable called STRING and then a pop up appeared stating:
Keywords2.png
(30.07 KiB) Downloaded 3434 times
saakis wrote:I want to have the oppurtunity to get out of the loop by having an INT0 with a switch.
Sakis
That is easy to do with the method I mentioned (see attached Flowchart), but before you can do that you must remove LCD connection from B0 as that is also the connection for INT0

If there is going to be more than one interrupt, then the switch component macro can be used instead of decision.

I can see if I can help you with your pulse generator.


Martin
Attachments
Multi-Pulse_gen2.fcfx
(13.9 KiB) Downloaded 224 times
Martin

saakis
Posts: 44
Joined: Sat Dec 11, 2010 8:50 pm
Has thanked: 8 times
Been thanked: 3 times
Contact:

Re: Macros...

Post by saakis »

Thank you Martin for your advice! I will do that.
Sakis

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: Macros...

Post by medelec35 »

No problem.

What period are the pulses?
I will need to determine if going to use built in PWM or timer interrupt.
Martin

saakis
Posts: 44
Joined: Sat Dec 11, 2010 8:50 pm
Has thanked: 8 times
Been thanked: 3 times
Contact:

Re: Macros...

Post by saakis »

Hi Martin,
the singe pulse from 10 uS to 1 sec, the square wave from 100 kHz to 1 Hz and the string from 2 to 1000 pulses and 10 uS to 0.5 sec period. These are not absolute but somwhere there would be good.
Sakis

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: Macros...

Post by medelec35 »

Flowchart is going to be complex.
For example you need a means of adjusting pulse width, frequency and to select which option to take.
Have you decided what switches/ADC''s will do what?

I won't have time to create the flowchart for you, and besides that won't help you to learn.

I can help you but you will need to do a lot of the flowchart.

First I would recommend learning about timer interrupts.
There are plenty of resources on this forum.

If you get stuck then just ask away

Martin
Martin

saakis
Posts: 44
Joined: Sat Dec 11, 2010 8:50 pm
Has thanked: 8 times
Been thanked: 3 times
Contact:

Re: Macros...

Post by saakis »

Hi Martin again,
two of the three pieses I told you I did it in the past and worked fine. I did the single pulse timer and was very accurate according to my oscilloscope. My problem is some problems using the v6 programm... For instance now I can't find how to see the values of the variables. In v5 was easy and also I could give my own values... Could you help me in that way? I don't want to make the flow code for me. I do all this not because I really need the generator but if you do a design you learn much more.
Sakis

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: Macros...

Post by medelec35 »

saakis wrote:For instance now I can't find how to see the values of the variables.
In V6 you use the Simulation Debugger.
See:
http://www.matrixmultimedia.com/wiki/in ... n_Debugger

With Flowcode simulation stopped press F8
You should see the simulation debugger:
Simulation debugger.png
(30.99 KiB) Downloaded 3405 times
Left click on the top left just below Expression, select add variable, then select all variables you wish to watch.
Selection has is the standard windows functions.
I.e hold control key while individually selecting.
Or
Select 1st variable, then Hold shift key and select the last variable.
All variables between the selected should also be added.

If you want to watch the variables whilst running simulation, you can either slide the slider to 50Hz or lower. or just single step by pressing F8

To alter variable value just select the value and type new value.

Martin
Martin

Post Reply