In SX Microcontrollers, SX/B Compiler and SX-Key Tool, mumcs01 wrote: I've been building a Nixie Alarm clock for the last 2 years. I'm almost done after 6 PCB rev's, a child, and significant frustration and fun. Most of the parts are old Soviet parts... Except for the SX that is the heart of it. Everything works. Except for one stupid thing. Would someone please look at my code snippet below. There is something dumb here that I'm overlooking that has had me stuck for a month (in the 15 minutes here and there I've had) [code] DEVICE SX28, OSCHS2,TURBO,STACKX,OPTIONX IRC_CAL IRC_FAST FREQ 50_000_000 o_statusled Pin RB.0 OUTPUT ' Status o_statusled On Circuit Board i_sw_alarm Pin RB.1 INPUT CMOS ' Used to toggle monitoring of the alarm time. Used to turn the alarm on and off. o_nixierelay Pin RB.2 OUTPUT ' 12V Relay Power to Supply Nixie Tubes Power o_colontriac Pin RB.3 OUTPUT ' 120V TRIAC Driver for neom seperator indicator colons o_alarmtriac Pin RB.4 OUTPUT ' 120V TRIAC Driver for neon alarm on indicator o_nixrck Pin RB.5 OUTPUT ' Nixie Data Driver Line. rck Pin (Latch Pin) o_nixsck Pin RB.6 OUTPUT ' Nixie Data Driver Line. sck Pin (Clock Pin) o_nixser Pin RB.7 OUTPUT ' Nixie Data Driver Line. ser Pin (Data Pin) Stack 8 ' Constants RtcId CON $DE ' I2c address of the RTC Chip Ack CON 0 ' I2c Ack bit Nak CON 1 ' I2c Nak bit True CON 1 ' True False CON 0 ' False ' Variables alarm_enabled VAR Bit 'Tells if the Alarm is on or off Program Setup_Time ' Run once to Setup the clock on power up and determine the battery condition. Setup_Time: 'Begin Standard bootup sequence LOW rb ' Setup everything low pause 250 goto Mainloop ' Proceed to main clock operation Mainloop: if i_sw_alarm = true then Toggle alarm_enabled do pause 100 loop while i_sw_alarm = true endif o_alarmtriac = alarm_enabled goto Mainloop [/code] So here is my delema. In 'Mainloop', i_sw_alarm is a button. When pressed it toggles alarm_enabled variable, its then followed by a wait to avoid bouncing. If the alarm_enabled variable is true, it assigns o_alarmtriac to true... Which is a triac type device that drives ON an neon indicator. So basiclly, this doesn't work. I never can turn on this neon when the button is pressed. However, in a test program, the following WILL work. [code] Setup_Time: if i_sw_alarm = True then high o_alarmtriac else low o_alarmtriac endif goto Setup_Time [/code] If I replace mainloop with the above, if I press the i_sw_alarm, the o_alarm triac comes on.... Which confirms that the hardware is working. Can anyone see something I'm missing. I'm just stumped at the moment. Thanks, ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=394263 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)