Page 1 of 1
Mathematics
Posted: Mon Jun 21, 2010 10:27 am
by Jan Lichtenbelt
I will use the graphic LCD and I intend to draw a circle. Is it possible to use the mathematical functions like cosinus and sinus in Flowcode 4?
Re: Mathematics
Posted: Mon Jun 21, 2010 12:24 pm
by Benj
Hello Jan,
Yes this is possible.
Re: Mathematics
Posted: Mon Jun 21, 2010 6:15 pm
by Jan Lichtenbelt
Hello Ben,
I did not expect that it would be possible. I tried it directly. Declaring the variable A (float) and in the C-Code box I put: A= cos(1). But this results only in the message: unknown indentifier. What's wrong?
Re: Mathematics
Posted: Tue Jun 22, 2010 8:48 am
by Benj
Hello,
In Flowcode PIC the trig functions are unavailable unless you use the HiTech compiler. A discussion on how this is done is available from here.
http://www.matrixmultimedia.com/mmforum ... =26&t=6812
My other suggestion would be to avoid the use of trig and instead use a look up table to calculate your COS and SIN values.
http://www.matrixmultimedia.com/mmforum ... =26&t=3543
This will probably be easier as you will be able to pre multiply up the cooordinates in your lookup table to define the size and location of the circle on the display.
Examples of Sin and Cos functions
Posted: Tue Oct 05, 2010 1:53 pm
by Jan Lichtenbelt
I made an example of lookup table for both sinus and cosinus functions, based on Ben's suggestions in
http://www.matrixmultimedia.com/mmforum ... =26&t=3543
The example uses 10 values stored in the EEPROM, instead of the C-program, for angles between 0, 10... 90 degrees. Angles between these values will be rounded to a mulple of 10. All angles are allowed even > 360 degree or negative angles.
The results can be shown in eg. the actual graphic display's (like E-blocks EB057 and EB058). X- and Y-scaling is possible.
Good luck.