This circuit to gerber file

MaxHeadRoom

Joined Jul 18, 2013
30,672
Normally I would see the out put of U1 pin 3 get flagged if a pwr flag was added as pin 3 is defined as power supply already, although if it passes it could be that you don't have the 5v power a designated power flag.
IOW, pin 3 could be undefined external to U1 as you have it..
Max.
 

MaxHeadRoom

Joined Jul 18, 2013
30,672
OK, I just tested it, if using a power flag on a already defined source such as a regulator IC output, you can label it with a power label as long as you don't assign a power flag.
Max.
 

Thread Starter

christiannielsen

Joined Jun 30, 2019
389
I have finished breadboarding it and it actually works! Gosh I am happy. Can't thank you guys enough.
I now have to finish designing the PCB and I will post a zip-file here.

I have recorded two videos of the circuit running for you to see.
Test with 1st servo motor:
Test with 2nd servo motor:

The 1st servo motor runs a bit unstable.
2nd servo motor runs more smoothly.

I Also tried with the bigger black servo motor of which I posted a picture of earlier and that one only moved the servo arm 180 degrees and then flickered and stopped the whole circuit after only a second or so. So that one i ruled out.
 

Thread Starter

christiannielsen

Joined Jun 30, 2019
389
1598289067088.png
1598289089524.png
1598289122214.png

Before I start drawing traces is there any way you can tell if this PCB design just by looking looks okay or if something sticks out? Can I post another more usefull file?
 

trebla

Joined Jun 29, 2019
599
Bigger servos can draw several amps from you circuit, measure your circuit supply voltage for fluctuations when you test the servos.
Some small cheap servos have issues with internal position potentiometer contacts and will behave erratically. Also can be some gear part defective.
 

Irving

Joined Jan 30, 2016
5,134
@trebla makes a good point. Even your mini-servo could draw a couple of 100mA when moving. A PP3 battery, even new, can have a high internal resistance of several tens or even 100s of milliohms. That could drop the voltage to the servo significantly and could affect the timing too. One thing you could try on your breadboard is to have a separate battery & 6v regulator for the servo. 4x Alkaline AA cells and no regulator would also be better than a PP3, they have a much lower internal resistance. A PP3 is only 6 x AAAA cells... Rubbish really for motors...

If you do try a separate battery don't forget to connect the -ve of both batteries together.

I'll have a look at your layout later today. At first glance my only comment is keep the decoupling capacitors as close to the chips VDD as you can... No more than 0.1" away assuming you're using a standard grid.
 

Thread Starter

christiannielsen

Joined Jun 30, 2019
389
Well the only reason I chose a PP3 9 volt is because of its size and because it can be bought every where.
4 x AA batteries is unfortunately not possible for this project because of its size.

Alternatively can you recommend a 6 volt battery at the size of a 9 volt battery that are easy to find and buy? Then I can dish the regulator.
 

Irving

Joined Jan 30, 2016
5,134
Tricky... An 850mA 7.4v lipo rechargeable pouch battery would be similar size to a PP3. Another option would be two 1600mA 3v CR123A non-rechargeable cells. Other non-rechargeable options might be 2 x 2450 coin cells @ 650mAh or 2 x 2477 @ 1000mAh. You could use smaller coin cells, the 3v 2032 size is 270mAh
 
Last edited:

Thread Starter

christiannielsen

Joined Jun 30, 2019
389
Tricky... A Pair of 1000mA 3.7v lipo rechargeable pouch batteries would be similar size to a PP3. Another option would be two 1600mA 3v CR123A non-rechargeable cells. Other non-rechargeable options might be 2 x 2450 coin cells @ 650mAh or 2 x 2477 @ 1000mAh. You could use smaller coin cells, the 3v 2032 size is 270mAh
You think 2 x 3 volt 2032 will work? I have that. I'll breadboard it tomorrow.
 

Irving

Joined Jan 30, 2016
5,134
It appears that the internal resistance of a 2032 cell is too high to be useful, in fact most coin cells aren't going to work it seems. Pity.

CR123A looks a better option, designed for high pulse currents like flash guns.

The Lipo option with a charger board would mean no changing batteries, just plug into any usb charger...
 

trebla

Joined Jun 29, 2019
599
Maybe this helps if you isolate servo power supply lines from your control logic supply by diode and use second regulator to powering servos. Maybe servo current just bleeds out your control logic supply voltage. In addition you can increase C1 capacitance.
 

djsfantasi

Joined Apr 11, 2010
9,237
Maybe this helps if you isolate servo power supply lines from your control logic supply by diode and use second regulator to powering servos. Maybe servo current just bleeds out your control logic supply voltage. In addition you can increase C1 capacitance.
if they are RC servos, there is no need to use a diode to isolate power supplies. Just tie both grounds together.
 

trebla

Joined Jun 29, 2019
599
I mean by isolating servos positive voltage from control logic positive voltage source putting a diode which prevent sucking down C1 cap charge and helping to keep control logic running in power shortage situations. I know that RC servo steering input does not need much current and i usually put at least 1k resistor on control circuit output for preventing output overload in short circuit situations.
 

Thread Starter

christiannielsen

Joined Jun 30, 2019
389
Ok, this is the revised circuit...

The main differences:
Uses CD4002 dual 4-input NOR gate instead of diode logic, to give a good pull-down on active;
Uses 2 P-Channel MOSFETS to give a good, low impedance, near 6v voltage source for the timing resistors. They're not the ideal MOSFETs as they are medium-power rather than small signal types, but its really hard to find a good small-signal PMOS device in a through-hole package for some reason;
Timing resistors have been made 10x smaller, and capacitor C3 10x bigger. This increases charge & discharge currents from uA to mA and overcomes some of the problems caused by D7. I'm still unhappy with that, I'd like to get rid of D7 but every way I tried was several additional parts. But you must use a small signal diode like 1N4148 or 1N914 otherwise the timing wanders wildly with even mild temperature changes.

View attachment 214764
Irwin I really appreciate your help. I would really like learn how you calculate which capacitors, resistors and trimpots to use for
creating the correct PWM signal to control the servo motor. Is it possible for you to explain?
 

Irving

Joined Jan 30, 2016
5,134
Of course. First, you have to understand how a 555 timer works. Look at the datasheet (attached), specifically the diagram in 8.2 and Fig12, both diagrams reproduced and annotated below

ne555.jpg

Looking first at the LH diagram,this show the innards of NE555 timer. The important bits are the resistor chain R1, R2, R3 and comparators C1, C2. A comparator's output goes high when its + input is at a higher voltage than its - input (the one with the circle attached). So when the voltage on the THRESHold input is higher than Vth C1's output goes high, resetting the flip-flop and putting the output LOW and also turning on the DISCHarge transistor at the bottom. Similarly, when the TRIGger input goes lower than Vtr, C2's output goes HIGH, setting the flip-flip and putting the output HIGH, turning off the DISCHarge transistor.

Now consider the voltages Vth and Vtr. Because R1, R2 & R3 are all the same value, Vth = 2/3 Vcc and Vtr = 1/3 Vcc.

Now look at the RH diagram, which shows an NE555 in astable (free running) configuration. Assume the capacitor C is discharged, so both TRIG and THRESH are at close to 0v. The output goes high, turning off the DISCHarge transistor, and the capacitor starts charging through RA and RB. When the THRESH input reaches 2/3 Vcc the output is set low and the DISCHarge transistor is turned on and the capacitor discharges through RB until its voltage, and the TRIG input goes below 1/3 Vcc and the cycle repeats, with the capacitor charging and discharging beteen 1/3 Vcc and 2/3 Vcc. Now it just so happens that the time for a capacitor to charge to twice its initial voltage or discharge to half its intial voltage is 0.7 x R x C. So in this case the charge time Tchg = 0.7 x (RA + RB) x C and discharge time Tdis = is 0.7 x RB x C.

But our circuit has a twist, a diode across RB in the charging direction. This means that RB isn't part of the charging circuit and so the charge time (output high) is just Tchg = 0.7 x RA x C. This true as long as the voltage feeding RA is Vcc or very near, and stable over the cycle as the capacitor charging current changes, and 2/3 Vcc is very much larger than the diode forward voltage (which also varies with capacitor charging current). The former was definitely not the case with the original circuit and the latter not true with the original values. The discharge time remains at Tdis = 0.7 x RB x C.

So now we can work out our values of RA, RB and C. Firstly we know the pulse rate should be 50Hz, or 20mS, which is Tchg + Tdis, and we know Tchg varies between 1mS and 2mS so Tdis must be 18.5mS (average). Using a C of 470nF means Tdis = 0.0185 = 0.7 x 470e-9 x R or R = 0.0185/(470e-9 x 0.7)= 56231, or 56k standard value.

Next, we can work out our values for RA, for which we have a variable component and a fixed component. We also have two ranges, for the open box and close box scenario. Assume OpenBox = 1.5 - 2mS (90 - 180deg movement) and CloseBox is 1 - 1.5mS (0 - 90deg movement), then

Tclose = 1.25mS +/- 0.25mS, therefore Rclose = 0.00125/(0.7 x 470e-9) = 3.8k (3.0k - 4.6k)
Topen = 1.75mS +/- 0.25mS therefore Ropen = 0.00175/(0.7 x 470e-9) = 5.3k (4.5k - 6.1k)

so a 5k variable trimmer (1k not enough) with a centre value of 2.5k, giving fixed resistors of 1.2k (close) and 1.8k (open). But allowing for a 10% tolerance on the capacitor (so run the same calculations for C = 423nF and 517nF) I opted for 1k fixed as the range of the 5k trimmer was adequate. In a production environment I'd have made the capacitor a 5% component and the 56k a 10k trimmer and 51k resistor.
 

Attachments

Last edited:

Thread Starter

christiannielsen

Joined Jun 30, 2019
389
Thank you so much. This was awesome. I think I understand the most part of it. I have never understood how R1,R2,R3 can be used for both charging and discharging but now I understand it depends on the state of the comparators in the 555 and how the current flows/changes direction by that. I also understand the comparators function. And the 1/3 and 2/3 is because the resistors are the same and function as a voltage divider (right?) :)

I actually did wonder about the limited range to the servo arm positions. Now I understand why it can't fully be adjusted to 0 and 180 degrees which is what I need. So I should be able to put in a larger trimpot to have more adjustment ability? I would say the range is about 0 to 150 degrees. The one position has reached the end though and starts to jitter if I crank up the trimpot.

I really learned a lot, thanks.
 

Irving

Joined Jan 30, 2016
5,134
If the capacitor is near the low end of its tolerance you'll have difficulty getting 2mS pulse width.

Increasing the series resistor from 1k to 2.2k should get you 180deg.
 

Thread Starter

christiannielsen

Joined Jun 30, 2019
389
Thanks, just to clarify:

1. By 'capacitor' you mean C9 or C11? Can I influence the tolerance of ceramic caps?
I can meassure all the ceramic caps I have and choose the one which is the closest.

2. And by 'series' resistor you mean R8 and R9 right? (because they are the only 1K resistors in the circuit)
 

Attachments

Top