bluejets:
It seems there is some internal controller that takes a specified frequency PWM via the blue wire to give speed control.
If the blue wire is connected to ground, the motor goes full howl.
Leave it open, and the internal circuit operates some form of brake.
There is also a feedback out from the motor which in this instance does not connect to anything which is fine.
I also understood the "spec" like this and I managed to control the speed using the following code:
/**********************************************************
Fast PWM Test
Demostrates the generation of high speed PWM
using timers 1 and 4
There are two pieces of code:
One for pins 9, 10 and 11 using TIMER 1
with frequencies up to 62kHz
Other for pins 6 and 13 using TIMER 4
with frequencies up to 187kHz
History:
12/12/2014 - Version 1.0
22/12/2014 - Adding a missing OCR4C value
***********************************************************/
/**********************************************************
Fast PWM on pins 6, 13 (High Speed TIMER 4)
Do not use analogWrite to pins 6 or 13 if using
this functions as they use the same timer.
Those functions will conflict with the
MSTIMER2 library.
Uses 7 PWM frequencies between 2930Hz and 187.5kHz
Timer 4 uses a PLL as input so that its clock frequency
can be up to 96MHz on standard Arduino Leonardo.
We limit imput frequency to 48MHz to generate 187.5kHz PWM
If needed, we can double that up to 375kHz
**********************************************************/
// Frequency modes for TIMER4
#define PWM187k 1 // 187500 Hz
#define PWM94k 2 // 93750 Hz
#define PWM47k 3 // 46875 Hz
#define PWM23k 4 // 23437 Hz
#define PWM12k 5 // 11719 Hz
#define PWM6k 6 // 5859 Hz
#define PWM3k 7 // 2930 Hz
// Direct PWM change variables
#define PWM6 OCR4D
// Terminal count
#define PWM6_13_MAX OCR4C
// Configure the PWM clock
// The argument is one of the 7 previously defined modes
void pwm613configure(int mode)
{
// TCCR4A configuration
TCCR4A=0;
// TCCR4B configuration
TCCR4B=mode;
// TCCR4C configuration
TCCR4C=0;
// TCCR4D configuration
TCCR4D=0;
// TCCR4D configuration
TCCR4D=0;
// PLL Configuration
// Use 96MHz / 2 = 48MHz
PLLFRQ=(PLLFRQ&0xCF)|0x30;
// PLLFRQ=(PLLFRQ&0xCF)|0x10; // Will double all frequencies
// Terminal count for Timer 4 PWM
OCR4C=255;
}
// Set PWM to D6 (Timer4 D)
// Argument is PWM between 0 and 255
void pwmSet6(int value)
{
OCR4D=value; // Set PWM value
DDRD|=1<<7; // Set Output Mode D7
TCCR4C|=0x09; // Activate channel D
}
// Start of demostration code
// Generates 4 PWM signals, two constant and two variable
void setup()
{
// Configure Timer 4 (Pins 6 and 13)
// It will operate at 187kHz
// Valid options are:
// PWM187k, PWM94k, PWM47k, PWM23k, PWM12k, PWM6k and PWM3k
pwm613configure(PWM23k);
// Pins 9 and 6 will change values in the loop function
// We first configure them
// Prepare pin 6 to use PWM
// We need to call pwm613configure
// For now, we set it at 0%
pwmSet6(0);
}
int value=255;
void loop()
{
// Set PWM at pins 9, 6
// Those fast macros require a previous configuration
// of the channels using the pwmSet9 and pwmSet6
// functions
// The functions pwmSet9 and pwmSet6 can be used
// instead, but the PWM9 and PWM6 macros are faster
// to execute
PWM6=value;
// Increment PWM value and return to 0 after 255
value=(value-10)%256;
delay(100);
}
The motor now does a ramp-up, but see for yourself:
Youtube link to testrun
Now I have successfully reengineered the required input signal and want to do the following:
- Put a ramp at the beginning of the first start up and then fix the speed at 50% => value=128
- Use the NANO that was yesterday in the mail instead of my big Leonardo.
How to I exit the loop or just run it up to a certain value?
The thing that worries me most ist the error I get when switching to my Nano-V3-0-Atmega328P
PWM_for_Unhold_fast.ino: In function 'void pwm613configure(int)':
PWM_for_Unhold_fast:59: error: 'TCCR4A' was not declared in this scope
PWM_for_Unhold_fast:62: error: 'TCCR4B' was not declared in this scope
PWM_for_Unhold_fast:65: error: 'TCCR4C' was not declared in this scope
PWM_for_Unhold_fast:68: error: 'TCCR4D' was not declared in this scope
PWM_for_Unhold_fast:75: error: 'PLLFRQ' was not declared in this scope
PWM_for_Unhold_fast:79: error: 'OCR4C' was not declared in this scope
PWM_for_Unhold_fast.ino: In function 'void pwmSet6(int)':
PWM_for_Unhold_fast:86: error: 'OCR4D' was not declared in this scope
PWM_for_Unhold_fast:88: error: 'TCCR4C' was not declared in this scope
PWM_for_Unhold_fast.ino: In function 'void loop()':
PWM_for_Unhold_fast:134: error: 'OCR4D' was not declared in this scope