Working on my senior design project and looking for some advice. Please be patient as my background is mechanical engineering and I don't have a strong foundation of electronics/hardware and some prior experience with Arduino, but mostly on smaller project with an Uno.
To keep it simple, I am planning to use an Arduino Mega to control 2 DC motors and 2 solenoids with a motor shield. I was hoping to be able to used a USB wired Xbox 360 (off brand) controller to control the motors. My understanding is I would either need a USB Host shield to do this? (When the Arduino is running, it will not be connected to a PC so using the Serial port isn't really an option, but please correct me if I am wrong) Or I could take apart the USB connector and wire the pins individually?
My questions are, a.) do I need the USB host shield? b.) Can I use both the USB host shield and the motor shield at the same time? c.) Would all of this be easier/avoidable by using a different controller than can communicate another way (Bluetooth?) Any help is really appreciated. Please be patient with me! Eager to learn and hoping I am asking the right questions.
You need a shield for most Arduino board, but not every USB device is supported. You could also use a board with a USB host included (but don't buy the Due board). A Raspberry Pi is full computer, that is better for USB devices.
Can you get a analog controller with normal buttons ? That is easier to connect to an Arduino. You can always upgrade to something better.
b. do shields have a conflict ?
That is indeed the question. If you have selected the boards, then you have to painstakingly check every pin they use ! Sometimes pins can be shared, sometimes not.
c. using a different controller ?
Bluetooth is easier, but might be less reliable and the controller is not dedicated to the project.
Thanks for taking the time to reply. I cannot go into too much detail about the project as there is IP related to it. However, I will explain what I can:
We have not selected the motors at this stage. The two motors will really only need to drive in one direction. One motor is used to prime a spring loaded mechanism, where the solenoid is pulled in to allow the mechanism to release, and then later pushed out to re-prime the system. The other motor is used to pull in a cable/line. Another mechanism makes releasing the line without driving this motor possible, so no worries there. I had selected a motor shield (Adafruit Motor/Stepper/Servo Shield for Arduino v2 Kit [v2.3] : ID 1438 : $19.95 : Adafruit Industries, Unique & fun DIY electronics and kits), letting my partners know that any motor/solenoid we use cannot exceed 12V. As I mentioned before, at this stage we haven't definitively selected the components yet, so I can't say much about the stall current. Let me know if that's helpful and if there's anything else I could clear up. Again, thank you for any advice!
A motor can be for example nominal 1A and the stall current is 15A. Then the motor is sold as being a 1A motor, but a "driver" is needed that can handle 15A.
I can not visualize a picture of your project.
Do you want to make a gondola lift for 20 persons or do you want to transport a Oreo biscuit a few centimeters.
A DC brushed motor "driver" or "controller" is for speed control and turning in both directions.
Your project can perhaps be done with a few mosfets: https://www.adafruit.com/product/355.
You also need a fly-back diode and a few resistors.
It might be a good idea to make a prototype with an Arduino Uno and a four mosfets and a analog controller.
The Arduino Uno has PWM signals of about 500Hz, that is okay for most small projects.
Others want to get everything right and do all the calculations. I like to get to know a project and get some feeling for it by testing it.
I wish I could tell you more, but I am not allowed to say too much about the project itself. It is on the smaller scale, but larger than an Oreo. A relevant reference mass would be a 2 lb (roughly 1 kg) rock.
The difficulty is for this project I have to order all my parts using my college's approved vendors, get approval for parts, stick to a budget, etc. Unfortunately is it not quick or convenient, and testing different motors may not be feasible. I wish I could do things differently, but that's the way it is for me right now. I appreciate your help though!
You will need a Host shield since your ARduino and your game controller are HiD gadget devices. The host shield will let you make the Arduino look like a host device to the game controller gadget. I just purchased one for a project and it uses I2C to connect to the Arduino library. You will need to look at what pins the Motor Shield uses and if it uses I2C you could have a problem. But you said you only need to control 2 motors so you could use a L298N h-bridge which allows for controlling 2 motors upto 2A ea.
For the Host board I'm using this one which is 3.3V compatible because I'll be using a Leonardo (32u4) based board which is also a 3.3V board. If you use a 5V Arduino you'll need to put in voltage dividers on the I2C bus to drop 1.7V so not to blow the Host board I2C interface.
The Arduino Due board causes troubles. Adafruit had written on their website not to buy the Due board, but I think they have removed that.
The 1k5 pullup resistors to 3.3V for the I2C bus are too low, adding modules (which also have pullup resistors) quickly results in a combined pullup that is outside the I2C bus standard. The Wire1 bus has no pullup resistors.
It is the only Arduino board with a SAM3X8E ARM Cortex-M3 processor, so there can be bugs and compatibility issues with libraries.
There are a few more problems that I forgot.
It is a matter of laziness on my side. When someone adds a few I2C modules, then I have to explain to remove the onboard pullup resistors.
A value of 10k pullup is better than nothing and a few modules can be added without problem.
The SAMD21G M0+ processor is more often used, for example on most MKR boards.
Meanwhile I'm getting more and more fond of the Raspberry Pi Pico with the Arduino software layer on top of the Mbed software layer.
Let me ask a different question then. What would be the simplest way to control the motor controller through user input? I was planning on using something like an Xbox controller or joystick controller. What would be the easiest way for it to interface with an Arduino Mega? My background is not in electronics, so I want to avoid a complex setup as much as possible. If I could replace the USB wired controller with something else, what would be best?
I would love to tell you exactly what I am working on, as I know this would make it easier, but I cannot. I will do my best to describe the inputs I need without revealing too much:
One input will need to be to pick a "power level" and then release for the spring I mentioned before. Best comparison to this is pulling back a pinball machine, and then releasing. The user should be able to set the spring compression, power level, whatever you would like, and then press a button and release. It could be large discrete intervals like 1 to 10 or much more variable like 1 to 1000; either is fine. Another necessary input is directly driving one of the motors. It would need to be at variable speeds, which is why I liked the trigger of a gaming controller. Press a little, low speed; press a lot, high speed. A key element of the project is providing haptic feedback (vibrations) to the user, which is another strong case for a handheld controller.
Again, I appreciate everyone's patience and willingness to help. Any advice is appreciated!
Have you googled around for all the projects which are using the Arduino USB Host Shield? There are versions which plug directly into the Arduino and I would not be surprised to find some which operate servo's and other Arduino pins. FYI, there are some which use a Bluetooth dongle in the Host Shield to wirelessly connect a game controller to the Arduino.