Look Up Tables using Flowcode and Microsoft Excel

Tips, Tricks and methods for programming, learn ways of making your programming life easier, and share your knowledge with others.

Moderators: Benj, Mods

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

Re: Look Up Tables using Flowcode and Microsoft Excel

Post by medelec35 »

Chirikas wrote: I have few other questions, maybe you have zens circuit drawn with some software? ?
Sorry have not got the circuit diagram
Chirikas wrote: Maybe it would help me to understand all connections. Maybe some other chip could be used instead of 16f884 and 16f887?
The great feature of flowcode is you don't have to sick with a circuit diagram posted.
You can load up the posted flowchart then select your own choice of microcontroller, o/p and i/p pins and osc type e.g crystal, ceramic, internal (so long as target device supports internal osc)
Just remember to set the configuration settings for your target device, or you will find hardware will not work.
See:
http://www.matrixmultimedia.com/mmforum ... =26&t=6936
For help and general advice.
There are plenty of people on this forum that are willing to help you when you get stuck.
As for drawing a schematic, if you want to give that a bash yourself, there seems to be a new popular packge called Designspark PCB. Only just downloaded and registered it all for free!
Plus unlike other free design software this one has no limitations, can import eagle libraries, good support and recommended by RS components.
Martin

zen
Posts: 8
Joined: Tue Dec 21, 2010 9:50 pm
Has thanked: 4 times
Been thanked: 5 times
Contact:

Re: Look Up Tables using Flowcode and Microsoft Excel

Post by zen »

I guess I should have explained the circuit drawing. You should scroll down to the bottom of the circuit schematic drawing to the detail on how I made the "reset" and "button" inputs. I did not have enough room to draw them in full on the top picture so I drew them on the bottom. I based the pushbutton design from some demo board made by microchip. If i'm ever in doubt about a design element I look up a microchip demo board that has what I want and use the schematic from their board. The pushbutton circuit is working fine on the board I built. I am not a professional or any kind of authority on embedded circuits. If in doubt listen to medelec. He is far more knowledgeable than I on this subject.

I liberally use capacitors(.1uf ..'104'/small yellow..most of the time) to create a low pass filters. ( limits circuit noise and/or minimizes contact bounce from the pushbutton for ex.).

