Exact match. Not showing close matches.
PICList
Thread
'[SX] SX/B Toggle behavior'
2006\04\11@054531
by
Dunnseptn/a
|
|
I have a really simple program with a timer in the ISR that increments secs, mins, and hrs. This code is right from the examples for clocks.
Then what I tried to do is make an LED blink every second.
To accomplish this I am using result = secs // 2 if result = 0 then
toggle rb.0 endif
The issue is that the LED behaves oddly. I did read in the SX/B help that toggle can have results other than what you expect. I tried that solution too but to no avail.
What the LED does is it goes from off to dim to bright to dim to off. then repeats:
off - dim - bright - dim - off - dim - bright - dim.
if I replace the above code with something like:
if result = 0 then
low rb.0
else
high rb.0
endif
it works as expected. I tried the toggle.sxb example and it works fine. Is something in the getting in the way? or is there some stupid little issue I missed.
thanks!
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120096
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)
2006\04\11@063136 by Jon Williamsn/a
|
|
I'm not sure what's happening with your LED, but you can simplify the program like this:
Main:
RB.0 = secs.0
GOTO Main
TOGGLE and HIGH and LOW all set the pin to an output state -- you've already done that with LOW RB.0 in the Setup section so there's no need to repeat that when you can write the odd bit of seconds (secs.0) directly to the LED pin.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120096#m120098
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)
2006\04\11@064057 by Dunnseptn/a
|
|
Thanks Jon.
obviously it works. worked too with the if then else but this is obviously more compact.
I took the original code, removed the ISR and just put in INC SECS and it works just fine with TOGGLE..
seems to be something goofy in my ISR. but heck if I can figure it out. I think I might start from scratch again, just to see if I can figure out why it doesn't work.
gonna drive me nuts all day if I can't find it
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120096#m120100
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)
|
|
Dunnsept,
The reason it is "dim" is because when secs = 0 the LED will be toggled EVERY time it loops. When secs changes to non-zero if the LED was off, it stays off. If the LED was on it stays on.
I would use:
Main:
result = secs // 2
RB.0 = result
GOTO Main
BTW: "RB.0 = ~RB.0" is much faster than "TOGGLE RB.0" if the pin is already setup as an output.
Bean.
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120096#m120102
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)
|
|
What fun would programming be if it didn't drive us nuts once in a while? ;)
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120096#m120103
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)
2006\04\11@070525 by Dunnseptn/a
|
|
exactly... and a big DUH from me... now I get it. I made the stupid assumption that my main loop is following along at the same pace..
turning out that the biggest obstacle so far is trying to not let PC/X86 programming cloud my thinking (at least that's my excuse and I'm sticking with it)
thanks guys.. I think I'll go let C++ and win32 drive me nuts for a while now instead ;-)
---------- End of Message ----------
You can view the post on-line at:
http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=120096#m120104
Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com
The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2006 (http://www.dotNetBB.com)
More... (looser matching)
- Last day of these posts
- In 2006
, 2007 only
- Today
- New search...