tecnition_ted
New Member
Hi All
I am trying to control a motor to have speed steps controlled by another picaxe through Ir numbers loaded into b0, the main idea of this project is to try and master gosub, return and PWM out.
The ultimate aim is to have the picaxe receive a number numbers 1 and 10 alter in puts C0 and C1 to controle forward/ reverse, number 20 is acceleration, 30 is deceleration.
I need the motor to slow before switching between forward and reverse then accelerate afterwards.
So far I have a IR module VS1838B connected to B.1 . C.0 and C.1 connected to in 1 and 2 on a L293E and C.2 (PWM out) goes into enable 1 on the L293E.
The SMPS sense is bridged to gnd on one and two.
Can anyone help make this work or explain why it does not
Thank you.
{code}
high c.0 ; change driver ic from satus to 0-1
low c.1
Let w2 = w2 max 10
Let w2 = w2 min 0
main:
symbol T1 = 500
irin [1000,main],B.1,b0 ;wait for new signal
DEBUG
if b0 = 1 then Mof ;motor forward
if b0 = 10 then Mor ;motor reverse
if b0 = 20 then Accel ;motor Accelerate
if b0 = 30 then Decel ;motor decelerate
Mof:
if w2 > 1 then gosub Decel
high c.0 ; change driver ic from satus to 0-1
low c.1
pause T1
if w2 < 10 then gosub Accel
if w2 = 10 then goto main
Mor:
if w2 > 1 then gosub Decel
high c.1 ; change driver ic from satus to 1-0
low c.0
pause T1
if w2 < 10 then gosub Accel
if w2 = 10 then goto main
Accel:
Let w2 = w2 max 10
Let w2 = w2 min 0
debug
pause T1
let w2 = w2+1
pause T1
gosub Main2
if w2 < 9 then Accel
return
Decel:
Let w2 = w2 max 10
Let w2 = w2 min 0
debug
pause T1
let w2 = w2-1
pause T1
gosub Main2
if w2 > 0 then Decel
return
Main2:if w2 = 1 then pwmout pwmdiv64, C.2, 255, 0
; send 0% pwm bursts out of pin c2
end if
if w2 = 2 then pwmout pwmdiv64, C.2, 255, 255
; send 25% pwm bursts out of pin c2
end if
if w2 = 3 then pwmout pwmdiv64, C.2, 255, 306
; send 30% pwm bursts out of pin c2
end if
if w2 = 4 then pwmout pwmdiv64, C.2, 255, 409 ;send pwm 40% bursts out of pin c2
End if
if w2 = 5 then pwmout pwmdiv64, C.2, 255, 511 ;send pwm 50% bursts out of pin c2
end if
if w2 = 6 then pwmout pwmdiv64, C.2, 255, 613 ;send pwm 60% bursts out of pin c2
end if
if w2 = 7 then pwmout pwmdiv64, C.2, 255, 716 ;send pwm 70% bursts out of pin c2
end if
if w2 = 8 then pwmout pwmdiv64, C.2, 255, 818 ;send pwm 80% bursts out of pin c2
end if
if w2 = 9 then pwmout pwmdiv64, C.2, 255, 920 ;send pwm 90% bursts out of pin c2
end if
if w2 = 10 then pwmout pwmdiv64, C.2, 255, 1023 ;send pwm 100% bursts out of pin c2
end if
return
I am trying to control a motor to have speed steps controlled by another picaxe through Ir numbers loaded into b0, the main idea of this project is to try and master gosub, return and PWM out.
The ultimate aim is to have the picaxe receive a number numbers 1 and 10 alter in puts C0 and C1 to controle forward/ reverse, number 20 is acceleration, 30 is deceleration.
I need the motor to slow before switching between forward and reverse then accelerate afterwards.
So far I have a IR module VS1838B connected to B.1 . C.0 and C.1 connected to in 1 and 2 on a L293E and C.2 (PWM out) goes into enable 1 on the L293E.
The SMPS sense is bridged to gnd on one and two.
Can anyone help make this work or explain why it does not
Thank you.
{code}
high c.0 ; change driver ic from satus to 0-1
low c.1
Let w2 = w2 max 10
Let w2 = w2 min 0
main:
symbol T1 = 500
irin [1000,main],B.1,b0 ;wait for new signal
DEBUG
if b0 = 1 then Mof ;motor forward
if b0 = 10 then Mor ;motor reverse
if b0 = 20 then Accel ;motor Accelerate
if b0 = 30 then Decel ;motor decelerate
Mof:
if w2 > 1 then gosub Decel
high c.0 ; change driver ic from satus to 0-1
low c.1
pause T1
if w2 < 10 then gosub Accel
if w2 = 10 then goto main
Mor:
if w2 > 1 then gosub Decel
high c.1 ; change driver ic from satus to 1-0
low c.0
pause T1
if w2 < 10 then gosub Accel
if w2 = 10 then goto main
Accel:
Let w2 = w2 max 10
Let w2 = w2 min 0
debug
pause T1
let w2 = w2+1
pause T1
gosub Main2
if w2 < 9 then Accel
return
Decel:
Let w2 = w2 max 10
Let w2 = w2 min 0
debug
pause T1
let w2 = w2-1
pause T1
gosub Main2
if w2 > 0 then Decel
return
Main2:if w2 = 1 then pwmout pwmdiv64, C.2, 255, 0
; send 0% pwm bursts out of pin c2
end if
if w2 = 2 then pwmout pwmdiv64, C.2, 255, 255
; send 25% pwm bursts out of pin c2
end if
if w2 = 3 then pwmout pwmdiv64, C.2, 255, 306
; send 30% pwm bursts out of pin c2
end if
if w2 = 4 then pwmout pwmdiv64, C.2, 255, 409 ;send pwm 40% bursts out of pin c2
End if
if w2 = 5 then pwmout pwmdiv64, C.2, 255, 511 ;send pwm 50% bursts out of pin c2
end if
if w2 = 6 then pwmout pwmdiv64, C.2, 255, 613 ;send pwm 60% bursts out of pin c2
end if
if w2 = 7 then pwmout pwmdiv64, C.2, 255, 716 ;send pwm 70% bursts out of pin c2
end if
if w2 = 8 then pwmout pwmdiv64, C.2, 255, 818 ;send pwm 80% bursts out of pin c2
end if
if w2 = 9 then pwmout pwmdiv64, C.2, 255, 920 ;send pwm 90% bursts out of pin c2
end if
if w2 = 10 then pwmout pwmdiv64, C.2, 255, 1023 ;send pwm 100% bursts out of pin c2
end if
return