Looking for PWM 1 & 2 Pins

Discussion in 'Build Help' started by Jeremy Sabatini, Nov 28, 2016.

  1. Jeremy Sabatini

    Jeremy Sabatini Active Member

    Joined:
    Feb 21, 2016
    Messages:
    37
    Likes Received:
    19
    Hi Everyone,
    I'm working on setting up RGB led's on my Bigbox to display temperature. I have it working, but I'm having issues with the Pin.h file. Currently it's working using the HE1 HE2 and Fan0 pins. I would like to have it use PWM 1 and PWM 2 on Exp3, but I'm not sure what pin numbers those are for the Pins.h file and I come up with different assignments based on what reference I find. If anyone knows or can point me in the right direction I would appreciate it greatly.

    I'm using npn transistor in the setup.
     
    #1 Jeremy Sabatini, Nov 28, 2016
    Last edited: Nov 28, 2016
  2. Stefan

    Stefan Well-Known Member

    Joined:
    Feb 17, 2016
    Messages:
    323
    Likes Received:
    43
  3. Jeremy Sabatini

    Jeremy Sabatini Active Member

    Joined:
    Feb 21, 2016
    Messages:
    37
    Likes Received:
    19
    Hi Stefan,
    I've identified the pins on the board, I'm just confused on what to put in the Marlin to get those pins to work. Any ideas?

    Jeremy
     
  4. Greg Holloway

    Greg Holloway Administrator
    Staff Member

    Joined:
    Sep 4, 2015
    Messages:
    565
    Likes Received:
    397
    It easy to get confused and I scratched my head for ages until I found this....

    https://www.arduino.cc/en/Hacking/PinMapping2560

    The complication arises from having two different pin number systems and not having anything which can directly correlate the two. From what I understand there is a holistic pin numbering, and an additional/alternative analogue pin numbering. Depending on what the configuration or code wants you have to assign the pins based on analogue numbering. If you look throiugh the Marlin code you'll see some sections labelled //ANALOGUE PIN
     
    mike01hu likes this.
  5. Jeremy Sabatini

    Jeremy Sabatini Active Member

    Joined:
    Feb 21, 2016
    Messages:
    37
    Likes Received:
    19
    Ok I think that answers my question, looks like PWM 1 and PWM 2 are pins 5 & 6

    Am I correct?
     
  6. Greg Holloway

    Greg Holloway Administrator
    Staff Member

    Joined:
    Sep 4, 2015
    Messages:
    565
    Likes Received:
    397
    Yes, probably.

    You should just try and see what happens. That's what I usually do :D
     
  7. Stefan

    Stefan Well-Known Member

    Joined:
    Feb 17, 2016
    Messages:
    323
    Likes Received:
    43
    sorry I did not get your problem reading it the first time :(

    but still reprap wiki to the rescue... maybe
    http://reprap.org/mediawiki/images/2/24/RRD-RUMBA_SCHEMATICS.png
    but I have not under stood pin names in marlin. What is this Analog Numbering in Pin_rumba.h?


    In the bottom left corner it says
    5 = PWM2 = PE3 = Digital pin 5 (PWM)
    1 = PWM1 = PG5 = Digital pin 4 (PWM)

    e.g. for y-En and y-Step
    upload_2016-12-1_15-35-14.png
    pin_rumba.h
    #define Y_STEP_PIN 54
    #define Y_ENABLE_PIN 55

    PinMap:
    Y-EN = 96 PF1 ( ADC1 ) Analog pin 1
    Y-STEP = 97 PF0 ( ADC0 ) Analog pin 0


    BUT
    upload_2016-12-1_15-32-54.png
    pin_rumba.h
    #define E0_STEP_PIN 23
    #define E0_DIR_PIN 22

    PinMap:
    77 PA1 ( AD1 ) Digital pin 23
    78 PA0 ( AD0 ) Digital pin 22


    upload_2016-12-1_15-3-55.png
     
  8. Jeremy Sabatini

    Jeremy Sabatini Active Member

    Joined:
    Feb 21, 2016
    Messages:
    37
    Likes Received:
    19
    Man why does it have to be some complex! So I would put in the Pin.h file:

    #define STAT_LED_RED 5

    for PWM2 to control the Red leds when connected to Pin6 on exp3?

    How does it know that it's digital vs analog? Looking at the current Pin.h file pin 5 is defined as: #define TEMP_1_PIN 5
     
    #8 Jeremy Sabatini, Dec 1, 2016
    Last edited: Dec 1, 2016
  9. Stefan

    Stefan Well-Known Member

    Joined:
    Feb 17, 2016
    Messages:
    323
    Likes Received:
    43
    ok 1st I would modify pin_rumba.h since we have a rumba board.
    2nd as far as I remeber c(++) these
    #define bla blup
    is kind of an alias since names are better than numbers.
    So you can use STAT_LED_RED and not 5 in the code were you switch the red LEDs on.
    I think... in the code you have written you have to configure it.
    like in the servo.cpp line 274
    Code:
      pinMode(servo_info[this->servoIndex].Pin.nbr, OUTPUT); // set servo pin to output
    
    I still have no idea hown Marlin counts(maps) the pins
    there is a file pin_arduino.h in \Marlin\ArduinoAddons\Arduino_1.6.x\hardware\marlin\avr\variants\mega

    Maybe this helps at least there is a connection from d55 to y-en to 96...
    http://www.robotiksistem.com/arduino_mega_2560_pinleri.jpg
     
  10. Jeremy Sabatini

    Jeremy Sabatini Active Member

    Joined:
    Feb 21, 2016
    Messages:
    37
    Likes Received:
    19

Share This Page