Hi,
first, thanks for this awesome project!
I am trying to use it with the Makeblock Laserbot and their MegaPi board.
I mapped all the pins, but my last problem is the laser pin. The MegaPi uses digital Pin 10 (PB4/OC2A).
This means, that I need to use timer2 for PWM on this pin and this is an 8-bit timer… the current implementation uses 16bit-timers.
Can somebody help me with using PB4 for the laser?
This is my current code in cpu_map.h
// Advanced Configuration Below You should not need to touch these variables
// Set Timer up to use TIMER2A which is attached to Digital Pin 10 - PB4
// warning: Timer2 is an 8-bit timer!
#define SPINDLEPWMMAX_VALUE 255.0 // Translates to about 1.9 kHz PWM frequency at 1/8 prescaler
#ifndef SPINDLEPWMMIN_VALUE
#define SPINDLEPWMMIN_VALUE 1 // Must be greater than zero.
#endif
#define SPINDLEPWMOFF_VALUE 0
#define SPINDLEPWMRANGE (SPINDLEPWMMAXVALUE-SPINDLEPWMMINVALUE)
//rb MegaPi THIS HAS TO BE CHANGED TO A DIFFERENT PIN! OC2A is for D10 (PB4)
//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
#define SPINDLETCCRAREGISTER TCCR2A
#define SPINDLETCCRBREGISTER TCCR2B
#define SPINDLEOCRREGISTER OCR2A
#define SPINDLECOMBBIT COM2A0
// 1/8 Prescaler, Fast PWM mode
#define SPINDLETCCRAINIT_MASK ((1<
#define SPINDLEOCRATOPVALUE 0xFF // PWM counter reset value. Should be the same as PWMMAX_VALUE in hex.
// Define spindle output pins.
#define SPINDLEPWMDDR DDRB
#define SPINDLEPWMPORT PORTB
#define SPINDLEPWMBIT 4 // MEGA2560 Digital Pin 10 - 12v output MegaPi
// Define flood and mist coolant enable output pins.
#define SPINDLEENABLEDDR DDRF
#define SPINDLEENABLEPORT PORTF
#define SPINDLEENABLEBIT 0 // MEGA2560 Analog Pin 0 - 12v output
#define SPINDLEDIRECTIONDDR DDRG
#define SPINDLEDIRECTIONPORT PORTG
#define SPINDLEDIRECTIONBIT 2// MEGA2560 Digital Pin 39 - MegaPi P15 5x2 pin1
// Define flood and mist coolant enable output pins.
#define COOLANTFLOODDDR DDRA
#define COOLANTFLOODPORT PORTA
#define COOLANTFLOODBIT 2 // MEGA2560 Digital Pin 24
#define COOLANTMISTDDR DDRA
#define COOLANTMISTPORT PORTA
#define COOLANTMISTBIT 0 // MEGA2560 Digital Pin 22
评论 (3)
#2 – Fusseldieb 于 2020-08-18
@renebohne Since you’ve already did things with PORTs and stuff, can you help me real quick on how my definitions should look. I’m setting up a Laser and am absolutely clueless on how to make the pin D11 work on the Mega2560
#3 – renebohne 于 2020-08-19
> @renebohne Since you’ve already did things with PORTs and stuff, can you help me real quick on how my definitions should look. I’m setting up a Laser and am absolutely clueless on how to make the pin D11 work on the Mega2560
>
> fra589#138
You can search for “//rb THIS CHANGED TO A DIFFERENT PIN! OC2A is for D10 (PB4) – using 8-bit timer Timer2”
in file https://github.com/renebohne/grbl-laserbot/blob/master/Arduino/cpu_map.h
And have a general look into my changes in that fork…
but my recommendation is not to waste time on this and use official hardware instead.
#1 – renebohne 于 2017-12-12
I fixed it. The MegaPi has a super slow mosfet, so I had to decrease the PWM frequency. If somebody is interested, you can have a look at https://github.com/renebohne/grbl-laserbot
I close the issue in this repo, since this was a very special feature request.