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 <Adafruit_PWMServoDriver.h> sketch, I see
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
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
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 <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
#include <Adafruit_PWMServoDriver.h> sketch using.
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:
- 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
- Shield without using of serial port runs servos successfully
- Arduino Uno and Due both controllers runs motor sweep and blinks LED without serial successfully
- I've checked two different USB cables for Uno and separate one for Due
- Adafruit library PWM connects COM3 from C# desktop application successfully, but does not turns servo with serial command from desktop
<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
- I have checked problem on two different computers with different version of Windows OS
- All motors are working
- Capacitor works
- Voltage on shield power terminal 6V and same on GND and V+ pins
- 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
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
<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.
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.