This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

change duty cycle seperatly and independently on each channel

hello 

i am using nrf52832 with pwm driver (working with ble and s132 if it metters)

i need to control 4 different motors speed via pwm, since there can be only 3 instances i am trying to use one instance and use its 4 channels

i am looking for an easy way to control each motor's speed (each channel) independently and separately 

for example at time t0 i start motor one at x sequence or x% duty cycle and at time t_1 (first motor still running) i need to start second motor at y sequence or y% duty cycle

and so on for the rest of the motors the activation and deactivation of the motors is a-synchronic and depends on inputs from UI.

is there an easy way of doing that ?

best regards 

Ziv

  • well i have tried to use the sequence definition like that:

    "

    static nrf_pwm_values_individual_t /*const*/ pumps_motors_seq_values[] = { 0 };

    nrf_pwm_sequence_t const seq0 =
    {
    .values.p_individual = pumps_motors_seq_values, //seq0_values,
    .length = 1,//NRF_PWM_VALUES_LENGTH(seq0_values),
    .repeats = 1,
    .end_delay = 0
    };

    "

    and activate each channel like that:

    "

    pumps_motors_seq_values->channel_0 = speed | 0x8000;
    nrf_drv_pwm_simple_playback(&pump_motors_pwm_speed, &seq0, 1, NRF_DRV_PWM_FLAG_LOOP);

    pumps_motors_seq_values->channel_1 = speed | 0x8000;
    nrf_drv_pwm_simple_playback(&pump_motors_pwm_speed, &seq0, 1, NRF_DRV_PWM_FLAG_LOOP);

    "

    but when i activate channel_0 it activats all motors and also channel_1 does not activate anything at all

    what can be the cause of that? what am i doing wrong?

  • SOLVED

    the problem was with the  " .load_mode    = NRF_PWM_LOAD_COMMON " in the "nrf_drv_pwm_config_t" struct

    instead of  ".load_mode    =  NRF_PWM_LOAD_INDIVIDUAL,"

    this way the values put to each channel affect one channel only and not all Slight smile

Related