Pages: [1]   Go Down
Author Topic: Automatic run - serial communication  (Read 964 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 207
Posts: 12910
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

How do I get my program to run on the arduino UNO automatically once power is supplied?

That's how the Arduino works.  Apply power and the program runs.

Quote
I am unable to get the Arduino to transmit/receive information without clicking "serial monitor" on the software interface on my PC.

Which indicates there is something special about your project.  The goal is to determine what that is so you can get around the problem.
Logged

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you post your code it will be a lot easier to help  smiley
Logged

Norfolk UK
Offline Offline
Faraday Member
**
Karma: 69
Posts: 2552
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Could noise or data on the RX line be preventing the bootloader from relinquishing control to the main program on reset? Maybe a pulldown resistor is needed.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 207
Posts: 12910
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Why do you believe the code is not automatically running?  Do you blink an LED in loop?
Logged

Offline Offline
Edison Member
*
Karma: 33
Posts: 1447
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Are you sharing the serial output with the monitor and the motor controller?

I would suggest using the SoftwareSerial library and using a different set of pins. That frees the standard serial monitor for debugging. (And if your control box is sending characters down the serial, the Arduino bootloader might think it is trying to set up a download.)
Logged

Pages: [1]   Go Up
Jump to: