Timer function enquiry. (flowcode does not do what i want)

Any general or miscellaneous queries that do not fit into the other forum catagories

Moderators: Benj, Mods

Post Reply
soccermad
Posts: 19
Joined: Wed Feb 09, 2011 12:56 am
Has thanked: 2 times

Timer function enquiry. (flowcode does not do what i want)

Post by soccermad »

i have managed to create the flowcode so i have a timer function but it does not work the way i want it to. i have managed to set it so that when the switch is pressed the motor is turned on for a certain value of time and then stops. but this is where the problem occurs has this now disables the whole timer program so i can not use that switch again unless i reset the board and i also wanted to add a function or program it in a way that for every time the swtich is pressed the time interval will increase.

PLEASE HELP I AM IN MAJOR NEED OF HELP

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: Timer function enquiry. (flowcode does not do what i wan

Post by medelec35 »

If you post the flowchart you have created, and suggest the minimum starting duration and duration increase every time switch is pressed, and max duration, then I can have a look at editing flowchart for you.
If posting about improving a flowchart, it is always better to supply as much information as possible.

Martin
Martin

soccermad
Posts: 19
Joined: Wed Feb 09, 2011 12:56 am
Has thanked: 2 times

Re: Timer function enquiry. (flowcode does not do what i wan

Post by soccermad »

medelec35 wrote:If you post the flowchart you have created, and suggest the minimum starting duration and duration increase every time switch is pressed, and max duration, then I can have a look at editing flowchart for you.
If posting about improving a flowchart, it is always better to supply as much information as possible.

Martin
The minimum starting i need is 15mins and for it to go up in 15mins intervals with a max duration time of 2 hours approximately. (so thats about a total of 8 times the switch is pressed).

Thank you very much for your time.
Attachments
REMOTE working progress.fcf_avr
(10.5 KiB) Downloaded 797 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: Timer function enquiry. (flowcode does not do what i wan

Post by medelec35 »

Hi soccermad,
Unfortunately I have only got a demo version of AVR V4, which does not load your file for some reason.
I only have full versions of Flowcode for PIC and flowcode for dsPIC.
The only way I can do this is import to PIC version modify flowchart, then save as PIC version so you can import with your AVR version.
I will save as a Flowcode V3 flowchart.
Martin

soccermad
Posts: 19
Joined: Wed Feb 09, 2011 12:56 am
Has thanked: 2 times

Re: Timer function enquiry. (flowcode does not do what i wan

Post by soccermad »

medelec35 wrote:Hi soccermad,
Unfortunately I have only got a demo version of AVR V4, which does not load your file for some reason.
I only have full versions of Flowcode for PIC and flowcode for dsPIC.
The only way I can do this is import to PIC version modify flowchart, then save as PIC version so you can import with your AVR version.
I will save as a Flowcode V3 flowchart.
That would be perfect thank you. i currently have and using Flowcode AVR V3.

soccermad
Posts: 19
Joined: Wed Feb 09, 2011 12:56 am
Has thanked: 2 times

Re: Timer function enquiry. (flowcode does not do what i wan

Post by soccermad »

Can anyone please help so that when when i press swtich D4 it does not count down but displays the timer length and starts the motor (speed 1). Then when i press swtich D5 it adds another 15mins interval and then it starts the timer and the motor (speed 2) but can you incopparte or edit to make D6 to decease the intervals for either tiimer functionsfor the set speeds and D1 which is the ON/OFF button to be the reset button so when pressed the program resets itself.

PLEASE PLEASE PLEASE
Attachments
REMOTE working progress_Modified.fcf_avr
(17 KiB) Downloaded 645 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: Timer function enquiry. (flowcode does not do what i wan

Post by medelec35 »

Here is a nearly completely revamped Flowchart which should do the following:
soccermad wrote:D0 = Temperature thermostat function (I'm going to include this later)

D1 = Resets the whole flowcode (technically has a turn off function where the flowcode is to begin from the start)
LCD to show OFF

D2 = Speed 1 (sends signal to the relay board so the fan motor speed 1 turns on)
LCD to show SPEED 1

D3 = Speed 2 (sends signal to the relay board so the fan motor speed 2 turns on)
LCD to show SPEED 2

D4 = Start timer 1 Instantaneously from timer 2 including the intervals (that would be for speed1, so for every press on the D4 the timer interval increases)
LCD to show TIMER 1's COUNT DOWN

D5 = Start timer 2 Instantaneously from timer 1 including the intervals (that would be for speed 2, so for every press on the D5 the timer interval increases)
LCD to show TIMER 2's COUNT DOWN

D6 = Decrease the interval of the timer 1
LCD to show TIMER 1's COUNT DOWN

D7 = Decrease the interval of the timer 2
LCD to show TIMER 2's COUNT DOWN
The only thing you did not say is if timer1 or timer2 is running, then if you pressed D2 or D3 what you want timer1 or timer2 to do when D4 - D7 is pressed after.

Give this a try and let me know how you get on.

Martin
Attachments
REMOTE working progress_Modified2.fcf
(27.93 KiB) Downloaded 710 times
Martin

soccermad
Posts: 19
Joined: Wed Feb 09, 2011 12:56 am
Has thanked: 2 times

Re: Timer function enquiry. (flowcode does not do what i wan

Post by soccermad »

medelec35 thank you and i appricate your help very much.

soccermad
Posts: 19
Joined: Wed Feb 09, 2011 12:56 am
Has thanked: 2 times

Re: Timer function enquiry. (flowcode does not do what i wan

Post by soccermad »

When Speed 1 D2 is pressed the relay does not come on at all but the light on the relay board shows.
When Timer 1 D4 is pressed the relay motor comes on for 2secs and then turns off but the light on the relay board stays on till the end of the counter.
When Timer 1 decreased D6 the LCD display says “OFFe Left Timer2” instead of “OFFe Left Timer1”

can anyone help?
Attachments
REMOTE working progress_Modified3.fcf_avr
(18.21 KiB) Downloaded 602 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: Timer function enquiry. (flowcode does not do what i wan

Post by medelec35 »

soccermad wrote:When Speed 1 D2 is pressed the relay does not come on at all but the light on the relay board shows.
When Timer 1 D4 is pressed the relay motor comes on for 2secs and then turns off but the light on the relay board stays on till the end of the counter.
This sounds like a hardware issue If relay LED is on then relay should also be on at the same time.
Have you got the +v of relay board connected to +14V?
It sounds to me that the Vin to realy coils are too low.
soccermad wrote: When Timer 1 decreased D6 the LCD display says “OFFe Left Timer2” instead of “OFFe Left Timer1”
I have sorted that out for you. Now when a timer reaches 0:00 eg timer 2, if the other timer has still got time left on it, then it continues to count down, switching relays over.

All I need to know is about functions of B0 and B4.

Also What is also causing a problem is port B has been changed form masking (how I left it) to non masking. So I have altered flowchart for individual bits instead of port masking.
Just in case the change is occurring automatically on import.


Martin
Martin

soccermad
Posts: 19
Joined: Wed Feb 09, 2011 12:56 am
Has thanked: 2 times

Re: Timer function enquiry. (flowcode does not do what i wan

Post by soccermad »

medelec35 wrote:
soccermad wrote:When Speed 1 D2 is pressed the relay does not come on at all but the light on the relay board shows.
When Timer 1 D4 is pressed the relay motor comes on for 2secs and then turns off but the light on the relay board stays on till the end of the counter.
This sounds like a hardware issue If relay LED is on then relay should also be on at the same time.
Have you got the +v of relay board connected to +14V?
It sounds to me that the Vin to realy coils are too low.
soccermad wrote: When Timer 1 decreased D6 the LCD display says “OFFe Left Timer2” instead of “OFFe Left Timer1”
I have sorted that out for you. Now when a timer reaches 0:00 eg timer 2, if the other timer has still got time left on it, then it continues to count down, switching relays over.

All I need to know is about functions of B0 and B4.

Also What is also causing a problem is port B has been changed form masking (how I left it) to non masking. So I have altered flowchart for individual bits instead of port masking.
Just in case the change is occurring automatically on import.


Martin
you forgot to attach the updated file that you altered.

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: Timer function enquiry. (flowcode does not do what i wan

Post by medelec35 »

medelec35 wrote:
All I need to know is about functions of B0 and B4.
I wanted to find out what the function of B0 and B4 is then I can post the Flowchart. Otherwise it means posting flowchart twice if functions are wrong.
So as soon as you say what they do I will post the updated flowchart.
Martin

soccermad
Posts: 19
Joined: Wed Feb 09, 2011 12:56 am
Has thanked: 2 times

Re: Timer function enquiry. (flowcode does not do what i wan

Post by soccermad »

medelec35 wrote:
medelec35 wrote:
All I need to know is about functions of B0 and B4.
I wanted to find out what the function of B0 and B4 is then I can post the Flowchart. Otherwise it means posting flowchart twice if functions are wrong.
So as soon as you say what they do I will post the updated flowchart.
B0 and B4 are attached to the LED board which has no relevance to my project anymore, i was planning to delete the LED board.

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: Timer function enquiry. (flowcode does not do what i wan

Post by medelec35 »

Try this, see if it does what you want it to now.

Martin
Attachments
REMOTE working progress_Modified4.fcf
(28.5 KiB) Downloaded 588 times
Martin

soccermad
Posts: 19
Joined: Wed Feb 09, 2011 12:56 am
Has thanked: 2 times

Re: Timer function enquiry. (flowcode does not do what i wan

Post by soccermad »

Martin you have been very very helpfull. thank you again so much. :D

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: Timer function enquiry. (flowcode does not do what i wan

Post by medelec35 »

Your welcome soccermad.

Here is the latest working version with speed1 enabled when temperature reaches a threshold temperature. It can be set up so Speed2 is enabled if temperature is say 10 deg above threshold.
Used Ben's excel sheet (see http://www.matrixmultimedia.com/mmforum ... 020#p22122 for data)

Button D0:
If you short press D0, activates Temperature sensor mode (sensor is HSTMP sensor available From matrix). When Temperature reaches 1C above threshold temperature, Speed 1 relay is activated.
When Temperature drops 1C below the threshold (2C hysteresis) Speed 1 relay is deactivated.
If you long press D0 for a min of 2 secs, then test mode will be activated. In test mode buttons D4 - D7 are disabled by design!
Test mode is designed for showing reading of ADC channel connected to sensor and value of LUT in the form of temperature in deg C.
To deactivate test mode then press reset switch D1.

Note about development. Just in case anyone else with Flowcode V3 AVR has similar issues.

This was fairly tricky since is was developed for soccermad who has got Flowcode V3 AVR professional.
I only had Flowcode V3 AVR demo, and V3 PIC professional.
So Flowchart was developed using V3 PIC professional.

There are a few bugs in V3 AVR and some differences (or a bug?) in the way LUT is used in supplementary code.
Bugs: If you look at the flowchart you can see several C code boxes with calculations in. E.g

Code: Select all

FCV_SET_MINUTES_TIMER2 =  FCV_SET_MINUTES_TIMER2 - 15 ;
and

Code: Select all

FCV_SET_MINUTES_TIMER2 =  0 ;
I had to replace the calculation boxes with C code because of this type of error:

Code: Select all

C:\Users\SANTAN~1\DOCUME~1\FLOWCODE\REMOTE working progress_Modified2.c:168: error: expected expression before ';' token
Looking at the C code, this is what's causing the issue:

Code: Select all

//Calculation
				//Calculation:
				//  Set_Minutes_Timer2 = Set_Minutes_Timer2 - 15
				//  0 = 
				FCV_SET_MINUTES_TIMER2 =  FCV_SET_MINUTES_TIMER2 - 15 ;
				0 = ;
0 = ; is causing failure, so I just copied the FCV_SET_MINUTES_TIMER2 = FCV_SET_MINUTES_TIMER2 - 15 ; line above and plced in a C code box, and deleted the calculation box.

Re LUT data: Normally we use format in Ben's excel sheet e.g
rom char* degrees =
{
255,243,203,183,169,159,151,144,139,134,129,126,122,119,........etc.}

This does not work with V3 AVR.
If used the following errors will occur:

Code: Select all

L:\>"C:\PROGRA~2\MATRIX~1\FL5939~1\Tools\MX_bats\..\bin\avr-gcc.exe" -mmcu=atmega32 -Os -funsigned-char -o "L:\REMOTE working progress_Modified5_Test.elf" "L:\REMOTE working progress_Modified5_Test.c" 
L:\REMOTE working progress_Modified5_Test.c:113: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'char'
L:\REMOTE working progress_Modified5_Test.c: In function 'FCM_Get_Temperature':
L:\REMOTE working progress_Modified5_Test.c:350: error: 'degrees' undeclared (first use in this function)
L:\REMOTE working progress_Modified5_Test.c:350: error: (Each undeclared identifier is reported only once
L:\REMOTE working progress_Modified5_Test.c:350: error: for each function it appears in.)

Error returned from [avr-gcc.exe]

Return code = 1
:idea: What I found works is: Change from

Code: Select all

rom char* degrees =
to

Code: Select all

char degrees[]=
I have left it as the latter. Since it also works in Flowcode V3 PIC and Flowcode V4 PIC.

Note about not reading correct temperature:
1st, I have not got the sensor to test with, so I can't confirm working 100%.
I have connected a pot up, and temperature reading goes up and the o/p pot voltage reduces. So am assuming all will work with sensor connected. :)
Long press key D0 as stated above.
Assuming your room temperature is 21deg. Measure the voltage at the ADC i/p (directly on the chip pin) you are using for temperature measurement.
The voltage at the pin should be about 3.08V

How I work this out is:
If you look at excel sheet (see http://www.matrixmultimedia.com/mmforum ... 5ae#p22122), go down Column G which is temperature in deg C.
the ADC bytes value for that is in Column D = 157.

Using maths to determine voltage:
V = 5/255 * 157 = 3.078

You could use two resistors in series of the same value to form a potential divider connected across 5V.
The voltage at the centre should be 2.5V = temperature reading of approx 32 deg C.

Connect this 1/2 VCC to ADC i/p (nothing else connected)
With 2.5V on i/p ADC, see what the reading is.

Lastly if importing to AVR or other versions of Flowcode, then don't forget to change timer0 interrupt to the lowest interrupt frequency e.g 75Hz.
Then make sure the Two decision icons within timer interrupt macro is set for interrupt frequency value. E.g

Code: Select all

Count_Timer1 >= 75
and

Code: Select all

Count_Timer2 >= 75
This flowchart will compile ok on Flowcode demo's since I have reduced number of lines in supplementary code box to four.
However you will not be able to add any more boxes since limit will be exceed. If you wan to add more functions, try to edit existing boxes to add more calculations etc..
You will not be able to simulate within Flowcode until all C Boxes are replaced with calculation boxes.

Martin
Attachments
REMOTE working progress_Modified3.fcf
(39.17 KiB) Downloaded 618 times
Martin

Post Reply