I am trying to transmit information from my Arduino UNO to a stepper motor control box via TTL to RS232 conversion adapter. I have successfully communicated from my Arduino to HyperTerminal on my PC.. I have been able to send the string needed by the control box to my PC and the string displays on the HyperTerminal display box.
However, when I try to connect to the stepper motor control box, there is no communication. I have ensured the Buad rate is correct. All the settings should be good to go. All the connections have been tested with HyperLink. The one thing I'm not sure about is the Serial.println() function. As I'm aware, it should be sending the commands to the stepper control box in ASCII form. I'm pretty positive the control box should be accepting ASCII values. I'm also pretty positive that something screwy in the format of the information being transmitted by the Arduino is the problem; thus, the control box won't accept it. Any ideas??
The issue I am having is not related to the code itself. The issue I am having is compatibility between the format of the strings the Arduino is outputting and the format the stepper motor control box needs to function. I have posted my question in a couple other relevant AP forums, but I just wanted to see if anyone on the programming forum has any ideas. I will supply the string output that I can view either on my programming computer (connected via USB and with serial monitor) or on the PC (connected via the TTL to RS232 converter). The string output is as follows:
@0. @0T0 @0B400 @0M600 @0- @0N0 @0CH100 @0G
So essentially, I need someone with experience on an Arduino as well as stepper motor control boxes. The specific box I am using is DP75601 by Anaheim Automation. As far as I can tell, the box should be accepting the string output by the Arduino via the Serial.println() function. However, I am getting no sign of communication between the Arduino and control box. I think there must be a discrepancy in format compatibility, but I also think that both hardwares operate with ASCII.
The issue I am having is not related to the code itself.
You hope. I'm not going to agree that that is the case.
The issue I am having is compatibility between the format of the strings the Arduino is outputting and the format the stepper motor control box needs to function.
WHAT ARE YOU TALKING TO?
I have posted my question in a couple other relevant AP forums, but I just wanted to see if anyone on the programming forum has any ideas.
Hopefully on those other forums you were willing to answer that question.
So essentially, I need someone with experience on an Arduino as well as stepper motor control boxes.
WHICH control box?
You are assuming that they are all the same. I seriously doubt that that is the case.
The specific box I am using is DP75601 by Anaheim Automation.
RS232 Protocol - Controller SW1 in RS232 Position
The DPD75601 is a DCE device, therefore it will transmit on pin 2 and receive on pin 3 of the DB9 RS-232 connector. The RS232 serial communication mode is single ended. This means that for each signal there is one wire, and a common ground reference used by all the signals. The DPD75601 does not use handshaking, thus the CTS and RTS lines are internally connected, and the CD, DTR and DSR lines are internally connected inside the DPD75601. The signal line maintains levels of +5VDC to +15VDC and -5VDC to -15VDC. For a valid logic level in the controller, the voltage must be at least +/- 3 volts. RS232 works at distances of up to 50 feet maximum. RS232 is susceptible to electrical noise, and should not be used in noisy areas. Always use the shortest cable con- nection possible. NOTE: Keep Controller wiring separated from motor cable/wiring.
Where is switch 1 set to?
I have ensured the Buad rate is correct.
What baud rate are you using? We would have more confidence in your answer if you posted your code.
The println function sends a carriage-return and linefeed. The documentation is unclear about whether the linefeed will hinder communications.
I am trying to create a control system that reads in a temperature using a thermocouple and transmits that to an arduino micro-controller, which then sends a signal to a stepper motor control box (Anaheim Automation DPD75601) which then controls the motion of the step motor and has it move a certain number of steps based on the difference between current temperature and previous temperature.
In order to do so, we needed to interface the Arduino with the stepper control box. This involved using a TTL comm to RS232 adapter. We have implemented the adapter and successfully interfaced with HyperTerminal on another computer via the RS232 port. We are able to send the string output command (needed to send to the control box) to HyperTerminal and print the command on the HyperTerminal dialog box.
However, when we connect the Arduino to the control box via the RS232 serial port (on the control box), we are not getting any communication. We THINK there might be a discrepency between the format of the string the Arduino is outputting and the format of the string the stepper control box needs to move the motor.
I am copying and pasting the code: I realize my if/else statement could be condensed.. going to do that soon.
/*
This example code is in the public domain.
*/
//establish LED pin, used for troubleshooting
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 38400 bits per second (required by control box):
Serial.begin(38400);
pinMode(led,OUTPUT);
//Serial.println(" ");
}
//initializing initial temperature value (called prevVal) needed to decide # of steps to move
float prevVal=70;
// the loop routine runs over and over again forever:
void loop() {
//LED blink code, used for troubleshooting
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
//print headings
// read the temperature transmitter input on analog pin 0:
int sensorValue = analogRead(A0);
//converting Arudino 0-1023 to Voltage Value supplied by TC
float voltVal = sensorValue*0.004887585;
//converting voltVal to tempVal
float tempVal = (60.162*voltVal)-131.88;
//calculating degrees Fahrenheit difference between now and last reading
float tempDegreeMove=tempVal-prevVal;
//converting from degrees Fahrenheit to circumferential degrees
float circumfDegreeMove=4.5*tempDegreeMove;
//calculating number of steps needed to move
int numSteps= circumfDegreeMove/1.8;
//calculating the temperature value needle is at, taking into account
//rounding of numSteps.. in other words, prevVal is the temperature the
//needle moves to, but not necessarily the temperature that was just
//deciphered by the Arduino
prevVal=prevVal+(numSteps*(1.8/4.5));
//if statement deciding if motion is clockwise or counterclockwise
if (numSteps > 0)
{
//String commands sent to control box
Serial.println("@0.");
Serial.println("@0T0");
Serial.println("@0B400");
Serial.println("@0M600");
//(+) for clockwise
Serial.println("@0+");
String string1 ="@0N";
//making number of steps positive number... direction controlled in "@0+"
int numStepsAbs = abs(numSteps);
String string2 = String(numStepsAbs);
String string3 = string1+string2;
Serial.println(string3);
Serial.println("@0CH100");
Serial.println("@0G");
}
//negatives..
else
{
Serial.println("@0.");
Serial.println("@0T0");
Serial.println("@0B400");
Serial.println("@0M600");
Serial.println("@0-");
String string1 = "@0N";
int numStepsAbs = abs(numSteps);
String string2 = String(numStepsAbs);
String string3 = string1+string2;
Serial.println(string3);
Serial.println("@0CH100");
Serial.println("@0G");
}
delay(10000); // delay in between reads
}
Moderator edit: [code] ... [/code] tags added. (Nick Gammon)
I am trying to create a control system that reads in a temperature using a thermocouple and transmits that to an arduino micro-controller, which then sends a signal to a stepper motor control box (Anaheim Automation DPD75601) which then controls the motion of the step motor and has it move a certain number of steps based on the difference between current temperature and previous temperature.
In order to do so, we needed to interface the Arduino with the stepper control box. This involved using a TTL comm to RS232 adapter. We have implemented the adapter and successfully interfaced with HyperTerminal on another computer via the RS232 port. We are able to send the string output command (needed to send to the control box) to HyperTerminal and print the command on the HyperTerminal dialog box.
However, when we connect the Arduino to the control box via the RS232 serial port (on the control box), we are not getting any communication. We THINK there might be a discrepency between the format of the string the Arduino is outputting and the format of the string the stepper control box needs to move the motor.
I am copying and pasting the code: I realize my if/else statement could be condensed.. going to do that soon.
/*
This example code is in the public domain. /
//establish LED pin, used for troubleshooting
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 38400 bits per second (required by control box):
Serial.begin(38400);
pinMode(led,OUTPUT); //Serial.println(" ");
}
//initializing initial temperature value (called prevVal) needed to decide # of steps to move
float prevVal=70;
// the loop routine runs over and over again forever:
void loop() {
//LED blink code, used for troubleshooting
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
//print headings
// read the temperature transmitter input on analog pin 0:
int sensorValue = analogRead(A0);
//converting Arudino 0-1023 to Voltage Value supplied by TC
float voltVal = sensorValue0.004887585;
//converting voltVal to tempVal
float tempVal = (60.162voltVal)-131.88;
//calculating degrees Fahrenheit difference between now and last reading
float tempDegreeMove=tempVal-prevVal;
//converting from degrees Fahrenheit to circumferential degrees
float circumfDegreeMove=4.5tempDegreeMove;
//calculating number of steps needed to move
int numSteps= circumfDegreeMove/1.8;
//calculating the temperature value needle is at, taking into account
//rounding of numSteps.. in other words, prevVal is the temperature the
//needle moves to, but not necessarily the temperature that was just
//deciphered by the Arduino
prevVal=prevVal+(numSteps*(1.8/4.5));
//if statement deciding if motion is clockwise or counterclockwise
if (numSteps > 0)
{
//String commands sent to control box
Serial.println("@0.");
Serial.println("@0T0");
Serial.println("@0B400");
Serial.println("@0M600");
//(+) for clockwise
Serial.println("@0+");
String string1 ="@0N";
//making number of steps positive number... direction controlled in "@0+"
int numStepsAbs = abs(numSteps);
String string2 = String(numStepsAbs);
String string3 = string1+string2;
Serial.println(string3);
Serial.println("@0CH100");
Serial.println("@0G");
}
//negatives..
else
{
Serial.println("@0.");
Serial.println("@0T0");
Serial.println("@0B400");
Serial.println("@0M600");
Serial.println("@0-");
String string1 = "@0N";
int numStepsAbs = abs(numSteps);
String string2 = String(numStepsAbs);
String string3 = string1+string2;
Serial.println(string3);
Serial.println("@0CH100");
Serial.println("@0G");
}
delay(10000); // delay in between reads
}
We THINK there might be a discrepency between the format of the string the Arduino is outputting and the format of the string the stepper control box needs to move the motor.
OK, so what format is needed?
Can you provide a link to the strings you are required to send.
Also do you have the baud rate and parity set right?
Have you followed the advice in the other thread to post a damned link to the device you are trying to talk to?
No. Instead you've ignored the questions there, and opened a new thread in the hopes that someone different will read it. Dumb assumption. Knock it off.
Hopefully a friendly mod will merge your two threads on this question - or perhaps just delete this one, since it adds nothing to your original question.
I don't understand why you would ignore the answers given last time and just ask your question again. At best, it's wasting everyone's time.
Based on Nick's quote, the control box acts as a DCE device. Your computer's port is wired as a DTE device. Thus you cannot use the same cable to talk to both from the Arduino, unless you re-configure the Arduino end.
If you used a null-modem cable to talk to the computer, you need a straight-through cable to talk to the controller, and vice versa. Or you need to change the Arduino end from DTE to DCE or vice versa.
That's just the tip of the iceberg on settings to check for successful RS232 comm.
I suggest doing what WildBill suggested and communicate with the box using Hyperterminal first to confirm the controller is working as expected.
I suggest doing what WildBill suggested and communicate with the box using Hyperterminal first to confirm the controller is working as expected.
We have tested the control box/stepper motor setup using labview directly from the PC, and it works. We have not used HyperTerminal to check it, but perhaps that will help.
If you used a null-modem cable to talk to the computer, you need a straight-through cable to talk to the controller, and vice versa. Or you need to change the Arduino end from DTE to DCE or vice versa.
I am a little confused. We are trying to run the setup without the use of a computer.. we have only been running the signal through the TTL to RS232 converter to the PC to test if we could convert the serial communication to an RS232 feed (ie convert 0-5V signal to +/-3-12V signal). Are you saying I need to change the Arduino end from DTE to DCE to communicate with the control box regardless? That could be the problem..