Team Members:
- Joseph Kopacz (Center)
- Torry Neuhoff (Left)
- Topher Peter (Right)
- Philip Karlberg (Not Shown)
Technical Specifications:
- 12 Volt Power Supply
- Drill Pump (1 Gallon Per Hour)
- LCD Screen with interactive display
- Song Selection
- Volume Adjustment
- Pump On/Off
- 63 High Output LED's
Video:
Pictures:
Mechanical Drawings:
Available upon request.
Electrical Schematics:
Pic Code:
Master Pic:
ANSEL = 0
CMCON = 7
define OSC 8 'Set the internal oscillator to 8mhz...
OSCCON = %01110010 ; intosc to 8mhz
'use the USART and HSEROUT commands.
'To set-up the UASRT ...
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_SPBRG 12 ' 38400 Baud @ 8MHz, 0.16%
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
trisb = %11010100 '0(pump),1(slave),3 (lcd),5(mp3) output, 2(mp3?),4(enter),6(down),7(up) input
pause 500 'wait for lcd to start up
lcdout $FE, 1, "Welcome!" '"welcome!" displayed
pause 3000 'pause 3 seconds
high portb.0 'activate pump
high portb.1 'activate slave PIC
voldis var byte
vollvl var byte 'declare song variable, volume displayed and volume variable
track var byte
vollvl = 0 ‘Initializing volume level
track = 1 ‘Initializing track number
Serial_out VAR PORTB.5 ' pin 5 to mp3 trigge
'subs:
displayout:
lcdout $FE, 1, "Volume-Up Song-Down", $FE, $C0, "Pump-Enter"
'display volume level, activate pump, and choose song options
pause 200
goto main
main: 'main menu
if (portb.7=1) then 'if up pressed gosub volume
goto volumex
pause 200
endif
if (portb.6=1) then 'if down pressed gosub songx
goto songx
pause 200
endif
if (portb.4=1 & portb.0=1) then 'pump off
low portb.0
pause 200
endif
if (portb.4=1 & portb.0=0) then 'pump on
high portb.0
pause 200
endif
goto main
volumex:
lcdout $FE, 1, " Up or Down", $FE, $C0, " Volume: ", DEC vollvl
'new display item. Volume is displayed.
goto volume
volume: 'volume menu
voldis=((250-vollvl)/25)*10 ‘voldis is for display purposes. Vollvl is for the mp3 trigger.
'track volume variable through up/down buttons (set minimum and maximum, mp3 ‘trigger only accepts numbers 0 though 255)
if (portb.6 = 1) then 'if statement prevents overflow for byte variable vollvl
if (vollvl < 250) then ‘sets a maximum for vollvl
vollvl = vollvl + 25
endif
lcdout $FE, 1, "Up or Down", $FE, $C0, "Volume: ", DEC voldis ‘displays volume level
hserout ["v", vollvl] ‘sends command to mp3 player to set volume level
pause 200
endif
if (portb.7 = 1) then 'if statement prevents overflow for byte variable vollvl
if (vollvl > 0) then ‘sets a minimum for vollvl
vollvl = vollvl - 25
endif
lcdout $FE, 1, "Up or Down", $FE, $C0, "Volume: ", DEC voldis ‘displays volume level
hserout ["v", vollvl] ‘sends command to mp3 player to set volume level
pause 200
endif
if (portb.4=1) then 'enter key pressed? then back to main menu/ main task loop
goto displayout
endif
goto volume
songx:
lcdout $FE, 1, "Up for forward", $FE, $C0, "Down for back" 'new display item
goto song
song: 'choose song
'track song variable # through up/down buttons (set loop for selection). This configuration is set ‘to play only 6 songs. But more can be added
if (portb.7=1 & track < 6) then ‘max track number set to 6
track = track + 1
lcdout $FE, 1, "Play Track", $FE, $C0, " ", DEC track, "?" 'new display item
hserout ["p", track]
pause 300
endif
if (portb.6=1 & track > 1) then ‘min. track number set to 1
track = track - 1
lcdout $FE, 1, "Play Track", $FE, $C0, " ", DEC track, "?" 'new display item
hserout ["p", track]
pause 300
endif
if (portb.4=1) then 'enter key pressed? then update song on mp3 and back to main
goto displayout
endif
goto song
end
Slave Pic:
‘This portion of programming controls the light display.
' 10-bit A/D conversion
' Connect analog input to channel-0 (RA0)
' Define ADCIN parameters
' Set number of bits in result
DEFINE ADC_BITS 10
' Set clock source (3=rc)
DEFINE ADC_CLOCK 3
' Set sampling time in microseconds
DEFINE ADC_SAMPLEUS 10
adcVar VAR WORD ' Create variable to store result
adcVar = 0
TRISA = 000101 ' Set PORTA to all input
TRISB = 000000
'high porta.2 'for testing
ADCON1 = %10000010 ' Set up ADCON1
Const1 var byte
Const2 var byte
Const3 var byte
Const4 var byte
Const5 var byte
Const1 = 33 ‘used a linear progression method for sound volume sensing, not a logarithmic
Const2 = 66
Const3 = 99
Const4 = 132
Const5 = 165
Row1 var portb.1 ‘Row 1 represents the bottom row of leds and Row 6 is the top row.
Row2 var portb.2
Row3 var portb.3
Row4 var portb.4
Row5 var portb.5
Row6 var portb.6
Pause 500 ' Wait .5 second
main:
while(porta.2 == 1) ‘the loop that keeps the ADC checking the current volume level.
ADCIN 0, adcVar ' Read channel 0 ‘reads the ADC and sets adcVar equal to it.
if (adcvar <= Const1) then 'check if row 1 should be active
high Row1
low Row2
low Row3
low Row4
low Row5
low Row6
Pause 10 ' Wait.01 second
goto main
endif
if (adcvar <= Const2) then 'check if row 2 should be active
high Row1
high Row2
low Row3
low Row4
low Row5
low Row6
Pause 10 ' Wait.01 second
goto main
endif
if (adcvar <= Const3) then 'check if row 3 should be active
high Row1
high Row2
high Row3
low Row4
low Row5
low Row6
Pause 10 ' Wait.01 second
goto main
endif
if (adcvar <= Const4) then 'check if row 4 should be active
high Row1
high Row2
high Row3
high Row4
low Row5
low Row6
Pause 10 ' Wait.01 second
goto main
endif
if (adcvar <= Const5) then 'check if row 5 should be active
high Row1
high Row2
high Row3
high Row4
high Row5
low Row6
Pause 10 ' Wait.01 second
goto main
endif
if (adcvar > Const5) then 'check if row 6 should be active
high Row1
high Row2
high Row3
high Row4
high Row5
high Row6
Pause 10 ' Wait.01 second
goto main
endif
Pause 10 ' Wait.01 second
Wend ‘end of while loop
goto main
end
No comments:
Post a Comment