Page 1 of 1

Count Down Timer Won't

Posted: Mon Sep 15, 2014 11:33 pm
by ionize
This is my first V6 Flow Chart and I can't get my count down timer tab to work in minutes in this flow chart, no matter how I configure it. If someone could show me what I'm doing wrong, it would be wonderful.
Thanks,
Scott

Re: Count Down Timer Won't

Posted: Tue Sep 16, 2014 12:10 am
by kersing
Ok, it would help if you could tell us what happens and what you expect it should do.

First strange thing I notice is in Main macro you call "eeprom1::Read(count)" why do you read the value and ignore it? Did you mean store the value from eeprom in a variable?

Second, in Countdown you increase the value of Count_3 if less then 59 (first decision icon "Yes" branch) and in the next calculation you assign it the value 0. Shouldn't that calculation be within the "No" branch of the first decision icon?

Re: Count Down Timer Won't

Posted: Tue Sep 16, 2014 7:23 am
by medelec35
Additionally to kersing's post You have got

Code: Select all

If Minutes < 65535 
decision icon which will always be true because minutes variable is assigned as a byte.
Therefore will only reach 255 then on next increment = 0.

So this will never be true:

Code: Select all

Minutes > 1439
Martin

Re: Count Down Timer Won't

Posted: Thu Sep 18, 2014 10:16 pm
by ionize
Thanks for your inputs. I was able to get the Countdown tab to work after moving that calculation :oops: . The reset section on Main, however, causes the program to hang. I thought I fixed it :lol: If there is a better way to restart- great. When the program is simulated, it acts differently than in hardware, so to see changes I have to program the chip and install it every time, which is time consuming. This is what I want it to do:
1. Power up using stored settings for the 2 PWMs and Countdown timer. it does this.
2. Default to Milliamp Display 4 & 4.1. it does this.
3. Return to Milliamp after 30 seconds on the other Displays. it does this.
4. UP/DN switches set values and stores them in eeprom. it does this.
5. Alternate a port pin continuously (C3). it does this.

6. Read and display two different mA values continuously X
7. Start over if over 24 hours X

Both ADCs appear to be controlled from ADC 2 and are giving negative numbers in the attached file. I am using two 0.47 ohm resistors for voltage drops (one for each channel)
The OLED is strobing too much in hardware for comfortable viewing.

Whatever your thoughts on this ,
Thanks,
Scott

Re: Count Down Timer Won't

Posted: Fri Sep 19, 2014 3:43 pm
by medelec35
Hi Scott,
For forcing reset I use a c code block with :

Code: Select all

asm
{	
goto 0
}
Alternatively you could enable Watchdog timer (enable Auto Clear watchdog from Build, Project options, General options tab).
Make sure program does not reset.
Then when you want program to reset, just use a decision branch to point to a endless loop with nothing inside.
Watchdog timer should then reset your hardware.


As for ADC, do you realise that if using GetVoltage the results will only be 0 to 5 if using variable assigned as integers.
For example pot set about half way then variable will only = 2!
If using GetInt then variable = 511
If using GetByte then variable = 127

GetVoltage is really for when variable used is assigned as a float.
Then range will be 0.000000 to approximately 4.995308.

I personally would avoid the float route with most of the 8 bit pics.

Also I would not use ADC_base.
So you can get an idea from running the simulator I would just use any of the other pots.
I.e any of the components with the word potentiometer in it.
E.g Potentiometer (Colour) or even the one you have chosen - Potentiometer (panel)

Martin

Re: Count Down Timer Won't

Posted: Mon Sep 22, 2014 5:15 pm
by ionize
Again, many thanks to the Professor!
Although every restart scheme I've tried works, the program hangs but I think its because the OLED problem described here: http://www.matrixtsl.com/mmforums/viewt ... 54&t=15016
If there is new code for the OLED component initialization that address this 'problem'?, that would be great otherwise, I'll report back after I work around it.

Scott

Re: Count Down Timer Won't

Posted: Sun Oct 05, 2014 7:36 pm
by ionize
I overcame the reset problem by adding a 1 sec delay connected to a PNP 2N3906 controlling the positive power input to the OLED (Thanks BENJ) and using ASM ("RESET"); instead of
asm
{
goto 0
}
, which appears not to reset the registers to startup values.
Thanks to all.
Scott