Simple problems and mistakes

Moderator: Benj

Post Reply
andyzwb
Posts: 6
Joined: Sun Dec 30, 2012 2:33 am
Contact:

Simple problems and mistakes

Post by andyzwb »

1.JPG
1.JPG (21.21 KiB) Viewed 8673 times
The above schedule after the operation result is A1=0 A2=0. Why go wrong?
2.JPG
2.JPG (28.44 KiB) Viewed 8673 times
The above process operation will make mistakes. When E2 = 1 cannot jump out of circulation.
Parameter Settings :
3.JPG
3.JPG (16.93 KiB) Viewed 8673 times
MCU is PIC18F4520;If you use Flowcode_PIC_V4, the result is correct; if use Flowcode_PIC_V5, the result is wrong;

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: Simple problems and mistakes

Post by JonnyW »

Hello. Can you tell us if this is in simulation or in hardware?

I have tested both on the full v5.4 in simulation and both examples work OK.

This may be an issue with the FCD files for that chip, though in my version the code to do I/O on both v4 and v5 versions is identical.

Perhaps you could try the following code in a calculation (on v5 only):

Code: Select all

$PORTA.1 = 1
$PORTA.0 = 0
And see if this has the same effect? This type of call uses a slightly different mechanism. Other to that I can only guess at differing config settings - perhaps you could post your v4 and v5 sample programs?

Cheers,

Jonny

andyzwb
Posts: 6
Joined: Sun Dec 30, 2012 2:33 am
Contact:

Re: Simple problems and mistakes

Post by andyzwb »

Hi Jonny,
Simulation run program are correct; When the program is downloaded to a MCU, hardware operation will make mistakes;

andyzwb
Posts: 6
Joined: Sun Dec 30, 2012 2:33 am
Contact:

Re: Simple problems and mistakes

Post by andyzwb »

Hi Jonny,Below is a set of information:
4.JPG
4.JPG (88.79 KiB) Viewed 8640 times

User avatar
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: Simple problems and mistakes

Post by Benj »

Hello,

Regarding the pin outputs I'm wondering if there is a read/modify/write issue. What speed are you running your microcontroller? Does it help if you add a delay of say 10us in between the output icons?
The above process operation will make mistakes. When E2 = 1 cannot jump out of circulation.
As you are reading RE2 the value returned is likely to be 4 not 1. I would simply put key0 as the while loop parameter as this will allow the code in the loop to run until the variable key0 is greater then 0.

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: Simple problems and mistakes

Post by medelec35 »

Hi Ben,
hope you and every one else on the forums had a good break?
Benj wrote:As you are reading RE2 the value returned is likely to be 4 not 1. I would simply put key0 as the while loop parameter as this will allow the code in the loop to run until the variable key0 is greater then 0.
I would like to point out that since andyzwb is reading an individual pin and not port (masked or not), then only 1 or 0 will be read and not 4.
Also the variable used is a Bool, so value will never be greater then 1
Since I/p condition is tested at the end and not the start, there should not be any problems?

as for the speed being too fast, PLL is not used.

My guess would be hardware not running at all, or i/p not reading value correctly?

But since it works with V4 i'm not so sure now.

@andyzwb
Would you mind posting your Flowchart, and generated hex file please?
Martin

andyzwb
Posts: 6
Joined: Sun Dec 30, 2012 2:33 am
Contact:

Re: Simple problems and mistakes

Post by andyzwb »

hello
I now find why will make a mistake. When I set below will go wrong, and when I will "override language" set to "English" on result is correct, don't know the problem if you can solve it.
11.JPG
11.JPG (43.33 KiB) Viewed 8626 times
Set as follows, the operation result is correct:
44.JPG
44.JPG (43.37 KiB) Viewed 8626 times

User avatar
JonnyW
Posts: 1230
Joined: Fri Oct 29, 2010 9:13 am
Location: Matrix Multimedia Ltd
Has thanked: 63 times
Been thanked: 290 times
Contact:

Re: Simple problems and mistakes

Post by JonnyW »

Evening. Thanks for letting us know.

