Kudos on some well documented code and my apologies if I am reading it incorrectly.'
This snippet seems to be saying that if the sampled position is less than the previous position, and the previous position was greater than 0, and later that we have crossed the plunger's rest position then we are in a firing event. I don't see the requirement that the distance between the znew and z0 must be greater than some threshold. This is the check you perform to see if a firing event occurs during a "highresscan".
This looks in contrast to the condition for any other time:
if (!firing && cfg.d.plungerEnabled && z >= JOYMAX/6)
Where it seems you require it be pulled back at least 1/6 of the travel (1/2"). Am I reading this correctly? It seems during the "highresscan" only a small amount of noise could trigger the firing event.
That's a good catch - I think you're right. That check for crossing the zero point probably needs to have a distance threshold from previous readings along the same lines as the others. I'll take a closer look and make a testing version for you to try out.
I just posted a new version with this change, and I also added some averaging to the analog readings. Hopefully the combination of the two will solve the spurious firing problem! Let me know what you find when you have a chance to test it.
http://mbed.org/user...ape_Controller/
You're probably right about my missing a few outliers visually on the windows output, however the oscilloscope noise now (since the GND wire addition) seems capped to 50mV on a 3.3V full scale signal. That's not bad.
I hadn't done the math before, but that level of noise is almost certainly enough to account for the spurious firing events with the missing threshold test in the old code. 50mV is about 1.5% of the overall 0-3.3V range; in terms of travel distance, that translates to about 1.25mm. The quantization level I use on the CCD is 1 part in 160, which is 0.6% or .5mm. So the 50 mV noise level is definitely in the range where I've been assuming a pretty noiseless signal. That's not a completely safe assumption even with the CCD, since even there you can get fluctuations of a few pixels plus or minus because the shadow edge on the sensor is fuzzy. So this was a good thing to fix even for the CCD.




Top











are all trademarks of VPFORUMS.