[gnea/grbl-Mega Issue#55] PWM on Ramps with grbl-MEGA not working. Only 0 to 5 volts nothing in between…

未分类 bolang 3周前 (10-15) 3次浏览 0个评论

Issue #55 | 状态: 已关闭 | 作者: bigshug | 创建时间: 2018-03-31


Hey folks. I can’t get PWM to function properly on Sainsmart RAMPS Mega2560 board with grbl-Mega.

First off – I’m checking output on D11. Correct pin for RAMPS? (I guess not but can’t find any other pin that gives me 5 volts when sending an M3)

It’s all or nothing – 0 or 5 volts. I can switch it on and off with M3 and M5 but get no change when changing the S value.

I’ve been through the config.h spindle settings and checked cpu_map.h but nothing fixes this issue.

Everything works as it should on an UNO with normal GRBL but it would be useful to get some use out of this board.

Any ideas on how to sort this before this board is consigned to the parts bin?

Cheers


评论 (11)

#1 – bigshug 于 2018-04-01

ok -so it looks like PIN 8 is the spindle PWM output – although I get nothing from it. I think it’s the hot bed output on this board.

How do I define another PWM pin for testing purposes? Will I need to change the register values too?

Yes I am in way over my head but really want to figure this out now :o)


#2 – bigshug 于 2018-04-02

Right then. Sorted. Pin 8 is indeed the PWM pin. However it is 12v when the board is externally powered and I’m after 0 – 5volts. There is 5 volts going to the mosfet – I guess this is the real D8. Will trace it back somewhere and take a feed off it.


#3 – chamnit 于 2018-04-02

@bigshug : The Arduino Mega does not operate at 12V. If you are reading 12V, you are doing something wrong or something is wrong with your board. It should be 0V to 5V.

FYI, cpu_map.h contains the pin configuration and shows you that D8 is the PWM pin.


#4 – bigshug 于 2018-04-02

The board is a ‘Sainsmart all in one’ that can be powered externally – I guess for high power heated bed etc. It gives a 12v PWM output at the ‘BED’ terminal or 5v PWM on D8 going into the FET. It’s a nice board so glad it’s now working.
!615q98yjevl sx385 copy

Incidentally – I’ve no idea why it wasn’t working immediately. Clearly I’d changed something in the GRBL settings but don’t recall doing so. It might have started working after doing the reset – $RST=*


#5 – bigshug 于 2018-04-02

See comment here about 12v – https://github.com/gnea/grbl-Mega/issues/11#issuecomment-311184454


#6 – rasciodc 于 2018-07-08

0-5V PWM on Pin D6:

I know this issue is closed, but, just in case someone else comes accross the same need of having a 0-5V PWM pin to control the Spindle, here is the code to have it working on pin D6 (Servo 2 on RAMPS). This should replace lines 259 to 283 on cpu_map.h:

// Advanced Configuration Below You should not need to touch these variables
// Set Timer up to use TIMER4C which is attached to Digital Pin 6 - Ramps Servo 2
#define SPINDLEPWMMAX_VALUE 255.0 // Since it's a 8bit timer
#ifndef SPINDLEPWMMIN_VALUE
#define SPINDLEPWMMIN_VALUE 1 // Must be greater than zero.
#endif
#define SPINDLEPWMOFF_VALUE 0
#define SPINDLEPWMRANGE (SPINDLEPWMMAXVALUE-SPINDLEPWMMINVALUE)

#define SPINDLETCCRAREGISTER TCCR4A
#define SPINDLETCCRBREGISTER TCCR4B
#define SPINDLEOCRREGISTER OCR4A
#define SPINDLECOMBBIT COM4A1

#define SPINDLETCCRAINIT_MASK (1<TCCRBINIT_MASK ((1<OCRAREGISTER ICR4
#define SPINDLEOCRATOPVALUE 0xFF // PWM counter reset value. Should be the same as PWMMAX_VALUE in hex.

// Define spindle output pins.
#define SPINDLEPWMDDR DDRH
#define SPINDLEPWMPORT PORTH
#define SPINDLEPWMBIT 3 // MEGA2560 Digital Pin 6

Cheers!


#7 – luisluna2 于 2018-09-02

Hello friends, I have a question, how make 3 PWM with D8, D9 and D10?


#8 – JeffHank1 于 2019-11-11

A Big Thanks to rasciodc for figuring this solution out and Posting it. It was very easy to cut and paste the solution into the appropriate file, recompile in Arduino IDE, create a Hex file and Upload it to my Arduino Mega 2560 with Xloader. Easy. Works perfectly with my 12V laser that wants a 5V TTL control signal.


#9 – thesalcedo 于 2021-01-06

> A Big Thanks to rasciodc for figuring this solution out and Posting it. It was very easy to cut and paste the solution into the appropriate file, recompile in Arduino IDE, create a Hex file and Upload it to my Arduino Mega 2560 with Xloader. Easy. Works perfectly with my 12V laser that wants a 5V TTL control signal.

