目录
简介
使用蓝色激光和磷光纸来说明围绕圆形绘制正弦波的意义
步骤一 材料准备
硬件准备:
arduino uno ;genuino uno
电机控制板
步进电机
带按钮的旋转编码器
软件准备:
arduino IDE
激光切割机
步骤二 原理说明
你有没有想过声音编辑软件如何削减或增强录音的基础?或者取消声音的耳机如何工作?或者土木工程师如何设计建筑物并避免地震的共振频率?那么,所有这些问题的答案都源于一个人:约瑟夫傅立叶。傅立叶想出了如何在数学上将复杂波制动成其组分正弦波,从而允许对每个波进行单独编辑或观察。一般的想法(没有进入它背后的微积分)是你拿波并将它环绕一个圆圈,以便它绘制一种花。然后,逐渐增加围绕该圆圈缠绕波浪的频率,观察图形绘制的形状发生变化。你这样做,直到你找到一个绘制看起来像心形的东西的频率。当您发现这一点时,这意味着您围绕圆圈缠绕波的频率与您正在分析的父波中的一个分量正弦波的频率相同。我决定对寻找组件正弦波的过程进行物理表示。
我提出的想法是用一个旋转的磷光纸圈和带有激光的线性执行器搭配。我的想法是,带有激光的线性执行器将跟踪正弦波,因为你改变了圆圈转向试图找到它们匹配的位置的速度,你开始画心而不是花。这可以通过驱动两个单独的步进电机并使用旋转编码器的输入来改变基圆旋转的速度来轻松实现。
步骤三 电路搭建
步骤四 编写程序
Arduino 1:Sine Wave Arduino
double ti; double inp; double cosine; double nn; double pi = 3.1415926535; int sinSpeed = 126; // How fast the arm is moving back and forth #include AF_Stepper motor(200, 2); // 200 steps per rotation void setup() { Serial.begin(9600); Serial.println("Stepper test!"); } void loop() { Moto1(); } void Moto1() { Serial.println("Moto1 init"); /* With the rack and pinion gears I printed, it is 400 steps from the center of the circle to the edge. Change entries in "@@" marked lines to half the number of steps. */ int in = -200; //@@ while (in < 200){ //@@ double cosine = cos( (in * pi) / 400); double nn = abs(cosine); motor.setSpeed((nn+0.1)*sinSpeed); motor.step(1, FORWARD, DOUBLE); in++; } in = -200; //@@ while (in < 200){ //@@ double cosine = cos( (in * pi) / 400); double nn = abs(cosine); motor.setSpeed((nn+0.1)*sinSpeed); motor.step(1, BACKWARD, DOUBLE); in++; } }
Arduino 2 : Base MotorArduino
#include #define pinA A0 #define pinB A2 AF_Stepper motor2(200, 1); void setup() { pinMode(pinA, INPUT); pinmode(pinB, INPUT); } void loop() { aState = digitalRead(pinA); if (aState != aLastState){ if (digitalRead(pinB) != aState) { value ++; } else { value --; } Serial.print("Position: "); Serial.println(value); } motor2.setSpeed(value); motor2.step(1, FORWARD, DOUBLE); }
Arduino : Dual runArduino
//Need to download the AFMotor library. #include #define pinA A0 #define pinB A2 AF_Stepper motor2(200, 1); AF_Stepper motor(200, 2); long previousMillis = 0; int lLim = 1; int uLim = 75; // Set max speed double ti; double inp; double cosine; double nn; double pi = 3.1415926535; int sinSpeed = 126; /* How fast the sin wave is going. This is not on the same scale as the motor speeds. In my case, 126 matched up with 16 to draw a cardioid. */ int value = 0; int aState; int aLastState; void setup() { Serial.begin(9600); Serial.println("program initiated..."); pinMode(pinA, INPUT); pinMode(pinB, INPUT); Serial.begin(9600); aLastState = digitalRead(pinA); } void loop() { aState = digitalRead(pinA); if (aState != aLastState){ if (digitalRead(pinB) != aState) { value ++; } else { value --; } Serial.print("Position: "); Serial.println(value); } aLastState = aState; int in = -200; while (in < 200){ double cosine = cos( (in * pi) / 400); double nn = abs(cosine); motor.setSpeed((nn+0.1)*sinSpeed); motor.step(1, FORWARD, DOUBLE); in++; } in = -200; while (in < 200){ double cosine = cos( (in * pi) / 400); double nn = abs(cosine); motor.setSpeed((nn+0.1)*sinSpeed); motor.step(1, BACKWARD, DOUBLE); in++; } if (valuevalue = 0; } if (value>uLim){ value = uLim; } if ((millis() - previousMillis) >= value){ motor2.step(1, FORWARD, DOUBLE); previousMillis = millis(); } }
非常好