closed loop DC motor speed control

davidwf

Senior Member
I am trying to copy old 8mm cine film to digital using a projector
I have been through hoops of trial and error and have settled on videoing the actual film itself using a close focus lens looking directly at the film gate (i.e. emulsion side) with the projection lens removed as it gives incredibly sharp results and colour, the camcorder produced HD mp4 file only needs flipping which I can do quickly in my PC video editing program and the resultant video looks excellent even on a 55" OLED TV :)

I need to closely and very precisely control the 12V DC motor that I have fitted to the projector as it MUST run at a precise speed (of around 2700 RPM via the geared pulleys) to give the required 16 2/3 fps on the projector shaft - which equates to 1000 RPM........ handily, with the 3 blade blanking shutter in the projector this translates to exactly 50Hz and ensures there are no black bars or sync issues with the camcorder

I have a slotted opto switch that I can mount to the projector shaft to detect the 3 shutter blades as they rotate - I did consider using a magnet and hall output but that only gives 16.66Hz whereas the 3 blades will give 50Hz which should allow a tighter control and wont upset the balance of the shutter plate…..

.....and thats about as far as I have got so would appreciate any suggestions and help in controlling the motor (via a MOSFET) and (if possible) an 8 pin 08M2 PICAXE as I have several going spare
The mechanics are sorted but I have little experience in programming
 
Last edited:

AllyCat

Senior Member
Hi,
The mechanics are sorted but I have little experience in programming
What about the "electronics" Hardware? The motor can be controlled by PWM which is available from pin {C.}2 (Leg 5) of the 8 pin chips. If it is an 08M (not 08M2) the you can't use the PWMDUTY command, but this is quite a "slow" command anyway and IMHO the PWMOUT is usually sufficient. I suggest starting with quite a low PWM frequency, e.g. within the rage 100 Hz - 1 kHz, and of course start with a "recommended" FET circuit, with good supply decoupling (capacitors), a commutating diode and Gate pull-down resistor, etc..

The speed control can be a classic "Phase Locked Loop" (PLL) , that can be implemented entirely within a (fast) software control loop, or by a "hybrid" hardware/software design. However, you haven't indicated where (or if) a "Reference" (50 Hz) pulse is available, to indicate the instant that the camera "looks" at each frame. In principle, a simple software loop can compare the optical "shutter" pulse with the "Reference" (camera sync) pulse: If the shutter pulse occurs first then slow down the motor (i.e. reduce the PWM value) and if the Reference is first then speed up the motor (increase the PWM value). In practice, some "hardware assistance" may be preferable, converting the time separation (delay) into an analogue voltage and reading that with a READADC command.

The design of the "Control Loop" can be quite complex (to avoid instability) if high performance is required and/or if the motor has high intertia (or slow response). But it's best to start with something simple (i.e. learn to walk before you run) which might well be sufficient. ;)

Cheers, Alan.
 

davidwf

Senior Member
Thanks for your prompt response
I can sort / make any electronics hardware as required...there will (can) be no synchronisation between the camera and projector ....which is why I need a precise and accurate speed controller.
I have set it (with voltage only) to run at about the right speed which gives excellent results for a short while, monitoring the motor speed it is clear that it only varies by a tiny amount .....but which causes big problems.
I managed to get the speed just right using the original a.c. synchronous motor (and a variable pulley mechanism) and it was fine for quite a while so I know that it will work but when the mains frequency varied slightly it went out of sync again hence the fitment of the smaller 12V DC motor
 

AllyCat

Senior Member
Hi,

It depends on the longest "sequence" time that you need to stay in lock, but the only long-term/automatic method is to phase-lock to the actual camera sync. Perhaps from a monitor, or the (electronic) camera viewfinder? The (M-series) PICaxe clock is probably accurate to only about +/- 0.1%, about the same as the mains frequency, so probably unsatisfactory for any period over about a minute. The larger X2-series PICaxes can run from an external crystal (clock), so may give a long enough sequence stability, but will still need to be manually "phased" each time.

With an 08M{2} PICaxe you should be able to use an external crystal-controlled pulse, for example from a RTC (Real Time Clock) module. But most RTC output pulses are set at 1 Hz or binary power multiples (i.e. 2 , 4 , etc. Hz) so you may have difficulty finding a precise 50 Hz source. However, it is possible to design a "Digital PLL" to lock a 50 Hz signal to a 1 Hz Reference pulse, which should be well within the (speed) capability of a PICaxe program. ;)

Cheers, Alan.
 

papaof2

