Page 1 of 1
interrupt
Posted: Thu Jul 31, 2014 9:10 am
by DELAK_ALED
Hello,
With this program I want to increment a counter one time. In simulation it increments two times. How can I avoid this?
Thanks in advance.
Re: interrupt
Posted: Thu Jul 31, 2014 10:00 am
by medelec35
Hi DELAK_ALED,
since IOC is Interrupt On Change and there is not a IOC Register on your target device, ISR will be accessed when any of IOC pins go from low to high or high to low.
So If operating one button at a time then the attached flowchart is a simple way around your issue.
It does not take contact bounce into consideration.
Martin
Re: interrupt
Posted: Thu Jul 31, 2014 3:40 pm
by DELAK_ALED
Thanks Martin for your reply.
I have tried to adjust your program. My intention was to encrement the variable if I push RB5 and to decrement the variable if I push RB4.
(I must use an interrupt)
In simulation it works fine, but if I download the program in the formula flowcode buggy it doesn't work correctly.
Is it possible to adjust the program in a simple way, so it works also correct on the buggy?
Re: interrupt
Posted: Thu Jul 31, 2014 3:55 pm
by medelec35
Hi DELAK_ALED,
Can you try the attached flowchart, and see if that works the way you want it to.
Tried to keep as simple as possible.
Martin
Re: interrupt
Posted: Fri Aug 01, 2014 11:02 am
by DELAK_ALED
Hi,
Unfortunately, your program interrupt V4 doesn't work in simulation and it doesn't work on the formula flowcode buggy.
In te program interrupt V5 I add one pictrogram and now I see the variable = 100 and if there was one interrupt the variable is always 50.
Re: interrupt
Posted: Fri Aug 01, 2014 12:00 pm
by medelec35
Hi DELAK_ALED,
The flowchart I posted was not tried on hardware, as my hardware was set up for something else.
The attached flowchart takes into account contact bounce.
Both hardware and Flowcode simulator works fine for me.
Can you try it and see if it works any better for you.
Martin
Re: interrupt
Posted: Fri Aug 01, 2014 3:29 pm
by DELAK_ALED
Hi Martin,
In simulation it works now fine. For my hardware I have to change the connection of the LCD to portD,
because there is only one subd on portD.
On my hardware (the formula flowcode buggy) it doesn't work. The variable has always the value 100, even if I push B4 or B5
Re: interrupt
Posted: Fri Aug 01, 2014 4:57 pm
by medelec35
Sorry I changed the LCD for my hardware, and forget to change it back to portD.
I have tested with
EB007 connected to portB.
Pressing sw5 (connected to B5) incremented display by 1 and sw4 (connected to B4 ) decremented by 1.
So not sure why its not working for you?
Unfortunately I don't have a buggy to test with.
How about creating a flowchart that output on portD is the same as input on portB?
Then you can press the switches and see if output on portD by measuring the voltages on port D.
Also can you measure the voltage at port B4 & B5 when switches are pressed and released?
Re: interrupt
Posted: Sat Aug 02, 2014 9:39 am
by DELAK_ALED
I have tested the program interrupt V5 with the hardware combination EB006-18F4455, LCD EB005 on port D and switches EB007 on portB and indeed the program works fine.
When I use the formula flowcode buggy (with µC 18F4455) the LCD on the subD =portD and the two switches are connected to B4 and B5 the program doesn't work. The variable stays 100
Afterwards I have adjusted the program to interrupt V6. (see attachment) I use now a mask on portB
Result: decrement the variable works fine
increment the variable works sometimes. When I push very fast I have an increment, when I push a little bit slower the variable := variable + 2
Re: interrupt
Posted: Sat Aug 02, 2014 5:24 pm
by medelec35
DELAK_ALED wrote:When I use the formula flowcode buggy (with µC 18F4455) the LCD on the subD =portD and the two switches are connected to B4 and B5 the program doesn't work. The variable stays 100
Sorry not sure why that is?
Very odd though.
DELAK_ALED wrote:increment the variable works sometimes. When I push very fast I have an increment, when I push a little bit slower the variable := variable + 2
Perhaps you can increase the delay in the decision branch to 100ms?
Sounds like your'e nearly there.
Re: interrupt
Posted: Sun Aug 03, 2014 3:32 pm
by DELAK_ALED
Thank you for helping me out of my problem.
I have increased the delay time to 150 ms. Now the program works verry good ( the increment and also the decrement)
