sbelsky
02-07-2010, 06:19 AM
So I built myself a nixie clock using the Basic Stamp 2 as the brains.
I used a multiplexed design... Only one bulb is on at a time. The code cycles through the six bulbs sending the correct digit for each bulb. Unfortunatly, my code runs too slow causing the bulbs to flicker. I was hoping someone might be able to point out how I might make the code more efficient. Do I need to use binary code to send the pin states? (%001001 or something?).
Youtube clip of the clock:
www.youtube.com/watch?v=FNFPThBWOUU (http://www.youtube.com/watch?v=FNFPThBWOUU)
Here is the portion of code in question:
' MAIN LOOP ------------------------
main:
FOR bulb = 0 TO 5
ON bulb GOSUB bulb_1, bulb_2, bulb_3, bulb_4, bulb_5, bulb_6
NEXT
GOSUB ReadRTCBurst
GOTO main
'----------------------------------------
'reads time from clock chip
ReadRTCBurst:
HIGH RTCReset
SHIFTOUT DTA, Clk, LSBFIRST, [%1\1,BrstReg\5,%10\2]
SHIFTIN DTA, Clk, LSBPRE, [Seconds,Minutes,Hours]
LOW RTCReset
RETURN
'---------------BULB WRITING SUBROUTINES BELOW ------------------
bulb_1:
LOW 7
digit = hours.HIGHNIB
ON digit GOSUB digit_0, digit_1, digit_2
HIGH 2
RETURN
bulb_2:
LOW 2
digit = hours.LOWNIB
ON digit GOSUB digit_0, digit_1, digit_2, digit_3, digit_4, digit_5, digit_6, digit_7, digit_8, digit_9
HIGH 3
RETURN
bulb_3:
LOW 3
digit = minutes.HIGHNIB
ON digit GOSUB digit_0, digit_1, digit_2, digit_3, digit_4, digit_5
HIGH 4
RETURN
bulb_4:
LOW 4
digit = minutes.LOWNIB
ON digit GOSUB digit_0, digit_1, digit_2, digit_3, digit_4, digit_5, digit_6, digit_7, digit_8, digit_9
HIGH 5
RETURN
bulb_5:
LOW 5
digit = seconds.HIGHNIB
ON digit GOSUB digit_0, digit_1, digit_2, digit_3, digit_4, digit_5
HIGH 6
RETURN
bulb_6:
LOW 6
digit = seconds.LOWNIB
ON digit GOSUB digit_0, digit_1, digit_2, digit_3, digit_4, digit_5, digit_6, digit_7, digit_8, digit_9
HIGH 7
RETURN
digit_0:
LOW 11
LOW 12
LOW 13
LOW 14
RETURN
digit_1:
LOW 11
LOW 12
LOW 13
HIGH 14
RETURN
digit_2:
LOW 11
LOW 12
HIGH 13
LOW 14
RETURN
digit_3:
LOW 11
LOW 12
HIGH 13
HIGH 14
RETURN
digit_4:
LOW 11
HIGH 12
LOW 13
LOW 14
RETURN
digit_5:
LOW 11
HIGH 12
LOW 13
HIGH 14
RETURN
digit_6:
LOW 11
HIGH 12
HIGH 13
LOW 14
RETURN
digit_7:
LOW 11
HIGH 12
HIGH 13
HIGH 14
RETURN
digit_8:
HIGH 11
LOW 12
LOW 13
LOW 14
RETURN
digit_9:
HIGH 11
LOW 12
LOW 13
HIGH 14
RETURN[/url] (http://)[url=http://] (http://)
I used a multiplexed design... Only one bulb is on at a time. The code cycles through the six bulbs sending the correct digit for each bulb. Unfortunatly, my code runs too slow causing the bulbs to flicker. I was hoping someone might be able to point out how I might make the code more efficient. Do I need to use binary code to send the pin states? (%001001 or something?).
Youtube clip of the clock:
www.youtube.com/watch?v=FNFPThBWOUU (http://www.youtube.com/watch?v=FNFPThBWOUU)
Here is the portion of code in question:
' MAIN LOOP ------------------------
main:
FOR bulb = 0 TO 5
ON bulb GOSUB bulb_1, bulb_2, bulb_3, bulb_4, bulb_5, bulb_6
NEXT
GOSUB ReadRTCBurst
GOTO main
'----------------------------------------
'reads time from clock chip
ReadRTCBurst:
HIGH RTCReset
SHIFTOUT DTA, Clk, LSBFIRST, [%1\1,BrstReg\5,%10\2]
SHIFTIN DTA, Clk, LSBPRE, [Seconds,Minutes,Hours]
LOW RTCReset
RETURN
'---------------BULB WRITING SUBROUTINES BELOW ------------------
bulb_1:
LOW 7
digit = hours.HIGHNIB
ON digit GOSUB digit_0, digit_1, digit_2
HIGH 2
RETURN
bulb_2:
LOW 2
digit = hours.LOWNIB
ON digit GOSUB digit_0, digit_1, digit_2, digit_3, digit_4, digit_5, digit_6, digit_7, digit_8, digit_9
HIGH 3
RETURN
bulb_3:
LOW 3
digit = minutes.HIGHNIB
ON digit GOSUB digit_0, digit_1, digit_2, digit_3, digit_4, digit_5
HIGH 4
RETURN
bulb_4:
LOW 4
digit = minutes.LOWNIB
ON digit GOSUB digit_0, digit_1, digit_2, digit_3, digit_4, digit_5, digit_6, digit_7, digit_8, digit_9
HIGH 5
RETURN
bulb_5:
LOW 5
digit = seconds.HIGHNIB
ON digit GOSUB digit_0, digit_1, digit_2, digit_3, digit_4, digit_5
HIGH 6
RETURN
bulb_6:
LOW 6
digit = seconds.LOWNIB
ON digit GOSUB digit_0, digit_1, digit_2, digit_3, digit_4, digit_5, digit_6, digit_7, digit_8, digit_9
HIGH 7
RETURN
digit_0:
LOW 11
LOW 12
LOW 13
LOW 14
RETURN
digit_1:
LOW 11
LOW 12
LOW 13
HIGH 14
RETURN
digit_2:
LOW 11
LOW 12
HIGH 13
LOW 14
RETURN
digit_3:
LOW 11
LOW 12
HIGH 13
HIGH 14
RETURN
digit_4:
LOW 11
HIGH 12
LOW 13
LOW 14
RETURN
digit_5:
LOW 11
HIGH 12
LOW 13
HIGH 14
RETURN
digit_6:
LOW 11
HIGH 12
HIGH 13
LOW 14
RETURN
digit_7:
LOW 11
HIGH 12
HIGH 13
HIGH 14
RETURN
digit_8:
HIGH 11
LOW 12
LOW 13
LOW 14
RETURN
digit_9:
HIGH 11
LOW 12
LOW 13
HIGH 14
RETURN[/url] (http://)[url=http://] (http://)