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

What I found works is: Change from
to
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
and
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