Author Topic: LM399 based 10 V reference  (Read 265323 times)

0 Members and 4 Guests are viewing this topic.

Offline branadic

  • Super Contributor
  • ***
  • Posts: 1181
  • Country: de
Re: LM399 based 10 V reference
« Reply #800 on: January 10, 2019, 09:13:05 am »
Hi Andreas,

thanks for your efffort. I still think power consumption can be reduced by using a lower frequency crystal such as 8MHz. The question left is, what about TC with external crystal and R15 tap as suggested by Kleinstein?

-branadic-
Prema 5000 | 2x Prema 5017 SC | GenRad 1434-G | Tek 2465A | VNWA2.x with TCXO upgrade and access to: Keysight 3458A, Keithley 2002, Prema 5017 SC, 34401A, 34410A, Keithley 2182A, HDO6054, Keysight 53230A and other goodies at work
 

Online Andreas

  • Super Contributor
  • ***
  • Posts: 2165
  • Country: de
Re: LM399 based 10 V reference
« Reply #801 on: January 10, 2019, 09:38:03 am »
Hello branadic,

one step after the other.
my plan is to measure first the current setup with 20 MHz and sleep mode.
2nd step is to change back to low noise R15 tap.

And finally go to lower X-TAL frequency.
My preferred frequency would be 4.9152 MHz to get to a standard baud rate from within interrupt routine.

With best regards

Andreas
 

Online Andreas

  • Super Contributor
  • ***
  • Posts: 2165
  • Country: de
Re: LM399 based 10 V reference
« Reply #802 on: January 13, 2019, 06:07:47 am »
Hello,

some further measurements with branadics PCB:

- 09.01.2019: removed R15 tap against Measurement of 07.01.2019

(RC-oscillator 8MHz + Sleep mode active ~ 6.6 mA no R15 tap)

box-TC. 1.3 ppm/K
average linear T.C. -1.34 ppm/K
3rd order TC @ 25 deg C -1.30 ppm/K

so no significant change in T.C. against R15 tap.

- 10.01.2019 changed back to 20 MHz XTAL oscillator

(XTAL-oscillator 20MHz + Sleep mode active ~ 11.6 mA no R15 tap)

box-TC. 0.12 ppm/K
average linear T.C. -0.10 ppm/K
3rd order TC @ 25 deg C -0.09 ppm/K

so comparable against first T.C. measurement with factor 10 lower T.C.

- 11.01.2019: re-installed R15 tap

(XTAL-oscillator 20MHz + Sleep mode active ~ 11.2 mA with R15 tap)

box-TC. 0.10 ppm/K
average linear T.C. -0.07 ppm/K
3rd order TC @ 25 deg C -0.04 ppm/K

So R15 tap seems to generage a slightly lower T.C.
(But I also guess that repeatability of measurement is around +/- 0.03 ppm/K)
But T.C. over temperature looks rather non - linear.

I have made a overview table over all T.C. measurements.

next measurement will be with 4.9152 MHz XTAL which looks promising with ~4.5 mA.

with best regards

Andreas

Edit: typo on XTAL frequency
« Last Edit: January 13, 2019, 09:57:10 pm by Andreas »
 
The following users thanked this post: branadic, Inverted18650

Offline branadic

  • Super Contributor
  • ***
  • Posts: 1181
  • Country: de
Re: LM399 based 10 V reference
« Reply #803 on: January 17, 2019, 06:45:18 am »
Thanks for the results.

Quote
next measurement will be with 4.9152 MHz XTAL which looks promising with ~4.5 mA.

So you will run the pwm at 2.4kHz (with prescaler set to /8) or will you change the prescaler to 4 or 2?

-branadic-
Prema 5000 | 2x Prema 5017 SC | GenRad 1434-G | Tek 2465A | VNWA2.x with TCXO upgrade and access to: Keysight 3458A, Keithley 2002, Prema 5017 SC, 34401A, 34410A, Keithley 2182A, HDO6054, Keysight 53230A and other goodies at work
 

