PDA

View Full Version : Multiplexing Bulbs on Nixie Clock



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://)

$WMc%
02-07-2010, 09:51 AM
sbelsky

Have You tried putting;
"ReadRTCBurst:
......HIGH RTCReset
......SHIFTOUT DTA, Clk, LSBFIRST, [%1\1,BrstReg\5,%10\2]
......SHIFTIN DTA, Clk, LSBPRE, [Seconds,Minutes,Hours]
......LOW RTCReset "

In the Main: loop with out a gosub?

This has worked for Me using seven seg. led displays

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
The Truth is out there············___$WMc%___······················ ······ BoogerWoods, FL. USA

sbelsky
02-07-2010, 11:39 AM
I've made some changes that improved it slightly but it still runs too slow (note: i changed some pins around as well)...




'define digit constants
d0 CON %0000
d1 CON %0001
d2 CON %0010
d3 CON %0011
d4 CON %0100
d5 CON %0101
d6 CON %0110
d7 CON %0111
d8 CON %1000
d9 CON %1001

'define bulb constants
bulb1 CON %000001
bulb2 CON %000010
bulb3 CON %000100
bulb4 CON %001000
bulb5 CON %010000
bulb6 CON %100000

DIRH = %11111111
DIRL = %11111111

' MAIN LOOP ------------------------

main:
FOR bulb = 0 TO 5
ON bulb GOSUB bulb_1, bulb_2, bulb_3, bulb_4, bulb_5, bulb_6
NEXT

'read time from chip
HIGH RTCReset
SHIFTOUT DTA, Clk, LSBFIRST, [%1\1,BrstReg\5,%10\2]
SHIFTIN DTA, Clk, LSBPRE, [Seconds,Minutes,Hours]
LOW RTCReset
GOTO main


' ----------------------------------



'---------------BULB WRITING SUBROUTINES BELOW ------------------

bulb_1:
OUTH = %000000
digit = hours.HIGHNIB
LOOKUP digit, [d0,d1,d2,d3,d4,d5,d6,d7,d8,d9], OUTL
OUTH = %000001
RETURN

bulb_2:
digit = hours.LOWNIB
OUTH = %000000
LOOKUP digit, [d0,d1,d2,d3,d4,d5,d6,d7,d8,d9], OUTL
OUTH = %000010
RETURN

bulb_3:
digit = minutes.HIGHNIB
OUTH = %000000
LOOKUP digit, [d0,d1,d2,d3,d4,d5,d6,d7,d8,d9], OUTL
OUTH = %000100
RETURN

bulb_4:
digit = minutes.LOWNIB
OUTH = %000000
LOOKUP digit, [d0,d1,d2,d3,d4,d5,d6,d7,d8,d9], OUTL
OUTH = %001000
RETURN

bulb_5:
digit = seconds.HIGHNIB
OUTH = %000000
LOOKUP digit, [d0,d1,d2,d3,d4,d5,d6,d7,d8,d9], OUTL
OUTH = %010000
RETURN

bulb_6:
digit = seconds.LOWNIB
OUTH = %000000
LOOKUP digit, [d0,d1,d2,d3,d4,d5,d6,d7,d8,d9], OUTL
OUTH = %100000
RETURN


Post Edited (sbelsky) : 2/7/2010 4:45:57 AM GMT

sbelsky
02-09-2010, 08:48 AM
Does anyone see a way to speed this up? Is the BS2 just too slow of a chip?