Hello
I am trying to adapt a wireless lens control system (called a Follow focus) that is based on an arduino Leonardo using a stepper motor
https://www.motiondogs.com/wireless-follow-focus-kits-and-packages/1-lenzhound-base-kit.html
to a film industry standard DC motor.
The motor I wish to use is a Heden m 26ve
http://heden-engineering.com/products/motors/m26ve_1/
Inside the casing is a faulhaber 2342s024cr motor
https://fmcc.faulhaber.com/details/o...8_13813/fr/DE/
At the bottom of the thread below are pictures of the Heden opened up:
http://www.reduser.net/forum/showthread.php?153329-Create-DIY-controller-for-Heden-motor
From what I understand, the Heden uses a quadrature motor system, connected to a controlling system via a 7 pin lemo connector. I have built a controller box, that contains the motiondogs receiver board connected to a Cytron 13A, 5-25V Single DC Motor Controller
that is wired to the 7 pin lemo.
For the moment, I am testing the possibilties using a potentiometer from motion dogs
https://www.motiondogs.com/products/7-thumbwheel-kit.html
The whole motiondogs system is controlled by software written in arduino leonardo sketches that can be downloaded here
The final goal is to integrate the new box with the wireless handset, but first I need to get the Heden motor working using the thumbwheel.
Motiondogs sent me a test sketch for a non quadrature motor that is primarily designed to test the Softpwm library. Obviously the sketch does not work with the Heden motor.
If I understand correctly, (you might have noticed by now that I am a total newby to all this) the sketch should be using the A&B encoder channels to control the motor. As the potentiometer cannot do this, maybe a PID library can do the error correction, but this is conjecture as I do not know if it is the right direction to go or how to integrate it into the code below.
For more information on industry standard follow focus systems connections:
Preston Cinema Systems page 25
Industrial Optics, Cine Optics and Photo Optics I Schneider-Kreuznach page 16
Below is the sketch that correlates to the attached pdf schematic.
Any help is much appreciated.
thank you
#include <SoftPWM.h>
#define PWMPIN A0 // Output pin to control PWM for motor controller
#define DIRPIN A1 // Output direction for motor controller
#define CHANNELA A2 // position sensor pin
#define CHANNELB A3 // position sensor pin
#define POTPIN A4 // select the input pin for the potentiometer
//#define DIRSW A3 // direction switch
//int dirSwState = 0; // last state of the direction switch
//int dirLast = 0; // last state to compare direction switch against
int potValue = 0; // variable to store the value coming from the sensor
int sensorValue = 0; // value of position sensor
long prevPos1 = 0;
long prevPos2 = 0;
long curPos = 0;
long prevSPos1 = 0;
long prevSPos2 = 0;
long curSPos = 0;
#define MIN_POT_VAL 0
#define MAX_POT_VAL 1023
#define MIN_SENSOR_VAL 32
#define MAX_SENSOR_VAL 1018
#define SLOW_RANGE 51 // number of encoder values away before decel begins
int mspeed = 0;
int newspeed = 0;
void setup() {
SoftPWMBegin();
SoftPWMSet(PWMPIN, 0);
SoftPWMSetFadeTime(ALL, 100, 400);
//pinMode(PWMPIN, OUTPUT);
pinMode(DIRPIN, OUTPUT);
// pinMode(DIRSW, INPUT);
Serial.begin(9600);
}
void loop() {
// read the value from the sensor:
long newPos = analogRead(POTPIN);
long newSPos = analogRead(CHANNELA);
// debounce pot
if (newPos != prevPos1 && newPos != prevPos2) {
prevPos1 = prevPos2;
prevPos2 = newPos;
curPos = map(newPos, MIN_POT_VAL, MAX_POT_VAL, MIN_SENSOR_VAL, MAX_SENSOR_VAL);
}
// debounce encoder
if (newSPos != prevSPos1 && newSPos != prevSPos2) {
prevSPos1 = prevSPos2;
prevSPos2 = newSPos;
curSPos = map(newSPos, MIN_SENSOR_VAL, MAX_SENSOR_VAL, MIN_POT_VAL, MAX_POT_VAL);
}
if(curPos <= curSPos){ // Backwards
digitalWrite(DIRPIN, LOW);
unsigned int in_range = curPos + SLOW_RANGE;
if(curSPos > in_range){ // Max speed
SoftPWMSet(PWMPIN, 255);
} else {
if((curPos+50) == curSPos) // 75%
{
SoftPWMSet(PWMPIN,190);
}
if((curPos+40) == curSPos) // 50%
{
SoftPWMSet(PWMPIN, 125);
}
if((curPos+30) == curSPos) // 25%
{
SoftPWMSet(PWMPIN, 60);
}
if((curPos+20) == curSPos) // 12%
{
SoftPWMSet(PWMPIN, 31);
}
if((curPos+10) == curSPos) // 12%
{
SoftPWMSet(PWMPIN, 15);
}
if((curPos+3) == curSPos) // 6%
{
SoftPWMSet(PWMPIN, 0);
}
}
}
if(curPos >= curSPos){ // Forward
digitalWrite(DIRPIN, HIGH);
unsigned int in_range = curPos - SLOW_RANGE;
if(curSPos < in_range){ // Max speed
SoftPWMSet(PWMPIN, 255);
} else {
if((curPos-50) == curSPos) // 75%
{
SoftPWMSet(PWMPIN,190);
}
if((curPos-40) == curSPos) // 50%
{
SoftPWMSet(PWMPIN, 125);
}
if((curPos-30) == curSPos) // 25%
{
SoftPWMSet(PWMPIN, 60);
}
if((curPos-20) == curSPos) // 12%
{
SoftPWMSet(PWMPIN, 31);
}
if((curPos-10) == curSPos) // 12%
{
SoftPWMSet(PWMPIN, 15);
}
if((curPos-3) == curSPos) // 6%
{
SoftPWMSet(PWMPIN, 0);
}
}
}
if(curPos == curSPos){ // Stop
SoftPWMSet(PWMPIN, 0);
}
// if(dirLast != dirSwState){
// Serial.println(dirSwState);
// dirLast = dirSwState;
//}
//analogWrite(pwmPin, val);
//SoftPWMSet(PWMPIN, val);
}
170228_LENSHOUND_SCHEMATIC.pdf (172 KB)