PIC-AIM

This started out as a top secret destruction weapon to be placed on the moon with plans of taking the world hostage, in order to make a trillion dollars... (...mmm... I think I´ve seen this movie before...)... and it ended up being a laser pointer mounted on a two axis jig, made out of Futaba servos. It is controlled by a hacked, 22-year-old IBM analogue joystick.   
Now back to reality: This really started as a comment by user chench (https://www.robotshop.com/letsmakerobots/user/5049) to a forum post of mine, (https://www.robotshop.com/letsmakerobots/node/27588) suggesting an analogue gauge. The neuron that was handling that idea collided with another one that was taking its time to decide what to do with a spare laser pointer I have. Presto-pronto an idea was born. 
A hacked 2 axis analogue joystick going straight to 2 ADC pins. That value mathematically translated to servo values (thank´s to Chench´s formula) and the laser pointer cable-tied to the horn. Let´s not forget the bracket I improvised to attach on servo to the other.
I am using a Picaxe 18X and here´s the code:
init: 
servo 4,75
servo 5,75
main:
readadc 1,b1
readadc 0,b0
let b2=b0/2+75
let b3=b1/2+75
servopos 4,b2
servopos 5,b3
goto main
The problem I´m having (take a look at the video) is that of servo jitter. As fas as I can tell, it is caused by the instability of the ADC reading coming from the joystick, even when I don´t touch it. I have gone though many posts in the Picaxe forum trying to find a solution, with no real luck. The best I can think of, is writing code to round up the values. According to the debug screen, my instability is smaller than value 5 (inside of the 0-255 range).
 Any ideas, community? H-E-L-P!

UPDATE (July 25th, 2011)
Finally I have been able to integrate the new 3A power supply to the old experiment and the jitter is more under control than before. See secong video near the top. Next step is to tie down all unused inputs and change the pots in the joystick as suggested by many "colleagues" in the forum.
Thanks to all!

UPDATE (July 26th, 2011)
At this point, and after today´s experiments, I believe it is safe to say that I have tried out every suggestion posted here and on the Picaxe forum. "We" have managed to reduce the jitter an awful lot, but it is still there. Take a look at the third video uploaded. Here´s an unofficial list of everything I´ve tried, hoping that it will be useful to someone else who decides to go this route.
  • I´ve run the servos and the logic from the same power supply and from different ones. The last one I´ve used for the servos alone was 3A properly regulated.
  • I have made sure that, if using 2 PS, that the GNDs were common.
  • I have switched the pots from the hacked joystick from 100KΩ to brand new and noiseless 10KΩ.
  • I have tied all unused inputs from the Picaxe down via 10KΩ resistors.
  • I have tried to implement filtering in the code.
...and none of this has truly solved the problem.
The jitter has diminished considerably... but it is still there. I don´t think it is going to get any better than this, so I´ll move on to other things.

I want to express my most heartfelt gratitude to all those who took the time to read the thread and chime in ideas.


UPDATE (Sep 4th, 2011)
Down in the commentary section, Dan M. (among others) suggested trying servopos commands on their own, isolating them from the readadc commands. I has taken me a while, but finally I got around to trying it out. This is in the context of another experiment. However all the boards and servos are exactly the same as the PIC-AIM project, with the exception of the joystick. 
The idea come to me while watching one of Chris the Carpenter´s recent videos, a quick demo on a GGBot. That particular bot, while asleep, has the PING))) sensor looking straight down. When you wake it up, the turret tilts up for distance sensing in autonomous mode. I don´t know if that is only for personality sake or not. However, I thought that it would look cool to have just one (Sharp, in this case) sensor to determine distance and to make sure that there is floor ahead of the robot. You can watch what I have come up with in the last video uploaded.
With this experiment, it becomes obvious that the hardware is not the problem. I can also discard the joystick as a source of jitter, because I´ve changed all the pots in it. Conclusion: I don´t think my approach can be built like I wanted, at least not without the addition of a servo controller, like LordGG suggested in the comments. 

