Browse Source

New scaling values etc.

git-svn-id: https://bucket.mit.edu/svn/nilm/zoom@7591 ddd99763-3ecb-0310-9145-efcb8ce7c51f
tags/zoom-1.0
jim 15 years ago
parent
commit
ab11999ef2
4 changed files with 18 additions and 6 deletions
  1. +1
    -1
      firmware/led.c
  2. +4
    -3
      firmware/scaling.c
  3. +13
    -2
      firmware/zoom.c
  4. BIN
      firmware/zoom.mcw

+ 1
- 1
firmware/led.c View File

@@ -5,4 +5,4 @@ void led_init(void)
{
TRISBbits.TRISB13 = 0;
PORTBbits.RB13 = 1;
}
}

+ 4
- 3
firmware/scaling.c View File

@@ -7,7 +7,7 @@ uint16_t current_to_dac(float amps)
float tmp;
uint16_t dacc;
tmp = 32768 * (1 + amps / 20);
tmp = 536.0 / 1.0 * amps + 32524;
if (tmp < 0)
tmp = 0;
if (tmp > 65535)
@@ -17,10 +17,11 @@ uint16_t current_to_dac(float amps)
return dacc;
}
/* Convert the DAC output value to an effective current in the measuring loop */
float dac_to_current(uint16_t dacv)
{
float amps;
amps = dacv * (20.0 / 32768.0) - 20.0;
amps = ((float)dacv - 32524.0) * 1.0 / 536.0;
return amps;
}
@@ -33,6 +34,6 @@ float adc12_to_current(int16_t picv)
if (picv > 2047)
picv = 2047;
amps = (1024.0 - picv) / 3522.6;
amps = (picv - 1024.0) / 404.0;
return amps;
}

+ 13
- 2
firmware/zoom.c View File

@@ -55,8 +55,14 @@ void TISR_HANDLER(5)
/* Convert ADC value to current */
i = adc12_to_current(v);

#if 0
/* Adjust DAC to null this current to 0 */
dac_current -= i;
#else
/* If this current exceeds +-1A, cancel it out at the DAC */
if (i < -1.0 || i > 1.0)
dac_current -= i;
#endif

if (dac_current < dac_current_min)
dac_current = dac_current_min;
@@ -85,12 +91,15 @@ void send_to_pc(uint16_t adc, uint16_t dac)

void degauss(void)
{
return;
#if 0
dac_write(65535); /* max */
msleep(25);
dac_write(0); /* min */
msleep(25);
dac_write(32768); /* middle */
msleep(25);
#endif
}

void run_debug(void)
@@ -214,6 +223,8 @@ int main(void)
led_init();

led_on();
/* debug */
TRISAbits.TRISA9 = 0;
/* Detect jumper on B10/B11 */
//TRISCbits.TRISC13 = 1;
//CNPU1bits.CN1PUE = 1;
@@ -232,9 +243,9 @@ int main(void)
/* If PGD is externally tied to ground, use MODE_1
(Short ICD pins 3 and 4) */
// if (PORTCbits.RC13 == 0)
MODE_1();
// MODE_1();
// else
// MODE_2();
MODE_2();

for (;;)
continue;


BIN
firmware/zoom.mcw View File


Loading…
Cancel
Save