![]() Next, connect one end of the resistor to the GND pin on the board. Connect one end of the photocell to the 5V pin on the Arduino board. Use a photocell and a resistor instead of the potentiometer you used in Task 4. In a dark room the motor shaft should be positioned at 0 degrees, while in a bright room it should be positioned at 180 degrees. In this task you will create a model that sets the position of the servo motor according to light intensity detected by a photocell. Task 5 - Control Servo Motor Position via Photocell If you have trouble creating the model as described above, you can use the Servo Control model. When the model starts running on Arduino board, observe the motor shaft sweeping between 0 and 180 degrees. The Simulink model will now be deployed to the Arduino hardware.ġ2. On the Hardware tab of the Simulink model, in the Mode section, select Run on board and then click Build, Deploy & Start. Select the Hardware Implementation pane and select your required Arduino hardware from the Hardware board parameter list. In your Simulink model, click Simulation > Model Configuration Parameters to open Configuration Parameters dialog.ĩ. Double-click the Gain block and set its value to 0.1760 (maximum servo motor displacement in degrees divided by analog input digital resolution i.e. From Simulink Math Operations library, drag the Gain block into the model and drop it on the line connecting the Analog Input and the Standard Servo Write block. Connect the Analog Input and the Standard Servo Write blocks.ħ. Double-click the block and set the Pin number to 4.Ħ. ![]() Drag the Standard Servo Write block into the model. Double-click the block and set the Pin number to 0, and the Sample time to 0.01 second.ĥ. Drag the Analog Input block into the model. In the Simulink Library Browser, navigate to Simulink Support Package for Arduino Hardware > Common.Ĥ. This opens the Simulink Library Browser.ģ. Enter slLibraryBrowser at the MATLAB® prompt. In MATLAB®, select HOME > New > Simulink Model.Ģ. Your task is to set the servo motor angle proportional to this voltage.ġ. As a result, the voltage at the analog input pin changes as well. As your rotate the potentiometer, its resistance changes. Connect the middle terminal to analog input pin 0. Connect the outer potentiometer terminals to 5V and GND pins on your Arduino board. In this task you will set the position of the servo motor shaft manually, using a potentiometer. Task 4 - Control Servo Motor Position via Potentiometer When the model starts running on the Arduino board, observe the motor shaft position sweeping between 0 and 180 degrees. On the Hardware tab of the Simulink model, in the Mode section, select Run on board and then click Build, Deploy & Start.Ħ. In your Simulink model, click Simulation > Model Configuration Parameters to open Configuration Parameters dialog.Ĥ. The block sets the new angle of the servo motor shaft every 0.01 second.ģ. The shaft angle will vary between 0 and 180 degrees, up and down.Ģ. In this task you will set the position of the servo motor shaft using an internal source. ![]() Task 3 - Set Servo Motor Position via Internal Source
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |