Input Switch Problem

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
Carlos Viveiros
Posts: 30
Joined: Tue Dec 26, 2006 9:04 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

Input Switch Problem

Post by Carlos Viveiros »

Hello, I'm running a very simple project no flowcode 5, and i found a problem, i have a switch to increment a number on my program, every time i press that switch it count up. but it's not running on full simulation... if i run step by step, it's all ok, all fine, but when i run normally, the program ignore my switch. I've already try dowload to my E-Block Programer, in hpe that the problem was just in simulating, and i used the E-block Switch, E-Block Led, and the problem is the same as simulating... nothing happens when i press the switch..
can someone help ?
I'm using a pic 16F877


I Will attach my project, you will see that is a very simple project, but i cant fix the problem, could be from my computer only?

Regards
Carlos Viveiros
Attachments
Projecto.fcf
projecto
(97.13 KiB) Downloaded 296 times

User avatar
DavidA
Matrix Staff
Posts: 1076
Joined: Fri Apr 23, 2010 2:18 pm
Location: Matrix Multimedia Ltd
Has thanked: 58 times
Been thanked: 258 times
Contact:

Re: Input Switch Problem

Post by DavidA »

Hello Carlos,

I have had a quick look at your project, however i dont have enough time personally to try and debug your program, I did disable a few icons and tested to see if the switch was jumping into the correct branches using an LCD i attached. It did seem to jump into the correct branches when the switch was pressed with the correct value.

Maybe if you go through the program in a similar manner you can debug where the error is occuring, this may also help us to determine whether the problem is our end or not!

The new disable icons feature in v5 is wonderful for this.
Attachments
Projecto_mod.fcf
(99.48 KiB) Downloaded 272 times

Carlos Viveiros
Posts: 30
Joined: Tue Dec 26, 2006 9:04 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: Input Switch Problem

Post by Carlos Viveiros »

Okey, when i arrive home, i will take a look on your modified file, then i will reply again ... =)

Carlos Viveiros
Posts: 30
Joined: Tue Dec 26, 2006 9:04 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: Input Switch Problem

Post by Carlos Viveiros »

Okey DavidA... I Understand what you said how to debug my program file... and i did it... and i disabeled and enabeled, and disabeled and enabeled again, and i found the problem, in an anex file, i resend to you the project again, with with a display like you did to me, and an image. The problem lives on an "Go To Point" if i disable that go to point, the program run perfectly, but i need that go to point for the program run the way i want. So i tried several things for the program run, i tried to invert "if switch" function, or move the "go to point" to another place, and unfortanly i could not solve... So the problem maintain.. in full speed the software igonres the entries on port A, but in step by step the software works fine. if i disable the go to point, the program acept the entries on port A. But i need that go to point ... :\ I belive that is a flowcode 5 problem. I tried to do everything i knew unsussefuly...
Sorry my bad english, I'm from Portugal, and my English is not so good, but i think i explain my problem detailed and understandable..
Attachments
Image Go To Point Fail
Image Go To Point Fail
projecto_fail.jpg (62.28 KiB) Viewed 11591 times
Projecto_2.fcf
Project
(103.73 KiB) Downloaded 247 times

User avatar
DavidA
Matrix Staff
Posts: 1076
Joined: Fri Apr 23, 2010 2:18 pm
Location: Matrix Multimedia Ltd
Has thanked: 58 times
Been thanked: 258 times
Contact:

Re: Input Switch Problem

Post by DavidA »

Hello,

i dont beleive the problem is with the go:to, if the "Conta" macro is disabled the program works fine, i would debug the Conta macro.

Also dont attach the LCD to A4 as this will pull it high and scew results when reading inputs from portA, or mask the input to only include A0-2.
Attachments
Projecto_2_mod.fcf
(104.59 KiB) Downloaded 266 times

Carlos Viveiros
Posts: 30
Joined: Tue Dec 26, 2006 9:04 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: Input Switch Problem

Post by Carlos Viveiros »

Hi,

Yes I can mask input to A0-2 only, no problem, i only include the lcd for debuging, not for final project, bu is strange, when i disable the "go to" funcion it works fine, and macro "Conta" works fine too.. I will run more tests on macro "conta" too, to try get some light on my head..

And tanks for trying to help.. =)

wayne1971millard
Posts: 4
Joined: Tue Apr 17, 2012 4:48 pm
Been thanked: 1 time
Contact:

Re: Input Switch Problem

Post by wayne1971millard »

Hi Try this :P

Hope you fix your problem soon
Attachments
Projecto_2_mod.fcf
(104.52 KiB) Downloaded 247 times

Carlos Viveiros
Posts: 30
Joined: Tue Dec 26, 2006 9:04 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: Input Switch Problem

