I'm sorry if this has been asked before but I couldn't find any threads. I'm working on an ROV using rs485 communication. One of the programs will be for the pan and tilt of a camera. I've written the code so that the sending picaxe (on the surface) includes the "loop" information to the receiving picaxe on the ROV. I've tested the code and the camera seems to respond to the commands with no particular problems.
Here is a sample of part of the code from the topside:
Init: 'sending chip master from topside - digital camera tilt control
setfreq m4
pause 2000
low c.1
let b3 = 150 'good servo position for vertical up/dn
let b4 = 155 'good servo position for horizontal rt/lt
start:
If pinc.3 = 1 then up
if pinc.4 = 1 then dn
if pinc.2 = 1 then rt
if pinc.5 = 1 then lt
goto start
up:
Let b0 = 1
for b1 = b3 to 175 step 2 'so b1 runs from 155 to 200
serout c.1, n2400_4, (b0, b1) 'send out data - 1,155
pause 40
let b3 = b1 'b3 now = 155 for starters
if pinc.3 = 0 then start
if b1 > 175 then start
next b1 'b1 now = 157
pause 40
goto start
A portion of the receiving picaxe code (rov) is something like this:
Main:
Setfreq m4 'set frequency at 4 mghtz to match other chip
pause 5000
servo c.1, 150 'vertical - center servo c.1,
servo c.2, 155 'horizontal - ditto
setint %000010000,%00010000 'set it up that if pin 4 (c.4) goes high, an interrupt occurs
pause 2050 'timing is everything relative to serin/serout
interrupt:
Serin c.4, n2400_4, b0, b1 'read data at pin c.4, b0 (1 or 2) & b1 (initial servo position)
if b0 = 1 then panupdn 'go to approp subroutine depending on b0 number
if b0 = 2 then panrtlt
goto interrupt 'if b0 not a 1 or 2, start over and read data again
panupdn:
Serin c.4, n2400_4, b0, b1 'reread data
if b0 = 2 then panrtlt
if b0 <> 1 then interrupt 'recheck if b0 has changed (no longer a 1)
let b2 = b1 'place b1 number (like 143) into b2
servopos c.2,b2 'move servo to position b2 - like 143
pause 20
if b0 = 1 then panupdn 'start over & read data again
setint %000010000,%00010000 'reset interrupt in case command changes
goto interrupt 'check again for new command info
return 'no idea but it is a needed code dealy
Here is my question: I'm wondering if it would be better or more efficient to have the "loop" programming at the receiving (ROV) end. In other words, would it be better to minimize the communication necessary to move the camera - to simply tell the camera to start or stop moving (from the topside) and to have the receiving picaxe (ROV) handle the code (loop information) to actually move the camera? Or is the communication fast enough that it really doesn't matter all that much? By the way, the communication tether is only 150 feet.
Ps: I'm sure many of you will ask, "where are the symbols, etc."? Sorry, but i'm still learning the basics here.
Here is a sample of part of the code from the topside:
Init: 'sending chip master from topside - digital camera tilt control
setfreq m4
pause 2000
low c.1
let b3 = 150 'good servo position for vertical up/dn
let b4 = 155 'good servo position for horizontal rt/lt
start:
If pinc.3 = 1 then up
if pinc.4 = 1 then dn
if pinc.2 = 1 then rt
if pinc.5 = 1 then lt
goto start
up:
Let b0 = 1
for b1 = b3 to 175 step 2 'so b1 runs from 155 to 200
serout c.1, n2400_4, (b0, b1) 'send out data - 1,155
pause 40
let b3 = b1 'b3 now = 155 for starters
if pinc.3 = 0 then start
if b1 > 175 then start
next b1 'b1 now = 157
pause 40
goto start
A portion of the receiving picaxe code (rov) is something like this:
Main:
Setfreq m4 'set frequency at 4 mghtz to match other chip
pause 5000
servo c.1, 150 'vertical - center servo c.1,
servo c.2, 155 'horizontal - ditto
setint %000010000,%00010000 'set it up that if pin 4 (c.4) goes high, an interrupt occurs
pause 2050 'timing is everything relative to serin/serout
interrupt:
Serin c.4, n2400_4, b0, b1 'read data at pin c.4, b0 (1 or 2) & b1 (initial servo position)
if b0 = 1 then panupdn 'go to approp subroutine depending on b0 number
if b0 = 2 then panrtlt
goto interrupt 'if b0 not a 1 or 2, start over and read data again
panupdn:
Serin c.4, n2400_4, b0, b1 'reread data
if b0 = 2 then panrtlt
if b0 <> 1 then interrupt 'recheck if b0 has changed (no longer a 1)
let b2 = b1 'place b1 number (like 143) into b2
servopos c.2,b2 'move servo to position b2 - like 143
pause 20
if b0 = 1 then panupdn 'start over & read data again
setint %000010000,%00010000 'reset interrupt in case command changes
goto interrupt 'check again for new command info
return 'no idea but it is a needed code dealy
Here is my question: I'm wondering if it would be better or more efficient to have the "loop" programming at the receiving (ROV) end. In other words, would it be better to minimize the communication necessary to move the camera - to simply tell the camera to start or stop moving (from the topside) and to have the receiving picaxe (ROV) handle the code (loop information) to actually move the camera? Or is the communication fast enough that it really doesn't matter all that much? By the way, the communication tether is only 150 feet.
Ps: I'm sure many of you will ask, "where are the symbols, etc."? Sorry, but i'm still learning the basics here.