I am still on holiday until the 7th so can not fix this properly until then, but the problem seems to be in the translation of some C code in the Flowcode language pack. The comment '// Initialization' when translated into Chinese has the newline cut off it.

This can be temporarily fixed for your build by adding a C-code icon to the top of Main() that has the code:

Code: Select all

adcon1 = 0xF;
I hope this helps (and works!)

Jonny

andyzwb
Posts: 6
Joined: Sun Dec 30, 2012 2:33 am
Contact:

Re: Simple problems and mistakes

Post by andyzwb »

hello
I think it should solve the problem of language pack can be cured

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Re: Simple problems and mistakes

Post by jadiflow »

Hi,

I have almost exactly the same issues as the original poster: output pins that seem to influence each other.
PIC12HV615, FC updated to V5.4
I also have a delay routine that doesn't seem to work in h/w (works in sim).
In searching for a clue I noticed that while the delay() routines were included in the C code, the build reports:

Warning unreferenced functions removed:
FCI_DELAYINT_US in: C:\Program Files (x86)\Flowcode\v5\CAL\PIC\PIC_CAL_Delay.c
FCI_DELAYINT_MS in: C:\Program Files (x86)\Flowcode\v5\CAL\PIC\PIC_CAL_Delay.c
FCI_DELAYINT_S in: C:\Program Files (x86)\Flowcode\v5\CAL\PIC\PIC_CAL_Delay.c

So is this an error? Are the removed non-referenced functions not necessary to use the delay functions??

Thanks for any pointers on this,

jan didden

User avatar
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: Simple problems and mistakes

Post by Benj »

Hello Jan,

Have you done the 1 second flasher test to get your delays correct. My guess is that your delays are appearing wrong because the software clock speed and configuration options do not match the hardware.

The DELAYINT functions are used to allow you to use 16-bit variables with the standard 8-bit delay functions without having to create a routine yourself. If your passing byte variables or constant values then these functions are not needed.

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Re: Simple problems and mistakes

Post by jadiflow »

Benj wrote:Hello Jan,
Have you done the 1 second flasher test to get your delays correct. My guess is that your delays are appearing wrong because the software clock speed and configuration options do not match the hardware.
Ben, thanks for replying. Tried a very basic thing, set two output pins, then delay, then reverse output pins. Appears that it stays in delay indefinitely. Tried both sec and msec delays. Verified same s/w clock speed and speed in config dialog.
Benj wrote:The DELAYINT functions are used to allow you to use 16-bit variables with the standard 8-bit delay functions without having to create a routine yourself. If your passing byte variables or constant values then these functions are not needed.
OK thanks for clearing that up.
BTW I assumed that the GPIO bits 0-5 pins on the 12HV615 datasheet correspond with the PortA bits 0-5 in FC?

jan

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Re: Simple problems and mistakes

Post by jadiflow »

Re-installed V4 (which doesn't recognise 12HV615 but does the 12F615 and I assumed it is identical as far as internals is concerned sans the shunt reg.
Same problem. Goes into the delay and stays there indefinitely.
Frustrating!

It appears that the original poster and I have in common the 12F6xx chip. Could there be an error in the definitions for thi
HVdelay-V4.fcf - Main.JPG
HVdelay-V4.fcf - Main.JPG (35.61 KiB) Viewed 8529 times
jan

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Re: Simple problems and mistakes

Post by jadiflow »

Post deleted - wrong info.

jan

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Re: Simple problems and mistakes

Post by jadiflow »

I think I have isolated the problem.

At the start of my flowchart I have:

asm
{
// bcf _option_reg, 7 //enable wpup
bsf _wpua, 2 //A2 wpu
}

If I un-comment the first line, the delay statement later on doesn't work and the program never gets out of the delay loop.
With this line commented out, all works as it should.
Any ideas?

jan

jadiflow
Flowcode v5 User
Posts: 273
Joined: Thu Apr 17, 2008 9:59 am
Has thanked: 19 times
Been thanked: 16 times
Contact:

Re: Simple problems and mistakes

Post by jadiflow »

If I move the two asm lines shown above *after* the delay, all goes well and subsequent delays also work as advertised.
Still have no idea why it doesn't work with the register settings at the beginning but it's a useable workaround.

jan

Post Reply