gnea / grbl-Mega

An open source, embedded, high performance g-code-parser and CNC milling controller written in optimized C that will run on an Arduino Mega2560
https://github.com/gnea/grbl/wiki
Other
496 stars 229 forks source link

Ramp 1.4 PWM Output Voltage #81

Open skylineboy20000 opened 5 years ago

skylineboy20000 commented 5 years ago

Hi all in the process of building a CNC powered by a Arduino Mega 2560 and Ramps 1.4. Almost everything is working great but having some issues with the PWM voltage output on Pin 6 to control the VFD. I've spent days working through all the issues reluctant to post for help but this one has stumped me.

The issue is the voltage directly from Pin 6 when issuing M3 S24000 (My Max RPM) only produces 4.89V.

This then goes through a PWM module, as I wanted something tidier than a home made lowpass and also wanted to boost the level from 5v to 10v (http://www.chinalctech.com/index.php?_m=mod_product&_a=view&p_id=1122) and the max voltage I can output is 4.34V with the pot wound all the way up and with a 12v VCC input to the module.

I was wondering if it was a frequency issue so i've tried 255 and 1024 in place of the Max PWM value.

I'm very much on a steep learning curve but any help would be very much appreciated .

Thanks in advance!

I've amended the code as at the bottom of the post in 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 SPINDLE_PWM_MAX_VALUE 1024.0 // Since it's a 8bit timer

ifndef SPINDLE_PWM_MIN_VALUE

define SPINDLE_PWM_MIN_VALUE 1 // Must be greater than zero.

endif

define SPINDLE_PWM_OFF_VALUE 0

define SPINDLE_PWM_RANGE (SPINDLE_PWM_MAX_VALUE-SPINDLE_PWM_MIN_VALUE)

define SPINDLE_TCCRA_REGISTER TCCR4A

define SPINDLE_TCCRB_REGISTER TCCR4B

define SPINDLE_OCR_REGISTER OCR4A

define SPINDLE_COMB_BIT COM4A1

define SPINDLE_TCCRA_INIT_MASK (1<<WGM41)

define SPINDLE_TCCRB_INIT_MASK ((1<<WGM42) | (1<<WGM43) | (1<<CS41))

define SPINDLE_OCRA_REGISTER ICR4

define SPINDLE_OCRA_TOP_VALUE 0x0400 // PWM counter reset value. Should be the same as PWM_MAX_VALUE in hex.

// Define spindle output pins.

define SPINDLE_PWM_DDR DDRH

define SPINDLE_PWM_PORT PORTH

define SPINDLE_PWM_BIT 3 // MEGA2560 Digital Pin 6

endif

sanalejo171 commented 5 years ago

Hello, I've been 2 days, testing 1 by 1 ALL the ramp pines, I can turn on and off the SPINDLER (DRILL) but none has pwm control, because they only mark 0 or 5v ........ IT ALSO WORKS ME PROBE or analog 15 or none, and probe one by one ....... someone found the solution? Or will I have to go back to Arduino one?