In SX Microcontrollers, SX/B Compiler and SX-Key Tool, originator99 wrote: I am trying to learn about interrupts and have a simple application that needs either an inerrupt or and if then to halt an activity temporarily. Here is the idea, leaving out parts of code: SIO VAR RA.0 'receive pin UP VAR RA.1 'motor driver inut up direction DN VAR RA.2 'motor driver input down direction PW VAR RA.3 'pwm out to low side of motor serByte VAR Byte RX_Byte SUB 0 ON CON 0 OFF CON 1 Main: serByte = RX_byte IF serByte = %00000001 THEN UP = ON PWM PW, 150, 50 UP = OFF ENDIF IF serByte = %00000011 THEN DN = ON PWM PW, 150, 50 DN = OFF ENDIF Goto main This code looks for a byte from a remote control that transmits a byte in a fast loop while a button is pressed. While the button is pressed, the motor turns uninterrupted. That part is working great. I need to add some lines in the event of a stall to prevent smoking parts. If I can make room on the board I'll add a sense circuit with logic back to the SX. In this case, would an interrupt be a better option that IF THEN for halting the output to the motors? The only other idea I can think of is IF SensePin = 1, SensePauseLoop (go to a routine, turn off motor, wait for a few seconds before returining to look for more bytes. I figure if the user notices that the thing isn't moving, they will stop presing the but rather quickly, and the pause loop will avoid the motor driver getting hot. I am studying the 3 interrupt programs that come with the SX Key. I am stil not clear on how to set this up to look for an interrup on a pin, but will the interrupt function the same way as IF THEN on a pin? ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=145994 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)