Based on the quite useful reverse engineered schematic at https://hackaday.io/project/174308-tradfri-pir-motion-sensor-hacking the measurements were somewhat sabotaged by the 2N7002 (see Connors comment "enables voltage dividers only when triggered").
the transistor is controlled by the Elmos E931.96 PIR motion controller IC.
The latter is programmable by the IKEA TRÅDFRI ICC-1 module's EFR32MG1P132F256GM32 MCU.
2. Blind Time
Ignores motion after the interrupt output is switched back to 0
Range: 0.5s... 8s.
The blind time is [Register Value] *0.5s
3. Programmable pulse counter
1... 4 pulses with sign change in between
Amount of pulses = [Register Value] + 1
4. Window time
For noisy environments
2s... 8s window
Window time = [Register Value] * 2s + 2s
https://github.com/basilfx/TRADFRI-Hacking gives a good overview on that.
What is the issue with tose 60s?
Frequency and voltage of an Atmega does not effect radio quality of a NFR24 in any way (if it is stable and well decoupled voltage).
@Ethan-Chua said in Increasing range of 8MHz ATMEGA328P with NRF24L01:
Defined #define MY_RF24_PA_LEVEL RF24_PA_LOW
That's the opposite of what you want to achieve.
It either problem with cheap nrf modules, or your pcb design. By the way you have big problems with the latter:
Your PCB doesn't have separated ground plane, and even that thin piece of ground track that tries to get to the point isn't connected. And what even worse it almost touching 3.3V out pin of BL8530. You need pay more attention to track clearance and consistency. How are you powering this board?
To provide a large enough pulse to drive the ceramic transducer , you need a lot of energy, so they pump up the 5v with an inductor/transformer to provide a high voltage pulse. This is 60v or more…
The more Energy you produce the farther the pulse will travel….
Everything thing else on the board run at 3.3 to 5V.
Add a large Capacitor of 100 µF are so between the 5v and ground on the device, this may clean up your problem.. Some CPU modules just can’t supply enough current quick enough that’s needed when the pulse is triggered.
These are very inexpensive device, we’re luck to see them work at 1/2 the spec range.
I made one myself a couple of years ago, and yes, it was a fair bit of trial and error to get it working.
Of course, the gain values will be dependent on a number of factors, for example, the torque constant of your motor, the gear ratio, the mass of the robot, where your centre of gravity is located, your loop rate, and where you've located your mpu-6050.
I located my mpu-6050 over the axis at 12 o'clock near the vertical centre of my bot.
What are you control variables?
I used pitch (angle of rotation around motor axis) calculated from gx, gz and tan function.
I also used pitch rate from the gyro.
Are you using the onboard DSP of the mpu-6050 to do the calculations?
I had no luck with this, the mpu-6050 kept freezing up, bad clone I guess.
You also have to verify the direction of rotation of your motor versus your control variables.
If you have the wrong direction, it will just run away.
My gains are Kp:41, Ki:160, Kd:0.4
I started with only Kp and kept increasing the value until the system became unstable, then I backed off to a stable point.
Next, I began increasing Ki. This will bring you to steady state stability. It should balance itself when Kp & Ki.
You will likely have to reduce Kp somewhat as you move to higher Ki values, if your system becomes unstable.
Finally, I added Kd, to help it react more quickly to changes in angle.
How do you change your gains?
I have a bluetooth module on mine, to allow me to send serial commands to the robot, to set the gains and other things.
My robot's biggest problem is gear backlash. This generates acceleration noise as it vibrates backward/forward, balancing itself. This vibration can feedback on itself and cause instability (when you increase Kp too high). It looks like the robot has Parkinsons when this happens!
I'd like to update my design to use a belt/gear drive or continuous rotation servo, but I haven't had a chance to get back to it.
I hope this helps.
Success! In all my testing and trying new settings, I missed that I had commented out on the gateway the frequency setting. It was noobie mistake and I want to thank all of you for your help. I ended up using @FarmerEd's sketches to get my gateway and sensor to work.