Once again,
Thank you all for taking the time to help me.
I have read the manuals, and thanks to the many people like westaust55, InvaderZim , BeanieBots , and many others I have been able to get this Far.
I'm using a potentiometer (b1)to get a reading from a steering wheel to the 28X1, according to the reading the 28X1 communicates with I2C to the MD03 controllers moving the motors Left (forward) or Right (reverse).
Also another Potentiometer (b2) to Act as Limit Switches for the motors.
Problemart 1
How can I make the Motors stop at a Designated b2 Reading?
Can it be done with just b1 only?
Problemart 2
When I go right (reverse) lets say all the way and turn left (forward), how can I accomplish this movement in the code when b1 still reading <120.
I hope I Explained my trouble so anyone willing to help me can understand.
this is the code I have so far:
Once again thanks for your time and Help !!!
Thank you all for taking the time to help me.
I have read the manuals, and thanks to the many people like westaust55, InvaderZim , BeanieBots , and many others I have been able to get this Far.
I'm using a potentiometer (b1)to get a reading from a steering wheel to the 28X1, according to the reading the 28X1 communicates with I2C to the MD03 controllers moving the motors Left (forward) or Right (reverse).
Also another Potentiometer (b2) to Act as Limit Switches for the motors.
Problemart 1
How can I make the Motors stop at a Designated b2 Reading?
Can it be done with just b1 only?
Problemart 2
When I go right (reverse) lets say all the way and turn left (forward), how can I accomplish this movement in the code when b1 still reading <120.
I hope I Explained my trouble so anyone willing to help me can understand.
this is the code I have so far:
Code:
'############################################
'Picaxe 28X1
'Using a 10K Potentiometer for Input
'2 DC Motors 24V and an MD03 as H-bridge
'############################################
'###################
'SETUP
'###################
Symbol Right=1
Symbol Left=2
Symbol E_right=0
Symbol E_left=0
Symbol Speed_1=100
Symbol Speed_2=200
Symbol Speed_0=0
HI2CSETUP i2cmaster, %10110000, i2cfast, i2cbyte ; %10110000 = $B0 = default MD03 Slave Address
HI2CSETUP i2cmaster, %10110010, i2cfast, i2cbyte ; %10110000 = $B2 = default MD03 Slave Address
'###################
'MAIN LOOP
'###################
main:
readadc 0,b1 ' read value on ADC0 into variable b1 from pot on steering wheel
readadc 1,b2 ' read value on ADC1 into variable b2 from pot to Stop movement in that direction
if b1<120 then gosub turn_right ' Go Right
if b2<40 then gosub Far_right ' Stop end travel right
if b1>135 then gosub turn_left ' Go Left
if b2>215 then gosub Far_left ' Stop end travel left
goto main
'###################
'SUBROUTINES
'###################
Turn_right:
HI2COUT [%10110000], 0, (Right)
HI2COUT 2, (Speed_1)
return
Far_right:
HI2COUT [%10110000], 0, (E_right)
HI2COUT 2, (Speed_0)
return
Turn_left:
HI2COUT [%10110000], 0, (Left)
HI2COUT 2, (Speed_1)
return
Far_left:
HI2COUT [%10110000], 0, (E_left)
HI2COUT 2, (Speed_0)
return
Last edited: