SLEEP

For general Flowcode discussion that does not belong in the other sections.
Post Reply
ELECTRONICA67
Posts: 153
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 3:59 pm
Has thanked: 29 times
Been thanked: 9 times

Flowcode v10 SLEEP

Post by ELECTRONICA67 »

Hello everyone on the forum, I hope you enjoy a Merry Christmas and a Happy New Year 2026 :!:

Continuing with the topic of the SLEEP, WDT, and CLRWDT commands, I'm using a PIC16F1939. It accesses the SLEEP command correctly, although sometimes it doesn't. Previously, I used a PIC16F1847, and SLEEP worked correctly there.

The problem is that the current draw suddenly changes from 0.020 mA to 25 mA after 2 or 3 SLEEP cycles. It starts at 0.020 mA and increases to 25 mA continuously.

This happens repeatedly, I've disconnected transistor outputs, grounded all unused pins, turned off the LCD, and used commands to disable PIC pins, but I can't get the current draw to remain constant while in SLEEP mode.

Initially, I even managed to get the selected outputs to activate correctly when the PIC woke up, and it would return to power-saving mode, but now, with all the changes and tests, it seems like I'm going backward instead of forward.

Could someone help me by taking a look at the flowchart?

I would appreciate any help. :)

Thanks
Enrique
Attachments
ReadRTC.fcfx
(17.49 KiB) Downloaded 17 times
Foto2.jpeg
Foto2.jpeg (137.14 KiB) Viewed 498 times
Foto1.jpeg
Foto1.jpeg (135.92 KiB) Viewed 498 times

BenR
Matrix Staff
Posts: 2063
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 549 times
Been thanked: 733 times

Re: SLEEP

Post by BenR »

Hello,

The errata document for that device does have something regarding Sleep which may or may not help, see page 8 of the doc below.

https://ww1.microchip.com/downloads/aem ... 000501.pdf

chipfryer27
Valued Contributor
Posts: 1806
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 404 times
Been thanked: 621 times

Re: SLEEP

Post by chipfryer27 »

Hi

I have used the 1939 quite a bit, indeed it is a default chip in a couple of my multi-programmers.

I don't recall having much issue with sleep. If I get a chance over the next few days or so I'll load one up and see how it behave during sleep.

Regards

ELECTRONICA67
Posts: 153
Joined: Wed Dec 02, 2020 3:59 pm
Has thanked: 29 times
Been thanked: 9 times

Re: SLEEP

Post by ELECTRONICA67 »

Thanks, I appreciate the help.

Best Regards

chipfryer27
Valued Contributor
Posts: 1806
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 404 times
Been thanked: 621 times

Re: SLEEP

Post by chipfryer27 »

Hi

Realistically it will now be after Christmas before I get a chance to play with hardware. Meantime, following on from Ben's post, it looks like you have BOR disabled so the errata may not apply.

That does however bring up a test you could do to see if you are resetting or Waking Up.

When I'm messing with WDT / sleep etc, until I get everything the way I want I usually have some code at the beginning of Main, before I enter my Main Loop that actually does something. That code could be to flash an LED for three seconds or such like and the point is that it will only flash if the program runs from the beginning. Once I enter my main loop the LED should never flash.

If WDT or something causes a reset rather than wake up then I know something is not correct as the LED will flash.

Regards

ELECTRONICA67
Posts: 153
Joined: Wed Dec 02, 2020 3:59 pm
Has thanked: 29 times
Been thanked: 9 times

Flowcode v10 Re: SLEEP

Post by ELECTRONICA67 »

Hi

Okay, I'll do that test. This way I'll know if it's restarting or continuing where the sequence left off in the programming.

Thanks

ELECTRONICA67
Posts: 153
Joined: Wed Dec 02, 2020 3:59 pm
Has thanked: 29 times
Been thanked: 9 times

Flowcode v10 Re: SLEEP

Post by ELECTRONICA67 »

Hello,

I tested it using the relay as an indicator at the beginning of the program, and it doesn't restart from the start. It continues after SLEEP, and suddenly, randomly, the current draw rises to 25 mA and remains there until the PIC wakes up 256 seconds later, then drops to 0.020 mA. It consumes 0.020 mA most of the time.

Happy New Year :!:
Best Regards

chipfryer27
Valued Contributor
Posts: 1806
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 404 times
Been thanked: 621 times

Re: SLEEP

Post by chipfryer27 »

Hi

You say this increase happens every two or three sleep "cycles". Is there anything connected at all that would draw the extra current? What happens with everything disconnected?

Regards

ELECTRONICA67
Posts: 153
Joined: Wed Dec 02, 2020 3:59 pm
Has thanked: 29 times
Been thanked: 9 times

Flowcode v10 Re: SLEEP

Post by ELECTRONICA67 »

It starts with a 16x2 LCD display and a 4x4 keypad to program, which I physically disconnect and add this parameter (LCDCONbits.LCDEN = 0;). When the main program routine starts, I convert pin of KEYPAD to GND outputs; and keep a DS1307 RTC in the main program routine, I power it with a BC548 transistor, read the hour, minute, and day clock, and disconnect I2C_MASTER1:STOP. I change the I2C port as inputs (set_bit(trisc, 3); set_bit(trisc, 4); I change the KEYPAD pins to GND outputs (0) and all unused PIC pins to GND outputs (0). With these parameters, I keeps current draw low from 0.020 mA in hours, but it suddenly changes to 24 mA during a 256-second SLEEP period and then drops back down to 0.020 mA for an undefined time.

Each time the PIC wakes up, it takes a reading from the RTC, increasing the current draw for a few milliseconds before immediately dropping back to 0.020 mA.

I think the sudden power consumption is caused by the RTC. As an observation, I'm using the DS1307 RTC reader program that Martin published in Flowcode 5 and adapted to Flowcode 10. Another detail is that I've connected the RTC to a PIC16F1847, and the SLEEP function works correctly. Another difference is that in that program, I don't connect the 16x2 display or the 4x4 keypad.

Regards

Post Reply