Originally Posted by
jeanbat
Hello, I managed to adapt the code for my esp32, but I'm not sure about the frequency to use for the solenoid pwm? I don't understand what frequency is set in your code?
Thank you
i'm using somewhere around 33.6 hz. here's how....
from the xiao code:
line 101 divides the 48MHz main clock by 1000 (except this divider can only be 8 bits or a max of 256 so 1000 rolls over 3 times and leaves 232 which i changed in the experimentsl code but not here.) => this generates a 206,896.5 Hz clock.
line 127 divides the 206.8 KHz clock that i generated above by the 6145 (remember, with computers counting starts at 0) which gives a carrier frequency for the PWM of 33.66 Hz with 6146 steps of resolution.
i should change line 101 in the code so it's not so confusing but it works so there's that.