My plan is to use Y axis for Servo motor and X axis for DC motor driven by H-Bridge. If we connect joysticks axis to analog pins and apply the rule from before we will have value of 0 when Y axis is down, 1023 when it is up and 511 when its in middle. So you should use pull-up of Arduino if you are planning to use it.Īrduino's ADC is 10bit, that means it will split input voltage to 1024 (2 to the power of 10) pieces starting with 0. There is also push button between ground and KEY pin. Rule is the same for Y axis, left is 0, right is 1 and middle is 1/2. If we let it go in idle position output voltage will be 1/2 multiplied by input voltage. Let's use X axis for this example: When its all the way up its output voltage is 1 multiplied by input voltage, when its all the way down its output voltage will be 0 multiplied by input voltage. For X axis if we go up voltage goes up and if we go down voltage goes down. Moving it in left is the same just in reverse, voltage is going down. If we start moving mushroom to the right we are changing position of Y axis potentiometer and moving it towards end that is connected to positive and we are getting higher and higher voltage on output of Y axis. It's because potentiometer pin is exactly in middle and we will get half of input voltage on output pins. When joystick is in idle position, voltage on both X and Y pins will be 2.5V. If VCC is 5V and GND is 0V then we will have output voltage range from 0V to 5V depending on position of mushroom. Now if we move mushroom, potentiometers will also change position and voltage will change on output pins (X and Y). By sliding the third contact we can get voltage between ground and positive potential. One end of resistive material is connected to ground and other to positive. Potentiometers are just classic resistors with third pin that can slide over resistive material. To switch off the controller just put the duty cycle to zero while to turn it on just put the duty cycle of the pin 13 to the previous value or a new value different from zero.Joystick has 2 main potentiometers. For example, if you want a 50% speed regulation enough to set the duty cycle of the pin 13 to 50% because at this corresponds to a voltage VCNT = 5 * 50/100 = 2.5V which is for the MST_K12 the voltage value for 50% of control level. In our case, for the Arduino, VCC = 5V that is compatible with the internal operation of the MST_K12 voltage while D may vary from 0% to 100%. where D is the duty cycle in% and VCC is the maximum voltage of the PWM signal. The value of this voltage that call VCNT = D / 100 VDC. As described in the tutorial on the use of the PWM it is possible to generate a DC voltage by a PWM signal. There comes to the aid of the PWM Arduino that has the ability to generate a PWM signal, via command, for some pin (2-13) with a value that ranges from 0% to 100%. To replace the potentiometer it is needed something that can generate a variable voltage from 0 to 5V into 256 levels. The principle of the control is very simple: in normal operation the MST_K12 takes the voltage, set by potentiometer, to control of the regulation value. The hardware implementation is performed using the Arduino MEGA 2560 card and the MST_K12 regulator without the potenziometerreplaced by a screw connector: It is needed to connect the positive input VCNT to the pin 13 pf the arduino card and the negative input pin GND to the gnd of the card as shown in the figure. */ //pin const byte vcnt = 13 //output pwm //variabili globali byte regolazione = 0 // contains the % value of the pwm on pin 13 int start = 0 // enable ignition of the regulator void setup () Schematics The accepted characters are only numbers (0 through 9). possible values for "xxx" are from 0 to 100. Possible answers: ENGINE on with speed regulation at xxx% ENGINE off with speed regulation at xxx% rxxx - set the speed regulation value at the xxx%. The commands accepted are: a - turn on the MOTOR s - switch off the MOTOR q - requests the status of the MOTOR. #Can arduino be used to control a forward and reverse motor serialBy connecting pin 13 at the entrance VCNT MST_K12 the positive and the negative input to GND GND of Arduino boards (MEGA), the controller may be controlled by sending commands via the serial monitor IDE dell'arduino with speed set to 9600. #Can arduino be used to control a forward and reverse motor code*CONTROL PROGRAM CONTROLLER MST_K12 WAY THROUGH SERIAL INTERFACE Code for piloting of MST_K12 speed regulator.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |