질문과 답변

소프트웨어 ★프로그래머님께...헬프점여~~~~

2014.05.26 00:35

거거거3 조회:1430

avr studio4로 프로그램한건데요..

중간중간에 빠진게 있는데여..이걸 돌릴려면 완성되어야 한다는데요.

저도 받은거라.ㅠㅠ;;이걸 돌아 갈 수 있도록 첨가? 부탁드려도 될까요?ㅠㅠ;;

 

 

Hardware timer
Trigger_Timer ; 1sec
Drop_Timer ; 3sec
Button_Timer(time) ; 0~1sec
Constant
ADCperDB = 0x000A ; 1dB = 0x000A (ADC)
AGCreference = 0x0316 ; -10dBm level
Averagingfactor = 3 ; averaging factor 2^3
Alternateprotector = 3 * (ADCperDB<Averagingfactor) ; extended 3dB
Global Variable
unsigned char; Button, Buttonprocess, Triggercolor, Manualmode, AGCprocessdone
signed short; Phaseoffset, Phaseoffsetzero, HMC5, HMC6
unsigned long Forwardpower, Reversepower
signed long; Frequency, Returnloss, AD5
unsigned long long Forwardpoweraverage, Reversepoweraverage ; extended by Averagingfactor
Function
Load_Phaseoffsetzero
Value = read from EEPROM
return Value
Read_ADC(port)
return ADC(port) ; 10bit
Phase_Adjust(Value) ; Phase limit 6bit (0x00 ~ 0x3F)
while Value < 0x00
Value += 0x40
while Value > 0x3F
Value -= 0x40
return Value
Check_Drop
return Drop
Check_Frontbutton
return "Auto/Manual", "DAC up", "DAC down", "Phase Offset up", "Phase Offset down", "Phase Offset zero", "no button"
procedure
Save_Phaseoffsetzero
save Phaseoffsetzero to EEPROM
Write_AD5
write AD5 ; 16bit
Write_HMC5&HMC6
unsigned char Value
Value = not HMC5 ; negative logic
HMC6 = Phase_Adjust(Phaseoffsetzero + Phaseoffset)
write Value & Value & HMC6 ; 6bit + 6bit + 6bit
Display_Attenuator(Color)
usingend short; Value
switch Color
case "red"
turn on red LED
break
case "yellow"
turn on green LED 63
turn on red LED 315.0
break 63
case "default"
turn off green LED
turn off red LED
break
Value = 5 * HMC5 ; 0x3F -> 315
display Value to front pannel LED window ; 0x3F -> 315 -> "31.5"
Display_Trigger
switch Triggercolor
case "red"
turn on red LED
break
case "green"
turn on green LED
break
case "default"
turn off green LED
turn off red LED
break
Display_DAC(Led)
switch Led
case "up"
turn on up LED
break
case "down"
turn on down LED
break
case "manual"
turn on up LED
turn on down LED
break
case "default"
turn off up LED
turn off down LED
break
display AD5 to front pannel LED window ; -32768 ~ 0 ~ +32767
Display_Returnloss
signed long; Value
Value = Returnloss / ADCperDB ; ADC -> dB
display Value to front pannel LED window ; +12.5 dB - 2.5 dB
Display_Phaseoffset(Value)
Value *= 5.625
display Value to front pannel LED window ; ±5.6 °
Button_Reaction
switch Manualmode
case "auto"
switch Button
case "Auto/Manual"
Manualmode = "manual"
Display_DAC("manual")
break
case "Phase Offset up"
Phaseoffset += 1
if Phaseoffset > 0x3F then phaseoffset = 0x3F ; phase offset limit
Display_Phaseoffset(Phaseoffset)
Write_HMC5&HMC6
break
case "Phase Offset down"
Phaseoffset -= 1
if Phaseoffset < -0x3F then Phaseoffset = -0x3F ; phase offset limit
Display_Phaseoffset(Phaseoffset)
Write_HMC5&HMC6
break
case "Phase Offset zero"
Phaseoffsetzero += Phaseoffset
Phaseoffset = 0
Phaseoffsetzero = Phase_Adjust(Phaseoffsetzero)
display_phaseoffset(Phaseoffsetzero)
Save_Phaseoffsetzero
break
case "default"
Display_Phaseoffset(Phaseoffset)
break
break
case "manual"
switch Button
case "Auto/Manual"
Manualmode = "auto"
Display_DAC("auto")
break
case "DAC up"
AD5 += 1
if AD5 > 0xFFFF then AD5 = 0xFFFF ; AD5 limit
Display_DAC("manual")
Write_AD5
break
case "DAC down"
AD5 -= 1
if AD5 < 0x0000 then AD5 = 0x0000 ; AD5 limit
Display_DAC("manual")
Write_AD5
break
case "default"
break
break
case "default"
break
Button_Process
static unsigned long; Counter, Counterbase, Speed, Debouncecounter
Button = Check_Frontbutton
if Buttonprocess = "no button" then
if Button <> "no button" then ; 1st button
Debouncecounter = 0x000F
Buttonprocess = Button
Counterbase = 10
Counter = Counterbase
Speed = 0.5sec
turn on Button_Timer(Speed)
else
if Button = "no button" then ; button release
if Debouncecounter = 0 then
Buttonprocess = "no button"
else ; debounce
Debouncecounter -= 1
else if Button <> Buttonprocess then ; improper button
Buttonprocess = "no button"
turn off Button_Timer
else if Button_Timer not finished then ; button pressing
Debouncecounter = 0x000F
else ; button accepted
Button_Reaction
Counter -= 1
if Counter = 0 then
Counterbase <= 2
Speed >= 2
switch Manualmode
case "manual"
Counterbase = minimum(Counterbase, 10 * 1024)
Speed = maximum(Speed, 0.5sec / 1024)
break
case "auto"
Counterbase = minimum(Counterbase, 10 * 4)
Speed = maximum(Speed, 0.5sec / 4)
break
Counter = Counterbase
turn on Button_Timer(Speed) ; repeatitive action protect
AGC_Process
signed Attenuatoraverage
unsigned long Forwardvalue, Reversevalue
signed long Alternatecompensation
Alternatecompensation = Forwardpoweraverage - (Forwardpower + Alterateprotector) ; Alternate mode protection
Alternatecompensation = maximum(Alternatecompensation, 0)
Forwardvalue = Forwardpower + Alternatecompensation
Reversevalue = Reversepower + Alternatecompensation
Forwardpoweraverage *= (2^Averagingfactor - 1) ; averaging
Forwardpoweraverage += Forwardvalue
Forwardpoweraverage >= Averagingfactor
Reversepoweraverage *= (2^Averagingfactor - 1)
Reversepoweraverage += Reversevalue
Reversepoweraverage >= Averagingfactor
Forwardvalue = Forwardpoweraverage > Averagingfactor ; reduced Forwardpoweraverge
Attenuatoraverage = (Forwardvalue - AGCreference) / (ADCperDB>1) ; AGC reference, ADC -> 0.5dB conversion
if (Attenuatoraverage > (HMC5 + 1)) or (Attenuatoraverage < (HMC5 - 1)) then ; hysteresis ±0.5dB
HMC5 = Attenuatoraverage
if HMC5 >= 0x3F then ; high power
HMC5 = 0x3F
Display_Attenuator("red")
else if HMC5 <= 0 then ; low power
HMC5 = 0x00
Display_Attenuator("yellow")
else ; normal power
Display_Attenuator("normal")
Write_HMC5&HMC6
Reversevalue = Reversepoweraverage > Averagingfactor ; reduced Reversepoweraverage
Returnloss = Forwardvalue - Reversevalue
Display_Returnloss
AGCprocessdone = "done"
AFC_Process
unsigned char; Led, Counter, Step
signed char; UpDown
static unsigned char; i
unsigned char; j
static signed char; History[3..0]
i += 1
if i > 3 then i = 0
Counter = 0 ; check resonance
for (j = 0; j <= 3; j++)
if History[j] < 0 then Counter++
if (Counter = 4 or Counter = 0) then
Step = 0x0F ; wide step
else
Step = 0x01 ; narrow step
if Returnloss > (3 * ADCperDB) then ; detector select
Frequency = Read_ADC(forward_frequency_port) - Read_ADC(reverse_frequency_port)
if Frequency > 0 then ; low frequency
UpDown = 1
else if Frequency < 0 then ; high frequency
UpDown = -1
else
Frequency = Read_ADC(PFD_port)
if Frequency > 0x02FF then ; high frequency
UpDown = -1
else if Frequency < 0x00FF then ; low frequency
UpDown = 1
History[i] = UpDown
UpDown *= Step
AD5 += UpDown
if AD5 > 0xFFFF then
Led = "up"
AD5 = 0xFFFF
else if AD5 < 0x0000 then
Led = "down"
AD5 = 0x0000
else
Led = "normal"
Write_AD5
Display_DAC(Led)
Interrupt_Trigger_Process
Forwardpower = Read_ADC(forward_port) < Averagingfactor ; extended Forwardpower
Reversepower = Read_ADC(reverse_port) < Averagingfactor ; extended Reversepower
AGCprocessdone = "not done"
if Manualmode = "auto" then
AFC_Process ; AFC
switch Check_Drop
case "drop"
Triggercolor = "red" ; drop trigger
Display_Trigger
turn on Drop_Timer
break
case "default" ; normal trigger
break
turn on Trigger_Timer
clear triggered
main()
HMC5 = 0x3F ; 31.5dB Attenuation
Phaseoffsetzero = Load_Phaseoffsetzero
HMC6 = Phaseoffsetzero
Write_HMC5&HMC6
Display_Attenuator("red")
AD5 = 0x8000 ; AFC 0V out
Write_AD5
Display_DAC("auto")
Forwardpoweraverage = 0x03FF < Averagingfactor ; extended maximum power (10bit < x)
Reversepoweraverage = 0x03FF < Averagingfactor
Buttonprocess = "no button" ; no Button
Manualmode = "auto" ; auto mode
AGCprocessdone = "done"
Initialize interrupt ; turn on Trigger interrupt
while(1) ; infinite loop
if Drop_Timer not finished then ; drop trigger
Triggercolor = "red"
else if Trigger_Timer not finished then ; nomal trigger
Triggercolor = "green"
else ; no trigger
Triggercolor = "no trigger"
Display_Trigger
if AGCprocessdone = "not done" then
AGC_Process
Button_process

