No, you will need additional hardware (e.g. a current sensor). Note that the VNH2SP30 motor drivers included some versions of the Orangutan X2 have built-in current sensors, but the VNH3SP30 drivers do not.
An encoder alone won’t be sufficient for measuring motor power. When you said “power” in your opening post, did you mean the term literally?
One way to limit the output voltage of a motor driver to 6V is to power it at 6V. Another option would be to limit your maximum motor speed to something under 100%. For example, if your power supply is 12 V but you restrict yourself to motor speeds from 0 - 50%, the motor will never see an average voltage above 6V.
Our forum and our general resources page could be helpful. Other than that, the internet is full of resources, so it really is just a matter of figuring out what to search for.
yes, i meant “power”, but perhaps i could solve my problem also via an encoder-based solution, don´t you think so? i need to turn the motor-direction on the point where the motor “feels” a complete mechanical barriere at one “side”…
If you are trying to detect that the motor has hit something and has slowed down or stopped, then yes, you could do that with an encoder or a current sensor, but that’s not the same thing as measuring the power of the motor.
Power is current times voltage or torque times angular velocity. If your voltage is constant, you can say that power is proportional to current, but in practice, your voltage will not be completely constant. This is important to consider if you really are trying to accurately measure power.
puh, i´m afraid my technical english is not soo secure;-)
can you please help me finding the right terms for everything?
“Power” means the thing with the unit “A” for Ampere?
And Motor Speed goes along with the amount of “V” for Volts, is that correct?
What exactly is happening with these values in the following example?
lets say we have a constant mechanical resistant on my 6V motor. i want to drive it with exactly 6 V, so i program it with half speed, e.g. 125. correct? what is happening, when there is a higher mechanical resistant? the motor wants to keep the speed, so what is rising then? the voltage (V) and the (A)mperes? what can i measure in which way?
sorry for these queations, but i´m anewbie in this area, and my english is not fluent in technical terms, so its very nice to have a “real” person answering my questions, and not only “talking” with google;-)
i have a 12v power adaptor (its not a robot, but a fixed machine on a table…). it provides more A than the motor needs.
6V is just the upper limit, just because of the motors ideal Voltage-range (must not be that exact 6V).
i bought a current sensor, because my Orangutan X2 with VNH3 hasn´t got one onboard.
but how do i get the values? on an analog input? can i use the x2 function x2_get_motor_current() in my case, or is it only useful for the built in current sensor of the VNH2?
How you read it depends on the kind of output it has. What is your current sensor? If it has an analog voltage output, you can use the analog_read() function, which is described in the Pololu AVR Library command reference. The x2_get_motor_current() function only works with the X2’s that have integrated current sensors (i.e. the ones with VNH2SP30 motor drivers).
when i switch it on channel 0 (with no voltage plugged on the IP+ and IP-) and call the function print(analog_read_millivolts(0)); i get a value “2522”. when i unplug the current sensor i still have a value of “767”. is that ok? why are there some values, when there is “nothing” plugged?
Yes, that’s ok. You should not expect to read a meaningful voltage on a floating analog input, because there’s no reason to expect it to be at any particular value. You might read 767 because the ADC capacitor still has some voltage on it from when you had the sensor connected, or the voltage on the pin might be weakly affected by what’s going on with the neighboring lines. If you want an input to have a known default state when nothing is connected to it, you would typically use a pull-up or pull-down resistor (but these are rarely used with analog inputs).
ok, i understand. thats going to be no problem for my usage. can you please tell me a last thing: (i hope the question is not too stupid?) when i want tu measure the corrent eg. of motor on motor port 1 of my Orangutan x2, which pins go to te IP+ and IP- connection on my current sensor? i thought i could connect the two motor power cables to the IP+ and IP- pins. Is that an absolute nonsens? (Sorry, i´m an absolute newbie in that area and i´m kearning al ot by making al ot of mistakes at the moment;-)
… and one more question: i saw, that when i call the function x2_get_motor_current(1) i get some values, raising when i increase the motor speed, annd falling until near to zero, when i´m decreasing. are these “phantom values” or is it possible that my orangutan has a built in carrier sensor? i have a X2 VNH3, i thought only the VNH 2 has got this onboard functionality?
Don’t feel bad about asking questions; we were all beginners at some point. Also, it’s good that you’re asking before actually making your connections since connecting things wrong could destroy your board.
You need to put your current sensor so that the current you want to measure flows through it (e.g. in IP+ pin and out the IP- pin). One way to do this would be to connect your system as follows:
one motor driver output (e.g. M1A) to IP+
IP- to one motor terminal
other motor driver output (e.g. M1B) directly to other motor terminal
Does this make sense?
You could also measure the total system current by putting the current sensor between your battery and the board’s VIN:
Positive battery terminal to IP+
IP- to board VIN
battery ground to board ground
at free run at speed 20 it shows up something around 2500
when i suddenly try to stall the motor it goes down to 2350 , but the value increases, even when i still hold the axis.
the problem is, that this value sometimes nearly is also reached without blocking the motor.
the values and this behavior doesn´t change a lot when i try a higher speed. should not increase the current significantly when the motor is stalled?
do you think, my setting is correct?
what i´m trying to get is a secure feedback when my motor is blocked (or nearly blocked), in form of a significant change of some value. i thought it would be possible via the current measuring. what do you think?
Do you have a multimeter? If so, then I’d suggest you use that to measure your current draw and confirm that it matches what your current sensor is reading. In general, it sounds like your current sensor is working (the output is 2.5 V when the current is almost zero, and the output changes significantly when you stall the motor).
Note that the stall current will slowly decrease over time as you hold a motor stalled: as the motor heats up, the resistance increases, and the current drops. It sounds like you are observing this effect when you say “when i suddenly try to stall the motor it goes down to 2350 , but the value increases, even when i still hold the axis.”
The particular sensor you are using has a sensitivity of 167 mV/A if you are powering it at 5 V, so you can program your X2 to output the current in milliamps using the following:
set_motors(0,20); // you probably want to use a higher speed here
print_long(((long)analog_read_millivolts(0) - 2500) * 1000 / 167);
I haven’t tested it, but I think the above code will work.
thank you again. i have a multimeter and i measured the mA: on the multimeter it says -83,2 and during freerun it is sometimes variyng between -83,8 and -82,0. when i start to hold the axis it goes down to -130. motor still not stalled. and the value stays there.
i uploaded your code example to my orangutan, and at the same time as measuring on the multimeter (same mechanical condition!) my lcd on the orangutan says 71 during freerun, BUT jumping around like cracy between -161 and + 161. when i start to stall, it goes down to -200.
as you can see, the values on my amperemeter are quite precise, on the current sensor its very unstable and not secure enough for my usage. do you think the current sensor itself is not precise enough in the value range of 80mA? or am i doing something wrong?
so i still have no secure solution for getting the info, if my motor is (nearly) stalling. i thought, thats one of the standard-challenges for robot builders and not so hart to solve:-(. i tried to get an other solution via the buildt in encoder of this motor, but i´m not firm enough in programming a software based “rpm-sensor”. i posted this question in the software-forum. could you perhaps be so kind and post some hints for me there? thanks a lot!