How do I control 4 motors with pc

I'm currently building an ROV being driven by 4x Marine Electric Bilge Pump 12v 1100gph for Boat, Caravan, Rv - Five Oceans. I want to use a gui or a 2 x USB GamePad Game Controller JoyPad for PC Computer Joystick to make it remotely operated. I'm using the ZITRADES (TM) 16-Channel 12V Relay Module for Arduino DSP AVR PIC ARM as a relay board. Is this possible? I'm not very good at coding, but I can edit basic commands.

camstarnight:
I’m not very good at coding,

You will be when you have this working :slight_smile:

Start by working through the examples that come with the Arduino IDE and which are relevant to different parts of your project - controlling motors, reading potentiometers, communicating with a PC, etc. Treat each of them as a separate learning exercise and only bring things together when you are familiar with the parts.

This Thread planning and implementing an Arduino program may help.

…R

You have not provided any of the critical Intel needed for this project. If you are serious about it you need to post the motor ratings in Amps. You have not mentioned what you plan to use for a motor controller. Do you know that ? What documentation have you got for the controller ? How did you envision this taking place ? Are you expecting to find all the answers here? Can you tell us what you are asking us for ? (can be more specific as to what role we play? You stated your idea. I hesitate to call it a goal since you are asking if it is possible. The motor cotrol ix certainly possible but I fail to see where the relays come in unless that is your idea of a motor control. Would you try to drive a car with just a clutch and no transmission? I'm not saying it won't work but it could be problematic. A proper motor controller for motors that size ( current unknown) could be costly unless you are only interested in using the relays and don' t care if the motion is jerky.

I'm planing to use an Arduino Mega. The 1100 gph pumps pull 1.7 amps with no stall. The relay board I realize is digital, which I'm fine with. The relay board can switch 30V/10AMPS with 5V/.25A and I plan to use a 12V/8A lead acid battery. Is it possible to control with a joystick using only arduino code or do I have to integrate it with python? I would just like to know if it's possible so I don't spend days on code that won't work.

You can't use ON/OFF control (relay bd) with analog pots (joystick= two pots) It's apples and oranges. If you had a real motor speed control it would be simple using the Map function but as it is a moyor is either on or off , which makes a joystick inappropriate. You might as well have one forward / reverse toggle that power left and right motors and teo push buttons to turn left and right that cut power to left or right motor causing it two pivot on thst wheel. You ARE talking about a land vehicle and not a water craft , right ?

camstarnight: I'm planing to use an Arduino Mega.

...

Is it possible to control with a joystick using only arduino code or do I have to integrate it with python?

What's Python got to do with it - controlling 4 motors is perfectly possible with a Mega, and so long as the joystick is analog rather than USB it can read that too!

All the codes that I see to interface to a usb device without a usb shield require python to work with arduino code

camstarnight: All the codes that I see to interface to a usb device without a usb shield require python to work with arduino code

You can certainly get joysticks with USB interfaces for connecting to a PC.

For an Arduino it is far easier just to connect the Joystick potentiometers directly to the the Arduino analog inputs. Either buy a joystick that has no electronics or strip the electronics out of a USB joystick.

...R

I would prefer not to take apart the joystick beccause the arduino is about 50 feet away underwater. The joysticks also have the option where you can switch between analog and digital signals.

PS2 controllers are basically SPI and there are libraries for interfacing to them, quite a nice way to do things I think (they are also available in wireless versions for approximately a very small amount of money). But not as linear as a good joystick.

You have not posted the Design Criteria that outlines how the joystick would control relays. As already pointed out, joysticks are analog, relays are digital ON/OFF. There is no standard we can google for what you are trying to do so until you post a Truth Table that explains how a variable device (joystick) would control a simple ON/OFF device (relay) , we still do not know how you expect this to work. Please post a reference table or list that correlates joystick position to relay control.

What I want the arduono to do If analog stick(AS) is half maximum then relay =on. The joystick has both an analog and digital mode and the digital mode is basically this code

A joysick is nothing moe than two pots in a gimble. I don't know what you mean by a digital mode but there was no code.

It greatly differs from USB device to USB device in how to interface with it.

Every USB device will have a control chip behind it to send and receive data. Every chip in theory could use different registries or different data communication protocols.

There are many standardized protocols so that it can be easy to talk to and use the USB devices among large name brand products, or someone simply hacked it and figured out what that protocol was.

In a lot of products like mice or keyboards, windows can use a default driver to be able to talk to it. In some cases by installing the driver you can unlock additional features because they tell the system how to access them and control them where previously it had no idea.

With something like a camera you need to install the drivers cause its a completely unknown device with no previous compatibly.

You can't even use arudino for code upload or serial monitor without installing the the drivers.

I know arudino/atmel chips can do this, but you need to know your coding and how to interface with the chip.

I took apart the controller and it has several chips with the names in japanese and I would prefer not to take apart the controller and connect it to the arduino directly.

camstarnight: I took apart the controller and it has several chips with the names in japanese and I would prefer not to take apart the controller and connect it to the arduino directly.

By FAR the simplest thing is to get another joystick that you don't mind taking apart and just connect the potentiometers directly to the Arduino.

...R

Because this is an ROV and the cable is 50' from joystick to arduino and I have a 50' USB extension, It seems easiest to go from joystick to pc to Arduino.

camstarnight: Because this is an ROV and the cable is 50' from joystick to arduino and I have a 50' USB extension, It seems easiest to go from joystick to pc to Arduino.

I hadn't realized you were thinking of connecting the joystick to the PC and using the PC to send the X/Y values to the Arduino. You will have two USB interfaces getting in your way - Joystick - PC and PC - Arduino so you may find a significant delay in transferring the data. USB is good at sending large volumes of data at high speed. It can be very slow with small packets of data. I presume you would need to write software for your PC so it can detect the joystick movements and pass them to the Arduino.

Performance would probably be much better if you connect a stripped down joystick to one Arduino and use that to pass data to the ROV.

...R

I took apart the controller and it has several chips with the names in japanese and I would prefer not to take apart the controller and connect it to the arduino directly.

One of the chips is a USB chip for data communication, what the others are doing are most likely ADC chips and then somehow saving there values into data registers for transmission threw USB on request.

Long story short, unless you know your coding and can find a data sheet that tells you what registers the device uses and what each of those registers do (protocol settings, raw data, calculated data…). You will probably have a better chance of flying a pig to the moon and back then getting any useful data from that joystick threw a USB connection.

That said perhaps if your lucky the pot wires can be de-soldered and you can just by pass the control board without removing it. If you can find pins or points on the board that vary in voltage as you move the joystick you might be able to solder wires to them. The risk is you parallel the signal with something else and either make it to weak to be of use or damage the control board in the joystick.