Programming assistance for my new Mech please (PS2)

LOL, im with you on the “funding”. i brought my wife a laptop and signed her up to clothing catalogs so that keeps her happy. :wink:
anyway…
the code i last posted has had the previous parts added (up to date) and should work as explained. dont quote me on that, i would need feedback on that to alter it if there is a problem.

Alright, I tried what you posted and Im not getting any response from the servo. Then I tried incorporating it into the code that I was using to drive the other servos. The other servos do work but the latest additions are non responsive. I did not get to test the actual drive system since I temporarily unmounted the electronis from the robot and detached it from the motor controller so I can program it more easily. I did however reattach all the servos on the proper pins. Attached is what I cobbled together.

Any thoughts? I tired to go through it to see if I could see anything wrong with it but I could not see anything that was off, But I know very little so check it out let me know what you think.
ps2_ssc_testdennis3.bas (8.81 KB)

i did notice that
Servo3 var word
was commented out.
try un-commenting… does it work now. if not then i will look closer at the commands i added.

I uncommented that but still didnt get any response. I did however change something in the code that got the servo to respond in each direction but not in realtime . It only goes completely to one direction or another and does not return to center when I let go of the stick. I have attached what I have changed. Let me know what you think, Thanks!
ps2_ssc_testdennis4.bas (9.35 KB)

ok its progress. i will run some more ideas this evening and try and give you what is needed. :wink:

cool, thanks :slight_smile: I will be looking forward to it

i have been rather busy this week but hopefully i will get back on track soon. i have been looking at code that i have used to get a servo to pan,
i have added the parts need for this.

i have made a few changes too.
there are a few minor faults but i will fix these with in time.
you can now pan servo3 in realtime. but it does need correcting. :wink:
april12code.bas (10.7 KB)

awesome thanks. I ended up burning through the batteries I had for the ps2 controller and the 9v for the botboard, so I ordered some rechargable batteries and am waiting for them to arrive any day now so I cant test this. BTW your iron wolf robot…amazing.

yeah iv resorted to rechargeable ones too. if you buy a couple you can then rotate them between charges. :wink:

Ok i have amended some of the errors i wrote.
you will see a i have placed the panning servo on the left j stick for now, i can move this with more testing. it just means changing the this line of code using the

if XCoord then Servo3_Pulse = Servo3_Pulse + XCoord / 8 if Servo3_Pulse > Servo3_PulseMax then Servo3_Pulse = Servo3_PulseMax elseif Servo3_Pulse < Servo3_PulseMin Servo3_Pulse = Servo3_PulseMin endif serout SSC32,i38400,"#",DEC Servo3Pin,"P",DEC Servo3_Pulse," T100",13] endif

with W X Y or X.
also of when testing it i put servo3 on pin 1. you will see its not in servodriver or servoupdate but at the top of the code as:

Servo3Pin con 1

this can be changed to what ever pin you are using.
i will look into speeding up the code as its lagging a slight bit.

also while testing it i changed SSC_out to P11 as thats how mine is connected, you can change this back to P8! sorry.
april13code.bas (9.87 KB)

So I got to finally test the new program out and it works pretty great :slight_smile: The servo speed is determined by the position of the joystick. Ultimately I would like a servo to reach a specified position based on the position of the joystick so that when I hold the joystick all the way to the left for example the servo reaches its highest specified position and when I let it go it returns to neutral and the positions in between are determined by how far left the joystick is pushed. Then of course the opposite direction if the joystick is pushed right. This all might be too complicated to pull off, Im not experienced enough to know yet :frowning: I am going to look through the new code you put in to try to see if I can figure anything out there also and will let you know how it goes. Thanks!

yes this also is what i will be trying to do. at the moment this is all i can manage but this weekend should give me more time to look at how it can be done. and yes it can be done. i do have it working as you explained but its written into another code with lots of variables branching off into and from different parts within the code. it would be hard to dissect it and grab whats needed. ill have a go tho! :wink:

have you tested the code for the tracks yet?

oh man I forgot all about the tracks. Basically I pulled the electronics out and was testing it on loose servos as you suggested earlier because it was just easier to do that since the mech is pretty big and my working area is too confined. I will attach the motor controller on again though to give it a crack this sunday and let you know. On anpther not, are you a video game player by any chance? and perhaps a Fallout 3 or Elderscrolls fan?

ok cool.

not played video games for years. i used to play Splinter Cell, Halo, GTO, Resistance, games like that.

ok iv been working on getting the servo to do what we have discussed, over the last few hours!! :confused:
anyway, we are close… :slight_smile:

the servo will rotate related to the rotation and speed of the J/Stick, but im finding that its returning to its lowest value when stick is released and not center as expected. there is a section in the code were it says this:

 servo3_Pulse =  ((servo3_PulseMax - servo3_PulseMin) * ((DAngle + 64 ) & $7F)) / 127 + Servo3_PulseMin

its the

  • Servo_PulseMin
    at the end that is doing this.
    if i change it to (Servo_PulseDef) which is center (1500) the servo moves to center but it seems its also stopping left rotations of the servo.
    if i change it to (Servo_PulseMax) which is (2500) im finding that its returning to its highest value, and not center! :confused: :confused:

any one got any thoughts on this. i have dissected the PowerPod “Deck control” using Basic Micro ATOM PRO IDE 08.0.1.7. do you think i’v missed parts of the code out thats needed for this to work.

anyway i have added the code here. Dennis its updated with what is needed and iv cleaned it up a bit. once we have some of the main parts working we can look at cleaning it up so its better to look at. apart from that everything should work as we intend.
april18code.bas (8.63 KB)

Ok so I gave it a shot last night and got no response from the servo. I didnt get to spend enough time with it though because I got home so late. I am going to llok into it more tonight once I get home to make sure I have everything plugged in correctly and all the pins are labled right. I will let you know my findgins tonight. Thanks!

any luck?
im not sure why it wouldnt work. i worked my end. check the codes SSC connection just in case its assigned to a different pin. im using P11 so i may not have changed it back. also check servodriver and variables as i have changed the way the servo gets updated. :wink:

Hi Innerbreed, Sorry I havent posted in a little while. Ive been totally swamped with work and trying to finish relocating my self. I did manage to look at the stuff and try it out, but there is somthing not working and I cannot identify it. Basically I have servos connected to P0, P1, P2. The thing is that the servo on P2 which is the servowe are trying to control with the joystick is not respoinding. Instead servo on P1 is twitching left and right really fast without any input from the controller. However if I push the right joystick up or down, the twitching servo does rotate one way or the other a slight bit but continues to twitch the whole time. Weird thing is that the code is supposed to be using P2 with the joystick but instead the only feedback coming from that joystick is coming from P1. Also I noticed that the button presses are not responding with a sound as they did before. I was using that to verify communication between the controller and the botboard. Let me know what you think. Thanks

i just uploaded the code and yes i can confirm that im getting the same response. :confused:
im not sure how that has happened or even why. it worked when i wrote it and as soon as i got it working i uploaded it without changing anything.! :confused: :confused:

also…
just check the jumper for the speaker. i haven’t changed anything that should effect this.
i will try and look over it some point this week for you to see if i can find the problem. im well confused!! :neutral_face:
dam bugs!

Hi Innerbreed, any luck with that code? sorry to bug ya, I was just curious. Thanks