Flowcode and Velleman PIC board 8048 help needed

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

Moderators: Benj, Mods

Post Reply
dhissink
Posts: 2
Joined: Mon Apr 03, 2006 7:49 pm
Contact:

Flowcode and Velleman PIC board 8048 help needed

Post by dhissink »

I am a newbie to PIC programming, having bought a Velleman 8048 board. For programming i have chosen for Flowcode but...run into trouble right away. The Velleman board works with progpic2 instad of ppp. I directed to this file in the config of Flowcode, but this does not seem to work. Next step was making a HEX file, and open it in my programming software. Then I get an error message that config file is missing....
There is an option in Progpic to slect config options for the pic, but what should i choose? The examples from the tutorial do not seem to work, even the most simple ones. Is there anybody out there able to get me going??
Thanks!
Dick

Ian
Posts: 110
Joined: Thu Sep 29, 2005 10:53 am
Location: Matrix Multimedia
Contact:

Post by Ian »

PICmicro programs use CONFIG words to tell the Chip how to set itself up.
E.g. whether to use XT or RC clock mode, whether to turn the watchdog timer off etc.
These config words can be either embedded into the code, or set by the programmer.

Flowcode assumes that you will use PPP, or your own programmer software to set the config options for the device.
The PIC -> Config... menu option in Flowcode allows PPP users to set the configuration for the chosen PIC.
If your programmer software has a similar config option you can edit the compiler options to access that function. You will need to refer to the operating instructions for your programmer to check how to pass any parameters that are required.
You will need to check your software, or contact Velleman to find out how to do this.
There seems to be a config button on the programmer from what I can gather looking at the 8048 pdf. This may enable you to add the config words that way.

If your programmer software does not have a configure option you can embed the config words directly into your program either with the Add Defines component and macro, or by using a C Code macro.
The code needs adding as early as possible into your code

The code to add would be similar to:

asm {

__config1 0x3FFF
__config2 0x3FFF
}

You will need to modify such code for the number of Config words, their names and their values.

If your programming software does not give you easy to understand options for the config words you can use PPP to calculate them. The exact number of configs, their names and their values are listed, along with a set of options to help configure the PIC.

dhissink
Posts: 2
Joined: Mon Apr 03, 2006 7:49 pm
Contact:

Yep, one step further, thanks

Post by dhissink »

Hi Ian,
Thanks for your help. I am a step further now. I create an assembly file with flowcode and pick it up in the velleman progpic2 software. That software automatically sets the control word to 3fff. Changing it to 3f29 (trial and error for a 18f627) does the job and i am able to write into the pic.
thanks
Dick

Ian
Posts: 110
Joined: Thu Sep 29, 2005 10:53 am
Location: Matrix Multimedia
Contact:

Post by Ian »

One handy tip is to use PPP to calculate the config words.
Use the Configure PIC option to open the PPP config screen.
Manually select the chip you want in advanced config mode.
If you have the simple config screen click on the Options button and uncheck 'use simple config'.

You can then change the parameters using the easier drop down option boxes. The corresponding config word(s) are displayed on the left near the bottom. You can then use these values to set the config word(s) in other programmers, or to embed it into your code.

The config words can be displayed in Hex, Binary or Decimal.
You can also edit these config words and they wil lcahnge the drop down boxes to match. This allows you to enter config words you have been given, or have read from a chip, to see what configuration settings they contain.

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Contact:

Post by echase »

Can anyone give me an update on this? I tried to use my Velleman K8048 board to programme a PIC by writing a simple test programme in Flowcode. I noted that the config word is listed by FLowcode as 3f29 for a 16F627 (think the 18f627 above is a typo). I then loaded the .asm file into MPASM as supplied with the board, and compiled it (to hex?). This gave 65 errors, but don’t know what they are as can’t work out how to read the error file. Did not try to load the hex into the chip using progpic2 as assume the errors should be fixed first.

Or should I have cut out the MPASM step and gone straight from Flowcode's hex file to progpic2?

Afraid I don’t understand Ian’s ‘embed config words’ instructions above. What are config words all about and where do they go?

echase
Posts: 429
Joined: Mon Jun 11, 2007 11:55 am
Contact:

Post by echase »

This is a link to the K8048 manual.

http://www.velleman.be/downloads/0/user ... 048_uk.pdf

User avatar
Steve
Matrix Staff
Posts: 3194
Joined: Tue Jan 03, 2006 3:59 pm
Contact:

Post by Steve »

Don't bother with MPASM - use the HEX file created by Flowcode.

Configuration "words" are between 1 and 14 words (i.e. 13 or 8 bits) depending on the PICmicro in question. They allow the PICmicro to be set up in a particular mode.

