I would like to use the arduino Mega 2560 to control the speed of all three motors and change it accordingly with the change I get in the Grove gyroscope+accelerometer. The whole system should be able to balance itself by changing the speed of eah motor in each of the three axis and at the same time, there is also be a light sensor and the board should rotate to follow the light.
Plan:
Basically, I am working with a governement agency and we would like to build the setup to teach kids about conservation of angular momentum as well as about satellite. I have some theoritical and programming knowledge but will be needing a lot of help and so I am submitting my request for help to all of you at the forum.
The first roadblock that I have now is that the speed control on the driver mentioned above, is analog control with 0-5V DC with 1024 resolution. From my understanding, the speed of the motor will change with the DC voltage. Is this correct? If so, how would I be able to control the output voltage of the arduino through a program on the arduino so that I can get the speed to change according to change in sensor reading. I have read about digital potentiometer and think that this might be the solution but would like to get second opinions. Also, can the potentiometer give a resolution of 1024?
However, there is a more expensive alternative that was proposed to me from the Maxon sale representatives. The drive (http://www.maxonmotor.com/medias/sys_master/8801022869534/12_290_291_292_EN.pdf) is programable and has monitor functions also and look quite reasonable but I am not sure whether it will be controllable by arduino.
I have to purchase the equipment in the next few days (2 to 3 days) and would really like some feedback, help, recommendation and any other ideas that you may have.
You will need to be able to drive three motors and be able to reverse each one.
Each motor would need an H-bridge driver to achieve this.
There are Arduino shields commonly available that support two H-bridge outputs. I understand there are some that support more but I'm not familiar with them, and you would need to locate one of these.
The most important criteria will be choosing the flywheel size, speed range and maximum torque required. This will determine the motor size and gearing needed, which will determine the power requirements of the motor, which will determine the spec of the motor driver and power supply.
I'm not sure how difficult it will be to achieve the 'light tracking' capability. I can't think of any easy way to achieve this on the Arduino itself, although perhaps others can. If you're allowed to tether this to a PC then the problem gets much easier since you can use a web cam and some trivial software on the PC to steer the web cam (by accelerating your flywheels) to keep the light source centered. This would also enable you to use an off-board power source which would make things lighter and easier.
You would control the motor speed using a Pulse Width Modulation (PWM) signal from the Arduino. This turns the motor on and off a few hundred times a second and by varying the proportion of 'on' time to 'off' time you can control the power output of the motor. This is perfectly straightforward to implement and is used all over the place. All you need to do is choose your motors, power supply and motor and locate a suitable motor driver.
Edited to add:
Do you really need three degrees of freedom? It seems pointless trying to rotate the device since your light source tracking algorithm does not define 'up' so you could arguably get away with two flywheels. If the device is going to be suspended in a way that keeps it the right way up, then it would only have one degree of freedom. I guess you'd be mounting it in gimbals, though, in which case you would need at least two degrees of freedom and perhaps three. As a proof of concept, you might consider just getting a UNO and standard dual output motor drive shield, some geared motors and heavy wheels from a wheeled robot kit, and strap a USB webcam to it. The hardware might not be suitable for your finished product but would demonstrate the principles without much investment of time or money.
From my understanding, the speed of the motor will change with the DC voltage. Is this correct?
Yes, if that's what the datasheet says.
If so, how would I be able to control the output voltage of the arduino through a program on the arduino so that I can get the speed to change according to change in sensor reading.
Yes and no. Your arduino is a digital device so it outputs natively a digital signal ('0' or '1'). It can output an analog signal, via some outside help, like a dac, or pwm + low-pass filter, or a digital pot, etc.
I have read about digital potentiometer and think that this might be the solution but would like to get second opinions. Also, can the potentiometer give a resolution of 1024?
They would work in general. In practice, they don't go to 1024 steps - typically 100 - 200 steps max. That may not be an issue. If it is, you can always use a dac (even a r2r network).
However, there is a more expensive alternative that was proposed to me from the Maxon sale representatives. The drive (Maxon 500 Error Page) is programable and has monitor functions also and look quite reasonable but I am not sure whether it will be controllable by arduino.
It looks to have digital and analog input so you may want to talk to the vendor about more specifics.
Either way, the modules are certainly capable of doing what you wanted them to do, and much more (particularly the 2nd one). Much less expensive modules can serve you needs - like a mosfet or a bjt switch.
Just to clarify some points in dhenry's reply, you don't need or want an analog DC output and you don't need or want to use a potentiometer to achieve one. That would be complicated, hugely inefficient (any voltage not delivered to the motor is dissipated as heat in your driver) and requires an expensive driver capable of directly controlling that much current and heat. This is simply the wrong way to tackle the problem.
To control the speed of the motor you just need to turn it on and off rapidly using pulse width modulation, and the Arduino has the capability to generate that sort of signal built in. You would just call analogWrite() with an argument giving the required speed, and the Arduino and your H-bridge driver would do the rest for you.
If you only wanted to drive the motor in one direction, you could achieve that just using a suitable transistor. Since you want to drive it in both directions, you need what is known as an H-bridge circuit consisting of four transistors able to drive each leg of the motor in either direction. These are readily available for low current+voltage applications and not expensive.
Thank you Peter and Henry for your advices. I had a look at the H-bridge as recommended by peter but, in my humble opinion, I do not think it will work as the motor is a brushless DC motor with hall sensors for feedback. I would have to build the whole driver board if I do not purchase the driver that comes with the motor.
I have purchased the second driver as mentioned in the first post as it could be control by digital signal and analog signal and am hoping that it will work like controlling a servo but will only know more once I get the motor, the driver and the corresponding manuals...
I would like the project to be self-sufficient and not connected to a PC and am looking at using solar panels or light detecting resistors (LDR) as sensors for the light-follower section. The aim is to only follow the light by changing the orientation not position.
Well, thank you everyone for their response and I will post more of the project when I have the equipments as well as when I have it up and running(hopefully)..
holypiston:
I had a look at the H-bridge as recommended by peter but, in my humble opinion, I do not think it will work as the motor is a brushless DC motor with hall sensors for feedback.
You are right. The H-bridge driver approach is aimed as motors that are powered and controlled by simple DC. If you are using a brushless motor then you will need a compatible driver for that motor, and then control that driver using whatever mechanism it provides. Ones designed for use in models typically accept a pwm of the sort used to control an RC servo,and there are Arduino libraries to generate this type of signal.