I am using a power bank or USB phone charger for power, both can
supply 5V and 2.4 amps. What I found out is that when the stepper
motor runs, the voltage in the circuit drops down from 5.2 volts to
4.6 volts, causing a dim in the LCD and sometimes it caused a hang in the PIC or the RTC.
The stepper motor is NEMA 17 HS4401 which has phase voltage of 2.6
volts and phase current of 1.7 amps but I am limiting the current to
less than 1.2 amps
After adding a 100 uf capacitor in parallel with PIC and increasing
the motor capacitor from 100 uf to 220 uf, things became better.
Getting the motor power wires (VMOT and GND) closer to the power
supply somehow reduced the drop, voltage now drop to only 4.9 volts.
So my questions:
1- Why is this voltage drop happening? as far as I understand, it
should not happen as long as I am drawing below the 2.4 amps the power
source can supply
Wires have resistance, and when current flows through a resistance, it creates a voltage drop over that resistance proportional to current and resistance. More resistance or more current means more voltage drop. This can cause a decrease in output voltage right at your regulator, or the regulator may just have variation while it tries to keep up to the surges, so you should apply max load and measure output right at the regulator to see if you need a regulator with better load regulation. The capacitors you've added/increased the size of act as pressure reservoirs to feed the surges so the regulator can have a more constant and therefore predictable output, but they can only charge up to the actual output voltage of the regulator, so if your regulator output is dipping when the load is applied and recovers it's output voltage with a constant load, the capacitors will help more. In the other case, the caps might not be able to cancel the voltage drop at the regulator output, but they can reduce it a bit and help keep it constant by smoothing the regulator output.
Your current rating can't easily be changed in this case, but your wire size may be an issue. Measure the length of your wire and look up it's resistance per length and calculate it's resistance, then decide if larger wire is in order. Use a voltmeter to measure voltage drop under load.
2- Is there any way to eliminate that drop? would using a bigger
capacitor for the motor make any difference?
A regulator with better load regulation might be necessary depending on your tests, and you may need to use larger or shorter wires. You could also use a separate regulator for your logic, which is more sensitive to voltage than a motor, although with a stepper motor you want to make sure regardless of voltage change it has enough power to make a full step when activated. If you don't want to separate the regulators, increased capacitance does help, but be aware when you first connect your regulator to capacitor, you'll have a current surge to charge the capacitors and your regulator may treat this as a fault and shut down or perform in other unexpected ways. The larger the capacitance, the longer it will take to charge, resulting in a slowly rising source voltage. From experience I've had logic circuits misperform when they're turned on too slowly and had to add a delayed enable so one part of the circuit didn't activate before the rest, so if you go overboard on the capacitor band-aid there are disadvantages.
3- The motor completes a cycle, stops a bit then moves again, which
keep changing the voltage between 5.2V and 4.9 volts, is there a risk
that the constantly changing voltage would damage any components?
This is the part where an engineer would guess better than me, but for hobby purposes, .3V variation isn't that much, especially if you can improve the variation on the logic circuit. You have 6% variation, but logic circuits use so little power I'd usually aim for 1% or better. Some circuits are more sensitive than others. I had one circuit that produced it's own regulated reference voltage to compare to output voltage, so its output was fairly resilient to input power changes.
In another part of the circuit I was timing by charging capacitors off the varying input voltage, and comparing that to a regulated reference. Even though the reference half of the circuit was resilient to input changes, the rate of capacitor charge was changed and varied the frequency of my timing loop.
So how much variation you can afford depends on each individual load and I don't know how each of your digital loads deal with voltage ripple. If the voltage ripple is slow enough and within the acceptable input range of your load, nothing bad will happen at all(IE battery output voltage slowly dropping), but your ripple is much faster than that.