Post by Carlos Viveiros »

wayne1971millard wrote:Hi Try this :P

Hope you fix your problem soon
Hi wayne1971millard,

tanks for helping... Indeed it works, basically you added a 1 second delay after decision INPUT > 0 ... And with 1 second it really work, but when i trie down that delay time, like 500 ms ou less the program start failing, sometimes recognize when i press a button, sometimes doesn't. And I need that delay time shorter than 100 ms, but the perfect way is to remove it, becouse i want the program as fast as it can to when i press the button in that precise time, the value must change.. I've added the macro "SHOW_DISPLAY" after macro "CONTA" for us to see what is happening in time we press button and after interpret thar pressed button and made calculations. I'm re sending the program file with the changes i made in hope that if you passed the eyes in my program file, and discover something that i could made wrong, you could tell me.

Regards
Attachments
Projecto_2_mod.fcf
received_and_edited_project_file
(104.65 KiB) Downloaded 239 times
Received_and_edited_file_img
Received_and_edited_file_img
projecto_fail2.jpg (126.97 KiB) Viewed 11554 times

wayne1971millard
Posts: 4
Joined: Tue Apr 17, 2012 4:48 pm
Been thanked: 1 time
Contact:

Re: Input Switch Problem

Post by wayne1971millard »

The problem is that if you use any delays in the program you will need to press and hold the button in for longer than all the delays add together.
i will have a look

Wayne :D

wayne1971millard
Posts: 4
Joined: Tue Apr 17, 2012 4:48 pm
Been thanked: 1 time
Contact:

Re: Input Switch Problem

Post by wayne1971millard »

Hi Carlos,

Try this update.
Attachments
Projecto_2_mod.fcf
(104.59 KiB) Downloaded 225 times

Carlos Viveiros
Posts: 30
Joined: Tue Dec 26, 2006 9:04 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: Input Switch Problem

Post by Carlos Viveiros »

wayne1971millard wrote:Hi Carlos,

Try this update.
Hello Wayne,

Yes, your update works at certain point, once again when i speed up the delay you put do 100 ms instead 200 ms the program start to fail. and you change my go to point to another place, place there i don't want it there. I want to press the button and the program only incremet one time, and one time only as i stay pressed down, and in that period of time that i stay pressed down the button, the 3 values i have in the program, must update continuosly on my leds. and the change you made on go to point puts the program increment automatically as i stay pressed the button down.


The original project file that i put here on forum, has everything to run perfectly without errors.. I mean, i think i have... In my opinion the solution don't pass to put a delay on main macro, I only have a delay on macro "saida_p_leds" to put a shortly pause between the transition of output value on the led, and its the only delay i belive i need. But if you tell me that i need to put a micro delay on main macro after pressed button, i can put there that delay, but not so long delays, must be very shortly, i want the program runs and update my output leds, whitout pausing on a place of an input that no one activated... :| :?

Thank you a lot for trying to help ... :D

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Input Switch Problem

Post by dazz »

Try this all i did was to add a loop to detect switch release and disabled the connection point,, try it if it does what you need try lowering the delays etc
Attachments
Projecto (1with loop delay).fcf
(98.01 KiB) Downloaded 156 times
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

Carlos Viveiros
Posts: 30
Joined: Tue Dec 26, 2006 9:04 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: Input Switch Problem

Post by Carlos Viveiros »

dazz wrote:Try this all i did was to add a loop to detect switch release and disabled the connection point,, try it if it does what you need try lowering the delays etc
Hello dazz,

Tanks for your post, but that solution doesn't work for me, in your solution the program stuck in that delay zone that you added , and does nothing on the output port until i release the button .. :( I need the output always refreshing the data if i press or not press a button, and when i press the button only increment one number and don't increment anything else until i press button again...

Carlos Viveiros
Posts: 30
Joined: Tue Dec 26, 2006 9:04 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: Input Switch Problem

Post by Carlos Viveiros »

