Thanks philba and gramo.
Yes, I think the PWM might be the problem. One of the old ADC (in MPLAB C18) functions used to have a PWM trigger - that does not seem to exist now.
I did discover that I am not getting the right ADC results, though. my mistake - It's supposed to be around 230 mA; which can be explained by that missing zero in the multiplier
.
One of the things that's happened since I posted the message is that the whole system is now haywire. I'm sensing current from pin 15 of the L298N. A .5 ohm, 12W current sensing resistor is connect to ground and a wire goes to ANO from pin 15, too.
technically, with this code, I should get a fair estimate of the current through the device. Well, I don't - no idea what the reason is. May be the PWM is messing things up.
Any idea how I can use the rising edge of the PWM to trigger ADC conversion?
I also want to make sure that I'm doing the right thing with reading the result of the conversion...
If not, I will have to go with gramo's note on medians...
To explain the application, I'm measuring the current through the motor terminals, and I need to get the motor to stop when it hits a physical limit switch and the load lead sto a jump in the current...
P.S. I won't be available from tomorrow evening till Wednesday - give you all some time to help me out!
Have a great long weekend!