Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Run stepper motor for particular time in sec

Status
Not open for further replies.

sagarnayak123

Newbie
Joined
May 30, 2022
Messages
3
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
22
Hello ,
In my project i am using stepper motor with nrf52840 controller so i want to run my stepper motor for particular time in sec like for example in my application i want o expel the fluid from the tube by using this stepper motor. out of 10ml fluid i need to expel 2ml /sec it means to expel 10ml it should takes total 5 sec.
this is how the motor should works based on the parameters which user can input. so to implement this i got stuck and if anybody have idea on this please help to resolve this.

thank you.
 

The nRF52840 is a Bluetooth SoC. What does that have to do with a stepper motor?

what are you stuck with? Did the motor blow up? Do you not know how to write the proper code?
 

Hello!
A good idea would be to start by posting what you wrote. I suppose you have a kind of interface for your stepper. Tell us how you access it, also tell us what kind of pump it is. For example, single piston pump will not give linear results vs crank speed. But a gear pump will. In this latter case, you can for example calculate how many ml per step you will get, then calculate the number of steps you have to send to the driver. As for the speed, calculate how many steps you need to have 2ml, and fit this to 1 second using a timer. You may define conversion functions like this:
uint32 Pump::cc_to_steps(uint16 cc);
uint16 Pump::steps_to_cc(uint32 steps);
Of course, you may decide to have decimal numbers for cubic centimeters, but I would not recommend float or double numbers in an embedded system, but rather to use integers.
Dora.
 

Hello!
A good idea would be to start by posting what you wrote. I suppose you have a kind of interface for your stepper. Tell us how you access it, also tell us what kind of pump it is. For example, single piston pump will not give linear results vs crank speed. But a gear pump will. In this latter case, you can for example calculate how many ml per step you will get, then calculate the number of steps you have to send to the driver. As for the speed, calculate how many steps you need to have 2ml, and fit this to 1 second using a timer. You may define conversion functions like this:
uint32 Pump::cc_to_steps(uint16 cc);
uint16 Pump::steps_to_cc(uint32 steps);
Of course, you may decide to have decimal numbers for cubic centimeters, but I would not recommend float or double numbers in an embedded system, but rather to use integers.
Dora.
Hello,
Thanks for the reply, here we are using single rod piston with zig-zac cuts for more information please find the below attachment and
regarding code i have used the pwm library from the nordic SDK only so a code snippet for forward moment please find the below code there i took 10000 HZ for maximum frequency and i don't know how to use duty cycle with respect to desired time in seconds.

Code:
   else if(strcmp(DATA,"F1")==0)                                               
    {
 
          uint32_t value;
          uint8_t target_ml;
          nrf_gpio_pin_set(SIP_SENSOR_BOARD_ENABLE);
          nrf_gpio_pin_set(SIP_SENSOR_BOARD_ROTATION);
          app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_1CH(10000, SIP_SENSOR_BOARD_PWM_PIN);
          app_pwm_init(&PWM1,&pwm1_cfg, NULL);
          app_pwm_enable(&PWM1);
          rightsensor=opt1;
          if(volume_flag==0)
          {
          monitor_volume=resist-AUTO_EXP_VOL;
          volume_flag=1;
          }
          if(rightsensor!=1)
          {  
              while (app_pwm_channel_duty_set(&PWM1, 0,1000) == NRF_ERROR_BUSY);
              nrf_delay_ms(100);   
              revs_fillback_flag=true;
          }
          else
          {
            app_pwm_disable(&PWM1);
            revs_fillback_flag=false;
            memset(FINAL,0,12);
          }

          if(resist <= monitor_volume)
          {             
            nrf_gpio_pin_set (SIP_SENSOR_BOARD_ENABLE);
            memset(prcol,0,120);
            memset(FINAL,0,120);
            revs_fillback_flag=false;
            proto_flag=false;
            volume_flag=0;
          }
          app_pwm_disable(&PWM1);
          app_pwm_uninit(&PWM1);
     }

or if you need whole code means please make this ticket as private then we can move to further discussion.

thank you.
 

Attachments

  • 03_06_18_19_30_24_Spring_return.jpg
    03_06_18_19_30_24_Spring_return.jpg
    28.6 KB · Views: 113
Last edited by a moderator:

The nRF52840 is a Bluetooth SoC. What does that have to do with a stepper motor?

what are you stuck with? Did the motor blow up? Do you not know how to write the proper code?
Hello,

thanks for the reply, actually i have used the code from the nordic SDK example only since i can ale to run the stepper motor but not for the desired time in seconds how can i set the duty cycle to get the exact time in seconds.


thank you.
 

Hello,

thanks for the reply, actually i have used the code from the nordic SDK example only since i can ale to run the stepper motor but not for the desired time in seconds how can i set the duty cycle to get the exact time in seconds.


thank you.
Duty cycle has nothing to do with The speed of a stepper. Speed is controlled by number of steps per second. Thus, “stepper” motor.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top