Hi,
I am struggling with controlling a fan with PWM.
By documentation of the fan a frequency for the signal from 1kHz up to 10kHz is supported. So I used 4kHz here.
I have read the KnowledgeBase article regarding PWM but it does not bring any light in here.
I checked the Neuron M103 register map.
So I use the following values:
- frequency = 4kHz = 4,000Hz
- resolution = 11 (want to have 0,10,20,...,100 as percentage)
I can not set these values directly to the registers, instead I have to use a "prescaler and a "cycle length" according to the Neuron modbus documentation above.
These values are to be calculated (again, see first linked doc) as follows:
PWM_Cycle = resolution - 2
4.8 * 10^7
PWM_Prescale = ------------------------------- - 1
frequency * ( resolution - 1)
So in my case I get the following calculated values:
- PWM_prescaler: 1199
- PWM_Cycle: 9
Both am I setting without any errors to the documented registers 1017 and 1018 (in C):
err = modbus_write_register(conn, PRESCALER_ADD, prescaler);
err = modbus_write_register(connection, CYCLE_ADD, cycle);```
Fine so far. Now I want to set the digital outputs according to any desired percentage value steps (0, 10, 20, ..., 100).
These are registers 16, 17, 18, 19 according to the DO numbers.
But which value am I allowed to write to these registrers?
There was a forum post where @tomas_hora stated:
The PWM value register takes values from zero to the number in the PWM cycle register.
So in my case the PWM cycle register has a value of "9" according to above calculations.
So I should be allowed to use values 0, 1, 2, 3, 4, 5, 6, 7, 8, 9.
But there are only 10 values and I do not know which percentage they match to.
I assume 0 equals to 10%, 1 to 20% and 9 to 100%, right?
If so, how do I tell the digital output to set "0"?
Or is 0=0%, ... 9=90%?
Again, if so how do I set 100%?
Any hints?
Thanks a lot!
/KNEBB