Serial Port Unavailable on Windows 10 Pro x64 and sketch not getting into loop

ballscrewbob:
@ancaonuta

Please read this then add any missing details .

It is important to have details of what you have tried and how.

Sometimes a fix can be as simple as clearing a browsers CACHE.
Or a little more involved such as turning off any additional computer security to test.

Bob.

I would like to know how this was marked “solved” since this last post is not any form of a solution but suggestions only.

I am running the web version of Arduino Create on a program to run a stepper based on input from the user via the Serial port and the serial port is available once in a while but mostly it is UNAVAILABLE.I am using the adafruit motor Shield V2.
The thing that clearly kills me here is that it NEVER enters the Loop. There is an explicit println that says i am in the loop that NEVER shows up.
The output just shows “Stepper test” and that is all.
Here is the code:

#include <Wire.h>
#include <Adafruit_MotorShield.h>

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// to motor port #2 (M3 and M4)
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println(“Stepper test!”);

AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000); // OR with a different frequency, say 1KHz

myMotor->setSpeed(.25); // 10 rpm
}

void loop() {
Serial.println(“In Loop”);
char ser =‘0’;

Serial.println(“Double coil steps”);

ser = Serial.read();
if (ser == ‘3’)
{
Serial.println(“Open Telescope Cap”);
myMotor->step(100, FORWARD, DOUBLE);
}
else if (ser == ‘4’)
{
Serial.println(“Close Telescope Cap”);
myMotor->step(100, BACKWARD, DOUBLE);
}

}

Well you HIJACKED a post that was marked as “solved” probably by the OP.

Clearly yours is a different issue so I am splitting this post.

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.

Posting tips.

  • Always list the version of the IDE you are using and the board version if applicable.
  • How to insert an image into your post. ( Thanks Robin2 )
  • Add your sketch where applicable but please use CODE TAGS ( </> )
  • Add a SCHEMATIC were needed even if it is hand drawn
  • Add working links to any specific hardware as needed (NOT links to similar items)
  • Remember that the people trying to help cannot see your problem so give as much information as you can

Hi folks…
I am using an adafruit stepper motor controller V2 and have the following code… I find that two things are plaguing me.

First the Serial monitor does not come up after coming up once.
Second: When it does, the “Stepper Test!” message does not show.
Three: ok three things are plaguing me… The “In Loop” message should be appearing constantly but it shows twice and that is all.

The program depends on getting input from an operator but without the Serial Monitor it cannot work…

I would love to debug this but the only tool available doesnt work.

Is there any other way to get input from the user? It cannot be physical buttons as this is a remote operation.

Clues? Here is the code…

#include <Wire.h>
#include <Adafruit_MotorShield.h>

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);

// Connect a stepper motor with 200 steps per revolution (1.8 degree)
// to motor port #2 (M3 and M4)
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.print(“Stepper test!”);

AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000); // OR with a different frequency, say 1KHz

myMotor->setSpeed(10); // 10 rpm
}

void loop() {
Serial.print(“in loop”);

int ser = Serial.read();
if (ser == 4) {
Serial.println(“Double coil steps”);
myMotor->step(100, FORWARD, DOUBLE);
} else if (ser == 5) {
myMotor->step(100, BACKWARD, DOUBLE);
}
}

Which Arduino board are you using ?

Is there any other way to get input from the user? It cannot be physical buttons as this is a remote operation.

The Serial link is the most obvious depending on the distance between user and Arduino 1 - direct connection 2 - Bluetooth 3 - RF24 wireless 4 - Lora (even via satellite !)

or, of course, given Internet access at both ends, via the Web

(deleted)

UKHeliBob: Which Arduino board are you using ? The Serial link is the most obvious depending on the distance between user and Arduino 1 - direct connection 2 - Bluetooth 3 - RF24 wireless 4 - Lora (even via satellite !)

or, of course, given Internet access at both ends, via the Web

I am connected to the observatory with a remote access app that is like sitting at the computer in the observatory. The distance then does not matter..

