Screen masking controller - how much could a Picaxe do?

Gunnar

New Member
I`m building a four-way masking system for my Home Theater screen. I would like to have it motorized and remote controlled. The horizontal masks would provide 2.7 , 2.4 , 2.35 , 1.85 and 1.78 aspect ratio, and with the horizontal masks fully open the vertical masks provides 1.66 and 1.33 aspect ratio.

I`ve seen systems that use a IR-relay block and switches to control the position. This probably works great, but I thought that this might be a suitable project to learn something about microcontrollers? Maybe a bit to ambitious for a newbie?

I would like to use a rotary encoder instead of switches. So far I got a prototype board with a PICAXE 18X and a 293D motor controller.
I found the "Finite state machine" code here at the forum for decoding quadrature encoders. I tried it in the simulator, and it works, except that I need more than 8 bits to avoid that the counter roll over. I use the guts of a Logitech mouse as rotary encoder(s), and the pulses seems very clean and stable on the oscope. I have not connected the pulses to the picaxe yet.

So far it seems that I need some external electronics. Maybe external counters? I need to have a way to calibrate the system. Maybe manual switches that move the masks, and then a switch to store the current position as a preset.

The current position should be stored when the system is turned off.

I plan to use a IR-receiver module with a demodulated output, eg. like this: https://www1.elfa.se/data1/wwwroot/webroot/Z_DATA/07520273.pdf

Any insight or suggestions are appreciated...

Gunnar
 

Gunnar

New Member
I have now connected a motor w/encoder, and a IR-receiver/demodulator to my Picaxe 18X prototype board, and done some programming. I`m using the infrain command, and let the motor go to predefined positions when pressing different keys on the remote (Philips Pronto w/Sony IR-codes).

Encoder consist of a (nearly unmodified..) PC-mouse. I use Hippys Finite State Machine code to decode the quadrature pulses from the mouse encoder. I get about 13 pulses/mm travel of the screen mask, which is more than good enough.

Next I want to do is to program two remote buttons for moving the mask up/down. Then a press on a third button could store current position in the last used preset position. I`m not sure how to do this, as the infrain command seems to freeze everything until the next IR-pulse is received. If this is the case I will not be able to count pulses at the same time as the infrain is waiting for the stop key to be pressed.

I checked the repeatability by lifting/lowering a pen about 20-30 times. Repeatability is good, though I see that it isn`perfect. The problem is probably that I stop counting when I turn off the motor, and it moves a bit further before stopping completely. So I need to modify the code to take this into account. Suggestions are appreciated..

Gunnar
 

Attachments

kevrus

New Member
Perhaps some form of braking will be necessary on the motor.
On permanent magnet motors, i.e. some car windscreen wiper motors, when the wipers return to their 'parked' position, the supply is removed and the motor terminals are shorted together to ensure consistent positioning.
 

Gunnar

New Member
Yes, shorting the motor could be done. I`m also thinking that when the target is reached and the power to the motor is removed, a timer could be started, and the counting proceed until the timer reach a curtain value. So, how to implement a timer? A little more searching of the forum..

Also, maybe I can`t use the Infrain command. If I decode without it I could use interrupt to read a new key without stopping the counting.
 

hippy

Ex-Staff (retired)
You may be able to scan for the presence of an IR signal ( goes low when signal present ) rather than INFRAIN'ing while stepping the motor but you could get tight on processing time ( 8MHz operation will help ). That will allow any button to stop the movement, then you can simply press button 3 to store where it is, button 1 or 2 to move up/down until you are happy. Maybe a separate mode to let button 1 and 2 nudge the motors for setting the stop points ?
 

Gunnar

New Member
Thanks!
Yes, I think that would work. I could have a separate mode that is initiated by the infrain, and then finish when a low signal is present on the IR-pin. I`ll give it a try..

Gunnar
 

Gunnar

New Member
It works if I just scan for a low IR-signal like this:

main:
infrain
if infra=4 then
low 4 rem motor forward
high 5 rem motor forward
goto jog
endif

jog:
ir = pins & 1
if ir = 0 then rem scan input 0 for low ir-signal
low 4 rem stop motor
low 5 rem stop motor
goto main


But if I include this in every count up and count down state in the state machine code it won`t work.

Gunnar
 

hippy

Ex-Staff (retired)
It depends on how you include "this" in your state machine and exactly what "this" is.

The state machine probably needs speed to do its thing. You can run at 8MHz to improve that ( drop back to 4MHz for INFRAIN then return to 8MHz after ) and you can reduce the IR detection overhead in each state by using a simple -

If pin0 = 0 Then IrDetected

Lose the intermeditate "ir=" assignment, don't use IF-THEN-ENDIF and put "IrDetected" outside the state machine to stop the motors and execute and handle the INFRAIN.
 
Last edited:

Gunnar

New Member
So far so good!
I found an error in my code that prevented the jog function to stop on a arbitrary IR-code. Now it works. I can also store the position into a preset by pressing a store button on the remote, and then the desired preset button.

The only issue left that I hope to solve is that the Finite State Machine should continue to count for maybe a second after I cut the power to the motor. As it is now I just stop the motor when the current position=target position, and return to wait for a new ir-code. The motor moves a bit further after the power is cut before stopping completely, so I miss a few pulses.

Same with the jog-function. I stop the motor when a low signal is detected on the ir-pin, and then returns to wait for a new ir-code.

I thought of putting in a test in the BRANCH-lines in the Finite State Machine to check if the snap variable changes or not. If it is not changing for a certain number of checks, the motor has come to a stop. But if the encoder stops on a transition..

Gunnar
 

Gunnar

New Member
Almost two years has passed, and the masking system has worked fine. Still only a two-way system, with a top and bottom mask. I couldn`t find a solution on how to continue counting pulses after the power to the motor is removed. I still want to solve this, since I will now try to implement 4 motors driving 4 individual masks. With this I will eg, be able to have a subtitle mode where the bottom mask stays down, compensate for off centered mastered movies osv..

I plan to use a 08M PICAXE for each motor counting encoder pulses. A bigger central PICAXE will handle IR, limit switches, transfer target positions to the counters osv. The counters will send back status on position to the central PICAXE that will start/stop the motors. Not sure if this can be done with serial communication, or if there is a better way? An alternative could be to let all PICAXEs receive the same IR-code to avoid some of the communication.
 

Gunnar

New Member
Using one 18M2 and one encoder for each mask seems to be much easier to do than my previous attempt. I found some very useful code posted by Hippy, that uses a lookup table to decode the encoder states. Works very well, and much less code than using the "final state machine" code that I used before. I simulated one mask with the hardware I already have, and it works. but this hardware uses a 18X, and this must use pin 1 for the ir. This is not optimal, as I need to use a few more lines of code shifting bits in the decoding loop, to make the lookup-index. Seems I can decode about 100 changes of states/second with this loop, and a 18X at 4MHz. I enclose the decoding loop for the 18X (using pin 2,3):

Code:
monitor_preset:

	if pos = target_pos then stop_movement				rem preset reached?
	enc_state = enc_state & %00000110 * 4				rem shift 2 bits left to save previous state
	enc_state = pins & %00000110 | enc_state				rem read new state, OR with previous state
	enc_state = enc_state /2						rem shift 1 bit right to make useful index for lookup table
	LOOKUP enc_state,(1,2,0,1,0,1,1,2,2,1,1,0,1,0,2,1),pos_change	rem determine count up/down or count unchanged.
	pos = pos -1 + pos_change						rem new current position
	enc_state = enc_state * 2						rem shift 1 bit left to be ready for next loop iteration
	GOTO monitor_preset
I got 4 quadrature encoders from eBay, see Link . Pulses are nice and clean, but the dutycycle and the phase difference between A and B is a bit off, se picture. Don`t know if this will affect the counting.
 

Attachments

Last edited:
Top