Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Programming PIC18 using function blocks and a graphical IDE

Status
Not open for further replies.

Lourens

Member
I have been working on an IDE to use function blocks (FB) in a graphical interface and would like to hear from others interested in this kind of thing. Programming is done by 'drawing' the the application using standard FBs. Debugging is done using the PIC and PC serial ports to display live data of the values present on the input/output pins of FBs. The FB library contains around 130 elements - from the humble AND/OR variety to PID controller and I2C Read Write elements. Compliments of Microchips asm, the IDE produces ready-to-burn hex code. As a picture is worth a thousand words.... included is an example of a simple temperature alarm.
 

Attachments

  • TemperatureAlarm.jpg
    TemperatureAlarm.jpg
    12.6 KB · Views: 1,087
We have one or two members using Flowcode for programming.

There is an educational tool from Yenka which is like flow code but produces basic code instead of boostc. Also has a limited hardware simulation.

I have some experience teaching with Yenka and helping people with flowcode projects.

IMHO Yenka in a great tool to introduce programming but students do not want to give it up.

As programming languages thee graphical tools are no less complex then other procedural languages. Just a different sort of syntax to learn and a bit easier to visualize to start with for most people.
 
Last edited:
I think that kind of programming is a good thing for automation people etc. But they almost always don't provide enough control to "fine tune" the system. For example, if I set up a PID control I want to at least know what is the update frequency of the discrete PID loop. Even better if I can choose the frequency, but many systems don't provide that kind of control. It is scary to just "drag and drop" a PID control block and not knowing how it's implemented.. I don't trust them to be high quality.
 
Hi, yes, but have you tried LabVIEW? It provides the same level of abstraction and if you want than you can go as deep as you want. Really good on the instrumentation side but very heavy if you take it as just a software thing. But way better than Matlab.
 
Hi misterT
You are right about PIC01_CB (thats what i call it), its is for automation, what most PIC's do (?). PIC01_CB provide all the things you mention. It will take to much typing to explain all, but the PIC software execute function blocks under a cooperative multi tasker (more correct a task manager) with 'time tasks'. With the IDE you assign a graphics page to a task. The IDE will automatically adjust PID time settings to cater for different execution times. There are also function blocks for integrators, rate limiters and pulsers that need their execution to be time regulated, and all being taken care of automatically, or should i say without you having to worry about it. I include a clip of the PID block documentation which you might find interesting. Lots more documentation is available on PIC01_CB for those interested.
 

Attachments

  • TestingPID.jpg
    TestingPID.jpg
    77.7 KB · Views: 573
  • PIC01_CB_Programming_with_Pictures.pdf
    153.7 KB · Views: 555
The IDE will automatically adjust PID time settings to cater for different execution times. There are also function blocks for integrators, rate limiters and pulsers that need their execution to be time regulated, and all being taken care of automatically, or should i say without you having to worry about it.

In "serious" control applications I need to worry about things like that. I need to know is the algorithm executed often enough, and how much delay there is between input read and output update.. and what are the integrator limits and can I set them manually? And is the derivative calculated from error signal or is there a more stable algorithm in use. Knowing the PID update frequency is crucial in order to tune the PID parameters correctly.

If PIC01_CB provides that kind of flexibility then I consider it to be potentially very useful. Otherwise it is only good for very simple things.
 
Last edited:
Great Cow BASIC has a Graphical BASIC, version 0.9 that was released last year that is really great you can make code using blocks. Then refine them with the basic editor which gives control over any of the set values
**broken link removed**
http://gcbasic.sourceforge.net/
 
Last edited:
Of Pictures PICs and PIDs

Hi misterT
I probably used the expression 'dont worry' wrongly. Anyway in PIC01_CB the PID execution rate is known; 10, 20 40, 50, 100 or 200mSec. Input can come from a AI or other function block and output can go to another (say a cascade controller) function block or drive the PWM function block. The integer term is limited (for windup) and the integer (I-gain term) you can change to suit loop parameters. Same goes for the P and D terms. The derivative calculation is not based on the usual 3-point differencing method where a 2nd degree polynomial approximation is used. The method i used is more related to a least-squares approach, and much simpler! The attached is an example of the documentation for PIC01_CB function blocks and will explain the derivative algorithm, which uses the error signal to calculate. I plan to later include an option to use PV for this calculation. Also in the pipeline in a controller using the velocity algorithm, then you realy dont need to worry about those integral limits!
You talk about 'serious' control applications - I will not use PIC01_CB for a pace-maker but so far it has served me 'very' well in a couple of applications and i learnt a few things about VB.NET, which is used for the IDE.
 