I am using the sparkfun uno clone.

How are you powering all this? If you are trying to power your servo with the +5V of the uno, you can't do it. If the power dips, the USB connection will also be lost which may be what you are seeing.

How about a schematic?

blh64: How are you powering all this? If you are trying to power your servo with the +5V of the uno, you can't do it. If the power dips, the USB connection will also be lost which may be what you are seeing.

How about a schematic?

Never considered the power issue...I am using USB since most of the sparkfun shields work with usb... I could try powering with the power suppl and using the USB to see how it goes I guess! But the stepper I am using is one that you can get for the sparkfun stepper motor controller V2 so I did assume power wouldnt be an issue for the Stepper motor. So much for assumptions right?

As far as a schematic, I dont have a clue how to generate one...

(deleted)

I just rtried it with wall power plus usb and is still unavailable. sigh...

As far as what the circuit looks like it couldnt be simpler. Stepper motor wired to the M3-M4 output on the sparkfun Stepper Motor shield V2. Thats it... Nothing else in the way other than the Uno clone from Sparkfun (redboard)

Power is from USB and wall power together now and still no joy...

"As far as what the circuit looks like it couldnt be simpler."

Perhaps you have a link to the schematic you used to as reference for your wiring?

fxmodels: As far as what the circuit looks like it couldnt be simpler.

Then you won't have much trouble making the drawing requested in Reply #6 and posting a photo of it. See this Simple Image Posting Guide

...R

If you disconnect the stepper motor from the shield, do you still see this behavior?

I am connected to the observatory with a remote access app that is like sitting at the computer in the observatory. The distance then does not matter…

The ASCII character with value 4 is End Of Transmission (EOT), a.k.a. Ctrl-D. Perhaps the EOT character has special meaning to the remote access app. Or maybe it’s the ENQ character (ASCII 5).

Ok it cant get much simpler than this! I removed ALL code regarding stepper motors and just left the following. It STILL says Serial Monitor Unavailable..

Here is the simple stub code now that will not work...

void setup() { Serial.begin(9600); // set up Serial library at 9600 bps while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } Serial.println("Stepper test!"); }

void loop() { Serial.println("in loop");

char ser = Serial.read(); if (ser == '4') { Serial.println("Open Telescope Cover");

} else if (ser == '5') { Serial.println("Close Telescope Cover");

} }


NO Serial Monitor Available.. nothing prints at all... This system needs a debugger ...

Since that didnt work I removed the stepper controller shield entirely leaving the genuine Arduino alone and it STILL didnt work...

Clearly the problem is NOT the arduino... What about these comports?

fxmodels: Ok it cant get much simpler than this! I removed ALL code regarding stepper motors and just left the following. It STILL says Serial Monitor Unavailable..

Where exactly does it say "Serial Monitor Unavailable" - please post the actual text or a screenshot.

...R

while (!Serial) {
 ; // wait for serial port to connect. Needed for native USB port only
}

An Uno, or a clone, does not have native USB. It has the '328P, and a separate chip for USB. Native USB would be found on a board that uses a '32U4 chip, like the Leonardo. Take this out.

Serial.println("in loop");

char ser = Serial.read();

I would add this line before attempting any reads:

if (Serial.available() >0){
// got at least one character, read it and act on it
}

CrossRoads: while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only }

An Uno, or a clone, does not have native USB. It has the '328P, and a separate chip for USB. Native USB would be found on a board that uses a '32U4 chip, like the Leonardo. Take this out.

Thank you I will... I was told to put it in by someone higher up in the message chain in an effort towait for the serial to become available in case that was the problem.

Robin2: Where exactly does it say "Serial Monitor Unavailable" - please post the actual text or a screenshot.

...R

The actual text is "Serial Monitor Unavailable" and it comes from the online Arduino Create online environment and appears to the left of the code when you select the monitor from the side menu. As its being uploaded the message is "Serial Busy". Then when its uploaded and running it changes to Serial Unavailable. Been trying to fix this for a week now. Cant see the forest through the trees any more..