For example, they determine the type of oscillator used, whether the chip has a watchdog timer, etc.

All the information you require for the configuration words is contained in the datasheet for that particular PICmicro (within the "Special features of the CPU" section).

It is vital that these configuration words are set up appropriate to your hardware settings. You will probably need to consult your Velleman manual for these.

User avatar
Benj
Matrix Staff
Posts: 14929
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Contact:

Post by Benj »

Hello

You need to load the hex file without the configuration word into the Velleman K8048 programming software. I used to have one of these boards myself. The configuration can be removed by using PPP to load the hex file and then clicking View -> Hex File. Double clicking on the config words will allow you to manually enter the number required or you can simply delete the information. Then using the Velleman programming software load the hex file and set the configuration word referring to the PICmicro datasheet.

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Contact:

Re: Flowcode and Velleman PIC board 8048 help needed

Post by 1Handypal »

Hello all and thanks for responses.

What confuses me is that when I tried to load hex file, produced by Flowcode, into the PIC and then read it back from PIC consequently saving with different name and comparing those two files gives me difference! I believe there's some conflict and/or overlap of features within Flowcode and PicProg2009. On the other hand, the effect of loading hex file, produced by flowcode, using PicProg2009 with selected features for particular micro, results in partially working code, looking as if code is periodically reset and starts from initial states. So if, for instance, you created a flowchart, where upon pressing a button an LED should light up and stay on, it would not stay, instead reset to off. Pushing button again will repeat the sequence and since there is a loop with delays, if you keep the button pressed down the LED would be cycling on/off. Additionally I tried loading hex file with PPP and checking config. bits, they look correct. Could somebody give me a hex file produced by FLowcode using 16F84A with the following periferals attached : B5 - LED, A0 - Button - both active high, XT oscillator 4 MHz. One press of a button should light up LED and keep it ON indefinitely unless reset or powered down, the next press within a few seconds should turn OFF LED?

Thanks for your support.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9015
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Flowcode and Velleman PIC board 8048 help needed

Post by medelec35 »

Hi 1Handypal,
Here are two hex files for 16F84A.
one is with osc set for HS and other with OSC set for XT.
With both programs:
Output B5 will change state each time you briefly press switch connected to A4 (which goes from low to high?)
If you keep I/p A4 high, then output B5 will keep changing state every 500ms, so you have a 1 Hz Flasher.
I agree with John when he stated about using a 1Hz flasher.
1Handypal wrote:
What confuses me is that when I tried to load hex file, produced by Flowcode, into the PIC and then read it back from PIC consequently saving with different name and comparing those two files gives me difference!
Could that just be the configuration data is contained within hex file generated by Flowcode, but configuration data is not present within hex file saved from chip?

What version of Flowcode V4 are you using?
E.g Demo, student or professional?

Martin
Attachments
Control A0 OSC HS.hex
(728 Bytes) Downloaded 161 times
Control A0 OSC XT.hex
(728 Bytes) Downloaded 141 times
Martin

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Contact:

Re: Flowcode and Velleman PIC board 8048 help needed

Post by 1Handypal »

