PID -Hardware needed for a software fix

Nice giant box just showed up on my doorstep, feels good to get my hands on these finally!

[attachment file=“IMG_20180531_114514~2.jpg”]

But, where are they?

https://vicious1-com.myshopify.com/collections/all?sort_by=created-descending

HAHAHAH, I really need to plug one in first. Need to test at least one of them. I pack a few boxes, answer some questions, plug in some wires, clean up my test bench…ahhhhhh too excited!

I really need to make a little box, I really hate shocking myself so I need a cover. Gnarly PID box…

Didn’t you just say a giant box just showed up? Add some tape. Done!

1 Like

Getting there.

[attachment file=60788]

2 Likes

Okay, the signal is great I had 60-840 as a best range out of a max 0-1024. The sensor wires will be passing directly between the AC switch wires so we will see if or by how much the signal degrades. I don’t think more than a few hundred are needed since we are just looking for rising and falling edges.

Todd, went with a cap inspired by you. Got the sensor closer, added a light baffle, and a place to cable tie it in. This allows for some adjustments if needed.

[attachment file=“IMG_20180531_181645~2.jpg”]
[attachment file=“IMG_20180531_181351~2.jpg”]
Led closer to the center works better for me.

[attachment file=“IMG_20180531_180807~3.jpg”]

Sharpie and WhiteOut, seems to work better than the reflective decal. But I wan to revisit this now that I have a better light baffle in place.

[attachment file=“IMG_20180531_180329~2.jpg”]

[attachment file=“IMG_20180531_184334~2.jpg”]
All tucked in.

 

[attachment file=“IMG_20180531_184207~2.jpg”]
Buttoned up, and ready for power.

 

[attachment file=“yeah baby.jpg”]
Yeah Baby, Clean signal!!! Game on…

Now I really need it to show up in the shop. :slight_smile:

COOL!

Will have to fire up the 3D Printer and print a new cap as soon as you post it online. I have all the parts and am ready to go.

My bad, I thought I attached it.

 

Wiring it up, commenting out the LCD stuff…Maybe a real test?

V1-660-PID.zip (29.1 KB)

Dang it, the new sensor is not cooperating. Maybe the signal is not as clean as I had thought, it is routed right between two live power lines…

Hmm. So this is the raw microsecond values it reads. This put it somewhere near 27,000rpm, wide open, no PID, hardwired.

The little dips are messing with the PID. Capacitor or software filter? No idea.

[attachment file=60857]

I would not know how to add a CAP to filter this kind of thing. I rerouted the wires a little bit and got an ideal signal.

[attachment file=60858]
You if you watch it you can even see like an RPM resonance happen while it is wide open. The spikes still happen but not very often. Maybe some shielding…

Okay, rerouted the wires even more. No glitches, max spikes ±250RPM @~27000, raw hardwired. Back to the PID now.

Do you think we may have to use shielded cable?

Also hit the 3D printed cap with some flat black paint to cut down on the shine of the plastic.

I also put some black paint on the Dewalt under the cap. Need to keep the IR light from bouncing around under the cap.

Hope to change out my cap this weekend and will see how the data looks after to goes all the way back to my control box.

May also try to find some shield cable.

 

 

I moved around the wires and by itself it has a great signal.

 

Drop the PID sketch back on it and it is horrible again. The raw time has random 12’s and 24’s, not even just the 1k drop outs. So I think there are some sketch issues. Not sure what is going on, or why it is different. I tried reading rising edge instead of falling, no different.

Just in case I am cleaning up my test bench and moving all the cords to the same power strip and everything. It gets a little frantic and messy when the goal is so near.

Soooooo, close…

Looking at the pic with the dips, you are looking at the processed value. The actual signal light be stuttering a little bit, causeing two quick edges. The simplest thing I can think of is a small median filter (software) on the microsecond values. If you keep the last 5 numbers, and drop the two highest and two lowest, you’ll be able to reject these outliers. Even a small filter on the input could also reduce the stuttering (a debounce circuit). That might eliminate the outliers completely.

The median filter is a little tricky, because you need to keep the last 5 values (so, a circular buffer) and then sort them, without moving your buffer. It’s not rocket surgery though.

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.