Count Down Timer Won't

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 6.

Moderator: Benj

Post Reply
User avatar
ionize
Posts: 25
Joined: Fri Aug 05, 2011 8:01 pm
Has thanked: 29 times
Been thanked: 11 times

Count Down Timer Won't

Post 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
Attachments
Spa_B.fcfx
(50.97 KiB) Downloaded 262 times

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times

Re: Count Down Timer Won't

Post 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?
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Count Down Timer Won't

Post 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
Martin

User avatar
ionize
Posts: 25
Joined: Fri Aug 05, 2011 8:01 pm
Has thanked: 29 times
Been thanked: 11 times

Re: Count Down Timer Won't

Post 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
Attachments
Spa_B.fcfx
(49.92 KiB) Downloaded 274 times

medelec35
Matrix Staff
Posts: 9521
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times

Re: Count Down Timer Won't

Post 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
Martin

User avatar
ionize
Posts: 25
Joined: Fri Aug 05, 2011 8:01 pm
Has thanked: 29 times
Been thanked: 11 times

Re: Count Down Timer Won't

Post 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

User avatar
ionize
Posts: 25
Joined: Fri Aug 05, 2011 8:01 pm
Has thanked: 29 times
Been thanked: 11 times

Re: Count Down Timer Won't

Post 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

Post Reply