Hello!
Well, I have set out to have analogue inputs to one PICAXE, convert to servo variables, do a little math, and send the results to another PICAXE via a pair of half-duplex RS-485 transceivers. The second PICAXE sends those variables to a AXE033 for now, need to wait on purchasing more parts to continue, but all is well. I figured that I would like to send info back to the first PICAXE, but I'm still thinking about how to "handshake" as suggested by lbenson a while back. So in the meantime, I introduced a DS18B20 to the second PICAXE to display on the AXE033, but I noticed that the program has slowed down, not as responsive as before. "The conversion takes up to 750ms", didn't seem long before I downloaded it to my project!
Is there another faster way to have a temperature reading included to my project? I would also like to add a pressure sensor and a couple discrete inputs as well down the road. Is it the 18M2, should I look into other PICAXEs?
Not sure if there was an easier way to get the results I'm looking for, but I certainly happy with what I have done so far! That being said, I am open to suggestions.
Thank you.
Well, I have set out to have analogue inputs to one PICAXE, convert to servo variables, do a little math, and send the results to another PICAXE via a pair of half-duplex RS-485 transceivers. The second PICAXE sends those variables to a AXE033 for now, need to wait on purchasing more parts to continue, but all is well. I figured that I would like to send info back to the first PICAXE, but I'm still thinking about how to "handshake" as suggested by lbenson a while back. So in the meantime, I introduced a DS18B20 to the second PICAXE to display on the AXE033, but I noticed that the program has slowed down, not as responsive as before. "The conversion takes up to 750ms", didn't seem long before I downloaded it to my project!
Is there another faster way to have a temperature reading included to my project? I would also like to add a pressure sensor and a couple discrete inputs as well down the road. Is it the 18M2, should I look into other PICAXEs?
Not sure if there was an easier way to get the results I'm looking for, but I certainly happy with what I have done so far! That being said, I am open to suggestions.
Code:
#PICAXE 18M2
Init: Pause 500
Symbol thrust=w1
Symbol yaw=w2
Symbol active_span=w3
Symbol deviation=w4
Symbol servo_left=w5
Symbol servo_right=w6
Symbol led_sw=pinB.7
Symbol led_latch=b0
Let led_latch=0
Main:
High b.2 ;enable send Max485 disable receive
serout c.2,n2400_4,("XYZ",servo_left,servo_right,thrust,yaw,led_latch)
low b.2 ;disable send Max485/ enable receive Max485
;calculate the x axis of the joystick to servo valuereadadc c.1,thrust
readadc c.0,yaw
if led_sw=1 then:gosub Latch:endif
if thrust>130 and yaw<128 then:gosub ForwardLeft
elseif thrust>130 and yaw>127 then:gosub ForwardRight
elseif thrust<125 and yaw<128 then:gosub ReverseLeft
elseif thrust<125 and yaw>127 then:gosub ReverseRight
else
gosub Neutral
endif
goto main
ForwardLeft:
let servo_right=thrust*150/255+75
let active_span=servo_right-150*2
let deviation=128-yaw*active_span/128
let servo_left=servo_right-deviation
return
ForwardRight:
let servo_left=thrust*150/255+75
let active_span=servo_left-150*2
let deviation= yaw-128*active_span/128
let servo_right=servo_left-deviation
return
ReverseLeft:
let servo_right=thrust*150/255+75
let active_span=150-servo_right*2
let deviation=128-yaw*active_span/128
let servo_left=servo_right+deviation
return
ReverseRight:
let servo_left=thrust*150/255+75
let active_span=150-servo_left*2
let deviation=yaw-128*active_span/128
let servo_right=servo_left+deviation
return
Neutral:
let servo_left=128
let servo_right=128
return
Latch:
High b.3
Pause 500
Do: Loop until Led_sw=0
low b.3
led_latch=led_latch+1
if led_latch>2 then
let led_latch=0
endif
return
Code:
#PICAXE 18M2
Init: Pause 500
Serout c.1,n2400,(254,1)
pause 30
serout c.1,n2400,(254,128,"Powering up")
pause 2000
Serout c.1,n2400,(254,1)
pause 30
Symbol thrust=w1
Symbol yaw=w2
Symbol servo_left=w5
Symbol servo_right=w6
Symbol led_latch=b0
;Symbol Temp=b15
Main:
Serin c.2,n2400_4,("XYZ"),servo_left,servo_right,thrust,yaw,led_latch
if led_latch=1 then
high b.3
elseif led_latch=2 then
high b.2
else
low b.2:low b.3
endif
;Readtemp c.0, Temp
Serout c.1,n2400_4,(254,128,#servo_left," ")
Serout c.1,n2400_4,(254,134,#servo_right," ")
Serout c.1,n2400_4,(254,192,#thrust," ")
Serout c.1,n2400_4,(254,198,#yaw," ")
;Serout c.1,n2400_4,(254,140,#Temp," ")
goto main