PIC18F13K50, CDC USB communication and ultra-low power temperature logger


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    Dec 2007
    Location
    Paris
    Posts
    101

    Default

    Tried this step by step.

    Commenting either or all of these:

    Code:
    OSCCON.1 = 0
    OSCCON.0 = 1 'Use Timer1 oscillator as clock source
    OSCCON.7 = 1 'Device enters in IDLE mode when sleep instruction issued
    stop operation. However I'm not sure if it's because the interrupt is not triggered anymore or if that's because the CPU does not come back from sleep. I remember reading that Timer1 oscillator was always running, but looking carefully at the datasheet again I cannot find that statement back. Only mention is that SLEEP (not IDLE) mode turn off all clocks and all oscillators, expect for the WDT oscillator (if enabled).

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959

    Default



    And you had more statements than those 3.
    One of them disables the Primary Oscillator, which will keep it from running after it wakes up I would assume.
    Attached Images Attached Images  
    DT

  3. #3
    Join Date
    Dec 2007
    Location
    Paris
    Posts
    101

    Default

    Yes but I commented all others as well. I just quoted the lines that caused the interrupt to stop working.

    I want to disable the primary oscillator, because I have 2 operating modes:

    1) USB attached, clocked from a 12Mhz ceramic resonator, with PLL enabled and CPU clocked at 48Mhz

    2) USB detached, standalone, CPU and peripherial clocked from Timer1 secondary oscillator.

    When the CPU wakes from sleep it should resume on the oscillator defined by the SCS bits, here SEC_RUN mode:

    Code:
    OSCCON.1 = 0
    OSCCON.0 = 1 'Use Timer1 oscillator as clock source

    Now you found that statement back from the datasheet, there's hope to make it work! I'll investigate harder and make some tests on a simplified program.

  4. #4
    Join Date
    Dec 2007
    Location
    Paris
    Posts
    101

    Default

    I realized that I have a very strange problem when I write to my I2C EEPROM when the CPU is clocked at 32.768kHz, I get corrupted data if there's a long chain of "0" being sent.

    I record my temperature samples two by two, and they span 3 bytes in memory (Byte A, B and C). One sample is 12bit, 8 bit for integer value (Sign + 7 bit value), and 4 bits for decimal value (0.0625 steps). They are recoded with an interleave routine as such:

    Sample 1 : AAAAAAAA.BBBB
    Sample 2 : BBBBCCCC.CCCC

    1811 2010/10/29 0h44m00s +23.9375
    1812 2010/10/29 0h44m10s +23.9375

    1813 2010/10/29 0h44m20s +24.0000
    1814 2010/10/29 0h44m30s -7.9375

    1815 2010/10/29 0h44m40s +24.0000
    1816 2010/10/29 0h44m50s -7.9375

    1817 2010/10/29 0h45m00s +24.0000
    1818 2010/10/29 0h45m10s -8.0000

    1819 2010/10/29 0h45m20s +23.9375
    1820 2010/10/29 0h45m30s +23.9375
    I have a 5ms pause between the 3 write operations, and there's about 20 sec between the record of each packets of 3 bytes. I tried increasing the write delay to 20ms without changes, and EEPROM VCC is within range.

    This occurs when odd samples ends with .0000, .2500, .5000, and .7500, the problem does not appears if I run the CPU using the internal oscillator at 250kHz (and readjusting all the delay values accordingly), which makes me wonder if I2CWRITE can be used with a CPU clock of 32.768kHz...

    Also, this might be related to the issue I have... is doing such operation:
    Code:
    DataValue = TempH >> 4
    modify the original value of TempH?

  5. #5
    Join Date
    Dec 2007
    Location
    Paris
    Posts
    101

    Default

    The logger project is getting near completion! I am now into the autonomous mode power, and I was able to measure these figures while powering the device from a battery across a 10 ohm shunt.



    It is quite clear that I have to improve power consumption as at 900µA the 130mAh battery runs for about 6 days... The PIC sits most of the time at IDLE, and here it shows where a second sample is read and written to memory with the first previously read sample (hence the 3 write cycles for 2x 12bits).

    I have not managed yet to make the true sleep mode to work, but at IDLE the power consumption seems to be very high... there's no difference than when running the CPU from internal clock at 250kHz. As I said above I tried running the CPU from Timer1 oscillator but that gave me some memory writing issue so I quitted.

    Other than the PIC eating power I have (when IDLE):
    LDO regulator, 500nA
    I2C EEPROM, 1µA
    I2C Temperature sensor, 1µA
    220k/220k voltage divider, 5µA

    Will try to investigate more and post results

  6. #6
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    4,116

    Default

    Maybe you can control EEPROM and Temp. Sensor power by a pin from your controller. When you have to make new measurements, just make the pin high, wait a little to let the circuit settle, and do your sampling and writing. Then switch them off again.

    Ioannis

  7. #7
    Join Date
    Dec 2007
    Location
    Paris
    Posts
    101

    Default

    Design is completed and can't be changed, beside there's no available I/O pin left.

    IDLE power consumption is actually from the PIC and not from the peripherals.

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts