Mathematics
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Mathematics
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?
- 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: Mathematics
Hello Jan,
Yes this is possible.
Yes this is possible.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Re: Mathematics
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?
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?
- 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: Mathematics
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.
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.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
- Jan Lichtenbelt
- Posts: 797
- Joined: Tue Feb 17, 2009 8:35 pm
- Location: Haren GN, the Netherlands
- Has thanked: 128 times
- Been thanked: 264 times
- Contact:
Examples of Sin and Cos functions
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.
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.
- Attachments
-
- Sin_and_Cos_functions.fcf
- (19.43 KiB) Downloaded 558 times