0
$\begingroup$

For a long time I use Arduino Uno controller and Adafruit Servo Shield with 6.3V 1000 uF capacitor, powered with 6V 8Amp adapter to control 8 digital servo motors from C# desktop application.

Code was successfully working for a long time of using my project device, but today I've plugged controller, and something goes wrong way, when I've not damaged of changed anything in my project, as in code, also in device assembly. I found two different and absolutely not clear problems, which newer was before with completely same code, devices, computer and Windows 10 pro OS:

When I'm loading Adafruit control #include <Wire.h> #include <Adafruit_PWMServoDriver.h> sketch, I see TX, RX and L led indicates upload as usually, but motors does not moves with command from desktop via serial port, just does some short random movements with load of controller and then stops, at the same time RX led indicates receiving of message from C# desktop command with button or trackbar successfully

When I'm trying to load another sketch, which uses <Servo.h>, which should receive serial command from my C# desktop, with same shown initialization, to check if I am able to move motor from desktop this way, but C# application hangs and freezes with selecting of same "COM3" in combobox. Then after number of attempts, it was somehow loaded and selected without freezing with port selection, but did nothing with servo, just indication of message with RX, and same unexpected random movements.

Both of this problems was never appeared before.

To be sure, I've checked all motors separately only with Arduino (without shield) from basic servo control with direct connection minus to GND, 5V to V+, Signal to PWM by this example, which also uses <Servo.h>, and works fine, turns all motors from sketch successfully.

Also I've checked absolutely new Arduino Due, which uses COM4 and it is same behavior. So, seems like controller and motors are fine, it looks like my USB serial port works incorrectly, or it is something wrong with shield, what is more likely, even if serial port selection freezing looks really doubtful and does not shows any error if I run application from VS debug, I almost sure that the problem comes from shield, because kind of proof is that I've checked same C# application from 2 different computers with Windows OS and with 2 different controllers Uno and Due, single or number of servos on board, and 3 different USB cables serial command received but motor does not moves by command, just does rare unexpected random movements.

Power to shield correct is a 6V, board and port selected in Arduino IDE tools by requirement.

It looks like something wrong with shield, even if freezing of serial port sounds like separate problem, but I don't have another shield to check, so I've to find out somehow with particular device

I'm not sure where to go next and what to check else.

Any advice, guide or example would be helpful

Edit 1:

I've follow @jsotola advice to locate the point of failure. I've tried this example, which works fine, blinks L led with my red led and 220 Ohm resistor on 13 pin and ground.

And I got same freezing with selection of serial COM3 in combobox, without any error report if I debug it from VS or will run .exe from desktop. This behavior looks incorrect, it is unclear where is a reason, because it does the same from another computer for both Uno and Due controllers, with same long time working code and devices, as I've said before nothing like this was happened before, I did not changed anything in code or assembly.

It seems like something goes wrong here, looks confusing, because when #include <Wire.h> #include <Adafruit_PWMServoDriver.h> control sketch uploaded to controller, it successfully selects COM3 from C# combobox, and failure comes with serial command receiving, which is indicated with RX each time I press button or scrolling trackbar, but does not turns motor.

Code with turning LED from C# or controlling motor, shown (number 2) in problem behavior description above, (both already checked long time before of successful working) does the same, failure appears with serial port selection, hanging and complete freezing, I can't say if it is initialization problem, because it does not reports about any bug there, and initializes same port with <Wire.h> #include <Adafruit_PWMServoDriver.h> sketch using.

Edit 2:

Now, I've checked this code, which runs servos without serial. I've reached completely unclear result, this way shield moves servo. I'm really confused, what I got here:

  1. I have 3 years old desktop application code and controller sketch, device assembly, working everyday successfully till yesterday. Important to note, all given examples was used and checked by me before, all was successful
  2. Shield without using of serial port runs servos successfully
  3. Arduino Uno and Due both controllers runs motor sweep and blinks LED without serial successfully
  4. I've checked two different USB cables for Uno and separate one for Due
  5. Adafruit library PWM connects COM3 from C# desktop application successfully, but does not turns servo with serial command from desktop
  6. <Servo.h> code or LED light to control from C# does not loads COM3 in 99% cases, and if does, then does not turns servo or LED
  7. I have checked problem on two different computers with different version of Windows OS
  8. All motors are working
  9. Capacitor works
  10. Voltage on shield power terminal 6V and same on GND and V+ pins
  11. Adafruit example code turns servo without serial successfully

