My dear, I have a project with pic, it is a sequence, I control three loads, the problem is when one of these loads is activated, which is a selenoid, my sequence is reset ... and I want to rule out that it is a programming problem, which I do not believe because at times it is going well, ooo that it is the assembly of the circuit ... that is not using the appropriate resistors or the ideal transistors ...
you must feed the pic
independent of the other elements, so use a regulator only for the pic and its peripherals, do not put motor or anything in those 5v since it resets it, also verify that the voltage is not falling when you activate the solenoid and check the resistor of the MCL that is not lazy and is about 10k to 4.7k.