Yea i don't plan to download a movie under the water so that is reassuring!Bennachie wrote:Presumably you are talking about Ethernet, which has data rates of 10Mb, 100Mb or 1Gb, depending on your network.fryslan76 wrote:UTP has a max distance of 100m with Cat 5 cable. Practical with interference it is a bit lower around 80m is the max I managed in a network setup with good cable, but interference of lamp transformators.
We are talking about data signals at 9600baud to 118.2kb (~0.01Mb to 0.1Mb). They will travel MUCH further.
Arduino/Teensy transmitting over RS485?
Re: Arduino/Teensy transmitting over RS485?
Re: Arduino/Teensy transmitting over RS485?
I'm having a hard time understanding this and am looking for a push in the right direction. I'm sure you will be able to tell from the question that I'm new at most of this.
I've read through the info and have done a simple set up example as found on the internet to control a servo using a potentiometer and adapted it to a joystick I'm using for my project but I'm lost on how to send/receive data from multiple sources (2 joysticks) to control brushless motors (forward-reverse)?
I was starting a setup using PWM and it was looking promising but I would end up using too many wires in the Cat 6 cable so this RS485 looked to be the solution but as I said I can't figure out how the arduinos distinguish between forward, reverse, up, down joystick data??
Can someone turn the light bulb on for me?
Thanks
Ken
I've read through the info and have done a simple set up example as found on the internet to control a servo using a potentiometer and adapted it to a joystick I'm using for my project but I'm lost on how to send/receive data from multiple sources (2 joysticks) to control brushless motors (forward-reverse)?
I was starting a setup using PWM and it was looking promising but I would end up using too many wires in the Cat 6 cable so this RS485 looked to be the solution but as I said I can't figure out how the arduinos distinguish between forward, reverse, up, down joystick data??
Can someone turn the light bulb on for me?
Thanks
Ken
Re: Arduino/Teensy transmitting over RS485?
Hi Ken,
Are you using an arduino topside and in the ROV? In that case you could send not the PMW signal over the line but a string representing the command you want the ROV arduino to execute. Topside says PWM11-1024 meaning fullspeed on PWM port 11 in the ROV, you would need only one communication channel then but you have to translate the received command strings in the ROV arduino to PWM signals.
Are you using an arduino topside and in the ROV? In that case you could send not the PMW signal over the line but a string representing the command you want the ROV arduino to execute. Topside says PWM11-1024 meaning fullspeed on PWM port 11 in the ROV, you would need only one communication channel then but you have to translate the received command strings in the ROV arduino to PWM signals.
Re: Arduino/Teensy transmitting over RS485?
Hello fryslan76
Thanks for the suggestion.
Initially I was only going to use an onboard arduino only but was concerned about the number of wires I would take up in the CAT 6 cable (I have 2 forward, 2 reverse and 2 ascend/descend thrusters) and then I read about the RS-485 and thought that would save me wires for other uses so I purchased the boards and got an example of a potentiometer controlling a servo functioning and adapted my joystick to it and I can control the servo fine.
The program outputs the joystick data to the serial monitor so I can see the changing readings but I’m trying to read the other half of the joystick for reverse but couldn’t figure out how to split the data into 2 separate commands to send to 2 different ESC’s. Once I understood that I think I could adapt the concept for the rest of the thrusters?
Thanks for the suggestion.
Initially I was only going to use an onboard arduino only but was concerned about the number of wires I would take up in the CAT 6 cable (I have 2 forward, 2 reverse and 2 ascend/descend thrusters) and then I read about the RS-485 and thought that would save me wires for other uses so I purchased the boards and got an example of a potentiometer controlling a servo functioning and adapted my joystick to it and I can control the servo fine.
The program outputs the joystick data to the serial monitor so I can see the changing readings but I’m trying to read the other half of the joystick for reverse but couldn’t figure out how to split the data into 2 separate commands to send to 2 different ESC’s. Once I understood that I think I could adapt the concept for the rest of the thrusters?
Re: Arduino/Teensy transmitting over RS485?
maybe post some output and code and a schema so people can help you.
Re: Arduino/Teensy transmitting over RS485?
fryslan76
I'm afraid I don't have much. I started on a PWM code for the front thrusters and it worked fine and then thought I was going to use up all of the CAT cable and would have nothing left for camera, activating lights, navigation, etc. so I looked for alternatives which led me to RS-485 but I know nothing about it. I've looked at many examples, copied code to operated a servo, have modified it to send joystick values to serial monitor but am stuck on how to split the code into individual commands to the ESC's. I know too little for it to make sense to me!!
below is the PWM code that I modified from someone else and below it the recent code trying to mimic what I done previously.
Transmit Code
Receive code - Again some other example that I mucked around with trying to get just a portion to work. It receives the info so I tried just pulling out the individual commands and it took out all of the digits but one and left the commas.
As you can see I haven't got a clue what to do and in the past I would find the concept to get one piece to work and then expand on it. This time I'm lost and thinking to go back to the PWM code and expand on it and forget the accessories I was looking to include
I'm afraid I don't have much. I started on a PWM code for the front thrusters and it worked fine and then thought I was going to use up all of the CAT cable and would have nothing left for camera, activating lights, navigation, etc. so I looked for alternatives which led me to RS-485 but I know nothing about it. I've looked at many examples, copied code to operated a servo, have modified it to send joystick values to serial monitor but am stuck on how to split the code into individual commands to the ESC's. I know too little for it to make sense to me!!
below is the PWM code that I modified from someone else and below it the recent code trying to mimic what I done previously.
Code: Select all
/*
Arduino Brushless Motor Control
by Dejan, https://howtomechatronics.com
with any modifications
*/
#include <Servo.h>
Servo FrontPS; // create servo object to control the Front Port Side ESC/motor
Servo FrontSS; // create servo object to control the Front Starboard Side ESC/motor
Servo RearPS; // create servo object to control the Rear Port Side ESC/motor
Servo RearSS; // create servo object to control the Rear Starboard Side ESC/motor
Servo UpPS; // create servo object to control the Port Side Up ESC/motor
Servo UpSS; // create servo object to control the Starboard Side Up ESC/motor
int ForRevValue; // value from the analog pin
int SidSidValue; // value from the analog pin
int ForPower; // this indicates joystick in forward direction
int FrontPSPower; // This will be the total for the forward stick PLUS side stick going to port side motor
int FrontSSPower; // This will be the total for the forward stick PLUS side stick going to starboard side motor
int RevPower; // this indicates joystick in reverse direction
int RearPSPower; // This will be the total for the reverse stick PLUS side stick going to port side motor
int RearSSPower; // This will be the total for the reverse stick PLUS side stick going to starboard side motor
int SidPower;
int SSPower; // this indicates joystick in starboard direction
int PSPower; // this indicates joystick in port direction
String (WhichWay); // string to store direction text
String (OtherWay) ; // string to store turning direction text
void setup() {
// Attach the ESC to their respective pins
FrontPS.attach(8,1000,2000); // (pin, min pulse width, max pulse width in microseconds) controls front port side motor
FrontSS.attach(9,1000,2000); // (pin, min pulse width, max pulse width in microseconds) controls front starboard side motor
RearPS.attach(10,1000,2000); // (pin, min pulse width, max pulse width in microseconds) controls rear port side motor
RearSS.attach(11,1000,2000); // (pin, min pulse width, max pulse width in microseconds) controls rear starboard side motor
// Setup Serial Monitor
Serial.begin (9600);
}
void loop() {
// not sure if delays are required. will test to make sure
ForRevValue = analogRead(A0); // reads the value of the forward/reverse joystick position to use in calculations
delay(10);
SidSidValue = analogRead(A3); // reads the value of the forward/reverse joystick position to use in calculations
delay(10);
// test stuff below
ForRevValue = map(ForRevValue, 540, 919, 0, 125); // scale it to use it with the servo library
delay(10);
SidSidValue = map(SidSidValue, 510, 919, 0, 125); // scale it to use it with the servo library
delay(10);
FrontPSPower = ForRevValue + SidSidValue; // applies more power to the port side motor to make the turn
FrontSSPower = ForRevValue - SidSidValue; // applies less power to the starboard side motor to make the turn
FrontPS.write(FrontPSPower); // Send the signal to the ESC
FrontSS.write(FrontSSPower); // Send the signal to the ESC
// Next part sends info to serial monitor
Serial.print("ForRevValue: ");
Serial.println(ForRevValue);
Serial.print("SidSidValue: ");
Serial.println(SidSidValue);
Serial.print("SidPower: ");
Serial.println(SidPower);
Serial.print("FrontPSPower: ");
Serial.println(FrontPSPower);
Serial.print("FrontSSPower: ");
Serial.println(FrontSSPower);
Serial.println();
}
Transmit Code
Code: Select all
#include <ArduinoRS485.h>
void setup() {
RS485.begin(9600);
}
void loop() {
int ForLeft= analogRead(0);
int ForRight= analogRead(1);
RS485.beginTransmission();
RS485.print(ForLeft);
RS485.print(",");
RS485.print(ForRight);
RS485.print(",");
RS485.println();
RS485.endTransmission();
delay(1000);
}
As you can see I haven't got a clue what to do and in the past I would find the concept to get one piece to work and then expand on it. This time I'm lost and thinking to go back to the PWM code and expand on it and forget the accessories I was looking to include
Code: Select all
#include <ArduinoRS485.h>
int ForRight = 0;
void setup() {
Serial.begin(9600);
while (!Serial);
RS485.begin(9600);
// enable reception, can be disabled with: RS485.noReceive();
RS485.receive();
}
void loop() {
if (RS485.available()) {
Serial.write(RS485.read());
Serial.parseInt(SKIP_WHITESPACE);
}
}
- Attachments
-
- Rear View.JPG (403.89 KiB) Viewed 10092 times
-
- Internal ESC.JPG (490.4 KiB) Viewed 10092 times
-
- Front view.JPG (484.98 KiB) Viewed 10092 times
Re: Arduino/Teensy transmitting over RS485?
In your receiver you want to read the input send by your sender:
Sent: ForRevValue: 123
Use startsWith to compare the beginning of the received sentence with your commands in the receiver. And then use subString to receive the value you need to send to a truster.
See the examples on this page https://www.arduino.cc/en/Tutorial/Buil ... gSubstring
Maybe you want to start your own build threat to post your photo's and code. Your ROV looks really nice.
Sent: ForRevValue: 123
Use startsWith to compare the beginning of the received sentence with your commands in the receiver. And then use subString to receive the value you need to send to a truster.
See the examples on this page https://www.arduino.cc/en/Tutorial/Buil ... gSubstring
Maybe you want to start your own build threat to post your photo's and code. Your ROV looks really nice.
-
- Posts: 187
- Joined: Mar 4th, 2018, 6:11 pm
- Location: Valverde de Júcar, Cuenca, España
Re: Arduino/Teensy transmitting over RS485?
Good afternoon
Welcome to the world of those in need of help in controlling our ROVs.
On this page, well known in the forum is built an ROV controlled by a Play Station 2 controller, which is an analog controller with two joysticks and 12 buttons / switches, using Arduino. Therefore, it will be very helpful for you to understand many concepts.
Greetings.
https://www.techmonkeybusiness.com/arti ... e_ROV.html
Welcome to the world of those in need of help in controlling our ROVs.
On this page, well known in the forum is built an ROV controlled by a Play Station 2 controller, which is an analog controller with two joysticks and 12 buttons / switches, using Arduino. Therefore, it will be very helpful for you to understand many concepts.
Greetings.
https://www.techmonkeybusiness.com/arti ... e_ROV.html