Jump to content

niksen

Members
  • Content Count

    3
  • Joined

  • Last visited

  1. Hello, i would like to control servo with web interface, but instead of turning up/down/right/left with buttons use JS or flash drag'n'drop joystick (http://www.codeproject.com/Articles/594186/Create-a-Cross-browser-Touch-based-Joystick-with-H). Is there any tutorials on this topic? Thanks in advance, Alex
  2. niksen

    Servo control

    Guys, thanks for answers. Here is my small and simple code for Energia: It should wait for key pressed with ASCII 44 and move servo connected to 9 pin 180 degree. It actually moves Servo, but then Serial Monitor is not responsible - Energia is crashed, no compiling errors. Please help #include Servo myservo; // create servo object to control a servo // a maximum of eight servo objects can be created int pos = 0; // variable to store the servo position int moveServo = 0; void setup() { myservo.attach(9); // attaches the servo on pin 9 to the servo object Serial.begin(9600); } void loop() { if (Serial.available() > 0) { // read the incoming byte: moveServo = Serial.read(); if (moveServo == char(44)) { //myservo.write(50); Serial.println("44 is pressed"); for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees { // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } } } }
  3. Hello, my name is Alex and i'm MSP430 beginner. I would like to controll 2 servo from my MSP board. Before i have experience with Arduino, so i'v donwloaded Energia software and was trying to compile Arduino Code to get it work on MSP430 - but still no luck. I saw couple of examples of Servo controll code on this forum but i guess they can not be compiled through Energia. this include - was wondering me. Please advice from where to start to build Servo control from MSP430 board. Here is my code for Arduino project that works well, but not on MSP430 board: #include Servo servo1; Servo servo2; int minPulse = 600; // minimum servo position int maxPulse = 2400; // maximum servo position int turnRate = 40; // servo turn rate increment (larger value, faster rate) int refreshTime = 20; // time (ms) between pulses (50Hz) int ledPin = 13; //laser stick /** The Arduino will calculate these values for you **/ int centerServo; // center servo position int pulseWidthServo1; int pulseWidthServo2; // servo pulse width int moveServo; // raw user input long lastPulseServo1 = 0; // recorded time (ms) of the last pulse long lastPulseServo2 = 0; void setup() { servo1.attach(2); servo2.attach(7); centerServo = maxPulse - ((maxPulse - minPulse)/2); pulseWidthServo1 = centerServo; // Give the servo a starting point (or it floats) pulseWidthServo2 = centerServo; pinMode(ledPin, OUTPUT); digitalWrite(ledPin, HIGH); Serial.begin(9600); Serial.println(" Ready"); Serial.println("Press < or > to move, spacebar to center, M, N to move up/down"); Serial.println(); } void loop() { // wait for serial input if (Serial.available() > 0) { // read the incoming byte: moveServo = Serial.read(); // ASCII '<' is 44, ASCII '>' is 46 (comma and period, really) if (moveServo == 44) { servo1.write(pulseWidthServo1 = pulseWidthServo1 - turnRate); } if (moveServo == 46) { servo1.write(pulseWidthServo1 = pulseWidthServo1 + turnRate); } if (moveServo == 32) { pulseWidthServo1 = centerServo; } if (moveServo == 32) { pulseWidthServo2 = centerServo; } if (moveServo == 77) { servo2.write(pulseWidthServo2 = pulseWidthServo2 - turnRate); } if (moveServo == 78) { servo2.write(pulseWidthServo2 = pulseWidthServo2 + turnRate); } // stop servo 2 pulse at min and max if (pulseWidthServo1 > maxPulse) { pulseWidthServo1 = maxPulse; } if (pulseWidthServo1 < minPulse) { pulseWidthServo1 = minPulse; } // stop servo 9 pulse at min and max if (pulseWidthServo2 > maxPulse) { pulseWidthServo2 = maxPulse; } if (pulseWidthServo2 < minPulse) { pulseWidthServo2 = minPulse; } // print pulseWidth back to the Serial Monitor (uncomment to debug) Serial.print("Pulse Width Servo1: "); Serial.print(pulseWidthServo1); Serial.println("us"); // microseconds Serial.print("Pulse Width Servo2: "); Serial.print(pulseWidthServo2); Serial.println("us"); // microseconds } } Error i receive is: core.a(TimerSerial.cpp.o): In function `TimerSerial__TxIsr': /Applications/Energia.app/Contents/Resources/Java/hardware/msp430/cores/msp430/TimerSerial.cpp:202: multiple definition of `__isr_9' Servo/Servo.cpp.o:/Applications/Energia.app/Contents/Resources/Java/hardware/msp430/libraries/Servo/Servo.cpp:87: first defined here collect2: ld returned 1 exit status Please advice
×
×
  • Create New...