Attachments

  • FBlock171_Description.pdf
    78.7 KB · Views: 504
you realy dont need to worry about those integral limits!

Sounds great and looks great, but let the user choose the integrator limit (it is important factor in PID control). Good documentation is the key to successful product.. so keep documenting all the details.
 
Last edited:
Hi Lourens,

I have great interest in their program "pic_cb".
I once had a version of the "Elektor Magazine," which did not function properly (PIC_CB v1.2). Where could I get a newer version?
(German -> English with google translate;-)

Many thanks
Steffen

PS. I hope that someone is still reading this old Thread
 
Hi Lourens,

I have great interest in their program "pic_cb".
I once had a version of the "Elektor Magazine," which did not function properly (PIC_CB v1.2). Where could I get a newer version?
(German -> English with google translate;-)

Many thanks
Steffen

PS. I hope that someone is still reading this old Thread

Hi Steffen
Give me more details of what did not function properly.
There is a newer version of PIC_CB available (which hopefully functions properly). It is also now available as an install file (3.7MB) that includes all current documentation. BUT there are still issues, i.e. you cannot use it with any version of MPLAB higer than 8.50, which is mainly the reason why i have not made it available. A solution to this issue is to include a version of MPASMWIN in the program but for that i must first get permission from Microchip.
I plan to make some modifications to PIC_CB; use the PLL to boost the clock to 32MHz, make communication faster (19200Bd), extend the i2c functions and include a simulator.
Greetings
Lourens
 
Hi Lourens,
thanks for the quick reply! The error comes at compile (Error Number: 170) and the MPASMWIN.exe has the version "5.35".
But I can certainly raise an older still. A small Dokomentation would not be bad, in the ELEKTOR was only "pic01_cb.exe" included, without documentation.
Thank you for the effort and Greetings
Steffen
 

Attachments

  • Error-170.jpg
    Error-170.jpg
    77 KB · Views: 512
Last edited:
Hi Steffen
Error 170 means: Macro library directory not found. Should be in C:\LLG_CB.
MPASMWIN v3.35 is OK, but pic_cb require that you have MPLAB installed (any version from 7.3 to 8.50) because it uses, in addition to the assembler, the pic-include files.
I suggest you send me a Private Message with your e-mail address so i can send you the install file for version 1.31. This will instal pic_cb and all current documentation (which include an Error Code List) in the required directories.

Lourens
 
Hi Lourens,

I sent you a PM.
thanks for the fast help.
I will contact you if all goes well.

Thank you and see you again
 
Hi Lourens,
It all worked out perfectly. thank you very much!
still have a question about lcd:
Actual state> "__1: __1: __1"
to condition> "01:01:01"
I can the "byte" result in a fast and can only show a leading zero (eg for watches)?

regards
Steffen
 
Hi Steffen
I do not understand your question so try to give more information of what you want to do. The documentation contains no information on how to connect the lcd device, so i attached it here.
Lourens

BTW i am glad you like the program. Once i have sorted out the assembler issue with Microchip i will probably put it on the forum for others to try.
 

Attachments

  • LCD_Display.pdf
    20.9 KB · Views: 408
Hi Lourens,
it will cut off the first zero and it will display a constant string without zeros. For example, three counter-fb with 2 digits display (with ":" separated 00:00)
I need the first zero and only two digits per counter. I hope I could explain it better now. the lcd is connected correctly;-)

regards
Steffen
 
Hi Steffen
The (fixed) string display function block can only disply a complete line (20 characters) on the lcd. With the next function block you can display a 'byte' variable at any position in the same line, but keep in mind byte variables use 3 character positions with spaces inserted for leading zeroes. Another option is to write code for your own function block. I have not had the time to do the documentation that will show users how to make their own function blocks. It is not difficult as you have the complete macro library to use and get ideas from, but nevertheless there are some basic information required. Send me a PM of what you want, i.e what character must occupy the 20 positions on the lcd line
regards
Lourens
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top