davyjoneslocker
New Member
Hello,
I'm very new to programming and after some faffing about with a OOPIC, which I found counter intuitive and ill suited to use with radio control, I chose the Picaxe as a better alternative for a project I have on the ways- a radio controlled swimming fish.
I hope some people on here can give me some advice on my thoughts so far.
Inspired by the work of Essex university, and their robotic fish on display at the London Aquarium- check the videos at the following links- I decided I’d like to have a go at something similar myself.
http://www.youtube.com/watch?v=REi1g69P9w8&mode=related&search=
http://www.youtube.com/watch?v=eO9oseiCTdk&mode=related&search=
http://privatewww.essex.ac.uk/~jliua/
The fish use four servos for articulation, This gives a very high degree of manoeuvrability, enabling the very realistic swimming motion and other benefits like ‘C-turns’ which enable the fish to turn in it’s own body length.
The position and speed of the servos are governed by a Totalrobots DS-SCX8S microcontroller, which I believe is a precoded PIC chip running at 8MHZ that can be addressed via I2C or RS232.
http://www.totalrobots.com/access_files/sm_drivers.htm#ds-scx
The Essex Uni team used a PIC chip to relay information from various sensors and to provide the necessary control bytes for the DS-SCX8S.
As opposed to autonomous control, in my case, I wish to control the fish manually via radio control- like a novel model submarine.
As the Picaxe has a pulse in facility and i2c, I considered it a good choice to convert the R/C signals to the control data required by the DS-SCX8S.
My jottings so far have come up with the following-
Use the pulse in command to read two channels from my R/C receiver, controlling speed and steering respectively.
Quantize each channel into 16 segments, which I think gives adequate resolution, and enables each channel to be represented by a nibble, thus the two channels will then be represented by a single control byte. I considered this would keep any control table within manageable limits.
Use the Lookup command with a control byte to obtain the necessary DS-SCX8S servo command bytes. The DS-SCX8S uses two bytes for each servo it controls. First byte controls speed and direction, and the second byte controls position. As I have four servos, that is eight bytes in total for control.
The section of code which has given me most head scratching, is how to simply divide the pulse into 16 parts to represent the final control byte.
One thought I have come up with is to use if and then-
Symbol radio_input1 = b0
Symbol radio_input2 = b1
Symbol control_byte = b2
Symbol servo_control1 = b3
Symbol servo_position1 = b4
Main:
erratum:
pulsin 0,1 radio_input1
pulsein 1,1 radio_input2
if radio_input1 <100 then erratum
if radio_input2 <100 then erratum
if radio_input1 =>115 then equalbit0
if radio_input1 =>120 then equalbit1
equalbit1: control_byte=0
equalbit2: control_byte=1
'etc. etc. until 15 is reached, then do the same for radio_input2 with the exception of
if radio_input2 =>115 then addbit0
if radio_input2 =>120 then addbit16
addbit1: control_byte= control_byte + 0
addbit2: control_byte= control_byte + 16
etc. etc.
Once the control byte is obtained, I would then use this with eight lookup tables for each of the servo control bytes, i.e.
lookup control_byte, (10,11,12,13……), servo_control1
lookup control_byte, (1,2,3,4,5……….), servo_position1
‘continue this for all eight control bytes
Then finally send the result via I2C to the DS-SCX8S. This chip auto increments it’s registers, so:-
i2cslave %11100000, i2cfast8, i2cbyte
Writei2c 0, (servo_control1, servo_position1)
‘Just shown for the first couple of control bytes
Write i2c 32, (0)
‘the final write command enables all the servo commands on DS-SCX8S, so that all the servos move at the same time.
goto main
What I'm not sure of is how quickly this will work, if it will work well at all (I'm using a 28X1).
Opinions are very welcome, and if someone can suggest a better way, I’d be very happy to read about it.
Thanks,
Andy
I'm very new to programming and after some faffing about with a OOPIC, which I found counter intuitive and ill suited to use with radio control, I chose the Picaxe as a better alternative for a project I have on the ways- a radio controlled swimming fish.
I hope some people on here can give me some advice on my thoughts so far.
Inspired by the work of Essex university, and their robotic fish on display at the London Aquarium- check the videos at the following links- I decided I’d like to have a go at something similar myself.
http://www.youtube.com/watch?v=REi1g69P9w8&mode=related&search=
http://www.youtube.com/watch?v=eO9oseiCTdk&mode=related&search=
http://privatewww.essex.ac.uk/~jliua/
The fish use four servos for articulation, This gives a very high degree of manoeuvrability, enabling the very realistic swimming motion and other benefits like ‘C-turns’ which enable the fish to turn in it’s own body length.
The position and speed of the servos are governed by a Totalrobots DS-SCX8S microcontroller, which I believe is a precoded PIC chip running at 8MHZ that can be addressed via I2C or RS232.
http://www.totalrobots.com/access_files/sm_drivers.htm#ds-scx
The Essex Uni team used a PIC chip to relay information from various sensors and to provide the necessary control bytes for the DS-SCX8S.
As opposed to autonomous control, in my case, I wish to control the fish manually via radio control- like a novel model submarine.
As the Picaxe has a pulse in facility and i2c, I considered it a good choice to convert the R/C signals to the control data required by the DS-SCX8S.
My jottings so far have come up with the following-
Use the pulse in command to read two channels from my R/C receiver, controlling speed and steering respectively.
Quantize each channel into 16 segments, which I think gives adequate resolution, and enables each channel to be represented by a nibble, thus the two channels will then be represented by a single control byte. I considered this would keep any control table within manageable limits.
Use the Lookup command with a control byte to obtain the necessary DS-SCX8S servo command bytes. The DS-SCX8S uses two bytes for each servo it controls. First byte controls speed and direction, and the second byte controls position. As I have four servos, that is eight bytes in total for control.
The section of code which has given me most head scratching, is how to simply divide the pulse into 16 parts to represent the final control byte.
One thought I have come up with is to use if and then-
Symbol radio_input1 = b0
Symbol radio_input2 = b1
Symbol control_byte = b2
Symbol servo_control1 = b3
Symbol servo_position1 = b4
Main:
erratum:
pulsin 0,1 radio_input1
pulsein 1,1 radio_input2
if radio_input1 <100 then erratum
if radio_input2 <100 then erratum
if radio_input1 =>115 then equalbit0
if radio_input1 =>120 then equalbit1
equalbit1: control_byte=0
equalbit2: control_byte=1
'etc. etc. until 15 is reached, then do the same for radio_input2 with the exception of
if radio_input2 =>115 then addbit0
if radio_input2 =>120 then addbit16
addbit1: control_byte= control_byte + 0
addbit2: control_byte= control_byte + 16
etc. etc.
Once the control byte is obtained, I would then use this with eight lookup tables for each of the servo control bytes, i.e.
lookup control_byte, (10,11,12,13……), servo_control1
lookup control_byte, (1,2,3,4,5……….), servo_position1
‘continue this for all eight control bytes
Then finally send the result via I2C to the DS-SCX8S. This chip auto increments it’s registers, so:-
i2cslave %11100000, i2cfast8, i2cbyte
Writei2c 0, (servo_control1, servo_position1)
‘Just shown for the first couple of control bytes
Write i2c 32, (0)
‘the final write command enables all the servo commands on DS-SCX8S, so that all the servos move at the same time.
goto main
What I'm not sure of is how quickly this will work, if it will work well at all (I'm using a 28X1).
Opinions are very welcome, and if someone can suggest a better way, I’d be very happy to read about it.
Thanks,
Andy