![Question :?:](./images/smilies/icon_question.gif)
I have put together 2 prototype circuit's with different power supplies capacitors etc. but with the same results.
I have run it through proteus (as per attachment) and it is predictable using software.
I have got myself a DSO oscilloscope which verifies what proteus predicts.
The flowcode program consists of code that produces a pwm signal using timer interrupts based on sean`s here in the forum.
The code is using only 2 of the signals for operating 2 servo`s. I have then added code to input 2 sensors using 2 ADC pins.
The object of the program is to modify these pwm signals using the data collected from the 2 ADC`s
together with my algorithms and a data file, the servo`s having end points programed together with a led to come on for each of the 4 end points.
Each servo output has its own chunk of algorithm.
So the situation is:
i am running a 18F2620 at 32mhz
with no algorithms the pwm is stable.
with 2 chunks algorithms servicing 2 pwm signals i get the glitch.
If i take away one chunk of algorithm i get a stable signal, although the pwm interrupts are still generating the 2 signals.
I have deduced from experimenting that if i slow the pic chip from 32mhz the glitch gets worse.
If i change the CCP1CON register to anything other than 1:1 prescale the glitch gets worse.
If i add a delay (using a `loop doing 255`) inside the macro that controls the interrupts, the pwm signal gets twice as long `but it does cure the glitch`. The trouble here is that the maths needed to correct the width of the pulse cause an over flow, as it appears that numbers greater than using 2 bytes would be required. The effect i get is, the pwm width can be slowly advanced but before it reaches an end stop it jumps back to the start, then carries on advancing before going completely crazy.
So from what i have gathered, i believe that the `ratio of time the interrupts use compared to the time used for the flowcode program `uses, needs to be changed in some form. I believe the interrupts cannot keep in step with the program completing, due to the fact that if half the algorithms are taken away the glitch is cured.
The size of my flowcode is not that large.
RAM available:3968 bytes, used:78 bytes (2.0%), free:3890 bytes (98.0%),
Heap size:3890 bytes, Heap max single alloc:127 bytes
ROM available:65536 bytes, used:2144 bytes (3.3%), free:63392 bytes (96.7%)
If i am right in believing that you are adding a pwm for use on servo`s in your update flowcode v4 this problem of mine is more than likely going to happen to your update when someone adds sufficient program code over a certain level!
So i would be grateful for any thoughts you may have on how to tackle this problem.
in the following picture of the oscilloscope, you will find 4 signals in 4 colours,
the green one not used.
the blue one is the led bulb that has come on, but does have a glitch at `B`
the red one is one servo, the `A` and `C`indicates the glitch.
the yellow is the other servo but still glitches.
Thanks in advance.