@JeffHank1 for this to work, does the laser 12V power need to come from the RAMPS +12V output (D8)? Since the – is shared? I was planning on powering my Laser controller externally.


#10 – fedex000000000001 于 2023-01-02

> 0-5V PWM en pin D6:
>
> Sé que este problema está cerrado, pero, en caso de que alguien más tenga la misma necesidad de tener un pin PWM de 0-5V para controlar el eje, aquí está el código para que funcione en el pin D6 (Servo 2 en RAMPS). Esto debería reemplazar las líneas 259 a 283 en cpu_map.h:
>
> “
> // Advanced Configuration Below You should not need to touch these variables
> // Set Timer up to use TIMER4C which is attached to Digital Pin 6 - Ramps Servo 2
> #define SPINDLEPWMMAX_VALUE 255.0 // Since it's a 8bit timer
> #ifndef SPINDLEPWMMIN_VALUE
> #define SPINDLEPWMMIN_VALUE 1 // Must be greater than zero.
> #endif
> #define SPINDLEPWMOFF_VALUE 0
> #define SPINDLEPWMRANGE (SPINDLEPWMMAXVALUE-SPINDLEPWMMINVALUE)
>
> #define SPINDLETCCRAREGISTER TCCR4A
> #define SPINDLETCCRBREGISTER TCCR4B
> #define SPINDLEOCRREGISTER OCR4A
> #define SPINDLECOMBBIT COM4A1
>
> #define SPINDLETCCRAINIT_MASK (1< #define SPINDLETCCRBINIT_MASK ((1< #define SPINDLEOCRAREGISTER ICR4
> #define SPINDLEOCRATOPVALUE 0xFF // PWM counter reset value. Should be the same as PWMMAX_VALUE in hex.
>
> // Define spindle output pins.
> #define SPINDLEPWMDDR DDRH
> #define SPINDLEPWMPORT PORTH
> #define SPINDLEPWMBIT 3 // MEGA2560 Digital Pin 6
>

>
> ¡Salud!

hello, do i have to enable $32 = 1 in grbl to use the PWN of pin d6 ?


#11 – luisluna2 于 2023-01-02

Te agradezco mucho tu apoyo y atención, lo estaré probando en la semana, muchísimas gracias.

¡Feliz inicio de Año 2023!
__
From: fedex000000000001 @.*>
Sent: Monday, January 2, 2023 1:03:49 PM
To: gnea/grbl-Mega @.*>
Cc: luisluna2 @.>; Comment @.>
Subject: Re: [gnea/grbl-Mega] PWM on Ramps with grbl-MEGA not working. Only 0 to 5 volts nothing in between… (#55)

0-5V PWM en pin D6:

Sé que este problema está cerrado, pero, en caso de que alguien más tenga la misma necesidad de tener un pin PWM de 0-5V para controlar el eje, aquí está el código para que funcione en el pin D6 (Servo 2 en RAMPS). Esto debería reemplazar las líneas 259 a 283 en cpu_map.h:

// Advanced Configuration Below You should not need to touch these variables

// Set Timer up to use TIMER4C which is attached to Digital Pin 6 – Ramps Servo 2

#define SPINDLEPWMMAX_VALUE 255.0 // Since it’s a 8bit timer

#ifndef SPINDLEPWMMIN_VALUE

#define SPINDLEPWMMIN_VALUE 1 // Must be greater than zero.

#endif

#define SPINDLEPWMOFF_VALUE 0

#define SPINDLEPWMRANGE (SPINDLEPWMMAXVALUE-SPINDLEPWMMINVALUE)

#define SPINDLETCCRAREGISTER TCCR4A

#define SPINDLETCCRBREGISTER TCCR4B

#define SPINDLEOCRREGISTER OCR4A

#define SPINDLECOMBBIT COM4A1

#define SPINDLETCCRAINIT_MASK (1<

#define SPINDLETCCRBINIT_MASK ((1<

#define SPINDLEOCRAREGISTER ICR4

#define SPINDLEOCRATOPVALUE 0xFF // PWM counter reset value. Should be the same as PWMMAX_VALUE in hex.

// Define spindle output pins.

#define SPINDLEPWMDDR DDRH

#define SPINDLEPWMPORT PORTH

#define SPINDLEPWMBIT 3 // MEGA2560 Digital Pin 6

¡Salud!

hello, do i have to enable $32 = 1 in grbl to use the PWN of pin d6 ?


Reply to this email directly, view it on GitHub<https://github.com/gnea/grbl-Mega/issues/55#issuecomment-1369150304>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AJIGRUPTVR2P3REXEC4XNL3WQMRBLANCNFSM4EYKPZYQ>.
You are receiving this because you commented.Message ID: @.*>


原始Issue: https://github.com/gnea/grbl-Mega/issues/55

喜欢 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址