Page 3 of 3

Re: Look-Up Tables Tutorial

Posted: Tue May 13, 2014 11:31 am
by vonskyes
medelec35 wrote:So SW_ST1 & SW_ST1 will have a value e.g 10, so you want to retrieve the 10th number within the look-up table?

One thing I have noticed is you have a calculation like this: SW_ST1 = (SW_A * 4) + (SW_B * 2) + (SW_C)
You will have errors if SW_A, SW_B or SW_C are Bool.
You will need to change Bool to Bytes.

To be honest I'm not following your explanation, but it could be the time of night.

Can you give examples what you want each LUT to retrieve as that will make it easier for me.

Martin
Hello martin,
thank you so much for helping me out with this and please forgive my late replies. I have explained in details what the program is about and what i want to achieve with the look up table in the word document attached to this post. I hope you find my explanations clear enough and if there's any part that isn't clear please let me know so i can make it clear. thanks again.

Re: Look-Up Tables Tutorial

Posted: Tue May 13, 2014 9:45 pm
by medelec35
No problem.
I can follow the document just fine.
I have simplified flowchart and cheated a bit.

LUT values on 8 bit chips are only 8 bit wide
Therefore only numbers 0 to 255 can be used.
On the over voltage side you wanted 260,265,270,275 & 280
So what I did was subtract 50 from each number, then added the 50 back on after the lut number has been retrieved by using:

Code: Select all

FCV_OVERVOLTAGE=OV_Eqv[7-(FCV_READDIPSWITCHES>>3)]+50;
The 7- is used because the switches or active low and not active high.
>> just bit shift by 3 so if all switches connected to B3,B4 & B5 are all closed, pulling 5V down to 0V the value will be 7
This is the same as if switches connected to B0,B1 & B2 are all closed, pulling 5V down to 0V the value will also be 7

Just remember that C code is not simulated, so the only way of confirming all is working is by either using a 3rd part simulator, or on hardware.

Martin

Re: Look-Up Tables Tutorial

Posted: Wed May 14, 2014 3:14 pm
by vonskyes
medelec35 wrote:No problem.
I can follow the document just fine.
I have simplified flowchart and cheated a bit.

LUT values on 8 bit chips are only 8 bit wide
Therefore only numbers 0 to 255 can be used.
On the over voltage side you wanted 260,265,270,275 & 280
So what I did was subtract 50 from each number, then added the 50 back on after the lut number has been retrieved by using:

Code: Select all

FCV_OVERVOLTAGE=OV_Eqv[7-(FCV_READDIPSWITCHES>>3)]+50;
The 7- is used because the switches or active low and not active high.
>> just bit shift by 3 so if all switches connected to B3,B4 & B5 are all closed, pulling 5V down to 0V the value will be 7
This is the same as if switches connected to B0,B1 & B2 are all closed, pulling 5V down to 0V the value will also be 7

Just remember that C code is not simulated, so the only way of confirming all is working is by either using a 3rd part simulator, or on hardware.

Martin

Hello Martin,
Thanks for the program, there are somethings you did in there that are new to me so i want to take time to study it for better understanding before i proceed to load it on my hardware. I appreciate your help greatly, what will my programming career be without people like you :) . I will give you feedback when i am done. Best Regards.