#Define
-
- Posts: 116
- Joined: Tue Jul 17, 2012 9:34 am
- Been thanked: 18 times
#Define
Coming from an assembler background something I miss in Flowcode is the ability to define Port pins with a label.
e.g
#DEFINE INHIBIT PORT B, 2
So INHIBIT = True
rather than B2 = True
It's all right using standard pin labels with simple projects, but gets tedious when many I/O pins are involved. Easy to make simple mistakes...
Is there anyway to use labels to reference Port pins in Flowcode ?
Cheers
Stewart
e.g
#DEFINE INHIBIT PORT B, 2
So INHIBIT = True
rather than B2 = True
It's all right using standard pin labels with simple projects, but gets tedious when many I/O pins are involved. Easy to make simple mistakes...
Is there anyway to use labels to reference Port pins in Flowcode ?
Cheers
Stewart
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: #Define
Hi Stewart,
The simplest way using Flowcode v6 is to use properties. Click on an empty area of the Flowcode panel and in the property window you will get properties for your project, default is none.
Click on the drop down by the "Properties" heading in the properties window and select "Add New".
Give it a meaningful name and variable name e.g. "My Pin" and "pin" and set the type to a "single digital pin".
Then you can select the pin as you normally would for a component and assign values to the pin by passing values to the variable.
e.g. using a calculation icon you can enter things like..
The simplest way using Flowcode v6 is to use properties. Click on an empty area of the Flowcode panel and in the property window you will get properties for your project, default is none.
Click on the drop down by the "Properties" heading in the properties window and select "Add New".
Give it a meaningful name and variable name e.g. "My Pin" and "pin" and set the type to a "single digital pin".
Then you can select the pin as you normally would for a component and assign values to the pin by passing values to the variable.
e.g. using a calculation icon you can enter things like..
Code: Select all
pin = 1 //outputs a logic 1
pin = 0 //outputs a logic 0
var = pin //Reads the input logic level and assigns to var
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 116
- Joined: Tue Jul 17, 2012 9:34 am
- Been thanked: 18 times
Re: #Define
Hi Benj,
I was OK up to "Give it a meaningful name and variable name e.g. "My Pin" and "pin" and set the type to a "single digital pin"."
Then I am lost...
If I want to set up for example PORT B pin 2 as INHIBIT, what must I enter ? The fancy bits can come later.
Cheers
Stewart
I was OK up to "Give it a meaningful name and variable name e.g. "My Pin" and "pin" and set the type to a "single digital pin"."
Then I am lost...
If I want to set up for example PORT B pin 2 as INHIBIT, what must I enter ? The fancy bits can come later.
Cheers
Stewart
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: #Define
Hello,
Creating a property is a lot like creating a variable.
The cosmetic name is essentially the label shown by the property in the property window.
The property type is a drop down list of available property types, for a single pin connection you need the single digital pin setting.
The property variable is the variable name which you will use to refer to the property value in your program.
When you click ok the property is created allowing you to assign a pin to the property variable, like you would for a LED component for example.
You then refer to the property variable in your program e.g. if the property variable is ready_led then in your program you would write ready_led = 1 using a calculation icon to output a 1 to the pin.
Creating a property is a lot like creating a variable.
The cosmetic name is essentially the label shown by the property in the property window.
The property type is a drop down list of available property types, for a single pin connection you need the single digital pin setting.
The property variable is the variable name which you will use to refer to the property value in your program.
When you click ok the property is created allowing you to assign a pin to the property variable, like you would for a LED component for example.
You then refer to the property variable in your program e.g. if the property variable is ready_led then in your program you would write ready_led = 1 using a calculation icon to output a 1 to the pin.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 116
- Joined: Tue Jul 17, 2012 9:34 am
- Been thanked: 18 times
Re: #Define
Hi Benj,
Got it...
I had not pressed OK, so did not take things to the next step - Duh !
That seems to work and do what I want. However, I have some questions.
1) Is the cosmetic name used anywhere other than the property window ?
2) What is "Generate a define for the property" used for ? It works OK with this unticked.
3) I presume that it is not possible to monitor a property variable in the Simulation window during debugging, but rather use the actual pin ?
Cheers
Stewart
Got it...
I had not pressed OK, so did not take things to the next step - Duh !
That seems to work and do what I want. However, I have some questions.
1) Is the cosmetic name used anywhere other than the property window ?
2) What is "Generate a define for the property" used for ? It works OK with this unticked.
3) I presume that it is not possible to monitor a property variable in the Simulation window during debugging, but rather use the actual pin ?
Cheers
Stewart
Re: #Define
Hi
stewartbaker asked " if I want to set up for example PORT B pin 2 as INHIBIT "
I´m with Flowcode 9 with microchip PICs at the enterprise I work.
At home I have bought flowcode 6 some years ago.
So, I ask nearly the same, assuming both version could do it:
If I want to set up for example PIC PORTB RB2 as TEST ?
Which will be the cosmetic name and the property variable.
should I check generate a variable for the property ?
Can someone tell me how to achieve the same, please?
Thanks,
Miguel
stewartbaker asked " if I want to set up for example PORT B pin 2 as INHIBIT "
I´m with Flowcode 9 with microchip PICs at the enterprise I work.
At home I have bought flowcode 6 some years ago.
So, I ask nearly the same, assuming both version could do it:
If I want to set up for example PIC PORTB RB2 as TEST ?
Which will be the cosmetic name and the property variable.
should I check generate a variable for the property ?
Can someone tell me how to achieve the same, please?
Thanks,
Miguel
.
.
Thanks in advance,
---------------------------------------------
Miguel Garcia
Electronics Technician
Electronic Systems Developer
.
.
Thanks in advance,
---------------------------------------------
Miguel Garcia
Electronics Technician
Electronic Systems Developer
.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: #Define
Hi Miguel.
Hover over the lower properties to show a drop-down.
Select Add new The Cosmetic name will be TEST
You can have spaces within the cosmetic name.
The Property type you can select Single digital pin.
The Property variable can be something like PIC_PORTB_RB2.
Leave Visible, Writable and Generate a define for the property as the defaults.
After Selecting OK, you will need to select the pin that is next to TEST
The TEST is now available to use which will be assigned to your chosen pin.
For future reference, the Flowcode forums are for any V9 related questions.
You can sign up for them here if not already done so
Hover over the lower properties to show a drop-down.
Select Add new The Cosmetic name will be TEST
You can have spaces within the cosmetic name.
The Property type you can select Single digital pin.
The Property variable can be something like PIC_PORTB_RB2.
Leave Visible, Writable and Generate a define for the property as the defaults.
After Selecting OK, you will need to select the pin that is next to TEST
The TEST is now available to use which will be assigned to your chosen pin.
For future reference, the Flowcode forums are for any V9 related questions.
You can sign up for them here if not already done so
Martin
Re: #Define
Hi medelec35
Lots of thanks for your answer...
That days my mind was too jammed and you made things much more clear..
Lots of thanks for your answer...
That days my mind was too jammed and you made things much more clear..
Last edited by miggarcbs on Sun Feb 13, 2022 5:18 pm, edited 1 time in total.
.
.
Thanks in advance,
---------------------------------------------
Miguel Garcia
Electronics Technician
Electronic Systems Developer
.
.
Thanks in advance,
---------------------------------------------
Miguel Garcia
Electronics Technician
Electronic Systems Developer
.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times