Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

Thread: Ws 2812b pixels to control Dc motors

  1. #11
    Join Date
    Dec 2011
    Posts
    5,733
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    Quote Originally Posted by MartinMueller2003 View Post
    I suggest you use the WeMos R1D1 board. 8266 based but has more of the IO pins available. You could do more than one motor on a single board.
    Thank you for posting this . I just googled the wemos will use them instead .

  2. #12
    Join Date
    Dec 2012
    Location
    Hudson MA
    Posts
    3,547
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    You are welcome. I have used it in a few projects and it works well. Very Arduino'ish in how it is set up.


    2019 - Just moved into a new home (yet another change of plans). Will be dim but not dark. Too much to do at the new place to leave time for a show.
    https://www.youtube.com/channel/UCyX...ttrsZNARkUce0Q

  3. #13
    Join Date
    Dec 2011
    Posts
    5,733
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    Quote Originally Posted by kockie View Post
    i'd like to control a stepper motor from e1.31 to make a kind of dmx-winch. I'd like absolute control meaning 1 in the channel is position 1 and 254 in the channel is position 254. I tried this half a year ago and got some rudimentary movement. I have to call in my neighbour to help (he's a programmer)....
    Hi kockie
    I have managed to get stepper motors working now with code that can be simply added to the espixel firmware .
    If you are looking for something functional to test with .

    Cheers

  4. #14
    Join Date
    Dec 2011
    Posts
    5,733
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    Quote Originally Posted by kockie View Post
    i'd like to control a stepper motor from e1.31 to make a kind of dmx-winch. I'd like absolute control meaning 1 in the channel is position 1 and 254 in the channel is position 254. I tried this half a year ago and got some rudimentary movement. I have to call in my neighbour to help (he's a programmer)....
    Your post has got me interested in steppers for the hobby . I think this can be done in a roundabout way using 2 rgb channels .

    1 for speed and direction and another for a set position .

    Yet to test .

    Code:
    void loop() {
      // Stepper  Control
      int speed = 0;
      int direction = 1;
      // Get position on PWM_pin
      int position = analogRead(14);
    
      /*
      Values between 562 and 1023 mean forward movement. Speed gets
      mapped from 0 to 100 and direction stays positive. Park_pin will
      stop any movement if HIGH.
      */
      if (position > 562 and digitalRead(4) == HIGH) {
        speed = map(position, 562, 1023, 0, 100);
      }

  5. #15
    Join Date
    Nov 2015
    Location
    The Netherlands
    Posts
    71
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    Quote Originally Posted by angus40 View Post
    Hi kockie
    I have managed to get stepper motors working now with code that can be simply added to the espixel firmware .
    If you are looking for something functional to test with .

    Cheers
    iI'm interested for sure!
    Errors for fun only.

  6. #16
    Join Date
    Dec 2011
    Posts
    5,733
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    Quote Originally Posted by kockie View Post
    iI'm interested for sure!
    I am happy to report , you have your winch !!

    forward , reverse .

    on/off-energize and ramp from 0-255

    Simple control via color intensity .


    Code:
    /* 
    Stepper Motor Control
    with L293D ic & 2 x ws2811  pixel boards
    */
    
    #include <Stepper.h>
    
    
    
    
    // Set steps per revolution
    const int PPR = 64;  //<<<<<<<<<<<  Change for your stepper's rating
    const int PWM_PIN =  14;  // PWM INPUT.    <<<<<  used red channel on first pixel board
    const int PWM2_PIN =  12;  // PWM Bsensor <<<<  used blue channel on 2nd pixel board
    
    /* Motor >>>>> in pins 15-5  Pins from motor to L293D
    connection order on ic 4,3,2,1    */  
    Stepper motor1(PPR, 15,13,4,5);
    
    
    void setup() {
         // Initial pin states
         pinMode(DATA_PIN, OUTPUT);
         digitalWrite(DATA_PIN, LOW);
         pinMode(PWM_PIN, INPUT);
         pinMode(PWM2_PIN, INPUT);
         
    
    
         int Bsensor = 0;
    
        {
    {
    
    void loop() {
    
         // MOTOR 1 CONTROL
      int speed = 0;
      int direction = 1;
      // select color using first pixel / board rgb channel ( used red ) position on PWM_PIN 14
      int position = analogRead(14);
      int Bsensor = analogRead(12);
      
      
      /*
      Values between 562 and 1023 mean forward movement. Speed gets
      mapped from 0 to 255 and direction stays positive. 
      */
      if (position >= 562 && analogRead(12) == 0 ) {
        speed = map(position, 562, 1023, 0, 255);        // These values can be modified 
      }
      /*
      Values between 0 and 462 mean backwards movement. Speed gets
      mapped from 255 to 0 and direction is negative. 
      */
      if (position <= 462 && analogRead(12) == 0 )  {
        speed = map(position, 0, 462, 255, 0);       // These values can be modified 
        direction = -1;
      }
      // Values between 462 && 562 mean no movement 
      if (speed > 0) {
        motor1.setSpeed(speed);
        motor1.step(direction);
    
      }
    }
    Last edited by angus40; 06-28-2019 at 03:51 AM. Reason: Simplified to 2 input pins for ez control

  7. #17
    Join Date
    Nov 2015
    Location
    The Netherlands
    Posts
    71
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    I am definitely going to try this... when my to-do list is a little shorter.
    Errors for fun only.

  8. #18
    Join Date
    Dec 2011
    Posts
    5,733
    Post Thanks / Like

    Default Re: Ws 2812b pixels to control Dc motors

    I just tested in sequencer to verify all is working . Success !

    Initially I tested via espixelStick effects test , this is much different than using a sequencer so results were totally different ,

    In sequencer , 1st channel needs to have sequence data to enable channels 2 and 3 .
    Channel 2 and 3 provide full control base on their respective sequence data's intensity .

    If required , I can do a tutorial on this but I think most will get the idea how this works .

    Thanks for motivating me to pursue this as this will work great for a prop I have in mind .

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •