Limit switch triggering too slowly / Actuator with max/min adjustment 2 limits

redneckcrake:
What would you suggest I check physically gcjr? As for the code, I would not even know what to add to what has already been written.

i'm trying to refresh my memory and believe i've confused you with another

the answer is to find the problem.

it looks like window for monitoring either limit switch is being restricted to a specific case and the delay()s narrow that further. it may be better to monitor all inputs constantly and take actions based on state.

if a particular limit switch is triggered, it shouldn't matter which state it "thinks" it's in.

it's not clear to me how much time a servo.write() or if it needs to be called repeatedly?

maybe the delay()s should be removed and the code made simply, which is closer to what it was originally

void loop (){
    if (digitalRead (cycleButton) == LOW) {
        motorCW ();
    }

    if (digitalRead (LMF) == LM_ON) {
        motorCCW ();
    }

    if (digitalRead (LMB) == LM_ON) {
        motorSTOP ();
    }
}

Reply wildbill,

So the code in theory should not be the issue. its the wiring then that you suspect. would a picture of the whole system and the connections be a good reference or of any use (if so let me know and I will get some from multiple angles). :slight_smile: :slight_smile: All the connections are made with the typical dupont connectors.

Put a serial.print in setup so that you can see if the Arduino is getting reset
What should I be looking for exactly? so plug the arduino system to the computer and power it up while testing the system? I do not understand what you mean by adding a "serial.print" how and at which point in the setup. I am sorry, this is my first REAL arduino project that I am trying and have been at it for months now.

Question 1:
I have a few questions, is 8V-8.4V to to arduino VIN too low and is causing the arduino to act out erratically (I'll give this a test also, if you think that it is a possibility)?

Question 2:
Would a faulty or semi functional power supply be a potential culprit? I have a few extra Power supplies, should I try those also?

Thank you for your patience :grinning: :blush:

============================================================

Reply gcjr

ััi'm trying to refresh my memory and believe i've confused you with another the answer is to find the problem.
Don't worry :slight_smile: I am super glad you are still helping me out on my project :grinning: :grinning: :grinning:

maybe the delay()s should be removed and the code made simply, which is closer to what it was originally

void loop (){
    if (digitalRead (cycleButton) == LOW) {
        motorCW ();
    }

    if (digitalRead (LMF) == LM_ON) {
        motorCCW ();
    }

    if (digitalRead (LMB) == LM_ON) {
        motorSTOP ();
    }
}

I'll give this a shot.

it looks like window for monitoring either limit switch is being restricted to a specific case and the delay()s narrow that further. it may be better to monitor all inputs constantly and take actions based on state.
So basically removing the "M=X" and as oppose to having it monitor the LMF it should just consistently monitor everything correct? So you are suspecting the delay function is messing with the program somehow? What happens if the delay is an important feature for it to function properly how would I implement that into the program. At this point what you have wrote in terms of the "if statements" actually makes sense to me now (at least I'm learning hahaha) :smiley: :smiley:

redneckcrake:
What happens if the delay is an important feature for it to function properly how would I implement that into the program.

then millis() could be used to postpone a 2nd action depending on a flag/state indicating the current action (e.g. motorCW())

It would help to see how your system is wired.

The serial print I suggested is simply to help see if the Arduino is rebooting. If you have power issues or electrical interference causing a crash, extra telemetry in the form of those print statements will help track down what's going on.

I have attached a few photos of the system and how it is wired. I do not exactly know which ones would be helpful or not (therefore I just took some general photographs of the system :frowning: ).

Note: I am using arduino IDE version 1.8.9 (I don't know if this information is useful or not)

Replay gcjr

maybe the delay()s should be removed and the code made simply, which is closer to what it was originally
I tried removing all the delays and I am still getting very strange and erratic behavior. I then tried reverting back to the code that constantly checked all the limits and still got moments where the cycle would begin by itself.

Reply wildbill

The serial print I suggested is simply to help see if the Arduino is rebooting. If you have power issues or electrical interference causing a crash, extra telemetry in the form of those print statements will help track down what's going on.
I plugged the arduino into the computer and opened serial monitor and had it report all the cases correctly on serial. It was just starting the cycle by itself at times and as mentioned would eventually come to a crash of some kind (worse case is crashing into the limits).

Reply wildbill & gcjr

After doing some more reading in regards to what you meant by serial printing in setup I finally understood what you meant and went to work. You wanted me to add "Serial.println ("some message");" into right somewhere in setup, so IF the arduino DOES reset itself then the message should come up on serial monitor. (please ignore that the fact that I spelled "resetted" lol). I also read that the arduino resetting itself has something to do the power (however I am not sure if this means that the power supply I am using is about to hit the can). Please continue to advise me on which direction to continue). :grinning: :grinning: :grinning:

Beyond the auto resetting of the arduino, some gibberish can be found reported on the serial monitor also. For example as oppose to reporting "case 0" it might report just "c" and the it would pause the program and the servo might not work after that.

Don't worry about the weird output you see at the beginning of your screenshot, I see the same thing on some of my code. As long as it settles down and produces legible output afterwards, it's fine.

It appears that the Arduino is resetting sometimes. That suggests power supply issues or electrical interference. It looks like the power you are running to the motors via the relays on the yellow wires runs right over the Arduino. That's not good.

It also appears (I'm not sure from the photo) that you are powering the relay coils from the Arduino. You may get away with this, but it's been known to cause crashing/resetting. Better to get that from another source.

I'm not sure that there's much point now, but it still might be instructive to remove power from the relays and run a test. You would have to work the limit switches manually of course.

Where does the servo get its power? If it is the Arduino, that's another potential culprit for a crash.

Reply wildbill

**It appears that the Arduino is resetting sometimes. That suggests power supply issues or electrical interference. It looks like the power you are running to the motors via the relays on the yellow wires runs right over the Arduino. That's not good... ...**I'm not sure that there's much point now, but it still might be instructive to remove power from the relays and run a test. You would have to work the limit switches manually of course.
Ok, I can now say with confidence that it issue is indeed coming from the motor. The moment I detach the motor from the relay and operated the limit switches with my fingers, everything checks out. The code ran flawlessly for over 30 cycles without missing a beat. So I tried shifting the motor wires over a little in the hopes of to avoid the EMI (sadly the shift did not do much :sweat_smile:; photo attached). I am considering buying some shielded CAT wires to route everything AND the motor wires (please let me know if this is futile :sweat_smile: :fearful: ).

It also appears (I'm not sure from the photo) that you are powering the relay coils from the Arduino. You may get away with this, but it's been known to cause crashing/resetting. Better to get that from another source.
I see, is it ok to power the relay from the same power supply powering everything? So if my understand is correct, I should break out the power terminals from the power supply to a screw terminal bus bar and power a step-down module to power the relays correct? Can I use the additional pins located on the step-down used to power the VIN of the arduino to also power the relays (so the power is coming from the step-down pins directly and not coming from the arduino board)?

Where does the servo get its power? If it is the Arduino, that's another potential culprit for a crash.
The servo is powered as follows, PSU >>> large stepdown to 8.4V >>> Servo.

I am learning so much and I am super grateful for all the input and help that I am getting. I am also very happy that I finally decided to post a question here :stuck_out_tongue_closed_eyes: :grinning:. I'll purchase some shielded wires and test out the system again tomorrow and post an update here as soon as possible.

NOTE: The crash was triggered when I tested with the motors attached.

That's odd, I would not have expected that the code would still be running, how it is printing "case 2" but not changing your m variable is a mystery. I suppose that when you have EMI issues, unexpected is what you get.

I can't really tell what I am looking at with some of those components, or how the system is wired overall, but that braided black cable is apparently going to the motor and passing right next to the Arduino. Better shielding may help but physical separation may be needed too.

Update

Hi all, so I am still fighting with the dc motor. I have moved the arduino as far away from the relays and the DC motor as I could. There are no more random resets, the servo always work and the program no longer freezes. Thanks to all you guys. The only issue that remains is that the relay still sometimes randomly starts the cycle by itself without any inputs. However, the cycle will complete without any issue. I am powering the 5V to the relay by its own buck-converter. The Arduino is powered by another buck-converter set at 9V. I have also tried out twisted pairs for all power wires including the DC motor. I have no idea if this has helped my cause or not; I am glad however that at least it no longer crashes into the limits or does random things except beginning the cycle all by itself at times.

So I have noticed something also, if the motor is running without any load on it. The random triggering of the second or third cycle is less likely (maybe once in every 20-30 manual activation). However, once I add load onto the dc motor the random self triggering of cycles begins to almost triple in occurrence.

I have attached a picture for better visualization of the wiring and where everything is placed.

====To summarize====

1: The program no longer crashes or does weird things.
2: Only remaining issue is the self triggering of a cycle once it has ended.
3: Having load on the motor vs no load affects how often the random self triggering occurs.

Hi,
What is in the chassis under the power supply converters?

Have you got a 0.1uF capacitor across the motor leads?
The other thing is you are relying on those plug in jumper wires, that is a lot of friction type connections to rely on.

Tom.... :grinning: :+1: :coffee: :australia:

Reply TomGeorge

What is in the chassis under the power supply converters?
Hi Tom George :grinning: I just just added some thick automotive double sided tape to the underside of the power supply converters (I can confirm that the underside is not touching the main power supply chassis).

Have you got a 0.1uF capacitor across the motor leads?
I could source some if they would help. So something like the attached picture correct? I would really appreciate a picture reference to what and where I am suppose to apply these to help me reduce the EMI. I have been reading multiple forum post and sites regarding my issue. Another concern is that I could possibly have back EMF (could this possibility be an issue, if so then a diode soldered between the + and - of the DC motor should help solve this correct)?

I have been reading the following also. So I would do something like the three capacitor on the motor leads correct? This should help end my struggle? :joy: :woozy_face:

I have also been looking into the following module, please take a look if this would actually do anything :woozy_face: :joy:

https://www.ebay.com/itm/50V-6A-DC-power-supply-filter-board-Class-D-power-amplifier-car-EMI-suppression-/132701685299

The other thing is you are relying on those plug in jumper wires, that is a lot of friction type connections to rely on.
Once I have all the kinks worked out, I would much prefer these be soldered on also :sweat_smile: :joy: However, for this specific unit, I would be holding the dupont pins down to there location with some additional automotive tape (so they should be able to shift about :sweat_smile: :joy: :crossed_fingers:).

Anyways, I really appreciate your reply and would really appreciate a picture reference to what is being said. I really want to get this project done with, its been weighing on my mind now for the past few months. It is just so close, just a little more. If anything the completion of this project would actually help alot of people in regards to using Brushed DC motors in their projects where issues could arise.

The following is the exact model of DC motor that I am using (running off 12V). :smiley: I also tried wrapping the DC motor's wires in aluminium foil tape, but that did not do much :joy:

You still have what appears to be long unshielded wires going to the cycle button, passing next to other wires I can't figure out the purpose of. It sounds like electrical interference is again the source of your problems.

One thing to consider would be to abandon input_pullup and supply your own physical resistor instead to get a stronger pullup.

Reply wildbill,

Hi, :smiley: :smiley: :smiley:

I think so too, since I moved the arduino to the top and did the twisted pairs for all the power wires including the DC motor, the program no longer crashes. So everything works and returns normally (except for the restarting of the cycle by itself; so the heavier the load on the DC motor the more often the random cycle is triggered). I think that I will purchase some 0.1µF and 0.047µF to do the the following modifications to the motor. Since it is the source of the electrical interference.

Can you please recommend a specific resistance for the resistors that I would need for all the inputs? A picture that demonstrates the use would be much appreciated. I have a good idea of how to wire it up (but a picture would speak solidify my understanding).

I'll get everything done as soon as I can, and post back an update. I really do hope that the ceramic capacitors will help finally put an end to my suffering. :joy: :woozy_face: :sweat_smile:

Hi,
What is UNDER the DC-DC converters?
Under the metal you have the converters stuck to?

Tom... :grinning: :+1: :coffee: :australia:

Hi all, here is another update.

I tried the three ceramic capacitor filter like in this picture but end up somehow burning the largest 0.1µF ceramic capacitor (I am running on only 12V).

I will arrange the process of adding the three ceramic caps to my dc motor in chronological order with some explanation.

1: Here I soldered the 0.1µF cap to both the + and - terminals while soldering one leg of the 0.047µF caps to one terminal each. Finally terminating the two remaining legs of the 0.047µF caps together.

2: Here I attached an extension wire from the joined 0.047µF cap's leg. which will be used to connect to the motor housing. I then reassemble the unit.

3: Finally I sand off some paint to create a bare metal surface where I can solder the wire that connects to the three caps in side.

4: I tested the motor and within a few seconds of running without any load attached to it... I let out the magic smoke. I tore open the motor to discover that the center 0.1µF ceramic capacitor burnt to a crisp.

Any idea what went wrong guys? I followed everything exactly from this description.

" The three-capacitor filter is just a combination of the one- and two-capacitor versions. One capacitor is connected across the motor terminals and one is connected to each terminal and the motor casing. This is the filter that I use on all my motors: use a 0.1µF (micro-Farad) capacitor across the terminals, and two 0.047µF capacitors between each terminal and the case."

Feeling super defeated to be honest. Any help would be greatly appreciated. I also read that when you are using any inductive load such as a solenoid or a dc motor, you should incorporate a fly back diode to help prevent voltage spikes and sparks. However, there seems to already be zener diodes already placed at the relays, so I am not sure if I have to add another to the motor's wiring.

Reply TomGeorge

"What is UNDER the DC-DC converters?
Under the metal you have the converters stuck to?"

Just thick automotive tape to hold everything in place. Once I am able to get everything working properly I can redesign the mounting holes and what not. :slightly_smiling_face:

Hi,

In other words...

LBFAS...
Tom... :grinning: :+1: :coffee: :australia:

Reply Tom

Ohh thats what you meant :sweat_smile::sweat_smile::sweat_smile: well thats the main power supply, and yes, the yellow block under the grill is the transformer.

Any idea why the ceramic caps went up in smoke Tom? I read in the provided link saying that the author uses sepcifically these for all his dc motors... Mine just blew up within seconds of use. :smiling_face_with_tear::pensive:

Hi,
Those ceramics should not have blown up, what voltage are the motors rated at?

I would have soldered the caps on the outside of the motor, rather than opening it up.
Does the motor still function?

You have your power supply boards close to the transformer windings, not a good idea as there will be some a magnetic field around the outside of the windings.

Tom.... :grinning: :+1: :coffee: :australia:

Hi Tom, :grin::grin::grin:

Those ceramics should not have blown up, what voltage are the motors rated at?

The motor is rated at 12/24 V (I am supplying 12V for the reduced speed as I do not need all 30 watts). Should I try resoldering another pair on the outside? Ill retry soldering some on the outside and post some pictures. The motor still functions just find, however before I let out the smoke, the motor seemed to be struggling to move, the moment the larger cap burned up it started to spin again.

I would have soldered the caps on the outside of the motor, rather than opening it up. Does the motor still function?

Oh, I was trying to go for a clean look; does it matter where I solder the caps, are they too close to the brushes?

You have your power supply boards close to the transformer windings, not a good idea as there will be some a magnetic field around the outside of the windings.

Understood, I will move the 5V and 9V converter modules farthur away from the PSU's transformer.

Thanks for your reply Tom, I truly appreciate it, the forum is the only thing keeping me sane at this point :sweat_smile: I have learned alot along the way... but man... it just doesn't end :sweat_smile::joy: cheers, I eagerly await a response from you Tom :grin::grin::grin: