Quantcast
Channel: Wicked Device Support - Latest posts
Viewing all articles
Browse latest Browse all 651

Motor Shield - Servo Set Up (Sketch)

$
0
0

My Results:

A - Six micro servos are hooked up to proper pins per instruction card.
B - USB remains connected to Arduino during operation and Serial Monitor window up to see channel activity.
C - 11.1 vDC battery hooked up to base Arduino board.**

1 - M4 servo erratic - pulsing movement of a degree or so. When a delay command was utilized (either at end of code or under Serial.print, it slowed the serial monitor display, as well as the small pulsing movement in the servo but does not eliminate it. It did slow the reaction time from Tx to servo an equal amount.

2 - M4 responds to only one r/c Tx channel (of two) with 180 deg movement. M3 moves about 30 degrees after slight delay, one direction and then returns to home when stick on r/c Tx is home. Switching channels or removing one has no effect.

3 - Motor Shield on/off switch has no effect (not that is should).

4 - Removing EXT jumper renders disabled (my power setup is 11.1 vDC to Arduino, nothing to shield.**

5 - Removing jumpers at Analog 0,1,2,3 has no effect.

6 - Removing jumpers at J5, no effect. Removing jumper at C2 disables everything. Remove other jumpers has no effect.

7 - Pressing Arduino reset button stops servo hunting, but gear chatter (voltage or signal bleed can be heard).

8 - Checked the constrain command against other servo scripts, seems to match what others are writing.

9 - Added language to include 4 more servos to sketch at all points in code: at 'int val_', at servo_.write, at servo_.attach (can't figure out what pin value to put in the parenthesis). Result: M4 and M3 super erratic. Still same Tx response.

10 - Wrote this code to the IDE and uploaded it. The result....

+++ ARDUINO STARTED SMOKING AND ARCING AND BURNED UP. TWO SERVOS ARCED INSIDE OF CHASIS AND ALSO BURNED UP. ALL COMPONENTS NON FUNCTIONAL AND MY BASEMENT SMELLS LIKE BURNING ELECTRONICS. +++

I'm way out of my league here. I am burning and expolding the board and my servos. I'm seriously stupid about this stuff and I don't want to burn my laptop through the USB cable (would be my luck). Your thoughts would be interesting to hear on this. I know you are probably super busy doing real work and you are the only tech supporting this forum and the threads inclusive. I bought two of these WD 4 Motor Shields and two UNO's as well as four servos in hopes to control multiple components (motors and servos) for a new r/c product I want to bring to market. I paid $275 for the lot and I return them to MicroCenter (minus the burned up gear) if the idea is a lost cause.

I still appreciate your support on my thread and many others. You are getting back to folks on the WD forum and that is super cool. Everything is a lesson in life; right? Here's the fire starting code lol:

#include <math.h>
#include <WickedMotorShield.h>
#include <Servo.h>

WickedMotorShield m;
long ch1;
long ch2;
const int timeout = 25000;

Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
Servo servo5;
Servo servo6;

void setup() {
  Serial.begin(115200);
  Serial.print("Hello World!");
  
  servo1.attach(5);  // servo1 on M3
  servo2.attach(10); // servo2 on M4
  servo3.attach(9); // servo2 on x
  servo4.attach(11); // servo2 on x
  servo5.attach(3); // servo2 on x
  servo6.attach(6); // servo2 on x
}

void loop(){
  //STEP 1: Read in the RC values
  ch1 = m.getRCIN(RCIN1, timeout);
  ch2 = m.getRCIN(RCIN2, timeout);

  Serial.print(ch1);
  Serial.print("\t");
  Serial.println(ch2);

  // STEP 2: 
  // pass through the RC input to one or more Servos of your choice
  // first constrain ch1 and ch2 to the range of 1000 to 2000
  ch1 = constrain(ch1, 1000, 2000);
  ch2 = constrain(ch2, 1000, 2000);

  // the servo write function wants an integer between 0 and 180
  // with 90 corresponding to no movement / neutral position (and which should be a 1.5ms pulse)
  // so we need to map the ch values back to this range from milliseconds
  int val1 = map(ch1, 1000, 2000, 0, 180);
  int val2 = map(ch2, 1000, 2000, 0, 180);
  int val3 = map(ch1, 1000, 2000, 0, 180);
  int val4 = map(ch2, 1000, 2000, 0, 180);
  int val5 = map(ch1, 1000, 2000, 0, 180);
  int val6 = map(ch2, 1000, 2000, 0, 180);

  servo1.write(val1);
  servo2.write(val2);
  servo3.write(val3);
  servo4.write(val4);
  servo5.write(val5);
  servo6.write(val6);
  
  // you could write to additional servo objects here as well
  // for example to drive multiple servos from the same RC control input

Viewing all articles
Browse latest Browse all 651

Trending Articles