You can try something like gweimer/utils/running-avg, but anything you do to smooth out the noise is going to reduce response time if that is important (like a balance sensor would be). There might be other libraries that can provide better response while still filtering some of the noise.
Is the noise problem only when you are running the motors? Could be electrical noise from the motors or controller, or power fluctuations. If possible, it would be better to fix the problem instead of trying to hide it.
If the same battery is powering other items (like your magnetic shocks), you may well be drawing too much current for a 9V battery, causing your fluctuations. If you have not added those yet, or they have a separate battery pack, it might still be electrical noise from the controller or shocks, but besides suggesting the addition of a small capacitor, I can’t help much with that. I’m not even sure what size or where you would need to add it. (In RC cars, a small capacity is sometimes added between the terminals of the motor to reduce electrical noise.)
If you had a clean signal on the bench, you might try disconnecting parts one at a time on the car to determine which one(s) are causing the fluctuations.
Haven’t connected anything to the system, it was just a Prototyping making sure the sensor works as intended run.
I’m pretty sure its from the vibrations of the car when its in motion.
this is for an actual car by the way, so it will eventually be powered by the 12v system with Mosfets driving the shocks, ride height sensors determining velocity etc,
this is just the first step of actual on car testing since everything is only bench tested at the moment.
Ah…if you are testing the G sensor in a real car, that would likely produce a lot of noise in the output of the G sensor since there will be a lot of vibration. You might be able to mount your sensor as a way to provide a sort of mechanical averaging rather than trying to do it in code (or maybe mechanical mount to reduce the bulk of the noise and filter the rest in software).
The trouble with doing it in software is that you will only be taking samples from the graphs you show. If you get “unlucky”, you might sample adjacent vibration peaks or both sides of a peak. If you take too many samples or space them too far apart, the “real” peaks could be done before you start to see them; too few samples and you still get a lot of noise. It is likely to be a balancing act between how often you sample and how many samples you average. If you are trying to stiffen shocks before the car bottoms out, you probably need pretty quick response time.
If the running average doesn’t work for you, maybe using gweimer/utils/queue-buffer (or just setting up your own buffer nodes) to save the last few values and compare the min and max of those values will allow you to see quick changes but still filter out some noise. I’m sure there are other options for comparing/filtering also.
Ever owned a car where if the antenna wasn’t properly connected, or the radio station was slightly off, you’d get the electrical buzz/whine?
Try insulating your wires leading into the G sensor, so they can’t pick up electrical noise from any wires they may be running next to/across, and also put a balun in line to limit noises from elsewhere in the vehicle
my 3c worth may not be worthy, but it’s worth a shot
How do i use the running average node? I set it to 10, 100 samples and I didn’t see a difference?
I ended up making 20 Clip Boolean Nodes so when the sensor is outputing between say 1.65v and 1.75 I get a .1G and then using fade to smooth it out. kinda works but i think the running average combined with Fade will work really well once i figure it out
You adjust the size of the running-avg node so the number of dummy pins matches how many numbers you want to average together.
VAL is where you input the numbers to be averaged. Pulse the UPD pin to tell the node when to read VAL & add it as a new number. The AVG output pin will have the average. Note that if you expand the node to include dumy3, The initial AVG will be 0 because everything initializes to zero. Sending one pulse to UPD will cause the 1st number to update to VAL, but the other 2 will still be zero until two more pulses are sent to update all 3 internal values to average together. If you keep sending pulse with the same VAL, the AVG will just be VAL. The unlabelled pins should not be used; they are used internally to pass the variadic data.
utils-example-avg is a demonstration of how to use the running-avg node.