Online Andreas

  • Super Contributor
  • ***
  • Posts: 2165
  • Country: de
Re: LM399 based 10 V reference
« Reply #804 on: January 17, 2019, 07:00:12 am »
Hello branadic,

unfortunately there is only a ratio 1:1 or 1:8 as pre-scaler for the used PWM-unit.
The interrupt routine takes around 300 clock cycles (at the 22 bit version of the SW).
(so with 1:1 the interrupt routine would calculate longer than the PWM cycle)

So the PWM-frequency has to drop to 2400 Hz.

I have some strange effects with ~5 MHz now where I do not know if I have contact problems or if the ATTINY oscillator cirquit has generally problems with lower frequencies.  -> will have to repeat some tests.
Also the 8 MHz R/C oscillator shows instabilities (high T.C.) here as already shown.

Can you check wether you have the same instabilities with the R/C clock as I have here?
Could also be that I got a bad batch of ATTINies on my side.

with best regards

Andreas



 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 5000
  • Country: de
Re: LM399 based 10 V reference
« Reply #805 on: January 17, 2019, 07:39:32 am »
300 Clock cycles for the fractional divider sounds like quite a lot. So I assume this would be C code. If it is just die divider and not much interface via UART, one could write ASM code. For a different project I have done a fractional  before - AFAIR the ISR was more like 20 cycles. So the power savings due to sleep mode could get more efficient. However it is still the oscillator running.

I don't think one would need a prescaler at the timer - this does not make much sense, it would mainly give away some resolution with no  savings in current consumption.
 

Online Andreas

  • Super Contributor
  • ***
  • Posts: 2165
  • Country: de
Re: LM399 based 10 V reference
« Reply #806 on: January 17, 2019, 07:54:35 am »
AFAIR the ISR was more like 20 cycles.

perhaps microseconds (at 16-20 MHz).
in C alone the saving/restoring of internal registers used by the Interrupt needs about 50 cycles.

And remember Its not only a fractional divider it is a fractional divider with dithering which takes a lot of the calculations.
(Have not analyzed yet if it could be optimized).

with best regards

Andreas
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 5000
  • Country: de
Re: LM399 based 10 V reference
« Reply #807 on: January 17, 2019, 08:19:54 am »
Of cause it's not a fractional divider, but sigma delta type modulation of the PWM setting. However the code is very similar to a factional divider - about the same code length just updating different registers.

C code can be quite long because of saving the registers. This is where ASM can come handy, as one can get away without it, or at least much less savings. In ASM its about 20 cycles if I remember right. It essentially adding a 16 Bit value, and than moving one bit from the result to the PWM setting. So it's really short code and thus easy to write in ASM.

As the timer is 8 bit, it would only need some 2.5 MHz clock to get a 10 kHz PWM frequency.
The ISR would than handle something like 15 or 16 extra bits, though it might be better not to use all of them, but this would be more like choosing the suitable settings.