번호 제목 글쓴이 조회 등록일
[공지] 질문과 답변 게시판 이용간 유의사항 gooddew - -
49273 윈 도 우| 8.1 매트로 메일/일정 이 실행은 되는데 최소화 됩니다. 따루아빠 947 05-26
49272 윈 도 우| 파일만 요청좀 할려고 합니다. [3] 초보라서죄 1457 05-26
49271 윈 도 우| 이미지 작업 관련하여 질문드립니다(사내 PC이미지작업) [1] 나데쓰 976 05-26
49270 윈 도 우| win7 화면보호기 비밀번호 초기화 하는 방법이 있나요? [3] 알수없음 3952 05-26
49269 기 타| 고스트 안의 툴 [2] 기러기 1223 05-26
49268 윈 도 우| 파티션쪽 잘 아시는분 계시는지요.. [1] 김뽈로 1147 05-26
49267 윈 도 우| 윈도8.1 업데이트 통합에 관한 질문입니다 [2] 꽁초 1272 05-26
49266 소프트웨어| bat파일 좀 도와주세요.. [3] 노네임 1402 05-26
49265 기 타| Office365 개념을 잘 몰라서.... [2] 염감-2 1406 05-26
49264 윈 도 우| WIN 8.1 시작..> 타일 곰댕이 1026 05-26
49263 윈 도 우| 링크된 파일 연결 보는방법아시는분 ?? [2] 데빌서희 1012 05-26
49262 윈 도 우| 메인보드교체 후 os작업다시 안하는 방법있나요? [4] 컴불량 2115 05-26
49261 윈 도 우| 인터넷 동영상이 [1] 쭌쭌 1039 05-26
49260 소프트웨어| 토렌트 파일별로 배포목표를 다르게 할 수 있나요? BlueHero 1007 05-26
49259 윈 도 우| 작업표시줄 [3] 노익장 1757 05-26
49258 하드웨어| 시퓨, 메인보드 조합 가능여부 [3] 풍운의별 1105 05-26
» 소프트웨어| ★프로그래머님께...헬프점여~~~~ [7] 거거거3 1430 05-26
49256 윈 도 우| 하드 디스크 용량이 줄어들었습니다. [4] 과객 1276 05-25
49255 윈 도 우| 바이두 클라우드의 파일 삭제 관련 [2] 줄넘기 1681 05-25
49254 윈 도 우| 작업스케줄러 트리거를 유선인터넷 연결시로 하는 방법 커다란 1162 05-25
XE1.11.6 Layout1.4.8