by Tim » Tue Jan 22, 2008 7:06 pm
by Tim
Tue Jan 22, 2008 7:06 pm
Entrastic
sorry for the delay - been on a stag do to sunny Liverpool (made a nice change from sunny Glasgow).
(1)
Logic voltage thresholds for 74HC CMOS are zero up to 1.3V, one above 3.7V (up to 5V). You can see some graphs of these for various families
here
The MR 3024 seems to run on 5V, and so do the servos (control input should be in the range 3V - 5V) so you're fine there.
(2)
Re the head turning problem, how long does it take to interrogate the camera? Off the top of my head, a suggestion for a possible approach (neglecting firmware mods) could be as follows.
If you set the speed to 5, then it takes 3.3ms for a robonova servo to turn 1 degree according to
this doc.
If you break the head turn from left to right into chunks that take just longer than it takes to talk to the camera, then you you could do something like this: command a section of the head turn, check the camera, decide whether to relinquish servo control to the camera or turn the head another section.
Assuming your head servo was the 17th servo, that the NAND gate switch was being controlled on port 3 (or whatever works for your setup), the following is an attempt to express the concept in code.
Warnings! I suspect there are bugs and misconceptions! Seeing as you can't use variables in servo movements, the code is pretty tedious! Also, I've not worked out whether the 'compiler' will bork when you use a GOTO to make an early exit from a GOSUB routine (it might upset the stack to have an unuseable entry in it?) - if so, the code below would get even more tedious because each segment would require its own label . . . ouch. I've not done much with robobasic yet and my last outing was with SystemC/C++ so I'm not tuned into the features/limitations/workarounds of robobasic yet...
'for the camera routine
DIM A AS BYTE
'============
turn_the_head:
'assert control over the head servo - this is the control signal to the switch circuit
OUT 3,0
'turn head 10 degrees
SERVO 17,10
'check the camera for movement...
GOSUB check_camera
'repeat tediously as follows ...
SERVO 17,20
GOSUB check_camera
SERVO 17,30
GOSUB check_camera
'code missing because it is tedious to type
SERVO 17,180
GOSUB check_camera
SERVO 17,190
GOSUB check_camera
'go back the other way
SERVO 17,180
GOSUB check_camera
'carry this on back to the starting position
SERVO 17,10
GOSUB check_camera
'go back to where ever you requested the head turn
RETURN
'============
'check the camera
check_camera:
'do whatever it is you do to get a response from the camera
'e.g. read value from AD input - just guessing here
'assume A is< 128 if nothing from camera
'assume A is >= 127 if camera wants control
A = AD(0)
IF A > 128
OUT 3,1
'camera has control of head now, until you assert OUT 3,0
'go back to main and do something else until next time you want to kick off the head turn
GOTO MAIN
ELSE
'nothing to see here, return to tedious head turning code
RETURN
ENDIF
'=======
You might also be able to use the serial HMI protocol and the digital outs to use the set servo speed using the HMI serial command, then just poll the camera. If the camera sees something, send an HMI servo command with the desired position. This way, you'd have to get the position info into the robot controller and I guessing you wanted to avoid that...
Hope that helps stimulate some thoughts on a solution . . . . I'm not set up to try it (no camera, and my RN has a head full of gyro, and chest full of bluetooth so no room for servo just now!)
Cheers
Tim
Entrastic
sorry for the delay - been on a stag do to sunny Liverpool (made a nice change from sunny Glasgow).
(1)
Logic voltage thresholds for 74HC CMOS are zero up to 1.3V, one above 3.7V (up to 5V). You can see some graphs of these for various families
here
The MR 3024 seems to run on 5V, and so do the servos (control input should be in the range 3V - 5V) so you're fine there.
(2)
Re the head turning problem, how long does it take to interrogate the camera? Off the top of my head, a suggestion for a possible approach (neglecting firmware mods) could be as follows.
If you set the speed to 5, then it takes 3.3ms for a robonova servo to turn 1 degree according to
this doc.
If you break the head turn from left to right into chunks that take just longer than it takes to talk to the camera, then you you could do something like this: command a section of the head turn, check the camera, decide whether to relinquish servo control to the camera or turn the head another section.
Assuming your head servo was the 17th servo, that the NAND gate switch was being controlled on port 3 (or whatever works for your setup), the following is an attempt to express the concept in code.
Warnings! I suspect there are bugs and misconceptions! Seeing as you can't use variables in servo movements, the code is pretty tedious! Also, I've not worked out whether the 'compiler' will bork when you use a GOTO to make an early exit from a GOSUB routine (it might upset the stack to have an unuseable entry in it?) - if so, the code below would get even more tedious because each segment would require its own label . . . ouch. I've not done much with robobasic yet and my last outing was with SystemC/C++ so I'm not tuned into the features/limitations/workarounds of robobasic yet...
'for the camera routine
DIM A AS BYTE
'============
turn_the_head:
'assert control over the head servo - this is the control signal to the switch circuit
OUT 3,0
'turn head 10 degrees
SERVO 17,10
'check the camera for movement...
GOSUB check_camera
'repeat tediously as follows ...
SERVO 17,20
GOSUB check_camera
SERVO 17,30
GOSUB check_camera
'code missing because it is tedious to type
SERVO 17,180
GOSUB check_camera
SERVO 17,190
GOSUB check_camera
'go back the other way
SERVO 17,180
GOSUB check_camera
'carry this on back to the starting position
SERVO 17,10
GOSUB check_camera
'go back to where ever you requested the head turn
RETURN
'============
'check the camera
check_camera:
'do whatever it is you do to get a response from the camera
'e.g. read value from AD input - just guessing here
'assume A is< 128 if nothing from camera
'assume A is >= 127 if camera wants control
A = AD(0)
IF A > 128
OUT 3,1
'camera has control of head now, until you assert OUT 3,0
'go back to main and do something else until next time you want to kick off the head turn
GOTO MAIN
ELSE
'nothing to see here, return to tedious head turning code
RETURN
ENDIF
'=======
You might also be able to use the serial HMI protocol and the digital outs to use the set servo speed using the HMI serial command, then just poll the camera. If the camera sees something, send an HMI servo command with the desired position. This way, you'd have to get the position info into the robot controller and I guessing you wanted to avoid that...
Hope that helps stimulate some thoughts on a solution . . . . I'm not set up to try it (no camera, and my RN has a head full of gyro, and chest full of bluetooth so no room for servo just now!)
Cheers
Tim