Page 1 of 1

#Define

Posted: Thu Jun 19, 2014 10:31 am
by stewartbaker
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

Re: #Define

Posted: Thu Jun 19, 2014 5:31 pm
by Benj
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..

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

Re: #Define

Posted: Thu Jun 19, 2014 11:05 pm
by stewartbaker
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

Re: #Define

Posted: Fri Jun 20, 2014 1:47 pm
by Benj
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.

Re: #Define

Posted: Fri Jun 20, 2014 4:04 pm
by stewartbaker
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

Re: #Define

Posted: Wed Jan 26, 2022 2:10 pm
by miggarcbs
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

Re: #Define

Posted: Wed Jan 26, 2022 3:12 pm
by medelec35
Hi Miguel.
Hover over the lower properties to show a drop-down.
Select Add new
Panel Properties.png
Panel Properties.png (27.5 KiB) Viewed 5454 times
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

Re: #Define

Posted: Fri Jan 28, 2022 11:39 pm
by miggarcbs
Hi medelec35

Lots of thanks for your answer...

That days my mind was too jammed and you made things much more clear..

Re: #Define

Posted: Sat Jan 29, 2022 2:44 pm
by medelec35
Hi Miguel.
You're welcome.
I'm happy I have helped you.