Searching \ for '[SX] Help with asynchronous interrupts' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/ubicom/sxints.htm?key=interrupt
Search entire site for: 'Help with asynchronous interrupts'.

Exact match. Not showing close matches.
PICList Thread
'[SX] Help with asynchronous interrupts'
2009\12\24@224735 by vchaneyn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, vchaney wrote:

Please, I need some help in the use of asynchronous interrupts.


I have two balls running down a track right-to-left, and as they enter a tunnel they run across a ballComing switch RB.0, which triggers an interrupt when it connects to ground. Then, a pattern of LEDs follows the balls as they go through the tunnel. The balls are not always the same distance apart, so the second ball needs to trigger the interupt, too, so that each ball has a pattern of lights following it. If there is no second ball (or the second ball is far enough behind), the pattern just follows the one ball.


Here is my problem. There are light patterns that are stepped from a position to the right and then back one position at a time until they are centered, and then they are stepped left one position at a time until the pattern is gone out the left side of the tunnel. Then it looks like the light pattern enters the tunnel on the right, and follows the ball through the tunnel until it runs out the left end. The switch triggers the interrupt to get the process started, and this works fine. Then there is a section of the program where an interrupt (for the second ball) should create a second light pattern overlapping the first light pattern, but this does not happen. Then there is a section almost identical to the first non-functioning section, and it works fine. The only difference is in which direction the pattern is being moved. The code which is detecting the interrupt is the same. Why won't the interrupt get detected on the first half of the light pattern's journey, and yet get detected just fine on the second half of it? As it is, my program works if the second ball is not following too close, but if it is close then the switch gets hit during the part of the program that is not detecting the switch, and I only get one pattern of lights as if there was only one ball.


I have attached my code. The troublesome section has some comments that point out where the problem is. The patterns in each step are shifted out to MAX6969 chips (constant current LED drivers, each drives up to 16 LEDs, they are connected together so that the patterns for all four sets of LEDs are shifted out all at once). The interrupt routine just sets a flag (runFlag), and the program uses the flag's being set to decide that there are some balls with light patterns to be overlapped. There is so much of the program that works, I can't see why the one section isn't working.


I have tried a zillion variations, and there is probably some simple thing that I am not doing right, but I sure can't find it. Thank you in advance for your help.


Vic
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=412878
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\12\25@174500 by mojorizingn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, mojorizing wrote:

It looks like you're clearing your runflag in a few places without any corresponding action.  The way you're using the interrupt will tell you a ball has passed by, not that the ball had just passed by.  The code is polling the value of the runflag, but in a few places the runflag has cleared before it is polled possibly erasing the fact that the ball has passed by.  One possible solution is to poll the switch in the Main code to capture time the first ball has rolled by, then using the interrupt routine to capture the second ball rolling by.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=412878#m412984
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\12\25@235924 by vchaneyn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, vchaney wrote:

Thank you for responding, mojorizing.

I first had a problem where it always acted as if there was an interrupt in the first part of the program, even if there wasn't. Somehow in the process of trying to correct it, now it acts as if there is never a second ball interrupt. So, I made a short section to keep it clear of interrupt, then hit the switch a second time to see where it will accept an interrupt, and where not. I tried clearing the runFlag at the beginning, one-third, and two-thirds through the trouble section, and it will still not detect the interrupt during the section where the runFlag is available to be set by the interrupt routine.

For the first ball, I can achieve recognition of the ball through polling the switch or by interrupt, and either way works.

When I clear the runFlag at the beginning, it still will not detect a second ball interrrupt during that troublesome section, and has no trouble detecting the second ball in the later section.

So I am still not working, but I appreciate your help! Thank you.

Vic
---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=412878#m413026
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\12\26@075256 by mojorizingn/a

flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, mojorizing wrote:

I think you need to add


WKPND_B = %1111_1110

to your "Init" section as you're setting up the ports to clear the pending register to enble new interrupts.

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=412878#m413075
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

2009\12\26@113637 by vchaneyn/a
flavicon
face
In SX Microcontrollers, SX/B Compiler and SX-Key Tool, vchaney wrote:

Thank you, mojorizing.

I gave it a try, and it doesn't help. Of course, my first interrupt always worked, and the "WKPND_B = %1111_1110" gets reset after each interrupt, and other interrupts are working.

Thanks!

---------- End of Message ----------

You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=412878#m413120
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2009 (http://www.dotNetBB.com)

More... (looser matching)
- Last day of these posts
- In 2009 , 2010 only
- Today
- New search...