Show Posts
|
|
Pages: [1] 2
|
|
1
|
Using Arduino / Motors, Mechanics, and Power / Re: Currently hating the currentsensing on MegaMoto Plus
|
on: March 11, 2013, 03:00:42 pm
|
|
Hi Lefty
Thanks for the response.
Regarding the brushes i doubt that they will cause that but i will try to bring my tachometer tomorrow so i can measure the RPM simultaneously - the thing is that it is a printed motor (aka. pancake motor) and they are extremely simple and have a very linear speed/torque characteristics. Could i be doing something wrong in my code? I am keeping one mosfet low and the other gets the PWM, it was my understanding that how it was done!
I may have been lost in translation regarding the second issue, sorry. What i meant is that if i turn the pot 2/3 of the way and wait, the Amps drawn (measurement generated from the code) shows a bit less than 1A - after it has settled. if i then start to turn the pot again, instead of drawing more amps, it starts to draw less!!!!! This can of cause not be true, because i can hear the motor increasing in speed........ And yes, i am turning the pot in the same direction ;-). Have i got a ghost haunting me or am i too stupid to see the obvious?
Best Regards
|
|
|
|
|
2
|
Using Arduino / Motors, Mechanics, and Power / Re: Currently hating the currentsensing on MegaMoto Plus
|
on: March 11, 2013, 04:29:10 am
|
|
OKAY - after wiring up the filter i connected it to the motor shield (very excited)...... and now now i was able to get a more stable reading, but there has shown to be 2 issues. 1) The motor seems to be drawing more current running one direction then the other - how is that possible? 2) The Amps drawn from the motor goes up rapidly in the beginning but then stabilizes somewhere just below 1 amp if i dont touch the pot - but if i continue to crank up the PWM the AMPS goes down to about 0.12A !!! THAT i dont understand!
|
|
|
|
|
5
|
Using Arduino / Motors, Mechanics, and Power / Currently hating the currentsensing on MegaMoto Plus
|
on: March 10, 2013, 06:35:23 am
|
HI someone. I have a problem i cant get rid of. I am trying to sense the current going through my dc motor, in order to control the Torque with a closed loop. The thing is that i cant seem to get the sensing working for me - i thought it was straight forward.... The MegaMoto Plus board (motorcontroller) has a build in 634Ohm resistor so the Arduino can read the voltage drop and thereby calculate the current running through the motor. Manual for the motorboard: http://www.robotpower.com/downloads/MegaMoto-user-manual.pdfit will return 3V at 40Amps i have connected a multimeter in series so i can check if the Arduino is calculating the correct current. 1) The reading is very jumpy - nothing like the multimeter i have connected. 2) the calculated current is way too low. When i first connected the motor, it started to "scream" when i was applying low PWM values. I got it to stop by changing the frequency to 32kHz - in the manual for the board it says the the maximum frequency for the board is 20kHz - i guess it will be switching at 20kHz even though the Arduino is running 32kHz? In the following script i have changed it to 7800Hz but that does not get rid of all the "screaming" but most of it. 3) Is there a way to run closer to 20kHz or can i just use 32kHz? 4) last question. I found that when running the motor at fairly high speeds but with no load, the MOSFETS got very hot - am i doing something wrong when switching??? Thanks a bunch for your help //****************Define variables************* const int pinPWMA = 6; const int pinPWMB = 5; const int pinENABLE = 8; const int pinTRANSDUCER = 2; // analog input (for now a POT) int pinCURRENT = A5;
int Setpoint; int Output;
float currentRAW; float currentVOLTS; float currentAMP;
//*************dfefine constanta************* float volt_per_amp = 0.075;
void setup() { //TCCR0A = 0x01; // Timer 2: PWM 3 & 11 @ 32 kHz TCCR0B = _BV(CS01); // timer 0: PWM 6 & 5 @ 7812.5Hz
pinMode(pinPWMA, OUTPUT); //Defining my outputs/inputs pinMode(pinPWMB, OUTPUT); pinMode(pinENABLE, OUTPUT); pinMode(pinTRANSDUCER, INPUT); pinMode(Setpoint, INPUT); pinMode(pinCURRENT, INPUT); Serial.begin(9600);
digitalWrite(pinENABLE, HIGH); delay(500); digitalWrite(pinENABLE, LOW);// Reset overcurrent or overtemp fault. May need to let the MegaMoto cool. delay(500); digitalWrite(pinENABLE, HIGH); }
void loop() { Setpoint = analogRead(pinTRANSDUCER); Setpoint = map(Setpoint, 0, 1023, -1000, 1000); //Converting value
if (Setpoint >= 0) { Setpoint = abs(Setpoint); if (Setpoint < 20) { // Dont do anything if value of setpoint is too low Setpoint = 0; } Output = Setpoint /3.92; //converts to 0-255 (PWM) digitalWrite(pinPWMB, LOW); analogWrite(pinPWMA, Output); Serial.write("You are now going right"); Serial.println(); } else { Setpoint = abs(Setpoint); if (Setpoint < 120) { Setpoint = 0; } Output = Setpoint/3.92; digitalWrite(pinPWMA, LOW); analogWrite(pinPWMB, Output); Serial.write("You are now going left"); Serial.println(); } currentRAW = analogRead(pinCURRENT); currentVOLTS = currentRAW *(3.0/1024.0); currentAMP = currentVOLTS/volt_per_amp; Serial.println(currentAMP); delay(10);
}
|
|
|
|
|
6
|
Using Arduino / Programming Questions / Re: How do i change direction
|
on: February 10, 2013, 12:45:04 pm
|
|
Of cause - i get it now.
After installing a button everything is working well. Now i have control of the speed and the direction of the motor. So i guess the next step is PID? or am i goint too fast again?
@PeterH You are probably right, but this is proof of concept on a patent. So i MUST build a system that works by reading a torque transducer and using that signal to apply torque (not position controlled) to the wheels on the road in order to make them turn.
|
|
|
|
|
7
|
Using Arduino / Programming Questions / Re: How do i change direction
|
on: February 10, 2013, 09:26:35 am
|
Thanks for the reply. Well, for PMDC motors the torque is proportional to current - the motor-shield i have, has an analog current sensor that provides a voltage to the Arduino. You can monitor this with the Arduino to give torque feedback as torque is equal to T=Kt*I, where T is torque, Kt is the motor torque constant, and I is the current. I need a linearly increasing output torque with respect to my input (torque transducer). const int pinPWMA = 11; const int pinPWMB = 3; const int pinENABLE = 8; const int pinTRANSDUCER = 5; // analog input (for now a POT)
int Setpoint = 5;
int CW = 7;
void setup() { pinMode(pinPWMA, OUTPUT); pinMode(pinPWMB, OUTPUT); pinMode(pinENABLE, OUTPUT); pinMode(pinTRANSDUCER, INPUT); pinMode(Setpoint, INPUT); pinMode(CW, INPUT); Serial.begin(9600);
digitalWrite(pinENABLE, HIGH); delay(500); digitalWrite(pinENABLE, LOW);// Reset overcurrent or overtemp fault. May need to let the MegaMoto cool. delay(500); digitalWrite(pinENABLE, HIGH); }
void loop() { if (digitalRead(CW) == HIGH) { digitalWrite(pinPWMB, LOW); digitalWrite(pinPWMA, HIGH); /*Setpoint = analogRead(pinTRANSDUCER); analogWrite(pinPWMA, Setpoint / 4); */ } else { digitalWrite(pinPWMA, LOW); digitalWrite(pinPWMB, HIGH); /*Setpoint = analogRead(pinTRANSDUCER); analogWrite(pinPWMB, Setpoint / 4); */ } Serial.write("Transducer input:"); Serial.println(Setpoint); delay(10); }
I am still having problems with the motor switching direction a few times when i connect CW to 3.3V (change direction) before "settling " in the correct direction. as you can see in the sketch i have tried with adjusting the speed and full speed. Also, when i get close to the pin with my finger, it does the same (switch direction) - do i need to add a pulldown or something to prevent that?
|
|
|
|
|
8
|
Using Arduino / Programming Questions / Re: How do i change direction
|
on: February 10, 2013, 08:12:38 am
|
|
@ Krodal
I am using the pins just as in the manual, and as you are describing.
For now i have added a pot as the torque transducer (it easier to test with) and the motor connected is not the one i will be using (see previous post).
|
|
|
|
|
9
|
Using Arduino / Programming Questions / Re: How do i change direction
|
on: February 10, 2013, 07:59:09 am
|
The project i want to end up with is this: I am trying to control the torque of a motor in both directions (CW & CCW) through MegaMoto Plus motor board: http://www.robotpower.com/downloads/MegaMoto-user-manual.pdfAnd the motor i want to control: http://www.pml.com.cn/ver2en/motors/GPM16LR.htmlThe control signal (signal into the Arduino) is a +-5V where - = CW and + = CCW rotation. This signal is generated by a torque transducer. As an input signal is given to the Arduino, the motor must produce a torque and continue to do so, even after the motor has stopped because the load is greater than the torque produced from the motor. You can think of it as a motor connected to a spring. When an input signal of eg. +2V the motor has to turn CCW with a torque 2/5 of maximum, hereby extending the spring - at some point the force from the spring will be the same as the torque/force from the motor and then then the system has reached an equilibrium. if you apply a higher input the motor will start turning CCW again and if you lower the signal the motor will unroll the spring until a new equilibrium has been reached. If no signal is provided the motor must become "loose" and the spring will be the only force (neglecting friction) in the system. Some will probably ask me why i dont just use a position servo so i will reveal right away that i need to control the torque, NOT the position. My guess is that i can use a closed loop servo approach, but instead of the feedback signal being a encoder it will be a current measurement. I want to use the current sensors in the motor shield hereby generating an error signal for the feedback loop. The error signal will result in a change in the PWM cycle in order to reduce the error so the produced torque will actually reach the desired value. Is that right? The system has to end up being a steer by wire system with haptic feedback. Because it will be a steering-mechanism it is important that there is no overshoot, thats why i think that the PID (or maybe PI only) is important to incorporate! I am learning every day, so please bear with me. Bjorn
|
|
|
|
|
11
|
Using Arduino / Programming Questions / Re: How do i change direction
|
on: February 09, 2013, 12:10:04 pm
|
|
I have some useful remarks: please delete the sketch. DONE I'm serious, you should make a fresh start.
You want to read input pins, use a motor shield, write a sketch, use a PID library (never easy).... all at once. Not even a advanced programmer would try this.
Forget the PID for now.
Try to get the motor running. How is the shield connected ? mounted on top of the Arduino (is that not the idea/function of a shield?) The motor should be connected to X1-1 and X1-2. What is that? You need an enable but also two PWM outputs PWMA and PWMB. Write a sketch that makes the motor run, nothing else.
To declare an output pin, use this: const int pinname = 10; Not a 'double'.
Write to the serial monitor what you are doing, like this: Serial.println("Forward for 5 seconds");
Use delays between the actions, and let the motor run forward, backward, slow, fast.
After that, read the input pins.
After that, you could try the PID.
|
|
|
|
|
12
|
Using Arduino / Programming Questions / Re: How do i change direction
|
on: February 09, 2013, 11:29:29 am
|
Post my code........ hmm.. okay, you asked for it. I am very new to this (Arduino and code in general) so please leave me with some useful criticism that can help me get better. What happens when loading this to the Arduino, is that the motor will spin in one direction (the initial one), but if i try to change direction the motor acts like a brake (the motor leads are shortened) and stay this way. Here it is: #include <PID_v1.h>
//Define Variables we'll be connecting to double SetpointPin = A5; //Setpoint from transducer double InputPin = 0; //Feedback signal double OutputPinCCW = 3; // OutputCCW (PWM) double OutputPinCW = 11;
double Setpoint = 0; double Input = 0; double Output = 0;
int ENA = 8; int CW = 7; //clockwise
//Specify the links and initial tuning parameters PID myPID(&Input, &Output, &Setpoint,2,5,1, DIRECT);
void setup() { Serial.begin(9600); //Opens serial at 9600 bps //initialize the variables we're linked to pinMode(InputPin, INPUT); //are these necessary? pinMode(SetpointPin, INPUT); pinMode(OutputPinCCW, OUTPUT); pinMode(ENA, OUTPUT); //turn the PID on myPID.SetMode(AUTOMATIC); }
void loop() { digitalWrite(ENA, HIGH); // Leave on HIGH if (digitalRead(CW) == HIGH) { Input = analogRead(InputPin)*2; //returns voltage*0.5 if full H-bridge config Input = map(Input,0, 611, 0, 1023); //input ranging from 0-3V, converting to 0-1023 Setpoint = analogRead(SetpointPin); myPID.Compute(); analogWrite(11, Output); } if (digitalRead(CW) == LOW){ Input = analogRead(InputPin)*2; Input = map(Input,0, 611, 0, 1023); Setpoint = analogRead(SetpointPin); myPID.Compute(); analogWrite(3, Output); //Output (PWM) on pin 11 }
Serial.write("OUTPUT:"); Serial.println(Output); Serial.write("Setpointet er:"); Serial.println(Setpoint); Serial.write("Inputtet er"); Serial.println(Input); delay(2); }
Thank you for your time, cant wait until i will be the one helping others out.
|
|
|
|
|
13
|
Using Arduino / Programming Questions / How do i change direction
|
on: February 09, 2013, 10:03:24 am
|
|
Hi. I have a question - might be trivial. I am on my way to control a motor in both directions, using a MegaMoto shield. The thing is - changing direction is done by changing the PWM-outputpin, but when i do that, the old outputpin is still HIGH thereby making the motor act like a brake. So i need a way to flip between the pins and at the same time setting the last used as LOW. I have of cause tried adding a line of code at the end, changing both pins to low, but that seems like it is adding a lot of delay to the system and also making the motor change direction a few times before rotating in the desired direction. the same goes for adding a pull-down.
Thank you.
|
|
|
|
|
15
|
Using Arduino / Motors, Mechanics, and Power / Re: Closed loop bi-directional torque control of DC motor!?!
|
on: January 29, 2013, 12:21:42 pm
|
|
Thanks for the reply. Well, for PMDC motors the torque is proportional to current - the motorboard i have has an analog current sensor that provides a voltage to the Arduino. You can monitor this with the Arduino to give torque feedback as torque is equal to T=Kt*I, where T is torque, Kt is the motor torque constant, and I is the current. I need a linearly increasing output torque with respect to my input signal - i am "just" having a hard time writing the code.
As i said i am completely new to both Arduino and quite new to programming in general. I am studying ME so hopefully i will be able to get my head around it with a little help.
|
|
|
|
|