[gnea/grbl-Mega Issue#39] Spindle PWM non-functional

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

Issue #39 | 状态: 已关闭 | 作者: MaxBareiss | 创建时间: 2017-09-23


I am using this version of grbl-mega with a RAMPS 1.4 board:

$I
[VER:1.1f.20170802:]
[OPT:VNML,35,255]

$$
$0=10
$1=100
$2=0
$3=2
$4=0
$5=0
$6=0
$10=1
$11=0.020
$12=0.002
$13=0
$20=0
$21=0
$22=1
$23=0
$24=500.000
$25=2000.000
$26=250
$27=5.000
$30=255
$31=0
$32=0
$100=200.000
$101=200.000
$102=4535.000
$110=3000.000
$111=3000.000
$112=300.000
$120=400.000
$121=400.000
$122=55.000
$130=600.000
$131=600.000
$132=60.000
`

I don't get any spindle PWM. If I turn the spindle on with any value but zero (M3 S1) I get full on, and when I turn it off with M5 or M3 S0 it turns off, but I don't get any PWM. I've modified this section of cpu_map.h:

`
//Control Digital Pin 6 which is Servo 2 signal pin on Ramps 1.4 board
#define SPINDLETCCRAREGISTER TCCR4A
#define SPINDLETCCRBREGISTER TCCR4B
#define SPINDLEOCRREGISTER OCR4C
#define SPINDLECOMBBIT COM4C1

// 1/8 Prescaler, 16-bit Fast PWM mode
#define SPINDLETCCRAINIT_MASK ((1<TCCRBINIT_MASK ((1<OCRAREGISTER OCR4C // 16-bit Fast PWM mode requires top reset value stored here.
#define SPINDLEOCRATOPVALUE 0x0100 // 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 5 // MEGA2560 Digital Pin 8

Because I’m trying to use that PWM pin. It doesn’t work for other pins, either. Enable and direction work correctly.

Thanks for any help you can give!


评论 (2)

#1 – X3msnake 于 2017-09-25

Are you using a PWM capable pin?

2017-09-23 23:24 GMT+01:00 MaxBareiss :

> I am using this version of grbl-mega with a RAMPS 1.4 board:
>
> $I
> [VER:1.1f.20170802:]
> [OPT:VNML,35,255]
>
> $$
> $0=10
> $1=100
> $2=0
> $3=2
> $4=0
> $5=0
> $6=0
> $10=1
> $11=0.020
> $12=0.002
> $13=0
> $20=0
> $21=0
> $22=1
> $23=0
> $24=500.000
> $25=2000.000
> $26=250
> $27=5.000
> $30=255
> $31=0
> $32=0
> $100=200.000
> $101=200.000
> $102=4535.000
> $110=3000.000
> $111=3000.000
> $112=300.000
> $120=400.000
> $121=400.000
> $122=55.000
> $130=600.000
> $131=600.000
> $132=60.000
>
> I don’t get any spindle PWM. If I turn the spindle on with any value but
> zero (M3 S1) I get full on, and when I turn it off with M5 or M3 S0 it
> turns off, but I don’t get any PWM. I’ve modified this section of
> cpu_map.h:
>
> //Control Digital Pin 6 which is Servo 2 signal pin on Ramps 1.4 board
> #define SPINDLETCCRAREGISTER TCCR4A
> #define SPINDLETCCRBREGISTER TCCR4B
> #define SPINDLEOCRREGISTER OCR4C
> #define SPINDLECOMBBIT COM4C1
>
> // 1/8 Prescaler, 16-bit Fast PWM mode
> #define SPINDLETCCRAINIT_MASK ((1< #define SPINDLETCCRBINIT_MASK ((1< #define SPINDLEOCRAREGISTER OCR4C // 16-bit Fast PWM mode requires top reset value stored here.
> #define SPINDLEOCRATOPVALUE 0x0100 // 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 5 // MEGA2560 Digital Pin 8
>
> Because I’m trying to use that PWM pin. It doesn’t work for other pins,
> either. Enable and direction work correctly.
>
> Thanks for any help you can give!
>
> —
> You are receiving this because you are subscribed to this thread.
> Reply to this email directly, view it on GitHub
> <https://github.com/gnea/grbl-Mega/issues/39>, or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AKke-mQYunkdFpmMMJDWwDnJvgY83Paaks5slYUCgaJpZM4PhtAj>
> .
>


Com os melhores cumprimentos,
Vinicius Silva


#2 – MaxBareiss 于 2017-09-25

I figured it out; the issue was that SPINDLEOCRAREGISTER needed to be OCR4A, not OCR4C. I’m going to make a PR soon that makes it clearer that SPINDLEOCRAREGISTER needs to be the ‘A’ register for the timer, regardless of which output pin is used.


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

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

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

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