Maybe i will reinstall my old flowcode v4 again and build the project again in that version of flowcode, and see if it works with flowcode 4, if work the problem must be form flowcode v5 .. :(

Carlos Viveiros
Posts: 30
Joined: Tue Dec 26, 2006 9:04 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: Input Switch Problem

Post by Carlos Viveiros »

I built a Flowcode V4 version of the program...

I have the same problem on this version too ... :cry:
Attachments
Projecto_FLOWCODE_V4.fcf
Flowcode v4 version of the project
(33.24 KiB) Downloaded 144 times

wayne1971millard
Posts: 4
Joined: Tue Apr 17, 2012 4:48 pm
Been thanked: 1 time
Contact:

Re: Input Switch Problem

Post by wayne1971millard »

Hi Carlos,

Try this the problem that i can see is that you dont read the status of the switchs when you are looping around a to a.
And i have put a loop in so that when any button is pressed it only clocks up one count.

Wayne
Attachments
Projecto_FLOWCODE_V5.fcf
(45.31 KiB) Downloaded 156 times

Carlos Viveiros
Posts: 30
Joined: Tue Dec 26, 2006 9:04 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: Input Switch Problem

Post by Carlos Viveiros »

wayne1971millard wrote:Hi Carlos,

Try this the problem that i can see is that you dont read the status of the switchs when you are looping around a to a.
And i have put a loop in so that when any button is pressed it only clocks up one count.

Wayne
Hello Wayne,

But i have the same problem, once i still with the finger in the button, the program always stay on that looping, and nothing happends on the output until i left the button ... And i need the output always working with or without the button pressed ... :(

Carlos Viveiros
Posts: 30
Joined: Tue Dec 26, 2006 9:04 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: Input Switch Problem

Post by Carlos Viveiros »

wayne1971millard wrote:Hi Carlos,

Try this the problem that i can see is that you dont read the status of the switchs when you are looping around a to a.
And i have put a loop in so that when any button is pressed it only clocks up one count.

Wayne
You light me ... i solve the problem with based on your solution ... Check it out ... =)

But i'm telling you, the original file, have all the steps to run without problems, and in my opinion the flowcode could have a bug, or need to have some kind of alert for the user know that sequence of item used togheter, or problems recognizing comands, or something like that, to warn the user to built in another way.

The problem is solved ... Tank You a lot ... =)
Attachments
Projecto_FLOWCODE_V5_wayne_based_solution.fcf
Wayne Based Solution Problem Solved
(44.7 KiB) Downloaded 143 times

wayne millard
Posts: 234
Joined: Thu May 31, 2007 2:18 pm
Has thanked: 7 times
Been thanked: 12 times
Contact:

Re: Input Switch Problem

Post by wayne millard »

Hi Carlos,

Sorry did not understand how it was going to work. i have fixed it now i hope this is what you want. :D

Wayne
Attachments
Projecto_FLOWCODE_V6.fcf
(46.45 KiB) Downloaded 151 times

dazz
Posts: 1314
Joined: Sun Jan 15, 2012 3:15 pm
Has thanked: 474 times
Been thanked: 458 times
Contact:

Re: Input Switch Problem

Post by dazz »

there isnt a bug it's just that flowcode is so flexible ,that matrix could not conceivably cover ever different way a user might programe or configured for a specific piece of hardware, one thing to note is if you look at the solution that wayne posted and the one i posted although mine wasnt what you needed it just illustrates slightly different placement of loops or other functions can make a small change to the way your firmware runs, thats why i love this software there is no right or wrong way to develop firmware on it but sometime just a small change can make the end product run in different ways, other things like being able to create your own macros and save them for reuse in other stuff you develop later on is a real plus point. As regards alerts as the software is so flexible that there is no specific order to placing of items in your firmware, the best way to learn flowcode is just make random stuff and make mental or written note so that if you move a loop you will soon begin to think of the best ways to place items so the code does exactly as you want. The most usefull part of this forum is the search button as there is a vast wealth of posted knowledge on this forum, an example i could not get a binary number to display correctly i was given two very different solutions both brilliant but so different hth
To sign up to the V5 forum follow this link http://www.matrixmultimedia.com/forum_upgrades.php

Carlos Viveiros
Posts: 30
Joined: Tue Dec 26, 2006 9:04 pm
Has thanked: 2 times
Been thanked: 1 time
Contact:

Re: Input Switch Problem

Post by Carlos Viveiros »

dazz wrote:...one thing to note is if you look at the solution that wayne posted and the one i posted although mine wasnt what you needed it just illustrates slightly different placement of loops or other functions can make a small change to the way your firmware runs...
Yes, I agree with you, and I appreciate very much your help, I really do.. But in the time you post your soltion, i wasn't see how i could adapt, or use it on my program, in fact your solution is similiar to wayne in terms of idea. But only now, after the solution of wayne my head light up, and see how to solve the problem. I must admit, i has so septic about my formula, and how right the formula was, that i didn't see waht is in front of me, and the solution is very simple.

About what you said about the flexible of flowcode. I know how flexible is flowcode, i understand that the flowcode cant cover all possible programing errors, i'm not an active user of the forum, but i am with flowcode since version 3, I made a some few programs, and when i got a problem or my solution is wasn't work all the times i tried varied ways, varied times, varied formulas to get what i want and work like i want. Don't get me wrong when i talk about the "bug". Once again i Understand all you said ...

Post Reply