UPDATE (Sep 17th, 2011)
For some reason this project of Rick100 came to mind today. I reread his post and downloaded his code for the Picaxe 08M and found what could be the solution to my problem. I quote a bit of his code:
'couldnt use servo and servopos commands because of jitter
'used pulseout for servo pulses and pause commands adjusted with oscope to get close on timing
I will try to adapt his approach for my project tonight.
I´ll keep you guys posted.
Andrés

UPDATE (Mar 18th, 2012)
SUCCESS, finally! I admit this has taken longer than anticipated, but you see, in between I started a company and got married, so I´m sure everyone will understand. The first video from the top shows the laser death ray in action.
I guess the only thing left now, is to figure out a way to get it to the moon so I can fulfil my plan of taking the world hostage, in order to make a trillion dollars...
Andrés
https://www.youtube.com/watch?v=S9gifFJFk3I

I have tried to filter out

I have tried to filter out some of the jitter with the code, like so:

init:
servo 4,75
servo 5,75
symbol TOLERANC = b13
toleranc = 9

main:
readadc 0,b0
readadc 1,b1
let b12=b0+toleranc
let b11=b0-toleranc
let b10=b1+toleranc
let b9=b1-toleranc
readadc 0,b2
readadc 1,b3
if b2>=b0 and b2<=b12 then main
if b2<=b0 and b2>=b11 then main
if b3>=b1 and b3<=b10 then main
if b3<=b1 and b3>=b9 then main
let b4=b0/2+75
let b5=b1/2+75
servopos 4,b4
servopos 5,b5
goto main

No luck.

Do you know the value of the

Do you know the value of the pots in the joystick . I think the IBM PC joysticks had 100K pots and the Picaxe needs approximately 10k or lower  . I once changed the pots in an IBM joystick to 5K so I could use it with a pic .  You could also moniter the voltage going into the adc with a voltmeter to see if it’s stable . Some of those joysticks had cheap pots and are just noisey .

Some capacitors installed

Some capacitors installed across the power leads of your servos may help.

Try adding some capacitors, as described in this comment.

The big cap across the main power will help reduce fluctuations on the power line. The two caps on the servo power lines (as close to the servo connector as possible) will help filter noise from the servo. You can even tuck the caps right into the servo connector itself.

Try a servo controller

I always had issues with Picaxe µcontrollers and servos (jittering). The only efficient solution I found is using a servo controller (SD20).

Hey Rick,You are indeed

Hey Rick,

You are indeed right. They are 100K. For the life of me, I don´t see how you can know that by memory. BIG thumbs up! I don´t see how that can be bad for the Pic, however. If you could explain further, I would be grateful.

About the values: using debug, I´ve learnt that the values fluctuate as much as +/- 5 at all times. Maybe changing the pots (regardless of their value) is the way to go. I remember punishing them back in the day… :smiley:

Thanks a lot for your input!

Andrés

Hey Andrew,When I said

Hey Andrew,

When I said before that I have tried capacitors “here and there”, well, let´s just say that “here and there” did not include your suggested locations. So thanks. At the time I was thinking more along the lines of filtering the “noise” closer to the pots. On my way home from work, I´ll stop by the shop and pick up the big capacitor (which I don´t stock) and also, just for the sake of it, some new pots, just like Rick100 suggested.

I´ll let you know as soon as I try it.

Cheers,

Andrés 

Hey LordGG,Up until you

Hey LordGG,

Up until you brought it up, I hadn´t researched servo controllers. (The same for the “Insert Custom Character” button).

I´ve looked into the SD20 (http://www.acroname.com/robotics/parts/R193-SD20.html) and the SD21 (https://www.robotshop.com/devantech-sd21-servo-controller.html). The SD21 (plug and play version) looks like the way to go, if it wasn´t that expensive. That makes me consider the SD20. There seems to be no fuzz in the PCB design, so I could probably tackle it. I have not even looked into i2c yet. That worries me a bit.

I´ll try all other cheap-o solutions first. If nothing really works, I´ll cough up the dough and bury my nose into the i2c book.

Thanks!

Andrés

Oscilloscope?

I´ve got an oscilloscope at work. I think I will sneak my Pic-Aim in at work tomorrow and try to locate the source of the noise…

**You might also try **

 I am not an analog guru so I can’t explain in detail the affect of the higher pot resistance . I know it will take longer to charge the internal hold capaciter through the higher resistance . I assume it would also result in less accuracy .

 You might also try running your program with the servos disconnected and observing the analog values . This will tell you if the current draw and noise from the servos are affecting the readings . If I’m having trouble with a circuit , especially on a breadboard , I always put a volt meter on the power rails while its running . A lot of problems on breadboards are caused by bad connections .

Good luck .

Rick

I have to say, everytime I

I have to say, everytime I see the title of your video I personally get quite offended. My father suffers from Parkinson’s Disease and it is not a pretty sight. To see a man of his stature waste away like he has and to face that fact that one day I very well may have to face the same fate…

I know you meant no harm in the title, but you should really think about stuff like that in the future.

It goes without saying that

It goes without saying that I did not mean to hurt you personally or anyone else for that matter. I have a lot of contact with Parkinson´s patients. As a matter of fact my (soon to be) wife is a neurosurgeon who is dedicating her life to treat Parkinson´s and Epilepsy. This started as a joke with her. That´s all.

Andrés 

New findings!

Here are your suggestions and what I´ve found right next to them.

1.- (Dan M. and KingsJester89) Find out if either current or tension is the problem. Nope it isn´t. I have to admit that the original power supply was somehow more marginal than what I expected, so I did two things. One) I left only one servo hooked up (half the current draw) and it still shook. Two) I used a lead/acid 12VDC 4Ah battery (properly regulated) as my power source and the shake was still there. Different frequency. But still there.  By the way, I´ve added Dan`s trick to my code (MIN 75, MAX 225).

2.- (Rick100) Change the pots in the vintage joystick. I simply unplugged the joystick from the breadboard and the shake was still there.

3.- (Boriz) Add pause 100 to the code, because it was cycling faster than the refresh rate. Didn´t solve it either. 

4.- (Ignoblegnome) Add caps as described in the forum topic he linked to. Didn´t get to the shop on time. I´ll try again tomorrow.

Thanks to all who participated. Stay tuned for more updates!

Cheers,

Andrés

The only thing that comes to

The only thing that comes to mind, and I apologize if its already been mentioned, is that perhaps you have a stalled servo. I am into R/C Helicopters and have had that problem with my Heli’s. Also, another thing, I haven’t given the whole thread a read, and again, I apologize, is that if you are using Digital Servos, they are very susceptible to noise. You really need a good source of power for them. I have one Heli with nothing but all Digital and had to run a separate BEC to deal with the problem.

I remember reading about servo jitter and PICAXEs

I believe Rev-Ed was doing some code updating on 08Ms(?) to cut back on servo jitter. If I recall correctly, the SD20/21s are just PICs with special programming. Your PICAXEs are just PICs with special programming. I believe a good deal of the issue is the ‘special’ programming that Rev-Ed uses. But, that is only my biased opinion.

Good point, birdmun! I have

Good point, birdmun! I have a parallel post in the Picaxe forum. I´ll give the technicians there some time to answer this and see if you are on the right track. 

As part of Dan M´s

As part of Dan M´s suggestion, I have measured current and I can tell you that they are not stalled. Nor are they digital servos. I appreciate your input and am glad to see that there are no hard feelings after my not so happy choice of title for the video.

Cheers,

Andrés

Tried smoothing the values

Tried smoothing the values from the joystick?


Pseudocode:

for (i < 10)

 take_reading

 put_in_array

 shift_array


remove_highest_and_lowest_from_array


reading = array[*]/8

 

I do this on my analouge sensors, makes a huge difference.

After studying the picture

After studying the picture you have to tell me something:

Is the servo ground and picaxe ground connected and how(I cant see it)? Also try using pots thats NOT 22 years old.

Good catch! At the time the

Good catch! At the time the picture was taken, they were not common! However (and only after I started this thread) I picked it up, solved it and the shake was still there. :frowning:

Yup. Changing pots is in my To-Do list. Incidentally, I have just ran them through a scope and this is the noisiest I got them to act. Which is not THAT bad, considering their age!

TEK0006.jpg