creating a component macro

For questions and comments on programming in general. And for any items that don't fit into the forums below.

Moderators: Benj, Mods

Post Reply
Alberta2012
Flowcode v5 User
Posts: 63
Joined: Fri Apr 19, 2013 2:18 am
Has thanked: 10 times
Been thanked: 14 times
Contact:

creating a component macro

Post by Alberta2012 »

Hi everyone,

First, I'm not 100% sure this post is at the right place, but I'm confident that if it's not the case, it will be pushed to the right location.

Second, I need some explanation regarding if it's possible or not to create our own "component macro"

I am currently using FC5 (I bought the FC6 upgrade, but I still prefer FC5)

In this particular case, I would like to create a component macro, that would accept a decimal value, and pushes it thru 4 lines, as a BCD value. I know, that it can be done within a routine, but I'm curious if one can create its own Component macro, where the 4 lines would be assigned, and a simple value could be passed ?!?!

I read a bit thru this forum, and found some explanations about creating some sort of component with FC6, but it looked to me, like I would have created an object, like a mecanical version, for simulation rather than a component....Am I missing something ???

To be honest with you, I find that the feature of being able to create "mecanical" components for animation in FC6, is absolutely useless. I would have prefered if MatrixMultimedia would have worked on getting us modules to decode DMX, or module to drive some WS2812 LED, or module to talk X-10....Stuff that you see on the forum, that people are struggling with ... If I want a 3D animation software, I will get a 3D animation software.... To me FlowCode is a programming software ! Please don't start bashing, it's my personnal opinion. Maybe a lot of people requested these, who knows !

So back to my original question: can I package my own component macro in FC5 ?

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: creating a component macro

Post by kersing »

A component macro is usually associated with a hardware component. For FC5 a component macro needs to be written in C and there is a limit of two custom components. To create one, add a custom component to your flow chart and modify the component code (right click menu) by adding a new macro and writing the required C code for it. Keep in mind C code can not be simulated, so once you use this method you will not be able to simulate your program.

If you want to create re-usable macros a better way (IMHO) would be to create a macro and export it. If you want to re-use the code in an other flow chart you simply import the macro to use it there. The disadvantage of this method: it is hard to synchronize changes as you will have to make the same change to the macro in every flow chart it has been imported into.

FC6 allows component code to be written in Flowcode. This allows simulation of your own components (macros) and simplifies the creation of component macros as C coding is no longer required. It also allows multiple (unlimited?) custom components to be created and added to your flow chart. This is fast improvement over previous versions of FC. The changes required enable this requires a complete redesign of FC and MM decided to add 3D while overhauling the code base to enable life like simulation for the users requiring it.
FC6 does require getting used to, but I found it well worth the investment (time).

BTW the changes made to the framework also allow for easier adding things like DMX. It can also be done by third parties, where previously everything had to be done by MM.
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

Kenrix2
Flowcode v5 User
Posts: 211
Joined: Tue Feb 19, 2013 9:51 pm
Has thanked: 72 times
Been thanked: 177 times
Contact:

Re: creating a component macro

Post by Kenrix2 »

As for your specific use of a macro to convert a decimal value to BCD by "pushing it thru 4 lines", this might be a good starting point for research: http://www.microchip.com/forums/tm.aspx ... &high=btoa
Good luck.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: creating a component macro

Post by medelec35 »

I help someone convert Decimal to BCD if that helps:
http://www.matrixmultimedia.com/mmforum ... 900#p18900
It could be the four lines your referring?

Martin
Martin

Alberta2012
Flowcode v5 User
Posts: 63
Joined: Fri Apr 19, 2013 2:18 am
Has thanked: 10 times
Been thanked: 14 times
Contact:

Re: creating a component macro

Post by Alberta2012 »

thanks everyone....I'll explore creating a component. Not sure how, but I should figure it out ...

When I mentionned the BCD conversion, it was pretty much as an example: I've done something similar in the past....

I was just curious on how to create re-usable component.

As a PLC programmer, I'm used to create my own "block" that I can re-use in different program; the main advantage is that my code within those block have been proven and help reducing development time.

Post Reply