So what is the conclusion, if shield works, controller works, USB works, C# desktop reads COM3 with PWM library and RX led indicates receiving of serial command message, but not turns servo, and does not reads COM3 with <Servo.h>.

What to check, code is shown above completely, there is nothing else, and it was working, I'm not sure, what can be wrong there.

Or it is something wrong with serial on PC, but I have checked it on 2 computers, behavior is equal, then more explainable should be some Windows OS update, which was changed something with serial ports in OS.

Or it is some connection damage between Arduino and Shield on shield, because I've tried 2 different controllers, which also appears doubtful, because behaves differently in case of using <Wire.h> <Adafruit_PWMServoDriver.h>and <Servo.h> in first case sends and receives message from C#, and second hangs with serial COM3 selection, I'm not sure what such damage should be for connection with serial, if PWM code uploading allows C# read COM3, and receive serial message, when examples freezes with selection of initialized port.

Everything looks so that the reason can be anywhere, but looking on the results, at the same time everything excluded.

I have two versions of VS15 .NET Framework 4.5.2, which build is my C# application used for long time, and VS 17 .NET Framework 4.7.2 on same OS also installed and updated long time ago before failure. So, also I can try run same code from 4.7.2 version build, where target is W10, version 1803 (10.0; Build 17134), but I'm not sure if it can be reason.

Everything used to work fine as a system with the old code until recently, and code has not been changed, it is still same old code, there is nothing added or even edited. I use this program and device for 3 years everyday. Now, every part of the system works fine individually, but not with serial command using, I have described this in details in 5 and 3 paragraphs of edit above. I'm really stacked, not because I can get new devices only in few weeks, but because devices separately works, seems like it is different problem.

Edit 3:

I've tried disable Defender in Windows OS, but it does nothing with problem.

I still can't find solution for this problem. Here is my minimal WinForms desktop application repository Single servo control, which is VS 17 .NET Framework 4.7.2 build, as example of my C# control with simple and basic button and trackbar controls for single servo motor. I'm almost sure, if you will try it for your controller with given PWN or any given sketch from above with appropriate shield library, it will work.

If someone has ideas, I'm not sure what can I check else, would be very helpful to get your advice.

$\endgroup$
7
  • $\begingroup$ @jsotola Hello, thank you for your quick feedback, by rate reason I'm not able to remove it from linked topic, and at the same time I'm not able to answer you there, so I will answer you here. The arduino also works different, when I'm trying to control servo from C# via serial to <Servo.h> Serial.begin(9600);, servo1.attach(9); in setup() and val = Serial.parseInt(); if(val == 9){ servo1.write(Serial.parseInt()); } it freezes with selection of COM3, or if connection successful, does not moves servo form myport.WriteLine("9"); myport.WriteLine(trackBar1.Value.ToString()); $\endgroup$ – user24233 Nov 22 '19 at 3:52
  • $\begingroup$ @jsotola So, this example works fine, blinks L led with my red led and 220 Ohm resistor on 13 pin and ground, as I've already noted above this example also works fine, turns servo from side to side, both examples without shield directly from controller. By the way power on shield pins also shows correct voltage $\endgroup$ – user24233 Nov 22 '19 at 4:38
  • $\begingroup$ @jsotola I've added edit to my post with description of this testing step, so it seems like something goes wrong here, and looks confusing. Please, check my edit $\endgroup$ – user24233 Nov 22 '19 at 6:12
  • $\begingroup$ do you have the Arduino IDE serial monitor window open? $\endgroup$ – jsotola Nov 22 '19 at 6:14
  • $\begingroup$ actually, forget about C# for now .... test Arduino sketch using the serial monitor $\endgroup$ – jsotola Nov 22 '19 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.