Thank you medelec35!
Your code worked nicely in both versions HS and XT. PicProg2009 (Velleman's supplied) seem to recognize config settings in each hex file correctly, once loaded into software you see corresponding features checked and/or un-checked. So all I had to do is just hit load and voila it worked. The version of Flowcode I am using is free, just installed on my main desktop yesterday for a fresh start, re-compiled my project file and moved back to my laptop to see if there was any difference - nope, still no go. I used power up timer enabled though, not sure if it matters that much. Really appreciate your help but still frustrated.
I am attaching my project file for your review.
Please let me know if I screwed up.
Attachments
Flowcode1.fcf
(7 KiB) Downloaded 168 times

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Contact:

Re: Flowcode and Velleman PIC board 8048 help needed

Post by 1Handypal »

Oh, forgot to mention my Flowcode is the latest available from the web site, it says version 4.3.9.65.
On the other note, I successfully ran other projects with simple blinking patterns, there are 6 LEDS to be utilized on the board and 4 push buttons. All seemed to work fine. I guess it could be a bug of interpretation of my flowchart into the hex or simply my omission of something important that was not obvious to me since I am a newbie in this kind of thing. Does it make any difference of how many times you call input and output on the same bit of a port during your code execution? Could it be an issue?
Thanks for all your input?

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9015
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Flowcode and Velleman PIC board 8048 help needed

Post by medelec35 »

You flowchart does not look correct. Configuration settings look Ok though.

E.g you have two inputs A0 and B5 as well has having B5 as an output that's probably the issue?.

I used Flowcode V4.5 to compile to hex.
Since its a later version than one you have, it will not load with V4.3
So I have posted Same flowchart created with V4.5 and Flowcode V3 (since V3 should load with your version of Flowcode)


Martin
Attachments
Control A0 OSC HS Flowcode V3.fcf
Created with FC3
(5.5 KiB) Downloaded 150 times
Control A0 OSC HS.fcf
Created with FC4.5
(5.5 KiB) Downloaded 156 times
Martin

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Contact:

Re: Flowcode and Velleman PIC board 8048 help needed

Post by 1Handypal »

Hello again,
Here's an update. I built another flowchart using port interrupt for the same purpose to toggle an LED with the port change. I have the following questions:
By default there is always PORTB interrupt shown as available, but could it be changed to any other port and masked? I highly suspect YES, but how?
Simulation does not seem to work correct if I use TIMER0 interrupt, is this a bug?
Attachments
Flowcode1_a.fcf
(6 KiB) Downloaded 130 times

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Contact:

Re: Flowcode and Velleman PIC board 8048 help needed

Post by 1Handypal »

Hello again!
I am so much relieved with your comments and help, before I could not sleep tight...hehe.
I'll give it a good test and report results later. It seems that some tricks are unspoken of and there should be a summary of pitfalls to avoid as well as good practices to follow.
I believe every line of micro has its own traps one needs to discover and to avoid... I have seen it before sometime somewhere...just cannot recall...getting older...
THANKS!!!

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9015
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Flowcode and Velleman PIC board 8048 help needed

Post by medelec35 »

Hi 1Handypal, no problems, so long as your getting further that's the main thing.
The probable reason for timer0 not working is when a interrupt is accessed, all other interrupts are disabled until interrupt routine is exited.
For that reason you can't really place any delays or components containing delays e.g LCD components within the interrupt routine.
Try deleting the delays.

Also if using Timer0, timer1 etc. To work you will need to change the properties from 'Transition on T0CKI pin'
To 'Internal clock (CLKO)'

Also not all chips allow port B masking, 16F84A will be one of those.
If you look at the datasheet you will see

Code: Select all

PORTB<7:4> interrupt-on-change
This just means if you use the portB interrupt, then each time pins connected to portB 4,5,6,or 7 change state than the interrupt macro is accessed.
It is within that interrupt macro you will need to read portB4 to portB7 (or just the pin your interested in) to determine if state has changed to high or low.

Have you looked at Matrix Multimedia Learning centre:
http://www.matrixmultimedia.com/lc_index.php?p=7

It's worth while working your way through the tutorial videos to familiarise your self with Flowcode.
Once you have learned you will be amazed at just what you can achieve!
Just bear in mind, there will be a few components and target devices you can't use and the code size limitations of the free version.

Martin
Martin

User avatar
1Handypal
Flowcode v5 User
Posts: 41
Joined: Fri Jan 06, 2012 8:17 am
Contact:

Re: Flowcode and Velleman PIC board 8048 help needed

Post by 1Handypal »

Thank you Martin and all others for your very constructive input.

Of course I remember my limitations within the free version, but no worries, it gives me a good motivation to obtain the full one, once I develop an appetite for something worthy, bearing in mind that new version 5 is coming soon some time later this year.
I have another question concerning use of ISRs. If I create PWM signal on a couple of outputs by way of using TMR0 interrupt and place delays in the ISR to change its frequency and/or duty, will this be a good idea or there is a better technique?
I feel that I still need to learn lots of C and assembler to better understand ins and outs of this trade, the software just makes it easier and fun.

Your support is greatly appreciated.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9015
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Flowcode and Velleman PIC board 8048 help needed

Post by medelec35 »

There a lot of posts to read about bit bang pwm using timers.
A method of increasing frequency can be found here:
http://www.matrixmultimedia.com/mmforum ... =26&t=8660

I have just noticed that the link for demo Flowcode V4.3 is actuality to demo Flowcode V4.5. you can confirm this by help about flowcode. so latest flowcharts created with V4.5 should work just fine assuning no advanced components are used.

Two ways of creating pwm one for controlling brightness of LED's.
1) is a great artical by Benj:
http://www.matrixmultimedia.com/article.php?a=52
or
http://www.matrixmultimedia.com/mmforum ... 54&#p27898
use 12F675 PWM1.fcf
not 12F675 PWM2.fcf
Another for servos, but can be adapted for DC motors:
http://www.matrixmultimedia.com/mmforum ... =25#p30748

There are loads of examples about. You can use key words like bit bang since this is a common way of creating PWM signals without using PWM component

Martin
Martin

Post Reply