Show Posts
Pages: [1]
1  Using Arduino / Programming Questions / Re: Arduino TTL to RS232 Communication (interfaced w/ stepper control box) on: October 20, 2012, 12:43:02 pm
Quote
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.

Quote
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..



2  Using Arduino / Programming Questions / Re: Arduino TTL to RS232 Communication (interfaced w/ stepper control box) on: October 20, 2012, 10:01:20 am
Stepper Motor control box that we are trying to connect to:

http://www.anaheimautomation.com/manuals/stepper/L010155%20-%20DPD75601%20Users%20Guide.pdf
3  Using Arduino / Programming Questions / Arduino UNO to Stepper Motor Control Box on: October 20, 2012, 01:12:39 am
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
}
4  Using Arduino / Programming Questions / Re: Arduino TTL to RS232 Communication (interfaced w/ stepper control box) on: October 20, 2012, 01:10:07 am
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.


Code:
/*
 
  
 
 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)
5  Using Arduino / Programming Questions / Re: Arduino TTL to RS232 Communication (interfaced w/ stepper control box) on: October 19, 2012, 05:59:04 pm
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.

Hunt
6  Development / Other Hardware Development / Arduino TTL to RS232 Communication (interfaced w/ stepper control box) on: October 19, 2012, 05:20:27 pm
Hello,

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??

Hunter
7  Using Arduino / Programming Questions / Arduino TTL to RS232 Communication (interfaced w/ stepper control box) on: October 19, 2012, 05:19:01 pm
Hello,

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??

Hunter
8  Using Arduino / Project Guidance / Re: Automatic run - serial communication on: October 18, 2012, 12:48:19 pm
So what I am trying to do is get the Arduino to read in a voltage value from a thermocouple and formulate a string output to a stepper motor control box, which in turn tells the stepper motor to move X amount of steps in order to turn the hand on a circular temperature dial.

The code looks like such..

void setup()
{
Serial.begin(9600);
}

//initial dial position
float prevVal=70;

void loop()
{
//reads in voltage from thermocouple
int sensorValue = analogRead(A0);
//converts arduino 0-1023 to voltage value
float voltVal = sensorValue*0.004887585;
//converts voltage value to temperature value
float tempVal = 33.75*voltVal-33.75;
//converts temperature value to degrees temperature needed to move on temperature dial by finding the difference between the read in temperature and where the dial currently is
float tempDegreeMove=tempVal-prevVal;
//converts degrees temperature needed to move to circumferential degrees to move
float circumfDegreeMove-4.5*tempDegreeMove;
//converts circumferential degrees to move to number of steps needed to move by stepper motor
int numSteps = circumfDegreeMove/1.8;
//saves the position the dial will move to in a moment.. reused on next loop iteration to calculate number of steps needed to move
prevVal=prevVal+(numSteps*(1.8/4.5);
int numStepsAbs = abs(numSteps);

if (numSteps > 0)
{
//creates string "@0+"
}
else
{
creates string "@0-"
}

//rest of code concatenates above strings with other strings for command to stepper motor control box, then..
Serial.println(stringFinal);
delay(10000);

}

The system needs to run without a computer; in other words, the Arduino is powered by a converter plugged in to a wall, as well as the temperature transmitter and other components. I have a TTL to RS-232 communication converter in order to talk between the Arduino UNO and the control box. The control box is powered by AC power directly from the wall. For some reason, I can't get the code to run automatically. I need that "Serial.println(stringFinal)" to transmit automatically without clicking "serial monitor" on my PC, because I want the system to run without the use of a PC.

Hunt

9  Using Arduino / Project Guidance / Automatic run - serial communication on: October 18, 2012, 11:24:34 am
Hello,

How do I get my program to run on the arduino UNO automatically once power is supplied? For programs like the "blink" sketch, the code runs automatically when the Arduino gets power. However, my program is using all serial communication between the Arduino and a stepper motor control box. I am unable to get the Arduino to transmit/receive information without clicking "serial monitor" on the software interface on my PC. Once I click "serial monitor", I can X out of the serial monitor box and the program runs until I disconnect power. This is not acceptable for my project as I want the Arduino to run in a remote location, powered by an AC/DC power converter plugged in to the wall. Please help???

Hunt
10  Using Arduino / Project Guidance / Run program automatically on: October 12, 2012, 03:20:51 pm
Hey,

Sorry, I am relatively new w/ the Arduino UNO. I have my program coded and ready to go, but I need the Arduino to operate automatically once powered. In other words, I need the Arduino to be able to start on its own once power is supplied.

I have a string output through the USB port and sent to an RS-232 serial input. I have bought a USB type B to RS-232 serial adapter in order to send the string output directly from the Arduino to a control box to turn a stepper motor, bypassing the computer. This is why I need the program to run automatically once the Arduino is powered, without having to click "serial monitor" on the Arduino software environment.

Hunt
11  Development / Other Hardware Development / USB type B to RS232 on: September 27, 2012, 01:37:55 pm
Hello,

I am looking for an adapter to go from the type B USB port on the Arduino to an RS-232 serial port on a control box for a stepper motor. I have found one online but I am not sure if it is reliable (http://www.usbgear.com/USBG-232PLG.html).

With this adapter, would I be able to transmit information from the UNO to the control box directly which would then control a stepper motor?

My project involves reading an analog voltage signal into the Arduino UNO which can be converted to a signal that is output to a stepper motor control box through the USB type B port to the RS-232 port.

Does this seem feasible? With the adapter, would I need any additional wiring to complete the task? I received my Arduino UNO yesterday, so I'm not very experienced.

Thanks!

Hunt
Pages: [1]