![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
Diff: SPI.c
- Revision:
- 116:66f1f0ff2dab
- Parent:
- 114:5cc38a53d8a7
- Child:
- 121:bbae560cdd43
diff -r e5a230e5af52 -r 66f1f0ff2dab SPI.c --- a/SPI.c Tue Apr 05 10:31:28 2016 +0000 +++ b/SPI.c Tue Apr 05 16:52:31 2016 +0000 @@ -67,7 +67,46 @@ } -void PlcRegul(void) +void PlcRegul(void) //Программа расчет напряжения для модулятора +{ + int PLC_In; + + PLC_In = Gyro.AD_Slow; +// PLC_In = Gyro.AD_Fast; + + Gyro.PLC_Delta = Gyro.PLC_Old - PLC_In; + + + + if(Gyro.RgConA&0x2) + { + if (Gyro.PLC_Znak > 1) {Gyro.PLC_Znak --;} + else if ( Gyro.PLC_Delta > (1000 * 65536)) {Gyro.PLC_Regul += 1000 << 16; Gyro.PLC_Znak = 5;} + else if ( Gyro.PLC_Delta < (-1000 * 65536)) {Gyro.PLC_Regul += 1000 << 16; Gyro.PLC_Znak = 5;} + else if ((Gyro.PLC_Delta * Gyro.PLC_Znak) > 0) + { + Gyro.PLC_Znak = 1; + Gyro.PLC_Regul -= ((Gyro.PLC_Delta * Gyro.PLC_Znak)/100); + Spi.DAC_B -= ((Gyro.PLC_Delta * Gyro.PLC_Znak)/655360); + + } + else + { + Gyro.PLC_Znak = -1; + Gyro.PLC_Regul -= ((Gyro.PLC_Delta * Gyro.PLC_Znak)/100); + Spi.DAC_B -= ((Gyro.PLC_Delta * Gyro.PLC_Znak)/655360); + + } +// Spi.DAC_B = (Gyro.PLC_Regul + 0x1fffffff)/65536; + + } + Gyro.PLC_Old = PLC_In; +} + + + + +void PlcRegul_old(void) // на всяни й случай { int Delta; @@ -101,6 +140,8 @@ } + + void DAC_OutPut(void)//выдача в цапы { LPC_SSP0->DR=0x5555;