圓坐標的計算
單片機源程序如下:
- #include "sys.h"
- #include "delay.h"
- #include "math.h"
- #include "USART.h"
- long XPoint[90];
- long YPoint[90];
- unsigned int Index;
- unsigned int j;
- unsigned int R;
- unsigned char Layer;
- int main(void)
- {
- Stm32_Clock_Init(9);
- uart_init(72,115200);
- Delay_Init(72);
-
-
- // for(Index=0;Index<180;Index+=2)
- // {
- // UART_Send_Str("G1 ");
- // XPoint[j] = (uint16 )(25000+4000*cos(Index*3.14/180)); //圓心坐標(25000,8500) R=2500
- // UART_Send_Str("X");
- // UART_Put_Num(XPoint[j]);
- // UART_Send_Str(" ");
- //
- // YPoint[j] = (uint16 )( 8500+4000*sin(Index*3.14/180)); //R=4000Pulse
- // UART_Send_Str("Y");
- // UART_Put_Num(YPoint[j]);
- // UART_Send_Str(" ");
- // UART_Send_Enter();
- //
- // j++;
- // }
-
- UART_Send_Str(" ");
- while(1)
- {
-
- for(R=4000;R>0;R-=40)
- {
- Layer++;
- UART_Send_Str(";LAYER:");
- UART_Put_Num(Layer);
- UART_Send_Enter();
-
- for(Index=0;Index<180;Index+=2)
- {
- UART_Send_Str("G1 ");
- XPoint[j] = (uint16 )(25000+R*cos(Index*3.14/180)); //圓心坐標(25000,8500) R=2500
- UART_Send_Str("X");
- UART_Put_Num(XPoint[j]);
- UART_Send_Str(" ");
-
- YPoint[j] = (uint16 )( 8500+R*sin(Index*3.14/180)); //R=4000Pulse
- UART_Send_Str("Y");
- UART_Put_Num(YPoint[j]);
- UART_Send_Str(" ");
- UART_Send_Enter();
-
- j++;
- }
- j=0;
-
-
- Layer++;
- UART_Send_Str(";LAYER:");
- UART_Put_Num(Layer);
- UART_Send_Enter();
-
- for(Index=180;Index>0;Index-=2)
- {
- UART_Send_Str("G1 ");
- XPoint[j] = (uint16 )(25000+R*cos(Index*3.14/180)); //圓心坐標(25000,8500) R=2500
- UART_Send_Str("X");
- UART_Put_Num(XPoint[j]);
- UART_Send_Str(" ");
-
- YPoint[j] = (uint16 )( 8500+R*sin(Index*3.14/180)); //R=4000Pulse
- UART_Send_Str("Y");
- UART_Put_Num(YPoint[j]);
- UART_Send_Str(" ");
- UART_Send_Enter();
-
- j++;
- }
- j=0;
-
-
- }
-
- }
- }
復制代碼
所有資料51hei提供下載:
CirclePoint.rar
(21.36 KB, 下載次數: 8)
2018-8-29 18:44 上傳
點擊文件名下載附件
圓坐標的計算
|