I have powered 5 rgb led's without any problems right from my 16f887, 16f877 and 18f4685. I suppose one of the benefits of using PWM and utilizing POV is that it minimizes power consumption. My entire circuit is powered from a modified moto. razr usb cell phone charger rated at aprx. 500mA/5v. You do not need a switching transistor to make this work for 5 rgb led's (=15 regular led's) as far as I can tell.
-------------------------------------------------------------
edit....here are a few pictures showing some the various colors and the board I built....
Attachments
begin.JPG
begin.JPG (49.84 KiB) Viewed 19686 times
combinedcolors.JPG
combinedcolors.JPG (68.9 KiB) Viewed 19686 times

zen
Posts: 8
Joined: Tue Dec 21, 2010 9:50 pm
Has thanked: 4 times
Been thanked: 5 times
Contact:

Re: Look Up Tables using Flowcode and Microsoft Excel

Post by zen »

I decided to activate the free trial of the Hi-Tech C compiler and tried to compile the RGB LED LUT program using it. The BoostC compiler has no problems with the code but the HTC compiler didn't like the program and is returning the following errors:

Warning [374] C:\...\RGB_lut_MAIN.C; 105.5 missing basic type; int assumed
Error [314] C:\...\RGB_lut_MAIN.C; 105.5 ";" expected
Warning [374] C:\...\RGB_lut_MAIN.C; 112.5 missing basic type; int assumed
Error [314] C:\...\RGB_lut_MAIN.C; 112.5 ";" expected
Warning [374] C:\...\RGB_lut_MAIN.C; 119.5 missing basic type; int assumed
Error [314] C:\...\RGB_lut_MAIN.C; 119.5 ";" expected
Error [192] C:\...\RGB_lut_MAIN.C; 479.15 undefined identifier "RED"
Error [981] C:\...\RGB_lut_MAIN.C; 479.33 pointer required
Error [981] C:\...\RGB_lut_MAIN.C; 479.33 pointer required
Error [192] C:\...\RGB_lut_MAIN.C; 480.17 undefined identifier "GREEN"
Error [981] C:\...\RGB_lut_MAIN.C; 480.37 pointer required
Error [981] C:\...\RGB_lut_MAIN.C; 480.37 pointer required
Error [192] C:\...\RGB_lut_MAIN.C; 481.16 undefined identifier "BLUE"
Error [981] C:\...\RGB_lut_MAIN.C; 481.35 pointer required
Error [981] C:\...\RGB_lut_MAIN.C; 481.35 pointer required

Ive tried several different ways to declare the " rom char* RED |BLUE|GREEN {1,2,3,......}; " array and get a different error every time. I'm not sure what must be done differently to make the LUT work for both compilers.

edit--------------------link to htc website on this topic

http://www.htsoft.com/support/faqs.php#faq22


edit #2---------------------------------------------

note: the original code that won't work with HTC used the format: "rom char * red = {1,2,3....}; "

I was able to make this program work by using any one of the following 3 formats:

1. char* red[]= {1,2,3....}; // All of these examples worked the same from what I could tell
2. unsigned char* red[] = {1,2,3....};
3. volatile unsigned char* red[] = {1,2,3....};

char* red[] = {red, array, here,....};

unsigned char* green[] = {green, array, here,....};

volatile unsigned char* blue[] ={blue, array, here,....};

I'm still getting a massive list of warnings saying "illegal conversion of integer to pointer", especially if I compile the code in MPlab instead of FC. I sort of understand the problem but don't either. All I know is that the program is working as usual and compileable with HTC.

User avatar
Steve
Matrix Staff
Posts: 3418
Joined: Tue Jan 03, 2006 3:59 pm
Has thanked: 114 times
Been thanked: 422 times
Contact:

Re: Look Up Tables using Flowcode and Microsoft Excel

Post by Steve »

This might be a better way:

In BoostC, define constant arrays like this:

Code: Select all

rom char* my_const_array = {1,2,3};
And in HITECH, use this:

Code: Select all

const char my_const_array[] = {1,2,3};
In fact, to make the code work with either compiler without modification, do something like this:

Code: Select all

#ifdef _BOOSTC
  rom char* my_const_array = {1,2,3};
#endif
#ifdef HI_TECH_C
  const char my_const_array[] = {1,2,3};
#endif

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Look Up Tables using Flowcode and Microsoft Excel

Post by JohnCrow »

medelec35 wrote:To help you are are two different ways you can convert from byte to integer and vice-versa

IntValue = ByteLow+(ByteHigh << 8)

ByteLow = IntValue & 0xFF
ByteHigh = (IntValue >> 8) & 0xFF


IntValue = ByteLow+(ByteHigh * 256)

ByteHigh = (IntValue/ 256)
ByteLow = IntValue - ByteHigh* 256

Not tried the lower three formulas within Flowcode but have included them so you will know how conversions can be done mathematically
Written a simple flowchart to combine HighByte LowByte values entered on the keypad, using above formula
Attachments
Program 5 - Combine with keypad input.fcf
(15.5 KiB) Downloaded 1040 times
1 in 10 people understand binary, the other one doesn't !

User avatar
JohnCrow
Valued Contributor
Valued Contributor
Posts: 1367
Joined: Wed Sep 19, 2007 1:21 pm
Location: Lincolnshire
Has thanked: 364 times
Been thanked: 716 times
Contact:

Re: Look Up Tables using Flowcode and Microsoft Excel

Post by JohnCrow »

medelec35 wrote:To help you are are two different ways you can convert from byte to integer and vice-versa

IntValue = ByteLow+(ByteHigh << 8)

ByteLow = IntValue & 0xFF
ByteHigh = (IntValue >> 8) & 0xFF


IntValue = ByteLow+(ByteHigh * 256)

ByteHigh = (IntValue/ 256)
ByteLow = IntValue - ByteHigh* 256

Not tried the lower three formulas within Flowcode but have included them so you will know how conversions can be done mathematically
Written a simple flowchart to combine HighByte LowByte values entered on the keypad, using above formula
Attachments
Program 5 - Combine with keypad input v2.fcf
(11.5 KiB) Downloaded 1008 times
1 in 10 people understand binary, the other one doesn't !

Eissa88
Posts: 1
Joined: Thu Feb 16, 2012 9:56 pm
Contact:

Re: Look Up Tables using Flowcode and Microsoft Excel

Post by Eissa88 »

hello there,

I want to use LUT to navigate between some words, can you show me how to do that in flowcode v4 please?

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Look Up Tables using Flowcode and Microsoft Excel

Post by Benj »

Hello,

Do you mean you need to store string data into a lookup table?

One way to do this is to have two arrays of data one for your string data and the other for the string lengths. Both variables should probably be byte based.

StringData[] = "HelloWorldMyNameIsBen"
IndexData[] = 0,5,10,12,16,18,21

Then when you need to pull out a word you first need to know its index so say you want to pull out word 2 - "World".

First you would look up the second index remembering that the numbering starts from 0.

idx = 1
Index = IndexData[idx] which equals 5

You then pull out the index for the next string so you know where the end of the current string is.

idx = idx + 1
NextIndex = IndexData[idx] which equals 10

You can then create a loop to cycle through each of the bytes in the string.

counter = Index
while (counter < NextIndex )
{
... = StringData[counter]
}

Hope this helps.

joe nova
Posts: 9
Joined: Sun Mar 01, 2015 10:55 pm
Has thanked: 14 times
Contact:

Re: Look Up Tables using Flowcode and Microsoft Excel

Post by joe nova »

http://www.matrixmultimedia.com/softwar ... _Table.zip[/quote]


Hi !

I did not get access to table the link above, someone help me, shows 404 error page not found

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Look Up Tables using Flowcode and Microsoft Excel

Post by Benj »

Hello,

Thanks for letting us know, here is the file.
Look_Up_Table.zip
(12.94 KiB) Downloaded 706 times

Post Reply