Maestro 18 to control valve for Prothstetic Knee- code help?

Hi Guys,

I’m new to the forums so hi,

I was just wondering if anyone could or point out the errors to me in the following code or give me tips??? I’m a newbie, the project is for a computer controlled hydraulic servo valve for a custom prosthstetic knee joint that I’m working on for myself. The old knee I used to use had a service quote come back at a mer $29,000 !!!

So I’m making my own knee that should do the same job for about $4000, and the code I’ve put together so far is giving me a (beginning not closed error) ???

I’m hoping to run a looping five (1-weight sensor toe, 2 weight sensor arch, 3 weight sensor heel, 4 - Accellorometre and 5 - Gyro) sensor sweep before it will goto a stance or swing phase for the knee, and also include two subroutines in there for automatic valve shut off if it senses weight on the toe or heel. Just to mention a few.

Thanks in advance :question:
Knee code.rtf (2.51 KB)

Hello,

That sounds like a very ambitious project! I do not really understand it from your description, but if there is really just one servo to control based on some simple readings of 5 analog sensor channels, it sounds possible. I would be very interested to see pictures of the setup.

Anyway, your code has multiple problems, starting from the very first line. You wrote “sensors”, but that subroutine is not defined anywhere. Later on you do “goto sensors”, but there is no “sensors:” label defined anywhere. You wrote “if while else” a bunch of times, which does not make any sense.

I recommend that you save this code somewhere and start over with the simplest possible thing that works. Add one or two lines at a time until you reach a problem that you are unable to solve yourself, then remove as many lines as possible from the problematic code to isolate the problem. If you have simplified it down to just a few lines that do not work, and you are still confused, post the code here with an explanation of what you expected the code to do. Note that you can post code directly using the “Code” button rather than attaching it.

Good luck!
-Paul

Thanks Paul,

yes I’m still learing the code as I’m sure you can tell, ok will do. Yes it’s just the one servo that controls that positions a proportional hydraulic servo valve.

I still have to make the loadbearing frame and buy the hydraulic cylinder but I hope to have the knee joint built sometime next year. But I thought there’s no point unless I’ve got the eletronics working as intended then I’ll have to mount them all into the knee frame. then calibrate all of the individual sensor values to the correct settings.

With any luck it just might work! if it does i’ll be very happy :smiley: , as the retail on a new C-leg in Australia is $80,000 and you only get a three year warrenty!

Thanks again for your help.

Thanks again for your tips Paul,

I have managed to get it working how I need with the following:

begin
start:
6000 0 servo
6 get_position 
200 less_than
if
goto Hold
else
endif
5 get_position # get the value of the pot, 0-1023
500 greater_than
if 
goto step_1
else
endif
goto Start
step_1:
3 get_position # get the value of the pot, 0-1023
220 less_than
if 
goto next
else
endif
3 get_position # get the value of the pot, 0-1023
300 greater_than
if 
goto next
else
goto hold
endif
repeat

next:
begin
3 get_position # get the value of the pot, 0-1023
4 times 2000 plus # scale it to 4000-8092, approximately 1-2 ms
0 servo # set servo 0 based to the value
200 delay
goto start
repeat

hold:
begin
6000 0 servo
6 get_position
200 less_than
if
goto start
else
endif
9 get_position
200 less_than
if
goto toe_load
endif
repeat

toe_load:
begin
9 get_position
100 greater_than
if
endif
3 get_position
4 times 2000 plus
0 servo
200 delay
goto Start
repeat

sub time
5 get_position
400 greater_than
if
goto next
else
endif
3 get_position
5 times 1000 plus
0 servo
200 delay
return

All I have to do now is wait for my voltage regulators to arrive and then build two more components and I can start assembeling the knee joint! :wink:

Thanks again

I am glad to hear that you got it working! Good luck with the rest of your project.

-Paul