Little Help with Lookup Table
- Jordy101091
- Posts: 519
- Joined: Sat Jan 08, 2011 4:02 pm
- Location: The Netherlands
- Has thanked: 25 times
- Been thanked: 188 times
- Contact:
Little Help with Lookup Table
Hi guys,
I want to read a temperature sensor with my PIC16F877a, I have bought one, the KTY21-6 from infineon. Because of it's 1% accuracy.
Because this sensor is not lineair I need to make a lookup table so I don't need to make a lot of calculations.
The creation of my lookup table is completed. Do you want to check it for me because I'm not sure it's correct.
And how do I import the data into my flowcode program. Can I do this in the student version of Flowcode?
Regards,
Jordy Kleian
PS, Thanks Tristan for you reply my buttons (HAND,AUTO) is working
I want to read a temperature sensor with my PIC16F877a, I have bought one, the KTY21-6 from infineon. Because of it's 1% accuracy.
Because this sensor is not lineair I need to make a lookup table so I don't need to make a lot of calculations.
The creation of my lookup table is completed. Do you want to check it for me because I'm not sure it's correct.
And how do I import the data into my flowcode program. Can I do this in the student version of Flowcode?
Regards,
Jordy Kleian
PS, Thanks Tristan for you reply my buttons (HAND,AUTO) is working
- Attachments
-
- lookup-table KTY21-6 no password.xls
- (49.5 KiB) Downloaded 619 times
the will to learn, should not be stopped by any price
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Little Help with Lookup Table
Hi Jordy.
This should help you with your LUT:
http://www.matrixmultimedia.com/mmforum ... =26&t=3543
Should work fine with student version.
If you get stuck, and don't mind your flowchart being public,
then post on here what you have done so far,and some one will look at it for you.
This should help you with your LUT:
http://www.matrixmultimedia.com/mmforum ... =26&t=3543
Should work fine with student version.
If you get stuck, and don't mind your flowchart being public,
then post on here what you have done so far,and some one will look at it for you.
Martin
- Jordy101091
- Posts: 519
- Joined: Sat Jan 08, 2011 4:02 pm
- Location: The Netherlands
- Has thanked: 25 times
- Been thanked: 188 times
- Contact:
Re: Little Help with Lookup Table
Hi all,
I have inserted the data from my lookup table.
But I dont now how to use it, can you tell me how I going to do that. So the next time I can do it on my own.
I have attached my flowcode program (its a bit messy) for measureing the temperature you need to be in the Temperatuur Macro.
Hope you can help me,
Regards Jordy
I have inserted the data from my lookup table.
But I dont now how to use it, can you tell me how I going to do that. So the next time I can do it on my own.
I have attached my flowcode program (its a bit messy) for measureing the temperature you need to be in the Temperatuur Macro.
Hope you can help me,
Regards Jordy
- Attachments
-
- Aqua Controller.fcf
- (25.36 KiB) Downloaded 495 times
the will to learn, should not be stopped by any price
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Little Help with Lookup Table
Your excel sheet is slightly wrong.
The first brace has to be the other way round and the last comma is not required within the data.
I have adjusted your flow chart to work correctly with LUT, but since LUT is done within C code, Flowcode will not be able to simulate correctly, so you will get 0 displayed using the simulator, no matter what postion pot is set at.
To see it all working you will either need to load hex file into a simulator that works with C. There one on tha market that works in real time and simulates C, LCD, PWM interrupts etc.See:
http://digitalelectrosoft.com
Or
best method is to load on to real hardware like Eblocks.
The alterations on your flowchart are done within 'Supplementary code' window (e.g The data must be entered in the top 'Definitions and function declarations:' box)
And
Temperatuur macro.
Within Temperatuur macro I have also added a bit of formatting to LCD so the Temperature reading is always next to the 'C' on the display.
Not sure if that's what you wanted to do, but added it just in case.
Hope this helps.
The first brace has to be the other way round and the last comma is not required within the data.
I have adjusted your flow chart to work correctly with LUT, but since LUT is done within C code, Flowcode will not be able to simulate correctly, so you will get 0 displayed using the simulator, no matter what postion pot is set at.
To see it all working you will either need to load hex file into a simulator that works with C. There one on tha market that works in real time and simulates C, LCD, PWM interrupts etc.See:
http://digitalelectrosoft.com
Or
best method is to load on to real hardware like Eblocks.
The alterations on your flowchart are done within 'Supplementary code' window (e.g The data must be entered in the top 'Definitions and function declarations:' box)
And
Temperatuur macro.
Within Temperatuur macro I have also added a bit of formatting to LCD so the Temperature reading is always next to the 'C' on the display.
Not sure if that's what you wanted to do, but added it just in case.
Hope this helps.
- Attachments
-
- Aqua Controller_Modified.fcf
- (27.43 KiB) Downloaded 560 times
Martin
- Jordy101091
- Posts: 519
- Joined: Sat Jan 08, 2011 4:02 pm
- Location: The Netherlands
- Has thanked: 25 times
- Been thanked: 188 times
- Contact:
Re: Little Help with Lookup Table
He,
I was just loading your modified code into my eblocks setup, but flowcode gives me an error.
It says "Aquaontroller_Modified(1): error: failure Return code = 1"
What do I need to change to make it work.
Regards Jordy
I was just loading your modified code into my eblocks setup, but flowcode gives me an error.
It says "Aquaontroller_Modified(1): error: failure Return code = 1"
What do I need to change to make it work.
Regards Jordy
the will to learn, should not be stopped by any price
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Little Help with Lookup Table
You should not need to change anything within flowchart.
I have tried it and gives me a status 0 and compiles to hex OK and I have compiled to 18F4455 after altering target device, and LUT is confirmed as working correctly on my hardware.
There are four things that I know of that causes a status 1 when compiling to hex or hardware.
1) With windows7 if you have flowchart saved in Libraries e.g. Libraries/Documents
Then you may get status 1, even if flowchart is 100% OK.
The solution is move flowchart to a different folder e.g C:\flowcharts etc.
2) If there is an error within supplementary code window , all errors are suppressed.
3) All errors are suppressed with some versions of windows7 if flowchart is within any folder.
The solution is move (or copy) flowchart to an external USB memory stick but not on the root drive different folder e.g E:\flowcharts etc. (assuming E is the usb sticks drive letter)
4) If compiling flowchart on the C:\ or USB memory sticks root. The root can only store a certain amount of files. when this max amout is exceeded then since no more files can be created then you get the status = 1.
Even if the same as 1) i.e nothing wrong with flowchart and should compile OK.
I have tried it and gives me a status 0 and compiles to hex OK and I have compiled to 18F4455 after altering target device, and LUT is confirmed as working correctly on my hardware.
There are four things that I know of that causes a status 1 when compiling to hex or hardware.
1) With windows7 if you have flowchart saved in Libraries e.g. Libraries/Documents
Then you may get status 1, even if flowchart is 100% OK.
The solution is move flowchart to a different folder e.g C:\flowcharts etc.
2) If there is an error within supplementary code window , all errors are suppressed.
3) All errors are suppressed with some versions of windows7 if flowchart is within any folder.
The solution is move (or copy) flowchart to an external USB memory stick but not on the root drive different folder e.g E:\flowcharts etc. (assuming E is the usb sticks drive letter)
4) If compiling flowchart on the C:\ or USB memory sticks root. The root can only store a certain amount of files. when this max amout is exceeded then since no more files can be created then you get the status = 1.
Even if the same as 1) i.e nothing wrong with flowchart and should compile OK.
Martin
- Jordy101091
- Posts: 519
- Joined: Sat Jan 08, 2011 4:02 pm
- Location: The Netherlands
- Has thanked: 25 times
- Been thanked: 188 times
- Contact:
Re: Little Help with Lookup Table
I have found the solution,
The file name of the projects contained the following chars %,20,_ I have deleted this (Aqua%20Controller_Modified.fcf -->> AquaControllerModified.fcf)
Now it compiles correctly.
But no I have another problem:
When my light sensor is under a certain limit my program will wright a digit 0-9 when it does for example 9%, the second digit of my temperature reading falls away so I get the result:
HH:MM 9 %
DD:MM:YYYY 1 C
But in realitie 1 C must be 19C
I hope you understand my problem,
Regards Jordy
PS. I have made a small modification to you code because the temperature reading on my LCD was continuous changing (flickering)
The file name of the projects contained the following chars %,20,_ I have deleted this (Aqua%20Controller_Modified.fcf -->> AquaControllerModified.fcf)
Now it compiles correctly.
But no I have another problem:
When my light sensor is under a certain limit my program will wright a digit 0-9 when it does for example 9%, the second digit of my temperature reading falls away so I get the result:
HH:MM 9 %
DD:MM:YYYY 1 C
But in realitie 1 C must be 19C
I hope you understand my problem,
Regards Jordy
PS. I have made a small modification to you code because the temperature reading on my LCD was continuous changing (flickering)
- Attachments
-
- Aqua Controller.fcf
- (25.36 KiB) Downloaded 469 times
the will to learn, should not be stopped by any price
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Little Help with Lookup Table
Not seen that occurring on my display.Jordy101091 wrote:I have found the solution,
When my light sensor is under a certain limit my program will wright a digit 0-9 when it does for example 9%, the second digit of my temperature reading falls away so I get the result:
HH:MM 9 %
DD:MM:YYYY 1 C
But in realitie 1 C must be 19C
Could be something you have altered on the modified flowchart I posted?
I can't test on the 2nd one you posted as it looks like the same as original file you posted. It has LUT data in wrong box etc.
Yes it will flicker if you do not put a delay within loop.Jordy101091 wrote:PS. I have made a small modification to you code because the temperature reading on my LCD was continuous changing (flickering)
If ADC i/p changes slightly due to tolerance, then a different LUT will be retrieved, so LCD will flicker.
I have not thoroughly checked your flowchart, as you will need to do so since It helps you to learn the product.
All I did was to Alter so LUT worked + formatted LCD slightly
One thing I did notice is you have not initialised some variables with 0. E.g delay_LDR = 0
There is an important rule which Benj stated: "Rule of thumb to follow when working with variables on micros is:
Do I read the variable before I write to the variable?
If you do then you must initialise the variable."
If you repost the flowchart you are having a problem with I can see what the issue is.
Martin
- Jordy101091
- Posts: 519
- Joined: Sat Jan 08, 2011 4:02 pm
- Location: The Netherlands
- Has thanked: 25 times
- Been thanked: 188 times
- Contact:
Re: Little Help with Lookup Table
Hi,
I have some trouble to get this to work.
I have made a new lookup table because the last one was a bit messy.
Now i have made amplifying circuit on my breadboard because my microcontroller had some trouble to read the value.
I'm amplifying the input voltage 10× so if the PTC gives 0.370V the output of the opamp aswel the input on the adc is 3.700V.
Now when I read the input of my adc and display this value as a Byte, it corresponts verry well with my lookup table. But when a whant to use the data from my look up table (the grey box). On my display it shows all these symbols like the omega sign, its verry wired.
Can you help me with this,
Regards Jordy
I have some trouble to get this to work.
I have made a new lookup table because the last one was a bit messy.
Now i have made amplifying circuit on my breadboard because my microcontroller had some trouble to read the value.
I'm amplifying the input voltage 10× so if the PTC gives 0.370V the output of the opamp aswel the input on the adc is 3.700V.
Now when I read the input of my adc and display this value as a Byte, it corresponts verry well with my lookup table. But when a whant to use the data from my look up table (the grey box). On my display it shows all these symbols like the omega sign, its verry wired.
Can you help me with this,
Regards Jordy
- Attachments
-
- Flowcode temperature test.fcf
- (7.5 KiB) Downloaded 538 times
-
- Lookup Table TEST.xls
- (39.5 KiB) Downloaded 526 times
the will to learn, should not be stopped by any price
- DavidA
- Matrix Staff
- Posts: 1076
- Joined: Fri Apr 23, 2010 2:18 pm
- Location: Matrix Multimedia Ltd
- Has thanked: 58 times
- Been thanked: 258 times
- Contact:
Re: Little Help with Lookup Table
Hello Jordy,
I see you are creating a Flowcode v4 project, this type of support request should go into the appropriate V4 forums, please either make a new post there or post here/PM me when you have had your account upgraded to allow access to the V4 forums and I will move the topic there for you.
An FAQ topic exists on how to access the V4 forums: http://www.matrixmultimedia.com/support ... f=29&t=602
Any questions please ask.
I see you are creating a Flowcode v4 project, this type of support request should go into the appropriate V4 forums, please either make a new post there or post here/PM me when you have had your account upgraded to allow access to the V4 forums and I will move the topic there for you.
An FAQ topic exists on how to access the V4 forums: http://www.matrixmultimedia.com/support ... f=29&t=602
Any questions please ask.
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Little Help with Lookup Table
Hi Jorden,
There is one thing vital to remember when it comes to look-up tables
If you have 58 sets of numbers, then your result before retrieving LUT must never exceed LUT Quantaty -1
i.e. 58-1 = 57
E.g. If you have several sets of numbers assigned to variable called lut_data:
rom char* lut_data = {2,4,5,6,9,10,28};
Then using your C block:
FCV_TEMP = lut_data [FCV_TEMP];
TEMP must never be higher than 6 (there are total of 7 sets of numbers. 7-1 =6 )
Since
TEMP(0) = 2
TEMP(1) = 4
TEMP(2) = 5
TEMP(3) = 6
TEMP(4) = 9
TEMP(5) = 10
TEMP(6) = 28
TEMP(7) = unknown value stored in Flash memory
So if TEMP is between 100 and 255
Then you must have a formula so 100 is converted to 0 (so 1st number is retrieved = 2)
And
255 converted to 6 (so last number is retrieved = 28)
With your flowchart, the TEMP value is not between 0 and 57.
That’s why you’re not getting correct readings.
Edit: Sorry Dave, I was typing answer while you posted your reply.
There is one thing vital to remember when it comes to look-up tables
If you have 58 sets of numbers, then your result before retrieving LUT must never exceed LUT Quantaty -1
i.e. 58-1 = 57
E.g. If you have several sets of numbers assigned to variable called lut_data:
rom char* lut_data = {2,4,5,6,9,10,28};
Then using your C block:
FCV_TEMP = lut_data [FCV_TEMP];
TEMP must never be higher than 6 (there are total of 7 sets of numbers. 7-1 =6 )
Since
TEMP(0) = 2
TEMP(1) = 4
TEMP(2) = 5
TEMP(3) = 6
TEMP(4) = 9
TEMP(5) = 10
TEMP(6) = 28
TEMP(7) = unknown value stored in Flash memory
So if TEMP is between 100 and 255
Then you must have a formula so 100 is converted to 0 (so 1st number is retrieved = 2)
And
255 converted to 6 (so last number is retrieved = 28)
With your flowchart, the TEMP value is not between 0 and 57.
That’s why you’re not getting correct readings.
Edit: Sorry Dave, I was typing answer while you posted your reply.
Martin
- Jordy101091
- Posts: 519
- Joined: Sat Jan 08, 2011 4:02 pm
- Location: The Netherlands
- Has thanked: 25 times
- Been thanked: 188 times
- Contact:
Re: Little Help with Lookup Table
hmm,DavidA wrote:Hello Jordy,
I see you are creating a Flowcode v4 project, this type of support request should go into the appropriate V4 forums, please either make a new post there or post here/PM me when you have had your account upgraded to allow access to the V4 forums and I will move the topic there for you.
An FAQ topic exists on how to access the V4 forums: http://www.matrixmultimedia.com/support ... f=29&t=602
Any questions please ask.
DavidA i dont now what you are pointing ad.
You say "PM me when you have had your account upgraded to allow access to the V4 forums" what do you mean by this. I have a original legal copy of flowcode v4.3, why do I need to upgrade my account.

