Thursday, December 15, 2005
Monday, December 12, 2005
Saturday, December 10, 2005
code for the pic
here's the working code for our project. This version has scrolling. you can end the scrolling by pressing any button.
'****************************************************************
'* Name : sevenSegmentCounter_wEdgeDetection.bas *
'* Author : Jenny Chowdhury &MichaelDelGadudio & Karl Channell *
'* : All Rights Reserved *
'* Date : 12/10/2005 *
'* Version : 1.0 *
'* Notes : seven segment display counter using edge *
'* : detection *
'****************************************************************
DEFINE OSC 4
' Set all of PORTB to outputs
TRISB = %00000000
'Set all A ports as digital
adcon1 = %00000110
TRISA = %00000000
TRISD = %00000000
'set buttons as input ports
input PORTB.7 'curser button
input PORTC.7 'forward alphabet
input PORTC.6 'backwards alphabet
'set pins as write control
output PORTC.5 'write control for 1st display
output PORTC.4 'write control for 2nd display
output PORTD.7 'write control for 3rd display
output portc.2 ' address pin for 1st display
output portc.3 ' address pin for 1st display
output PORTC.0 ' address pin for 2nd display
OUTput PORTC.1 ' address pin for 2nd display
output PORTE.1 'address pin for 3rd display
output PORTE.2 'address pin for 3rd display
timer var byte
timer = 0
myDigit var byte[12]
j var byte ' counter for for loops
'initialize letters
FOR j=0 to 11 STEp 1
myDigit[j] = j
next j
alphabet var BYTE[27]
alphabet[0] = "A"
alphabet[1] = "B"
alphabet[2] = "C"
alphabet[3] = "D"
alphabet[4] = "E"
alphabet[5] = "F"
alphabet[6] = "G"
alphabet[7] = "H"
alphabet[8] = "I"
alphabet[9] = "J"
alphabet[10] = "K"
alphabet[11] = "L"
alphabet[12] = "M"
alphabet[13] = "N"
alphabet[14] = "O"
alphabet[15] = "P"
alphabet[16] = "Q"
alphabet[17] = "R"
alphabet[18] = "S"
alphabet[19] = "T"
alphabet[20] = "U"
alphabet[21] = "V"
alphabet[22] = "W"
alphabet[23] = "X"
alphabet[24] = "Y"
alphabet[25] = "Z"
alphabet[26] = " "
' --- Edge Detection vars for cursor ---'
switchStateVar var byte
switchStateVar = 0
lastSwitchStateVar var byte
switchCountVar var byte
switchCountVar = 0
' --- Edge Detection vars for alpha ---'
alphaSwitchStateVar var byte
alphaswitchStateVar = 0
alphaLastSwitchStateVar var byte
alphaSwitchCountVar var byte
' --- Edge Detection vars for backwards alpha ---'
backAlphaSwitchStateVar var byte
backAlphaswitchStateVar = 0
backAlphaLastSwitchStateVar var byte
backAlphaSwitchCountVar var byte
' Display 1
' PIC B0-B6 maps to 1414 D0-D6
' -- Set the initial display state -- '
gosub reset
MAIN:
' -- Edge detection for cursor --'
switchStateVar = PORTB.7
if switchStateVar <> lastswitchStateVar THEN
timer = 0
if switchStateVar = 1 then
' the switch went from off to on
switchCountVar = switchCountVar + 1
switchCountVar = (switchCountVar//12)
high PORTD.2
' clear it all out
gosub reset
else
' the switch went from on to off
' test pin
low PORTD.2
endif
' store the state of the switch for next check:
lastswitchStateVar = switchStateVar
else
'increment the timer
timer = timer + 1
if timer >= 100 then
while (switchStateVar = lastswitchStateVar && alphaswitchStateVar = alphalastswitchStateVar && backAlphaswitchStateVar = backAlphalastswitchStateVar)
gosub scroll
switchStateVar = PORTB.7
alphaSwitchStateVar = PORTC.7
backAlphaswitchStateVar = PORTC.6
wend
endif
endif
' -- Edge detection for forward alphabet button --'
alphaswitchStateVar = PORTC.7
if alphaswitchStateVar <> alphalastswitchStateVar THEN
timer = 0
' the switch went from off to on
if alphaswitchStateVar = 1 then
'increment the current digit
for j= 0 to 11 step 1
If(switchcountvar = j) then
mydigit[j] = mydigit[j]+1
myDigit[j] = myDigit[j]//27
Endif
next j
' clear it all out
gosub reset
else 'the switchpin went off
endif
' store the state of the switch for next check:
alphalastswitchStateVar = alphaswitchStateVar
endif
'backbutton edge detection
' -- Edge detection for backwards alphabet button --'
backAlphaswitchStateVar = PORTC.6
if backAlphaswitchStateVar <> backAlphalastswitchStateVar THEN
timer = 0
' the switch went from off to on
if backAlphaswitchStateVar = 1 then
'increment the current digit
for j= 0 to 11 step 1
If(switchcountvar = j) then
mydigit[j] = mydigit[j] + 26
myDigit[j] = myDigit[j]//27
Endif
next j
' clear it all out
gosub reset
else
' the switch went from on to off
endif
' store the state of the switch for next check:
backAlphalastswitchStateVar = backAlphaswitchStateVar
endif
'Letters are written right to left thus digit 3 appears first and so on
'Display three
'end of display three
if switchCountVar = 11 then
High PORTD.7
' Digit 0C
Low PORTE.1
LOW PORTE.2
'_
PORTD = alphabet[myDigit[11]]
low PORTD.7
pause 50
High PORTD.7
' Digit 0C
Low PORTE.1
LOW PORTE.2
'_
PORTD = " "
low PORTD.7
pause 50
endif
if switchCountVar = 10 then
High PORTD.7
' Digit 1c
high PORTE.1
LOW PORTE.2
'_
PORTD = alphabet[myDigit[10]]
low PORTD.7
pause 50
High PORTD.7
' Digit 1c
high PORTE.1
LOW PORTE.2
'_
PORTD = " "
low PORTD.7
pause 50
endif
if switchCountVar = 9 then
High PORTD.7
' Digit 2c
low PORTE.1
high PORTE.2
'_
PORTD = alphabet[myDigit[9]]
low PORTD.7
pause 50
High PORTD.7
' Digit 2c
low PORTE.1
high PORTE.2
'_
PORTD = " "
low PORTD.7
pause 50
endif
''put in 8
if switchCountVar = 8 then
High PORTD.7
' Digit 3c
high PORTE.1
high PORTE.2
'_
PORTD = alphabet[myDigit[8]]
low PORTD.7
pause 50
High PORTD.7
' Digit 3c
high PORTE.1
high PORTE.2
'_
PORTD = " "
low PORTD.7
pause 50
endif
' Display two
if switchCountVar = 7 then
High PORTC.4
' Digit 0B
Low PORTC.2
LOW PORTC.3
'_
PORTA = alphabet[myDigit[7]]
low PORTC.4
pause 50
High PORTC.4
' Digit 0B
Low PORTC.2
LOW PORTC.3
'_
PORTA = " "
low PORTC.4
pause 50
endif
if switchCountVar = 6 then
High PORTC.4
' Digit 1B
high PORTC.2
LOW PORTC.3
'_
PORTA = alphabet[myDigit[6]]
low PORTC.4
pause 50
High PORTC.4
' Digit 1B
high PORTC.2
LOW PORTC.3
'_
PORTA = " "
low PORTC.4
pause 50
endif
if switchCountVar = 5 then
' Digit 2B
High PORTC.4
' Digit 2B
LOw PORTC.2
high PORTC.3
'_
PORTA = alphabet[myDigit[5]]
low PORTC.4
pause 50
High PORTC.4
' Digit 2B
low PORTC.2
high PORTC.3
'_
PORTA = " "
low PORTC.4
pause 50
endif
if switchCountVar = 4 then
' Digit 3B
High PORTC.4
' Digit 3B
high PORTC.2
high PORTC.3
'_
PORTA = alphabet[myDigit[4]]
low PORTC.4
pause 50
High PORTC.4
' Digit 3B
high PORTC.2
high PORTC.3
'_
PORTA = " "
low PORTC.4
pause 50
endif
' Display One
if switchCountVar = 3 then
High PORTC.5
' Digit 0
Low PORTC.0
LOW PORTC.1
'_
PORTB = alphabet[myDigit[3]]
low PORTC.5
pause 50
High PORTC.5
' Digit 0
Low PORTC.0
LOW PORTC.1
'_
PORTB = " "
low PORTC.5
pause 50
endif
if switchCountVar = 2 then
High PORTC.5
' Digit 1
high PORTC.0
LOW PORTC.1
'_
PORTB = alphabet[myDigit[2]]
low PORTC.5
pause 50
High PORTC.5
' Digit 1
high PORTC.0
LOW PORTC.1
'_
PORTB = " "
low PORTC.5
pause 50
endif
if switchCountVar = 1 then
' Digit 2
High PORTC.5
' Digit 2
LOw PORTC.0
high PORTC.1
'_
PORTB = alphabet[myDigit[1]]
low PORTC.5
pause 50
High PORTC.5
' Digit 2
low PORTC.0
high PORTC.1
'_
PORTB = " "
low PORTC.5
pause 50
endif
if switchCountVar = 0 then
' Digit 3
'letter3 = alphabet[myDigit[0]]
High PORTC.5
' Digit 3
high PORTC.0
high PORTC.1
'_
PORTB = alphabet[myDigit[0]]
low PORTC.5
pause 50
High PORTC.5
' Digit 3
high PORTC.0
high PORTC.1
'_
PORTB = " "
low PORTC.5
pause 50
endif
goto main
'This subroutine resets all digits on both displays
reset:
' Start Write
high PORTC.5
' Digit 0
Low PORTC.0
LOW PORTC.1
'_
PORTB = alphabet[mydigit[3]]
' End Write
low PORTC.5
' Start Write
high PORTC.5
' Digit 0
high PORTC.0
LOW PORTC.1
'_
PORTB = alphabet[mydigit[2]]
' End Write
low PORTC.5
' Start Write
high PORTC.5
' Digit 0
Low PORTC.0
high PORTC.1
'_
PORTB = alphabet[mydigit[1]]
' End Write
low PORTC.5
' Start Write
high PORTC.5
' Digit 0
high PORTC.0
high PORTC.1
'_
PORTB = alphabet[mydigit[0]]
' End Write
low PORTC.5
'send letters to 2nd output display
' Start Write
high PORTC.4
' Digit 0b
Low PORTC.2
LOW PORTC.3
'_
PORTA = alphabet[mydigit[7]]
' End Write
low PORTC.4
' Start Write
high PORTC.4
' Digit 0
high PORTC.2
LOW PORTC.3
'_
PORTA = alphabet[mydigit[6]]
' End Write
low PORTC.4
' Start Write
high PORTC.4
' Digit 0
Low PORTC.2
high PORTC.3
'_
PORTA = alphabet[mydigit[5]]
' End Write
low PORTC.4
' Start Write
high PORTC.4
' Digit 0
high PORTC.2
high PORTC.3
'_
PORTA = alphabet[mydigit[4]]
' End Write
low PORTC.4
'send 3rd output display
' Start Write
high PORTD.7
' Digit 0
Low PORTE.1
LOW PORTE.2
'_
PORTD = alphabet[mydigit[11]]
' End Write
low PORTD.7
' Start Write
high PORTD.7
' Digit 0
high PORTE.1
LOW PORTE.2
'_
PORTD = alphabet[mydigit[10]]
' End Write
low PORTD.7
' Start Write
high PORTD.7
' Digit 0
Low PORTE.1
high PORTE.2
'_
PORTD = alphabet[mydigit[9]]
' End Write
low PORTD.7
' Start Write
high PORTD.7
' Digit 0
high PORTE.1
high PORTE.2
'_
PORTD = alphabet[mydigit[8]]
' End Write
low PORTD.7
return
'This subroutine scrolls all digits
scroll:
i var byte
scroller var byte [36]
scroller[0] = " "
scroller[1] = " "
scroller[2] = " "
scroller[3] = " "
scroller[4] = " "
scroller[5] = " "
scroller[6] = " "
scroller[7] = " "
scroller[8] = " "
scroller[9] = " "
scroller[10] = " "
scroller[11] = " "
scroller[12] = alphabet[mydigit[0]]
scroller[13] = alphabet[mydigit[1]]
scroller[14] = alphabet[mydigit[2]]
scroller[15] = alphabet[mydigit[3]]
scroller[16] = alphabet[mydigit[4]]
scroller[17] = alphabet[mydigit[5]]
scroller[18] = alphabet[mydigit[6]]
scroller[19] = alphabet[mydigit[7]]
scroller[20] = alphabet[mydigit[8]]
scroller[21] = alphabet[mydigit[9]]
scroller[22] = alphabet[mydigit[10]]
scroller[23] = alphabet[mydigit[11]]
scroller[24] = " "
scroller[25] = " "
scroller[26] = " "
scroller[27] = " "
scroller[28] = " "
scroller[29] = " "
scroller[30] = " "
scroller[31] = " "
scroller[32] = " "
scroller[33] = " "
scroller[34] = " "
scroller[35] = " "
FOR i=0 to 23 STEp 1
gosub checkinput
if (switchStateVar <> lastswitchStateVar || alphaswitchStateVar <> alphalastswitchStateVar || backAlphaswitchStateVar <> backAlphalastswitchStateVar) then
timer = 0
return
endif
' Start Write
high PORTC.5
' First Letter
high PORTC.0
high PORTC.1
'_
PORTB = scroller[i]
' End Write
low PORTC.5
' Start Write
high PORTC.5
' Second Letter
low PORTC.0
high PORTC.1
'_
PORTB = scroller[i+1]
' End Write
low PORTC.5
' Start Write
high PORTC.5
' Third Letter
high PORTC.0
low PORTC.1
'_
PORTB = scroller[i+2]
' End Write
low PORTC.5
' Start Write
high PORTC.5
' Fourth Letter
low PORTC.0
low PORTC.1
'_
PORTB = scroller[i+3]
' End Write
low PORTC.5
'send letters to 2nd output display
' Start Write
high PORTC.4
' Fifth Letter
high PORTC.2
high PORTC.3
'_
PORTA = scroller[i+4]
' End Write
low PORTC.4
' Start Write
high PORTC.4
' Sixth Letter
low PORTC.2
high PORTC.3
'_
PORTA = scroller[i+5]
' End Write
low PORTC.4
' Start Write
high PORTC.4
' Seventh Letter
high PORTC.2
low PORTC.3
'_
PORTA = scroller[i+6]
' End Write
low PORTC.4
' Start Write
high PORTC.4
' Eigth Letter
low PORTC.2
low PORTC.3
'_
PORTA = scroller[i+7]
' End Write
low PORTC.4
'send 3rd output display
' Start Write
high PORTD.7
' Ninth Letter
high PORTE.1
high PORTE.2
'_
PORTD = scroller[i+8]
' End Write
low PORTD.7
' Start Write
high PORTD.7
' Tenth Letter
low PORTE.1
high PORTE.2
'_
PORTD = scroller[i+9]
' End Write
low PORTD.7
' Start Write
high PORTD.7
' Eleventh Letter
high PORTE.1
low PORTE.2
'_
PORTD = scroller[i+10]
' End Write
low PORTD.7
' Start Write
high PORTD.7
' Twelveth Letter
low PORTE.1
low PORTE.2
'_
PORTD = scroller[i+11]
' End Write
low PORTD.7
pause 200
next i
return
'this subroutine updates button values
checkinput:
switchStateVar = PORTB.7
alphaSwitchStateVar = PORTC.7
backAlphaswitchStateVar = PORTC.6
return
Wednesday, December 07, 2005
next on the agenda
Michael and I have succesfully programmed 2 segment displays to be controlled by one pic. This "control" consists of the following:
1) cursor selection - allows user to choose the location of specfic letter he/she is changing with a press of a button.
2) forward scrolling letter selection - allows user to choose which letter for that particular spot(selected with the cursor button) with a button which makes letters appear in alphabetical order
3) backwards scrolling letter selection - allows user to choose which letter for that particular spot with a button which makes letters appear in reverse alphabetical order.
The code is really ugly and long because it's procedural. Apparenlty you can't do the OOP thing with pic basic pro. Or even pass parameters to subroutines for that matter.
Meanwhile, Karl has been working on getting the text to scroll across the segment.
Today, we'll be working on getting a third segment on the pic, getting scrolling to occur after an idle period and generally, making our code uglier and longer.
Michael talked to Todd about buying back the other segment displays yesterday so hopefully, we can get start soldering before long.
Also, I called Jameco to today to yet again tell them about their duplication error. I really had hoped that they would send me a shipping label as I have no time to go to the post office. I couldn't convince the rep though.
Tuesday, December 06, 2005
Summary
Segment Tags aim to allow for the personalization of space and objects in an environment. Through the use of interactive displays users can create their own tag or message without the destruction of property. Visitors of a restaurant, bar, or public space are encourage to leave a word, thought, question or message of what's on heir mind with relation to their surroundings. The intent is to open a dialog between visitors who share a space at different times.
Walls, furniture, and objects don't commonly allow people to leave their mark or capture a thought. The desire for people to leave traces of their presence can be seen in graffiti, guest books, customized cars, blogs, and bumper, where we leave behind signs that we have been someplace and have something to say. As individuals, we desire the ability to leave a bit of our selves in an environment. Segment Tags bridge this gap by providing people the opportunity to leave a few words behind.
Saturday, December 03, 2005
PIC Code and the 1414

Yesterday Jenny Karl and I worked mainly on the software side. Karl worked on making the text display scrollable, while Jenny and I worked on implementing edge detection for the cursor and letter selection. One big ah-ha happened when we realized that the decoder in the 1414 cal translate string character like "A". This saves a lot of time because we no longer need to send the IC binary.
Thursday, December 01, 2005
1414 Smart Display Photos



On top: Karl & Jenny setting up the 1414 on the board. On the bottom: The 1414 smart 16-segment display. This display is great. It's easy to setup and easy to send data to. ASCII characters are sent to the display where they are decoded, stored in memory, and multiplexed. The character size is small but the LEDs are bright and make up for their size in brightness.







