Help Useng Shaft Encoder cnc mill

Hi there
I have a prob i want to use a shaft encoder and a picaxe 14 to drive my milling mechine interface. i need a pulseout from the picaxe when i turn the encoder cw or acw but i need to set a pin high or low to drive the step direction on the interface. can somebody help with the code i have only got so far and had a block???. regards Andy Quirot (Jersey Channel Islands)
 

demonicpicaxeguy

Senior Member
i'm doing somthing similar myself only using modified rc servo that turns 360+ and going to use the internal gears to provide a pulsed position out put
 

SD2100

New Member
I have this connected to a 100 pulse per rev encoder, the outputs are connected to a 3 digit led display, as the encoder changes direction pin0 changes high/low to control the up/down counting of the display.

Code:
#Picaxe 08m
setfreq m8

symbol CountDir    = 0    'Sets counter for Up/Down count (0=down,1=up)
symbol Clock       = 1    'Clock pulse to external counter
symbol ZeroCounter = 4    'Zero display
symbol EncoderA    = pin2 'Input A from encoder
symbol EncoderB    = pin3 'Input B from encoder

pulsout ZeroCounter,5

do
    ;Increment Counter
    if EncoderA=1 and EncoderB=0 then
        high CountDir    'Encoder forward, set for Up count
        do
            if EncoderA=0 and EncoderB=1 then
                pulsout Clock,1
                exit
            elseif EncoderA=0 and EncoderB=0 then
                exit
            end if
        loop	
    end if
	
    ;Decrement Counter
    if EncoderA=0 and EncoderB=1 then 
        low CountDir    'Encoder reverse, set for Down count
        do
            if EncoderA=1 and EncoderB=0 then
                pulsout Clock,1						
                exit
            elseif EncoderA=0 and EncoderB=0 then
                exit
            end if
        loop
    end if	
loop
 
Re Encoder

Looks like what i may need a starting point

i need
2 outputs
2 inputs

input a,b are for the shaft encoder a and b
output 1 (when you turn the encoder eather way this pin must go high,low in time with the encoder pluse (ie is the encoder output))
Output 2 this pin hust go high when the encoder is rotated clockwise, low when rotated anti-clockwise.

I have tryed writing the code but have found when the encoder is in a certain position the program loop

start:
zzzzz
xxxxx
xxxxxx
xxxxxx
goto start

causes the output to pulse so driving my stepper motor any thoughts guys and dols
Regards Andy Quirot
 
Top