Sorry for not understanding
Regards Jordy
the will to learn, should not be stopped by any price
- DavidA
- Matrix Staff
- Posts: 1076
- Joined: Fri Apr 23, 2010 2:18 pm
- Location: Matrix Multimedia Ltd
- Has thanked: 58 times
- Been thanked: 258 times
- Contact:
Re: Little Help with Lookup Table
Hello Jordy,
To make sure we are giving our customers the best support we ask people who request help with their Flowcode V4 projects to post in them in the Flowcode V4 section of the forums, the forum account upgrade process means that we end up not wasting our limited support time supporting pirate users and give our legitimate customers the best support we can.
If you have a legal copy of Flowcode then if you follow the FAQ topic its really simple and quick to get your account upgraded, then i can move your topic into the V4 forums to continue the support.
To make sure we are giving our customers the best support we ask people who request help with their Flowcode V4 projects to post in them in the Flowcode V4 section of the forums, the forum account upgrade process means that we end up not wasting our limited support time supporting pirate users and give our legitimate customers the best support we can.
If you have a legal copy of Flowcode then if you follow the FAQ topic its really simple and quick to get your account upgraded, then i can move your topic into the V4 forums to continue the support.
- Jordy101091
- Posts: 519
- Joined: Sat Jan 08, 2011 4:02 pm
- Location: The Netherlands
- Has thanked: 25 times
- Been thanked: 188 times
- Contact:
Re: Little Help with Lookup Table
DavidA,
I have completed the instructions that are posted in the FAQ.
Its says my current version is 4.3 and its up-to-date.
Can you help me with the comment medelec35 gives me,
I dont understand it, what do I need to do to make it work (you dont need to give me the solution just a push in to the correct direction)
Regards Jordy
I have completed the instructions that are posted in the FAQ.
Its says my current version is 4.3 and its up-to-date.
Can you help me with the comment medelec35 gives me,
I dont understand it, what do I need to do to make it work (you dont need to give me the solution just a push in to the correct direction)
Regards Jordy
the will to learn, should not be stopped by any price
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Little Help with Lookup Table
Jordy,
The updating account, just means you can post in 'Flowcode V4' topic
If you try and post in Flowcode V4 section and you can't, then your account will need upgrading.
If you can post in Flowcode V4 section then your account has already been upgraded.
To upgrade, all you do is within flowcode, Select Help, Online Resources.
That will take your browser to a web pagethat look like: Then just submit your Forum user name and email address.
If after you select Help, Online Resource and you don't see Username: & Email:
What about changing you default browser?
As for following the information about LUT.
Sorry I tried to give information as clear as I could, I will have a look and see if I can re-word it a bit better.
Mean while I will see if I can help you with your flowchart, and post a modified working (hopefully
) version.
The updating account, just means you can post in 'Flowcode V4' topic
If you try and post in Flowcode V4 section and you can't, then your account will need upgrading.
If you can post in Flowcode V4 section then your account has already been upgraded.
To upgrade, all you do is within flowcode, Select Help, Online Resources.
That will take your browser to a web pagethat look like: Then just submit your Forum user name and email address.
If after you select Help, Online Resource and you don't see Username: & Email:
What about changing you default browser?
As for following the information about LUT.
Sorry I tried to give information as clear as I could, I will have a look and see if I can re-word it a bit better.
Mean while I will see if I can help you with your flowchart, and post a modified working (hopefully

Martin
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Little Help with Lookup Table
Maybe this will help.
You are reading ADCi/p and assigning to a variable called TEMP
when TEMP = 0 then 183 is retrieved from LUT. = 1st value
When TEMP = 1 then 184 is retrieved from LUT
When TEMP = 2 then 186 is retrieved from LUT.
....
When TEMP = 30 then 227 is retrieved from LUT. = last value
This means that 30 is the maximum number TEMP can ever be. Never exceed this value
So if ADC i/p = 3V then TEMP = 255/5*3 = 153.
Since you can only go up to 30, when ADC i/p = 3V then a character that has nothing what so ever to do with your look-up table will be displayed.
There are two ways around this.
If Max value of Voltage at the i/p = 4.45V then bytes = 255/5 * 4.45 =227.
So you have 227 bytes of data in your LUT, and not 31 as you currently have.
Or scale down TEMP by TEMP - TEMP - 191.
I have modified your Flowchart to use the second option.
Note: It is only representative only after ADC i/p >190.
But with all this information, you should be able to tailor your LUT data to represent temperature.
You are reading ADCi/p and assigning to a variable called TEMP
when TEMP = 0 then 183 is retrieved from LUT. = 1st value
When TEMP = 1 then 184 is retrieved from LUT
When TEMP = 2 then 186 is retrieved from LUT.
....
When TEMP = 30 then 227 is retrieved from LUT. = last value
This means that 30 is the maximum number TEMP can ever be. Never exceed this value
So if ADC i/p = 3V then TEMP = 255/5*3 = 153.
Since you can only go up to 30, when ADC i/p = 3V then a character that has nothing what so ever to do with your look-up table will be displayed.
There are two ways around this.
If Max value of Voltage at the i/p = 4.45V then bytes = 255/5 * 4.45 =227.
So you have 227 bytes of data in your LUT, and not 31 as you currently have.
Or scale down TEMP by TEMP - TEMP - 191.
I have modified your Flowchart to use the second option.
Note: It is only representative only after ADC i/p >190.
But with all this information, you should be able to tailor your LUT data to represent temperature.
- Attachments
-
- Flowcode temperature test_Modified.fcf
- (9 KiB) Downloaded 460 times
Martin
- Jordy101091
- Posts: 519
- Joined: Sat Jan 08, 2011 4:02 pm
- Location: The Netherlands
- Has thanked: 25 times
- Been thanked: 188 times
- Contact:
Re: Little Help with Lookup Table
Thanks man,
I have uploaded your version and it works.
Now I was thinking,
When I have my lookup table with the data going from 10 degree celsius to 40 degree celsius (with corresponding byte), but when my ADC reads some data that cannot be found in the lookup table, I need to fill up those gaps with lets say zero's.
The conclusion that I can make,
When using a lookup table you need the full range of data (0-255) oderwise it's shows only things that you dont whant.
So my solution for this problem is:
With my solution and a little help from my dad its finally working in both ways,
Yours and mine
Realy realy thanks, medelec35
Regards Jordy
Hoping you will support me in my next sub project
Aqua Controller:
Light control (realtime light tracking): Done
Temperature reading: Done
DCF77 clock: next project
I have uploaded your version and it works.
Now I was thinking,
When I have my lookup table with the data going from 10 degree celsius to 40 degree celsius (with corresponding byte), but when my ADC reads some data that cannot be found in the lookup table, I need to fill up those gaps with lets say zero's.
The conclusion that I can make,
When using a lookup table you need the full range of data (0-255) oderwise it's shows only things that you dont whant.
So my solution for this problem is:
Code: Select all
rom char* degrees=
{
0,0,0,0,0,0,0,0,0,0, ect (50)
0,0,0,0,0,0,0,0,0,0, ect (50)
0,0,0,0,0,0,0,0,0,0, ect (50)
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,10,11,11,12,13,
14,14,15,16,16,17,18,18,19,20,20,21,22,23,23,24,25,
25,26,26,27,28,28,29,30,31,31,32,32,33,33,34,35,35,
36,37,37,38,39,40
};
Yours and mine
Realy realy thanks, medelec35
Regards Jordy
Hoping you will support me in my next sub project
Aqua Controller:
Light control (realtime light tracking): Done

Temperature reading: Done

DCF77 clock: next project

the will to learn, should not be stopped by any price
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
Re: Little Help with Lookup Table
That's great!Jordy101091 wrote:With my solution and a little help from my dad its finally working in both ways,
Yours and mine
Realy realy thanks, medelec35
Regards Jordy
Gald all up an running. Your welcome.
Thanks for letting us know
Nearly correct. You only need 256 bytes of data if last byte value of ADC i/p = 255 = 5V (does not matter what the lowest value is)Jordy101091 wrote: When using a lookup table you need the full range of data (0-255) oderwise it's shows only things that you dont whant.
E.g.
If byte value of i/p you are reading is 200 to 255, then you need 256 bytes of data
1st 199 bytes can be any value as they won't be read. so can all be 0's etc.
Then the important data is contained in the last 56 bytes.
If byte value of i/p you are reading is 100 to 145, then you need 146 bytes of data
1st 99 bytes can be any value as they won't be read. so can all be 0's etc.
Then the important data is contained in the next 46 bytes.
Anything after will just be ignored.
Martin
Re: Little Help with Lookup Table
hello, This article has been helpful but somehow i am still having problems with my look up tablesmedelec35 wrote:Hi Jorden,
There is one thing vital to remember when it comes to look-up tables
If you have 58 sets of numbers, then your result before retrieving LUT must never exceed LUT Quantaty -1
i.e. 58-1 = 57
E.g. If you have several sets of numbers assigned to variable called lut_data:
rom char* lut_data = {2,4,5,6,9,10,28};
Then using your C block:
FCV_TEMP = lut_data [FCV_TEMP];
TEMP must never be higher than 6 (there are total of 7 sets of numbers. 7-1 =6 )
Since
TEMP(0) = 2
TEMP(1) = 4
TEMP(2) = 5
TEMP(3) = 6
TEMP(4) = 9
TEMP(5) = 10
TEMP(6) = 28
TEMP(7) = unknown value stored in Flash memory
So if TEMP is between 100 and 255
Then you must have a formula so 100 is converted to 0 (so 1st number is retrieved = 2)
And
255 converted to 6 (so last number is retrieved = 28)
With your flowchart, the TEMP value is not between 0 and 57.
That’s why you’re not getting correct readings.
Edit: Sorry Dave, I was typing answer while you posted your reply.
here is what i want to do:
switch status-0,1,2,3,4,5,6,7
voltage value-150,160,170,180,190,200,210
i want the voltage value to appear to the LCD for each corresponding switch status value. Pls help!!!! been on this for 3days now. Thank you so much guys
hi, pls i am working on something similar will this be in a c-block on the flowchart or in the supplementary code.medelec35 wrote:E.g. If you have several sets of numbers assigned to variable called lut_data:
rom char* lut_data = {2,4,5,6,9,10,28};
Re: Little Help with Lookup Table
hi guys,
Thanks for all your tips and LUTs they have been helpful. But somehow i am still having problem with mine and i need you thoughts on this. I am relatively new to flowcode, started a few months back so i don't know my way around much.
i have a table where i am comparing two values
switch status- 0,1,2,3,4,5,6,7
voltage value-0,150,160,170,180,190,200,210
i need to display the voltage value for each of the corresponding switch status value i get. i followed some of the procedures but i seem not to get it. so basically i have some questions.
what do i put in my supplementary code window?
what do i put in my c-block code and how do i relate this two together?
looking forward to your response.
best regards
Thanks for all your tips and LUTs they have been helpful. But somehow i am still having problem with mine and i need you thoughts on this. I am relatively new to flowcode, started a few months back so i don't know my way around much.
i have a table where i am comparing two values
switch status- 0,1,2,3,4,5,6,7
voltage value-0,150,160,170,180,190,200,210
i need to display the voltage value for each of the corresponding switch status value i get. i followed some of the procedures but i seem not to get it. so basically i have some questions.
what do i put in my supplementary code window?
what do i put in my c-block code and how do i relate this two together?
looking forward to your response.
best regards