Senior Member
Maybe a totally different approach?

Use the original AC motor but powered by a small pure sine wave inverter which puts out a steady 50Hz? The inverter will provide a source of stable 50Hz power. Can you make allowances if the inverter's output is 49.9 Hz or 50.1 Hz, as long as the frequency is stable? Not the smallest or prettiest option but one that will provide reliable and stable 50Hz power for the AC motor - an option you've already verified to work.

You will need an adequate 12 volt power source to power the inverter (12 volt battery with a charger adequate for the motor's running power and let the battery provide the start surge - if any). In the limited testing I did on a 12 volt DC => 120 volt AC pure sine wave inverter at 60Hz, a clock powered by that inverter kept accurate time for 72 hours.

I suspect the level of speed accuracy/stability you're looking for would require a speed sensor on the DC motor's shaft so you can make very fine speed adjustments (responding to very small changes in motor RPM) very quickly. That level of control may require a larger PICAXE running at high speed to keep up with the pulses from the motor's speed sensor and do the required PWM adjustments - probably using HPWM instead of PWM.
 

davidwf

Senior Member
hmmm...would something as simple a a CMOS based 555 variable mark-space generator circuit do the trick...

24876

....adding an averaged voltage derived from a slotted opto switch to pin 5 of the 555 to give feedback/control

24877

feasible ???
 

AllyCat

Senior Member
Hi,

I wasn't impressed with the frequency stability or modulation capability of the "555" timer when it was designed over 50 years ago :( . IMHO the only thing a 555 can do better than a PICaxe is to work at 15 volts :) . Your type of feedback circuit has no capability to improve on that basic frequency (un)stability. Coding a PICaxe to operate as a PLL at these low frequencies is not difficult, provided that you don't attempt to use too much loop gain.

The camera will be using a Quartz Crystal oscillator, so you need to either lock (synchronise) to that system, or at least to lock to another Quartz Crystal (or better) oscillator (not just a "resonator"), to give comparable stability. There are numerous sources which use a Quartz crystal, such as a RTC module, a PICaxe 28X2, or various Radio Transmitters (the ultimate being the GPS system), etc., but in my opinion nothing less will give satisfactory long-term stability.

Cheers, Alan.
 

davidwf

Senior Member
Again thanks...
I don't THINK the frequency matters here...it is the mark-space ratio that is important as that is what is controlling the motor speed
 

AllyCat

Senior Member
Hi,

The PWM Duty Cycle (mark-space ratio) is ONE of the factors which determines the motor speed. Others are: The supply voltage, the mechanical load on the motor shaft (perhaps including the viscocity of its lubrication), the Resistance of the motor coils (which being copper varies with temperature), etc.. So you need a (frequency) "feedback" speed control system, that your shutter appears to give, and it's THAT (frequency) which needs to be controlled against a (very) precise time reference (in a PLL system).

Cheers, Alan.
 

tmfkam

Senior Member
To throw another spanner into the mix...
If the projector's lamp is not powered by DC, and also not LED or Compact Fluorescent, there may be some strobing generated by the "flicker" from the lamp.

In a system where the motor and lamp are driven by the same AC source (possibly through a transformer) this would hopefully be designed so that both are synchronised and show no visible effect. However, if your motor becomes DC powered, it will no longer have the same phase relationship as the lamp.

It could also be that the video recording device has a far shorter persistence of vision than the human eye. If the projector relied on this alone, possibly some post processing of the recording could "average" out any flicker?
 

davidwf

Senior Member
I have already replaced the bulb with a DC driven LED and there are no issues with it :)
Main problem now is to get the motor speed precise...I have engineered the attached to drive a small DC motor which generates 6V at the required speed
I am still favouring a PICAXE PWM controlled system which reads the DC voltage and adjusts the PWM output to the motor (via a power MOSFET)
 

Attachments

piclt

Member
We will soon have completed the full circle.
You changed the motor to a DC motor the speed of which depends on the applied voltage and the load it is driving. From your picture I see it is a XD3420 and you now have it driving a generator as well, I assume to act as a tacho-generator. so you must have intended some form of voltage feedback/control to maintain a constant speed and from the title of this thread, closed loop control. What power supply are you using to drive the motor and how is it controlled, How dit you get it to run at the correct speed to give you 6 volts from the generator. Controlling the voltage to the motor and measuring the voltage from the tacho can be used for closed loop speed control. If the position of the cine track (frame relative to camera) needs to be in synch then you will also need position or timing control as well. I see you are using Toothed timing belts so no slippage. A white mark on a pulley or belt could be used for position control and keep everything in synch. Where does Picaxe fit in.?
Picaxe can be the controller, but it depends on what you want to actually control. Consider the bits and pieces.....put them together as a system ...then rough design it... and post the problems and queries... then do it
 

davidwf

Senior Member
I ran it from a stabilised PSU (an old laptop one)....."the picaxe fits in" as the motor speed will vary very slightly due to load, friction, temperature and who knows what else is still needs to be regulated
 

piclt

Member
Did the stabilised PSU "magically" run the motor at the correct speed or did you need to "tweek" the PSU.
What do you mean "the picaxe fits in" do you mean physically inside the PSU or "it fits in" as a component part of the project.
Yes, I know the PSU output may need regulated if it is not stable enough.
Options ..... can the "tweeking" of the PSU be controlled by Picaxe ....that may be simpler as the PSU is already equipped to drive the motor. So no need for mosfets and other power components.
Is your generator for feedback of speed .....incorporate the to in the "tweeking" circuit
 

davidwf

Senior Member
apologies...I WILL be running it from an old laptop PSU - 15V@5A....at the moment I am running it from my bench PSU at about 12V, tweaked to get 1000RPM at the shaft

in your previous post you asked "Where does Picaxe fit in.? " :)

I do not know how to tweak a switch mode PSU....and it is all sealed up anyway

My small motor would, ideally be incorporated into the feedback loop,...... kinda pointless having it there otherwise :unsure: ..... presumably something along the lines of read ADC - being the voltage of the motor/generator and adjust the m/s ratio of the main motor to suit
 

piclt

Member
OK, the laptop PSU is a black box you cannot get inside so you will have to control its output going to the motor using mosfet and PWM
Do you know what current (amps) the motor takes when running normal speed 1000 rpm driving the machine.
When you know that decide the mosfet you are going to use and make sure from the datasheet it will switch on/off from the voltage from Picaxe pin.
You can test the power components by connecting the mosfet in series to your bench PSU output and on to the motor wiring and apply a voltage to the gate to switch the motor on/off by applying and removing the voltage on the gate. Now you will know the mosfet works and does not heat up or if it needs a heatsink.etc.
Regards where" the Picaxe fits in" it will be used to control the mosfet. As a first simple test, setup and program your picaxe to flash a simple LED on an output pin. all you need is In main loop
do
High C.2
Pause 5000
Low C.2
Pause 10000
loop

That will let you know the 08m2 is working..............

then connect the gate wire to pin C.2 and the motor should start and run for 5 seconds then off for 10 secs.
That will get it all connected and working.
Then you can try and setup PWM to give you variable speed. C.2 on 08m2 is PWM pin
 
Last edited:

davidwf

Senior Member
the motor pulls about 1.3A at the desired speed
I am using STP55NF06L VMOS as they have always been my choice and seem to work well in just about anything, it does not even get warm so I know it is fully conducting
 

piclt

Member
Are you using the XD3420, I looked up the spec. It is rated at 400mA at 12 Volts.
Is the motor over loaded...??? .....Your measurement is over 3 times the rated current...??

Motor Type: XD3420.
Low Noise Type: < 30dB.
Operating Voltage: 6~20Vdc. (Nominal 12Vdc)
No Load Speed: 3,500 RPM @ 12V.
Rated current: 400mA @ 12V.
Rated Torque: 19.6N.cm/2Kg.cm.

Did you connect it up to Picaxe and drive it via picaxe yet.....??
 

davidwf

Senior Member
Hmmmm....I am using that motor but it doesnt seem over stressed.....and after 20 minutes running is barely warm!
The spec says it is a 12V 30W motor which would equate to 2.5A....there is also a 24V version which would still be 1.25A.....that 400mA looks wrong, it is quite a "beefy" and powerful motor - I dont think it could generate 0.19Nm of torque at 400mA!
No, no PICAXE yet

On page 6 of this PDF https://handsontec.com/dataspecs/motor_fan/XD3420-Motor.pdf the example suggests a 19W draw at 1.65A
Thank you for pointing it out though, but with the greatest respect I will worry about the mechanicals....just need help with the PICAXE part :)
 
Last edited:

rq3

Senior Member
I am trying to copy old 8mm cine film to digital using a projector
I have been through hoops of trial and error and have settled on videoing the actual film itself using a close focus lens looking directly at the film gate (i.e. emulsion side) with the projection lens removed as it gives incredibly sharp results and colour, the camcorder produced HD mp4 file only needs flipping which I can do quickly in my PC video editing program and the resultant video looks excellent even on a 55" OLED TV :)

I need to closely and very precisely control the 12V DC motor that I have fitted to the projector as it MUST run at a precise speed (of around 2700 RPM via the geared pulleys) to give the required 16 2/3 fps on the projector shaft - which equates to 1000 RPM........ handily, with the 3 blade blanking shutter in the projector this translates to exactly 50Hz and ensures there are no black bars or sync issues with the camcorder

I have a slotted opto switch that I can mount to the projector shaft to detect the 3 shutter blades as they rotate - I did consider using a magnet and hall output but that only gives 16.66Hz whereas the 3 blades will give 50Hz which should allow a tighter control and wont upset the balance of the shutter plate…..

.....and thats about as far as I have got so would appreciate any suggestions and help in controlling the motor (via a MOSFET) and (if possible) an 8 pin 08M2 PICAXE as I have several going spare
The mechanics are sorted but I have little experience in programming
What you are describing is what used to be called a telecine ( pronounced telasinee). Unless there is an optical audio track involved, and you need high speed transfers, you are grossly complicating this.

You seem to have a handle on the projection of the film image, and the exposure of the digital image. Do they need to be syncronized at actual film speed? Can you advance a film frame, take a shot, advance another film frame, take a shot, ad infinitum? At one frame per second, it would take 24 times as long to transfer a 24 frame per second film. Do you care?

Any standard 8 or super 8 projector (indeed ANY projector, other than early highly experimental "optically intermittent" cameras and projectors) will have any number of places to insert an optical switch or microswitch to trigger the digital camera staring into the projector gate. Keep in mind that a mechanical film projector does not smoothly flow the film. It advances one frame, stops the film, projects the image, blocks the image, and then moves to the next frame. Repeat.

If there is an optical or magnetic audio track on the film, that is another issue, which can, and should, be addressed seperately. Most film and audio is recorded divorced from each other (hence the classic "Take 12, Count 3,2,1, CLACK") that we've all seen. The CLACK is an audio recording syncronised in time to the film frame when the sound occured (+/- one frame). Different machines were used for the video and audio, hence the need for the clacker.

End of life Super 8 film did include magnetic and optical audio of very poor quality. If that is your situation, I would stongly recommend treating the audio and video as two competely different issues. Make a good digital video dub, and then make an audio master from the original that can then be manipulated and added as required.
 
Last edited:

davidwf

Senior Member
well yes.... at 1fps it would take around 5 hours to copy a 20 minute film...

As we are heading towards PICAXE would it not be easier to re-fit the slotted opto switch that I originally suggested and program the pic to count the number of pulses, compare that with the required number of pulses and adjust the motor speed accordingly?

I THINK….
The shaft rotates at 1000RPM so, 1000/60 = 50 revs per second and has 3 shutters which would give 150 pulses per second (each pulse being 6.6666667mS apart)……and potentially 150 motor speed “corrections” per second…..surely enough ?

At startup there would be zero pulses so maximum power would be applied, negating the need for two ADC channels as the “correct” speed (150) would be programmed into the PIC

Needless to say I am a bit stumped as to how to start this
 

AllyCat

Senior Member
Hi,
.... to copy a 20 minute film...

.... would it not be easier to re-fit the slotted opto switch that I originally suggested .... and adjust the motor speed accordingly?
Absolutely, but it was you who (apparently) removed it and headed along a "dead end" of introducing an (open loop) tacho-generator! :(

And at last, an (implied) answer to my (implied) question in #4. So the "requirement" is for the "phase" of the camera ("shutter") to remain within around 10ms of the shutter (gate) opening, over a period of 20 minutes? "Open Loop", that's one part in 100 * 20 * 60 = 120,000 (or 8 ppm or 0.0008% "accuracy").

The only way you'll achieve that requirement is with a "proper" closed-loop (feedback) system (as described in the title), i.e. compare the instant in time that the camera takes a shot with the instant that the gate/shutter opens. A PICaxe can "easily" make measurements/comparisons to within a few ms for as many hours as desired, but you must have (two) time references (i.e. "desired" and "actual") to compare and "close the loop".

IMHO the way to make this work (reliably) is to get a reference (sync) pulse from the camera; Several suggestions were made of how to achieve this, from various contributors near to the start of the thread.

Cheers, Alan.
 

piclt

Member
Are we not trying to control 2 things here. Speed and Position. And to complicate matters we have to control the relative position while it is moving at speed.
A bit like the old TVs, the horiz. or vertical oscillators had to keep running and keep in sync.
There was a thing called flywheel sync and it got a nudge now and again from the sync pulses in the signal.
The tacho was already fitted so assumed it would be used to measure speed.
The set speed (setpoint) can be set with a potentiometer as an input to Picaxe and setup untill near enough and get things working to see what is happening. The tacho output can be fed back and subtracted from the setpoint pot signal and the error will then be used to drive the PWM speed. This will give proportional closed loop control for the speed....but.... the error can never be zero because we need to keep the motor moving and need an offset to maintain the speed. If the speed drifts over time the offset will gradually increase or decrease in proportion to the change and in the direction to compensate.
If this level of control is not close enough then we could measure sync pulses from the camera and/or the film strip gearing and use this to reset the setpoint error/offset . We will also need to know is the motor running faster than the sync pulses or slower in order to correct it.
 

davidwf

Senior Member
Wow.....
I had previously proved that recording the cine film worked with the original AC motor but over time there was a slight drift and therefore the black bars. I fitted the DC motor in order to be able to control it's speed a bit "easier" (????)
 

piclt

Member
Get it working with good stable speed control first. If that does not work sufficiently well and be reasonably stable then adding sync pulses will not help.

I am not a film person, how is the film driven in the projector, are there holes along the side and a toothed wheel driving it, and you have all toothed timing belts so no "slippage". You could detect a mark on a belt or pulley or fit your slotted opto switch.
 

AllyCat

Senior Member
Hi,

The User Manual > Recording > Notes says:
"While recording movies in the XAVC S 4K 100Mbps or XAVC S 4K 60Mbps format, video signals (HDMI output signal/AV cable output signal) are not output to external media", which suggests to me that in the other recording modes an Output/Sync signal is available from the HDMI connector?

If that really isn't possible, then a precise Crystal-controlled 50 Hz (ideally), or down to a 1 Hz pulse (e.g. from a RTC) at worse, should allow the projector to be kept in sync with the camera, at least for some minutes using a simple "PLL" PICaxe program. A manual delay (e.g. Potentiometer+READADC+PAUSE) could be used to "phase" the projector/gate to the camera shutter.

Basically, the program can be just of the form: "If motor/gate pulse is 'Late' then increase the PWM value (i.e. motor speed), if the Reference (=camera sync) pulse is 'Later' then decrease the PWM value". The speed of detection and the amount that the PWM is changed each time (i.e. the loop gain) would obviously need to be optimised by some trial and error.

Cheers, Alan.
 

piclt

Member
Thats why I say get the basics working first.
Most people having their car re-sprayed will not worry about the detergent to use to wash their car when it gets dirty after the respray. They will have the bodywork prepared and actually re-sprayed, and have taken it out for a spin to get it dirty.

From where I am sitting nothing has been tried yet to see if it will work even under test.
 

davidwf

Senior Member
piclt :
for reference I checked the motor current with absolutely no load and nothing connected to it and guess what....at 12V it was 400mA :)
Maybe the spec got confused in translation.....anyway as previously stated it is quite a powerful motor
 

piclt

Member
The spec sheet may be rated at no load OK, constant conditions. and it shows no load speed 3500 rpm.
You earlier said you needed the motor to run at 1000 rpm when driving the film projector.
What voltage did you need to get the motor to run at 1000 rpm. was it driving the projector.
What amps.
If it looks that it is capable when you do a short run, then run with it and watch what it does, look out for overheating etc.
Also try it with the Picaxe and Mosfet, low mark/space ratio to start with.
 

piclt

Member
These are all the thing you have to sort, you are at the machine and see it running.
But looking at you picture in your earlier post there looks like a 3 to 1 ratio to the pulley on the tacho, that means the tacho is running at about 10000 rpm, what voltage is it outputting at that speed ?? seems fast ??
And from the picture you have about 1 to 3 ratio reduction to the brass wormwheel,.....is that "the shaft" you mention you want to run at 1000 rpm.

You need to try the picaxe and the mosfet to see how it behaves.
 

piclt

Member
OK, If you reduce the speed by say 10% does the tacho volts go down proportionately say 10% or more. And similarly if you increase the speed 10% does the tacho volts rise in the same proportions.. You will need good linear response of tacho volts change for change in speed to give good control.
 

piclt

Member
Why do you need it..??? Have you tested the Picaxe and mosfet speed control with the tacho feedback on the actual motor. Did it not work. ?? What was it not doing..??
 
Top