The ISR would be something like
ADD   sum_L ,  increment
ADC   sum_H,  increment
"Bit 7 of sum_H to  T"   (currently don't know the command)
"T reg. to bit 0 of PWM value"
out  compare1A,  PWM value


RTI  and go back to sleep mode in main loop

So this would be something like 6 cyles + interrupt start overhead and RTI, which should be around 10 cycles.

Using the UART could cause some minor glitches, but may be OK too.

The difficult part would be converting the incoming UART commands and such things.


Edit:
The end of the code suggestion is wrong. Right would be something like this:
mov temp, PMW_coarse
adc temp,  Reg=0
out  OC1A,temp
« Last Edit: January 17, 2019, 06:31:04 pm by Kleinstein »
 

Offline e61_phil

  • Frequent Contributor
  • **
  • Posts: 689
  • Country: de
Re: LM399 based 10 V reference
« Reply #808 on: January 17, 2019, 06:42:55 pm »
I haven't in mind what is done over the UART, but if it is only setting new PWM values I wouldn't use an ISR for the PWM at all. One can save the time for pushing everything to the stack and popping it back afterwards. Just a loop which checks for a new UART byte and doing the PWM. If there are new PWM settings it shouldn't matter if the PWM glitches during the new setting.
 

Offline Kleinstein

  • Super Contributor
  • ***
  • Posts: 5000
  • Country: de
Re: LM399 based 10 V reference
« Reply #809 on: January 17, 2019, 07:30:04 pm »
To get the high resolution without too much amplitude at the lowest frequencies, it is not just simple PWM, but PWM modulated in a Sigma delta way. So the main PWM frequency is around 10 kHz, but some low amplitude components can extend down to 10 Hz.

The more I look at it, it might not even work so simple, starting with 8 bit PWM - so it may need more advanced software to emulate a higher PWM resolution from the start. Or one would have to start with an even higher PWM frequency.

I would normally prefer a ┬ÁC that has 16 Bit (or at least 10 Bit) PWM in hardware. So it would be starting with 10 or 11 bit resolution PWM and get the finer part by modulation.
 

Offline branadic

  • Super Contributor
  • ***
  • Posts: 1181
  • Country: de
Re: LM399 based 10 V reference
« Reply #810 on: Yesterday at 05:09:46 am »
Quote
Can you check wether you have the same instabilities with the R/C clock as I have here?
Could also be that I got a bad batch of ATTINies on my side.

Can do that next week, the reference is currently measured with 3458A.

-branadic-
« Last Edit: Today at 03:44:59 am by branadic »
Prema 5000 | 2x Prema 5017 SC | GenRad 1434-G | Tek 2465A | VNWA2.x with TCXO upgrade and access to: Keysight 3458A, Keithley 2002, Prema 5017 SC, 34401A, 34410A, Keithley 2182A, HDO6054, Keysight 53230A and other goodies at work
 

Offline branadic

  • Super Contributor
  • ***
  • Posts: 1181
  • Country: de
Re: LM399 based 10 V reference
« Reply #811 on: Yesterday at 08:41:40 am »
Since the source code is accessable via the former link we can also quote it here, so it becomes obvious what is done and the base for a discussion:

Code: [Select]
/*******************************************
Original code: adver ([url]http://radiokot.ru/forum/viewtopic.php?p=3112844#p3112844[/url])
Modified & ported to AVR Studio: Mickle T.
*******************************************
Compiler                : WinAVR
System Clock            : 16-20 MHz
Fuses : Ceramic Resonator, NO prescaler
*******************************************/
#include <avr/io.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include <avr/eeprom.h>
//******************************************
#define BASIS 14            // 14 bits of fractional part (8+14bit total => 2.4uV resolution)
#define DIVISOR (1<<14)
#define Key_Up()   !(PINB & ~(1<<PB1)) // Is "UP" pressed?
#define Key_Down() !(PINB & ~(1<<PB2)) // Is "DOWN" pressed?
//******************************************
unsigned long Value = 2885765UL;         
// Value have a fixed point format [8.14]
// 256/Value = amplification factor of 7-10 V converter
// If LM399 output voltage = U_Zener, then
// Value = (U_Zener/10.000 V)*256*(1<<BASIS) = (U_Zener/10.000 V)*4194304
// Value = (6,877576V  / 10V) *256 * 16384 = 2884664,4527104 = 2884664
//******************************************
// MASH internal variables
unsigned int ValInt;                        // Integer part of Value
unsigned int ValFrac;                       // Fractional part of Value
unsigned int q[3]={1,0,0};                 // Latch outputs 16bit
char c[3][3]={{0,0,0}, {0,0,0}, {0,0,0}};   // Carry flip flops 1bit
unsigned int d[3];                          // Adder output / latch data input 16bit
//******************************************
// Calibration factor (Value), saved in EEPROM
EEMEM unsigned long CFG_CAL_VALUE = 2885765UL;
//******************************************
void Init(void)
{
    DDRB |= (1 << PB0);                 // PWM active
    DDRB &= ~((1<<PB1) | (1<<PB2));     // UP & DOWN key pins config
    PORTB |= (1 << PB1) | (1 << PB2);   // Pullup resistors

    ValInt = Value >> BASIS;
    ValFrac = Value % DIVISOR;
    OCR0A = ValInt-1;          // PWM compare match register initial value
    TCCR0A = (1<<COM0A1) | (1<<COM0A0) | (0<<COM0B1) | (0<<COM0B0) | (1<<WGM01) | (1<<WGM00);       
    // Set OC0A on Compare Match, BOTTOM, Normal mode, OC0B disconnected, Fast PWM Mode (WGM = 3)
    TCCR0B = (0<<WGM02) | (0<<CS02) | (1<<CS01) | (0<<CS00);    // Prescaler CK/8
    TIMSK = (1 << TOIE0);  // Enable overflow interrupt
    sei();
}
//******************************************
ISR (TIM0_OVF_vect)
{
    // Carry flip-flops
    c[1][1] = c[1][0];  c[2][2] = c[2][1]; c[2][1] = c[2][0];
    // Adders
    d[0] = (q[0]+ValFrac) % DIVISOR;
    d[1] = (q[1]+d[0]) % DIVISOR;
    d[2] = (q[2]+d[1]) % DIVISOR;
    // Carries
    c[0][0] = (q[0]+ValFrac) >> BASIS;
    c[1][0] = (q[1]+d[0]) >> BASIS;
    c[2][0] = (q[2]+d[1]) >> BASIS;
    // Latch
    for (int i=0; i<3; i++) q[i] = d[i];
    OCR0A = ValInt - 1
            + c[0][0]
            + c[1][0] -   c[1][1]
            + c[2][0] - 2*c[2][1] +   c[2][2];
}
//******************************************
// PWM configuration update
//******************************************
void Update(void)
{
    cli();
    ValInt = Value >> BASIS;
    ValFrac = Value % DIVISOR;
    OCR0A = ValInt-1;         
    sei();
}
//******************************************
// Loading the calibration factor (Value) from EEPROM
//******************************************
void ConfigLoad (void)
{
// If the both keys was pressed on the startup,
// only the failsafe initial value is loaded !!!
    if (!Key_Up() && !Key_Down()) {
      eeprom_read_block(&Value,&CFG_CAL_VALUE,4);
      _delay_ms(3000); };
}
//******************************************
// Update calibration factor in EEPROM
//******************************************
void ConfigUpdate (void)
{
    eeprom_update_block(&Value,&CFG_CAL_VALUE,4);
    _delay_ms(3000);
}
//******************************************
int main( void )
{
    ConfigLoad(); // If UP & DOWN keys was pressed at startup
// then load default config
    Init();

    while(1) {
      if (Key_Up() && Key_Down()) // If UP & DOWN keys was pressed
    ConfigUpdate(); // then save config to EEPROM
      if (Key_Up() && !Key_Down()) {
        Value ++;
        Update(); };
      if (!Key_Up() && Key_Down()) {
        Value --;
        Update(); };
      _delay_ms(300);
    };
}


-branadic-
« Last Edit: Yesterday at 05:44:35 pm by branadic »
Prema 5000 | 2x Prema 5017 SC | GenRad 1434-G | Tek 2465A | VNWA2.x with TCXO upgrade and access to: Keysight 3458A, Keithley 2002, Prema 5017 SC, 34401A, 34410A, Keithley 2182A, HDO6054, Keysight 53230A and other goodies at work
 

Offline fmaimon

  • Supporter
  • ****
  • Posts: 164
  • Country: br
« Last Edit: Yesterday at 10:09:21 am by fmaimon »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf