pulsin then servo

eclectic

Moderator
@ Alband.
I've totally lost track of this thread, but, your post #187

“Also, does anyone know of a female 3.5mm 4 pole connector
that is only as long as the plug (e.g.), that is in the UK for a decent price.
(would get the one in link but P&P cost £12 standard.)"

Might the Lumberg sockets from this link be OK?

http://uk.farnell.com/jsp/search/browse.jsp?N=500006+1002313&Ntk=gensearch_001&Ntt=4way+socket&Ntx=

I'm sure that you could easily make up a larger order from Farnell.


Also, several times, you have mentioned “Laser”, in the gun barrel.

Is it a real Laser, or an LED?

e
 

alband

Senior Member
That OK, 15.5mm tall as apposed to my current 12mm with only 3 circuits. It may provide useful if all else fails.
I'm sure that you could easily make up a larger order from Farnell.
...Who can't :D

No worries, its a diode laser, it was mentioned before but I haven't a clue where either.
Nice little things, I got two from Germany from http://www.roithner-laser.com/
Click on laser modules then Red and I've bought both the ones next to the matchstick, the larger is in the barrel. I toyed with the idea of having an auto focusing system but decided it would have been too fun.
 

alband

Senior Member
Right, hello again, long time no see (post).

Rick has been VERY kind and I may soon be getting a gyro from him. I will need two though, so I got this one of eBay.

I'm trying to hook it up to the gun elevation servo with limmited success.
It is hard to do that with my own greabox system for the gun (derrived from a servo but SO disembouled) so i'm trying to get it to work on a normal servo.

My setup:
I have the Gyro connected to the Rx (old rubbish 27Mhz one before you ask, so old in fact that I had to open it up and solder the servo's +V to the other +V as it was designed for some old 3V servos), and the servo connected to the gyro.
The servo has a circular "horn" attached to it and the gyro is attached to that.

Now as BB said, with a gyro, you just set the gain as high as possible without it oscillating. But once I turn it down so that is doesn't oscillate, it doesn't have any effect unless I turn the servo vigorously.
The gyro seems to be working (I've never used one so I cant be sure). When I turn it on, the LED flashes slowly until it gets servo pulses, then flashes faster until it's ready at which point the light stays on.
I'm not sure if it is a heading hold gyro or rate. It says "HEAD LOCK GYRO" on the box and "EK2-0704B".
This says something about which type is HH and which is rate but doesn't mention the "B" version.
:confused:
 
Last edited:

alband

Senior Member
:(
Just solved it.
I don't have the "B".
I just have the normal Rate gyro.
The seller put it in a B's case but very carefully didn't mention it wasn't a B.
Damn.
I now know I have a rate gyro, how much difference will this make?
 

BeanieBots

Moderator
See post 106 for the difference between HH & rate.
Have you tried the reversing switch? If you can't get it stable with moderate gain it may need reversing.

Addition: You should not move it until the LED stops flashing or it gets upset.
Try without mounting on the servo first. Just turn the gyro and the servo should follow.
 
Last edited:

BeanieBots

Moderator
So basically, I need HH.
Yeah, I've tried the reversing switch.
I've tried that too.
Technically speaking, HH is a rate gyro with infinite gain that does not oscillate. A rate gyro will give a similar response to what you wanted to go with, namely an accellerometer. Essentially, that's all it is except it saves you having to write the code required to modify the servo pulses.
If you want to "reverse engineer" a rate gyro to get back to RAW accellerometer values. Feed it with a fixed servo signal and then read it's output using pulsin. The variation from '150' will be the rate of turn.
If you then put that difference through a PID loop, you can integrate the "rate of angle change" with respect to time to generate a "heading" servo demand. That is essentially what you would have had to do if you had gone down the accellerometer path.

However, if you stick with the functioning of the rate gyro, you SHOULD be able to get quite a high gain before oscillation starts. It needs to be FIRMLY attached. If you've stuck it with blu-tak or similar then response will be very sloppy. Also, your servo with just a gyro on its back will be VERY fast. Probably too fast for the gyro to respond. Try slowing things down. Either add some momentum (eg, long boom) and/or add a few tens of ohms in series with the motor. A typical servo will do 90deg in <100mS. How fast will your turret rotate?
 

alband

Senior Member
Well, it is currently held on with a loose elastic band to say the least:rolleyes:.
I'll try and fix that up.

How does rate of change of pulse variable turn into a heading?
I could make a PICAXE work out rate of change but not sure how that turns into a heading.

Edit: Also worth mentioning that this is currently working towards the gun elevation system. If I get a HH gyro, and therefore end up with a HH & a R, which would be best for each task?
 
Last edited:

alband

Senior Member
Well, I've tried that and it still doesn't work. It i now held on with super-glue and a tight elastic band and there is a pencil running through some loops in the band to give it a bit of momentum. It still oscillates at a very low setting.
When I turn it back and forth sharply, it doesn't seem to turn as much. It is acting as if it responds to the force but then moves back to the previous servo position and wobbles into that place.
 

BeanieBots

Moderator
That sounds about the right behaviour for a rate gyro but I don't know why you can't get the gain higher. Probaly your pencil held on by elastic band. Not exctly much in the way of momentum. You need enough to see a significant slowing down of the servo. Does it?
The 'momentum' also needs to be firmly coupled.

If you want to stay with a rate gyro (or accellerometer) you will need to integrate the error signal or the "correction" will only be proportional to the opposing rate of change. ie, it 'helps' but does not 'correct' the position.
I'm sure we covered all this earlier.
 

BeanieBots

Moderator
How many times do I need to say it? Integrate the error!
That's part of a PID loop. Not very easy to do with integer maths which is why I tried so hard to steer you away from that type of sensor!
 
Last edited:

alband

Senior Member
Yes but what do you mean by integrate the error.
Is the error the rate of change?
Do you mean integrate as in the opposite of differentiate?
I'm very interested in what the maths is behind this.

Anywho, I've now attached some pliers to it fairly securely and if I oscillate the servo fast then the pliers stay in roughly the same place. This unfortunately uses the weight of a pare of pliers. The plasic gun does not equal that. I'm am going to have to get a couple of very expensive HH gyros.
This will do, won't it?
 

BeanieBots

Moderator
Yes, integrate as in the opposite to differentiate. Every school boys favourite, CALCULUS. Now you know how it's used in real life. Shame they never gave such examples when teaching it. It wasn't until I became an engineer that all that "pointless" number manipulating and funny symbols suddenly made sense.

The output of the rate gyro is NOT the error signal. It is the proportionaly corrected servo signal. The error signal is the difference between the servo signal going into it and the signal comming out. (as described earlier).

The gyro you reference does NOT look like a HH type. Couldn't find a proper spec for it. Also, seems too cheap to be HH.

Try slowing the servo down with a resistor. (as described earlier)
 

alband

Senior Member
Sure it not HH? I pretty certain it is.
How's about this for a PID algorithm?

So a HH gyro:
Take in where the output should be,
Looks at the current sensor position,
Works out the current difference,
Works out the derivative of the previous difference,
Adds that to the current difference,
Adds that to where the output should be,
Then sends it to the servo?

Thought this might be relevant. Listen to "USAF Training.wav".
 

BeanieBots

Moderator
The algorithm is fine and there are plenty of others "out there".
The problem is that you need to work out all the time constants for YOUR turret loading and YOUR servo speed. Then there is the minor issue of being able to iterate the algorithm at least a few times between each servo frame rate:eek:
I'd be tempted to try an integral only version first.
With a little help of a gate or two it should be reasonably easy to get the error signal as a pulse difference which could be read using pulsin. Alternatively, read both signals and work it out in the PICAXE.
There is a chip (ZN425?? maybe) which might be able to do it for you??

Anyway, past my bedtime.
 

manuka

Senior Member
For those in fear of calculus, consider our mentor Micheal Faraday's empirical skills-

Faraday was largely self taught & received little formal education, knowing little of higher mathematics such as calculus, but he was one of the most influential scientists of all time- some refer to him as the best "hands on" experimentalist in the history of science
 

BeanieBots

Moderator
Don't give them excuses!
MOST won't succeed without it.
Be it right or wrong, a fact of life is that without a piece of paper which states you "know" how to do calculus, you won't get the job before someone with it gets there first. Also, once you have that job, your design won't be taken seriously unless you can "prove" (mathematically) that it works.

I have no idea how it's taught these days, but the way I was taught gave absolutely no indication of its use except as a requirement to pass the exam. A few real-life examples would have made it interesting enough to learn properly. It's all very well being hands on, but without calculus, it's very difficult to even describe a control scenario let alone solve it.
 

alband

Senior Member
This would do to work out an integration wouldn't it?
b0 is the multiplier
b1 is the value
b2 is the indice
Code:
main:		pause 5000
		serin 2,T2400,(b0,b1,b2)
		pause 10000
		let b2 = b2 + 1
		let b0 = b0 / b2
		pause 10000
		goto main
Edit: This for a chip?
 

BeanieBots

Moderator
Integration is nothing more than the summation of the error (with a suitable scaling) with respect to time.

eg

do
get error
output=output+(error * scaler)
wait iteration_time
loop

Think about YOUR example for minute.
Pause 10000....
How far will your servo have moved in that time?
Take out the pauses and then think about it again.
Do you see the problem?
Now add in all the other required sums and ensure the loop runs several times within the required iteration period.

The best PID loop bandwidth I've ever managed on a PICAXE is a few hertz. Your loop needs to iterate at least ten times over the period it takes for the servo to move the smallest amount of the position resolution you require.
Your loop would only work if it took the turret about 3 hours to rotate 90 degrees.

Get a HH gyro!
 

alband

Senior Member
That code was nowhere near intended to be used, I was just trying to intergrate on a PICAXE. The pauses were just so that I could see the result without needing bionic eyes. I assume it orks but don't know because for some reason my simulator gets stuck on serin.

Yeah, HH, I know :rolleyes: :(. That one I found before is the cheapest I can find. It is basically the HH version of the one I've got. Normally £30.
Sigh, I'm not looking forward to parting with yet more cash.
 

BeanieBots

Moderator
Bottom line, the time taken for each iteration is just as important as any of the numbers in the calculations.
The other problem you are likely to encounter is magnitude and precision of the required numbers.
You are quite likely to end up with something like this.

b0=b0*10000 + b1
I'm not saying that's insurmountable, but hopefully, you can see the problem.
(the next iteration would require the increase of b1 to be noticed)

Control requires internal calculations to be about 100 ~ 1000 times the required resolution.
 
Last edited:

BeanieBots

Moderator
I've not used it so would prefer not to comment. I'd not be able to sleep at night if I said "yes perfect" and then it wasn't:eek:

I didn't read the whole thread but got the feeling it had remote gain.
If it does, then you will need another signal to set the gain.
I don't see remote gain being of any use to you. You just need to get the value right and then leave it fixed. (unlike with a heli where it is advantagous to adjust in flight).
 

alband

Senior Member
That's cheap!
Must be a catch somewhere.
Funny though. With the current gyro, I've never been able to get it to accept servo pulses from a PICAXE, only an Rx. Are servo pulses from a PICAXE different from an Rx e.g. more "Dirty"?

Edit, in which case, would it be more sensible to use PWMout?
 

BeanieBots

Moderator
The timing of PICAXE servo pulses is pretty good in my experience.
Never had any problem with any servo but can't say I've tried PICAXE gyro combo. See no reason why it should be problem. Maybe logic level problem. Are you running the PICAXE from a different supply to the gyro? If yes, try with a series resistor (say 330R) and pull-up or down (say 1k) at the gyro end. It might be that the gyro wants TTL levels in which case you'll need a CMOS-TTL buffer. (who knows what those cheapskate chinese use?!)
 

alband

Senior Member
Will try that, going to have some grub now.
About that servo, It seems genuine but you have to create an account to find out P&P costs. I don't need a servo right now but I've bookmarked it for the future; thanks.
 

BeanieBots

Moderator
I used them for the first time Weds.
Very pleasant on-line experience. Easy account creation and e-mail confirmation within seconds.
I bought a charger, some leads and plugs, total value was £16.
P&P appears to be flat rate. Two options £2.50 standard, £3 first class.
I opted for 1st class but nothing has arrived yet. (no tracking).
 

alband

Senior Member
Do tell when it arrives.

When I use the PICAXE pulse, I also use the PICAXE power supply. The gyro is acting as if there is no pulse present. I turn it on, the light flashes fast while the gyro sets up, then, when it's finished, it flashes slowly to indicate no pulse. I was using a 330R resistor in series and have just tried without with no success. I've also tried tying it high an low with a 1K, with and without the 330R in series. Still no success.
What PWM would be a safe bet?

Edit: Also, I think I just quickly start a new thread to see if anyone else has any experience with that gyro.
 
Last edited:

BeanieBots

Moderator
Funny enough, just got e-mail confirming despatch. Should arrive tomorrow.
They do have a page which explains all their P&P costs. (gone up since my order). You can also see order status on-line but as it's mail, no tracking.

Can't see how PWM would help.
You know the spec. 1.5mS pulse every 20mS. Standard PWM is too fast.
Get your scope on it. What is the difference between PICAXE signal and Rx signal? (loaded, not OC). I bet it's level related.
I need to fit series cap once but can't remember on what.
 

Wrenow

Senior Member
I'm with BB here. What is the program you are using to send the signal and how did you wire it? You indicate tie Picaxe power supply - thus common earths, correct?
Did you just sent a pulsout 150? One pulse will, of course, not run it, it needs a stream of pulses every about 20ms, just like a servo.

A lot of people seem to be getting a servo command confused with a binary, on-off, type of signal, like high or low. The servo is expecting a continuous update of where it is needed to be every 20ms, so it is a signal stream or series of highs and lows. The Servo command handles this routine in the background, making the coding easier in many cases than pulseout, but it seems to have engendered a bit of confusion as to how it works. Though a close read of the fine manual would clarify it.

I would be truly surprised if the level is insufficient using the Picase output if it is a RC Hobby gyro or a TTL level accelerometer. Many will trigger on a lower voltage pulse.

Cheers,

Wreno
 

alband

Senior Member
I'm using code that initializes using servo, then uses buttons to increase and decrease the position using servopos. It works for a servo.

I'm running the gyro on the 5V from a 7805 that is also going to the PICAXE. I plug the lead of a servo into the wires and, it works. I plug the gyro into the same wires and, it doesn't work. I plug the gyro lead into an Rx and it works. :confused:
 

papaof2

Senior Member
I have no idea how it's taught these days, but the way I was taught gave absolutely no indication of its use except as a requirement to pass the exam. A few real-life examples would have made it interesting enough to learn properly.
Practical examples of using math help most of us - Albert Einstein and Steven Hawking are probably exceptions.

The solid geometry & trig teacher in high school did bring in real world applications, such as: If you are orbiting the earth at X miles up, how much of the earth's surface can you see? The answer is the intersection of a cone and a sphere, but the selected sphere and the origin of the cone made the use a lot more interesting ;-)

John
 
Top