0

I was working on controlling a high power motor with a heavy duty motor controller, and I was able to make my motor spin, but I wasn't able to incorporate a program for my pressure sensor and make it determine the speed of the motor. I'm pretty sure I connected the parts correctly on my circuit board, so I figure my code must have some mistake, or something missing. The pressure sensor I'm using: The motor controller I'm using: http://www.robotshop.com/en/arduino-compatible-mega-motor-shield-1a-5-28v.html#Useful The code I have:

int motorValue=0;
int sensorValue=0;
int sensorPin=A0;
int EnablePin=8;
int PWMPin2=3; 

void setup() {
  // put your setup code here, to run once:
pinMode(EnablePin, OUTPUT);
//pinMode(sensorPin, OUTPUT);
Serial.begin(9600);
pinMode(PWMPin2, OUTPUT);
pinMode(sensorPin, INPUT);
}

void loop() {
// put your main code here, to run repeatedly:
sensorValue = analogRead(sensorPin);

//float voltage = sensorValue * (5.0 / 1023.0);

//Serial.println(voltage);

delay(50);

motorValue=map(sensorValue,0,1023,0,255);
//motorValue=sensorValue / 4;
//analogWrite(motorPin,motorValue);
digitalWrite(EnablePin, HIGH);
analogWrite(PWMPin2, motorValue);
}

Edit: The sensor works by reading the voltage. Here's an actual picture of how I wired it: Here's how I wired it I used this wiring to print out the voltage with just the Arduino and it worked, and I'm using it with the same wiring but while having the motor shield on top, so that's why I'm guessing that I must not be programming the sensor right with the motor controller. I couldn't get the voltage readings when I used this setup with the motor driver shield.

  • "I'm pretty sure I connected the parts correctly" - You may be pretty sure, but we aren't certain at all. Can we maybe see what you have wired up and how it is all connected? – Majenko Mar 14 '16 at 11:45
  • Besides adding a schematic and a photo, you might explain how or why motor speed is related to "pressure" in your setup. Ordinarily, speed is sensed using an encoder, or a tachometer, or a Hall sensor, or voltage readings, etc. rather than "pressure" – James Waldby - jwpat7 Mar 14 '16 at 16:23
  • This won't make a difference but the ground and 5V from the arduino are not going to the correct spot on the breadboard. Change that to keep things standard, as if there were polarized parts there they would be dead. Also where does the red line go from the side of the flex pot? – RSM Mar 15 '16 at 4:39
  • I changed the polarity of the ground and the 5V, but it didn't seem to make a difference, as you stated. I had the red wire going to negative in the picture, but now it's going to the positive. The odd thing I noticed; I got tiny voltage readings when I pushed on the sensor, but much lower than they should have been, like 0.01-0.05, when it should've been more like 1 to 5 given how hard I was pushing. So some voltage must be getting through, but somehow not enough. – Tom Mar 15 '16 at 15:47
  • How about uncommenting the logging code so you can see what it is reading with the motor shield installed and being commanded. Also make sure that the motor shield doesn't wire something to A0, either as a control signal or as potential feedback (motor current sense, for example). – Chris Stratton Mar 15 '16 at 19:34
0

Depending on the jumper settings, the MegaMoto shield will drive current sense voltages onto one or two of the Arduino analog inputs.

Your picture shows the shunt installed to drive A0, which is of course going to conflict with your attempt to use the same pin for the force sensor.

If you are not using current feedback, it seems like you may be able to just remove that jumper, otherwise you will need to pick distinct pins for the current sense and your force sensor. Consult the manual to be certain.

(The other placement of the other jumper in that block looks a bit suspicious too, almost seems it may be shorting the two current sense channels together, but not certain about that)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.