질문과 답변

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

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 - -
49287 윈 도 우| 윈도우 삭제 프로그램 제거... [1] 늑돌이 1329 05-27
49286 기 타| 노트북 초기화 [2] 당근죠 1654 05-27
49285 윈 도 우| 무인설치중 인증키 입력창 건너뛰기 설정하기 [1] 레프 1491 05-27
49284 윈 도 우| windows7 msdn 순정 iso파일 문의드립니다. [7] 슝슝이 2554 05-27
49283 윈 도 우| 윈8.1PE 안에 appetizer 추가할 수 있나요? [2] 알키온 1196 05-27
49282 윈 도 우| fontlink 질문^^ rokag3 1211 05-27
49281 윈 도 우| 윈8....윈7.... 뭐에 정착해야 좋을까요... [5] 응가 1242 05-27
49280 하드웨어| SSD 뉴비가 질문 드립니다. [4] 당근당근 1435 05-27
49279 기 타| VHD와 디스크 할당크기에 관해서 이해가 안가는 부분이 있... [3] 라푸아 1294 05-27
49278 윈 도 우| 자꾸올려서 죄송합니다) 윈도우8설치후 기존드라이부 접속 ... [1] 대머리윈도 1222 05-27
49277 소프트웨어| 아이온 패스트핑3.0 [2] @LostED 1262 05-26
49276 윈 도 우| 자동이든아니든 관리자권한으로 설치했어도 [2] 어사또 1166 05-26
49275 윈 도 우| 윈7,8에서 설치DVD/USB 사용시 복구모드 들어가는 단축키는... 메리아 1174 05-26
49274 윈 도 우| VMware Workstation [3] 어사또 1783 05-26
49273 윈 도 우| 8.1 매트로 메일/일정 이 실행은 되는데 최소화 됩니다. 따루아빠 947 05-26
49272 윈 도 우| 파일만 요청좀 할려고 합니다. [3] 초보라서죄 1458 05-26
49271 윈 도 우| 이미지 작업 관련하여 질문드립니다(사내 PC이미지작업) [1] 나데쓰 976 05-26
49270 윈 도 우| win7 화면보호기 비밀번호 초기화 하는 방법이 있나요? [3] 알수없음 3953 05-26
49269 기 타| 고스트 안의 툴 [2] 기러기 1223 05-26
49268 윈 도 우| 파티션쪽 잘 아시는분 계시는지요.. [1] 김뽈로 1147 05-26
XE1.11.6 Layout1.4.8