PID -Hardware needed for a software fix

You can also cheat.

If new measurement < old measurement * 0.05
// Reject it.

I think it is the sketch somehow. I have to run to the post office real quick but I am going to do a clean up of it (get rid of the LCD stuff), read the same values with the same variables, one just plain reading rising times, one with the PID loop (but not running on it). The values are too far off when the loop is runningā€¦but it wasnā€™t with the other sensor.

I am sure you are right about a filter though. I just want to make sure the hardware is as proper as possible first.

Your sketch is just fast enough to catch it.

Ohā€¦ so maybe limit the reading to no faster than Max RPM, plus a little overhead?

Back from the PO and Cleaning it up now and trying without moving or touching anything.

hmmā€¦

everything connected and powered up even if I am not using it. The issues are there. So a raw test next (solo board only the 3 sensor wires).

[attachment file=60870]

This is a good sketch to test the filtering (or whatever solution) on I would think, the same butā€¦naked. Dam I knew the encoder was better but not by this much.

Ā 

The signal is kinda wonky only when the ground is connected between the rambo and the nano.

Yeah. This is a good test script, after youā€™ve cleaned it up enough to trip the interrupt.

The 12/24 doesnā€™t bother me, but the 1100 does. Thatā€™s pretty far off of the mark.

Why dont you bring it over to my shop and weā€™ll take a look :wink:

Do you have a ground loop? Two ground wires connecting the same two grounds?

Well, yes and no. Its a mess but it is as simple as I can get it I think.

To test I have the rambo powered, USB to computer, ground and 2 signals to the nano. Bad things happen without the ground.

The nano is also Usb to the next computer port, sensor wires, ground power signal to the dimmer. Dimmer is powered. All the power is in the same power strip.

I canā€™t monitor the speed or signal but I did just try power to nano from the rambo (how it should be when finalized), no USB. Didnā€™t seem to help.

Scope might help if I knew how to troubleshoot with one. I have about 1 hour worth of experience with one.

30000 RPM is 500rps or 2000us period. Ignoring anything thatā€™s less than 1500 would be reasonable. Itā€™s definitely strange that youā€™re getting an edge in the middle of a cycle. (The two 1100ish nimbers means itā€™s triggering twice, probably).

I think a 5 element median filter makes sense. Iā€™ll think about a clever way to implement one in arduino. Even if you fix your hardware issue, someone else will hit something similar. For now just cut out anything under 1500.

So it only happens when the rambo power supply is connected. I tried a direct ground from the power supply instead of from the board same issue.

Here is the rub.

When the ground issue happening the data is wrong. Turning it by hand low RPM, the numbers are wrong. Hmmm, unplug the ground, perfect. Frustrating.

Iā€™m far from an analog circuit expert. I bet thereā€™s a simple thing to fix it. Some kind of ground isolating circuit or a capacitor or diode somewhere. Maybe you need more groundingā€¦ You might have a high frequency signal thatā€™s just ok the edge of tripping, and this getting circuit stuff is just topping it over the edge.

The noise youā€™ve shown so far is definitely fixable in software though.

When it is solo.

[attachment file=60888]
stable at what Ā± 3ā€¦max deviation is Ā±10. Hmmm. Need to figure out some google ground isolation or something. Filtering this will be much better than trying to filter out 1k-2k dips. Just not understanding how it can change the time readings. Solo turning it by hand the time readings are 6 figures or so. Just connecting one ground lead basically reverses it and I get 30, 112, ect.

Jinx!

Ā 

grrrrrrrrrrrr ffuuuc77777777777 A whole wasted day. 99.9% sure I soldered a wire wrong. shoot. I bread boarded another sensor, no issues. Same readings grounded or not. I must have the signal on the wrong side of the sensor.

The diagrams are all jacked but if you follow it carefully this works. Dammit, another Friday night solderingā€¦

Dā€™oh!

OMGā€¦

Bud light break, before I break something else. Man, I am pretty disappointed I didnā€™t try that sooner, also amazed it worked backwards. I was getting great signals solo. Nice to know basically reverse voltage on the Rambo, nano, dimmer, and my computers USB is solidā€¦

Breatheā€¦silver liningā€¦breathe

If youā€™re interested, here are two files that you should be able to add to your arduino project to get the median filtering. I didnā€™t try them in arduino, I just build them with g++.

Itā€™s not perfect, but it will do. I usuall work with ā€œmodern C++ā€ and lots of standard template library tools, so this was a fun exercise for me.

Dangā€¦ You are freaking really good at this stuff. I have to dig into it a little more.

Today has been irritatingly hectic, and I have to leave soon but I have the new sensor wired up. Made me realize I might finally have a reason to mill a PCB! Nano, sensors and resistor plateā€¦Anybody have suggestions, eagle or should I just do it in CAD?

eagle or kicad. I havenā€™t messed with them in a long time (since before I had my own CNC machine), but IIRC the hardest part is getting the schematic for the parts you have. Even if the parts are 4x1 jst connectors. Being able to wire it up in the schematic view and then place things where you want them after is very valuable. CAD will be a lot faster to do the first time, and a lot longer the second time.

I also remember sparkfun having a reasonable set of parts available in their library.