Understand and how to hook up this circuit to an output of a pic16f..

Thread Starter

heunen

Joined Nov 26, 2009
6
Hello,

Before stating my questions I like to give some background info first:

I am interested in modelrailroad circuits and I found this one from http://users.skynet.be/pro-rail/ukindex.htm:

The circuit is actually a variable current source for memory wire, with adjustment via the pot. The current is limited between 180 and 240 mA.
I tried to understand how the circuit works. I can calculate the resistance of 9.2 to 6.4 Ohms when the pot is turned at the emitter side. But I can not get to the values of 180-240mA.

So my first questions are (I tried several other forums for an explanation, but it seems that no one can really explain it to me.):

- Can someone explain me how to obtain the values of 180-240mA?
- What is the reason using the 4.7kOhm resistor?

Anyway, I still would like to use the circuit (even when I can't understand it), and control it with a pic16f628, hence circuit activated/deactivated.

Here my question concerns the connection from the pic port to the transistor (b-gate):
- Can I hook-up the output port of the pic to the transistor directly (including the 120 Ohm and 4.7kOhm resistors)? or
- Do I need a special resistor instead of the 120 Ohm/4.7kOhm)? or
- Do I need a second transistor stage between pic and this circuit?
- What to do with this 2.4V?

Any help concerning the theory of the circuit and a possible circuitry for the link to the pic is appreciated.

Thanks,

Guido
 

Wendy

Joined Mar 24, 2008
23,429
The input is meant to be two voltages, either 2 or 4V. This sets up the two currents.

A transistor with a emitter resistor is a constant current source. Whatever is on the base is on the emitter subtracting the .6V BE drop. The voltage on the emitter is that voltage and doesn't vary, so this sets up the current through the collector.

I suspect my 1st paragraph answered your question though.
 

Thread Starter

heunen

Joined Nov 26, 2009
6
Alberto,

I understand that I can do PWM. However, the current through the memory wire should be limited to ~200mA otherwise the memory wire breaks down.

I would like to use the circuit above because of the fine tuning possibility of the current limit.
I know that I can do that with PWM, but there I have to do the fine tuning at the level of software and not at hardware.
So, correct me if I am wrong, my duty cycle should be less 100% to maintain my current limit. Since the length of the wire will vary, also my resistance will vary, hence I need to adapt the PWM accordingly. With the above circuit the current is always limited and does not depend on the length of the wire.

However, I keep this PWM option open for development ...

Thanks,

Guido
 

Wendy

Joined Mar 24, 2008
23,429
Hi,

The 2,4V is the european notation for 2.4V so there is only one voltage supply to the transistor.

G.
OK, so how do you think they select the values between the two settings? It switches between two states, correct? 0V when they want to be off?

OK, minimum resistance for the emitter is 6.4Ω, maximum resistance is 9.2. Going with 2.4V on the base you will get 1.8V on the emitter.

1.8V/6.4Ω = .280A or 280ma
1.8V/9.2Ω = .196A or 196ma

Since their is a base resistor those values will drop a little. That schematic isn't very good, designators should always be part of one. It allows you to discuss a specific part in one word.
 
Last edited:

Thread Starter

heunen

Joined Nov 26, 2009
6
Alberto,

I dont see how I can control the lm317 with a uln2803. Can you give me a circuit scheme?

Thanks

Guido
 

CDRIVE

Joined Jul 1, 2008
2,219
The ULN2003 has all the Emitters tied to GND. Because of this it can't be wired as shown in your original circuit. On the other hand I don't see the necessity for the NPN to be wired as such. I really think that the Transistor should be either on or off, and when on it should saturate. This would necessitate setting the ON current through the MemWire by other means. Since the supply voltage is regulated @ 5V, I would think a limiting resistor should suffice. Diodes placed in the collector circuit could also be used to reduce the power dissipated by the limiting resistor.

This circuit should be kept in the KISS category. On the other hand, you have the programming power of the PIC which can PWM as suggested.
 

SgtWookie

Joined Jul 17, 2007
22,230
Hi Guido - Welcome to AAC.
Hello,

Before stating my questions I like to give some background info first:

I am interested in modelrailroad circuits...
I spent many enjoyable hours with my model railroads. :)
...and I found this one from http://users.skynet.be/pro-rail/ukindex.htm:

The circuit is actually a variable current source for memory wire, with adjustment via the pot.
I am not familiar with "memory wire". It would help a great deal if you could explain it's characteristics.

Does its' resistance change?
What is its' resistance when it is in one memory state, and what is its' resistance in another memory state?

The current is limited between 180 and 240 mA.
Actually, in that circuit, the current sort of depends upon the memory wire. However, it would be fair to say that the current would be under 240mA, until the transistor got quite warm.
I tried to understand how the circuit works. I can calculate the resistance of 9.2 to 6.4 Ohms when the pot is turned at the emitter side. But I can not get to the values of 180-240mA.
I simulated the circuit using a 2N2222 instead of a BC337, and it did seem to work in the simulation. However, I did not know the value of the "memory wire", so I used a very low value of resistance (less than 1 Ohm).

So my first questions are (I tried several other forums for an explanation, but it seems that no one can really explain it to me.):

- Can someone explain me how to obtain the values of 180-240mA?
We would need to know the value of the "memory wire" first.
- What is the reason using the 4.7kOhm resistor?
That would keep the BC337 transistor turned off when the 2.4V source was removed. Otherwise, the "memory wire" might still get some current flowing through it.

Anyway, I still would like to use the circuit (even when I can't understand it), and control it with a pic16f628, hence circuit activated/deactivated.
Well, a PIC would not be able to source enough current, I don't think. You would need a driver circuit for it to be able to supply the necessary current.

Here my question concerns the connection from the pic port to the transistor (b-gate):
- Can I hook-up the output port of the pic to the transistor directly (including the 120 Ohm and 4.7kOhm resistors)?...
It would be very risky.
...or
- Do I need a special resistor instead of the 120 Ohm/4.7kOhm)? or
- Do I need a second transistor stage between pic and this circuit?
This is the way I would go.
- What to do with this 2.4V?[/QUOTE]
You might use a voltage divider network between 5v and ground. Use a P-channel logic-level MOSFET to switch the high side of the voltage divider network on and off.

Any help concerning the theory of the circuit and a possible circuitry for the link to the pic is appreciated.
OK, I'll make a stab at it.

Most of the power dissipation in the circuit is in the transistor itself. If this "memory wire" has a low resistance, the transistor will be dissipating nearly maximum power at minimum current (almost 600mW), or well over it's limits (lmaximum current, about 860mW, limit is 625mW) for a TO-92 package.

It seems to be an unnecessarily complex circuit for current regulation, with components stressed far beyond their limits.

It would help a good deal if you could post more information about this "memory wire", as I have no clue what to expect, or what it might measure, or what it might be used for.
 

Thread Starter

heunen

Joined Nov 26, 2009
6
Hi SgtWookie,

In general a metalic wire expands when heated. A memory wire is actually a memory shape alloy (MSA) which shrinks when heated. For modelrailroading this material can be used to set in a realistic way (switch-)points as the motion is slow and with no clicking (as selenoids do). See for more details: http://users.skynet.be/pro-rail/ukindex.htm. I don't have any idea about the resitance of the wire.

The wire losses its contraction behaviour (that's the memory effect of the wire) if you heat to much, that is higher than 250mA, I believe.

I want to control with ONE Pic16f6.. controller 6 of these wires simultanously. I believe that PWM can not be directed to 6 different outputs. That's why I want an easy and fine tuneable current limiter (180-240mA) circuitry for control of my MSA.

Guido
 

CDRIVE

Joined Jul 1, 2008
2,219
Hi SgtWookie,

II believe that PWM can not be directed to 6 different outputs.
Guido
Sure it can, that's what Microcontrollers do best. They simplify circuitry by replacing hardware with a few lines of code. If you can code a pin to go high or low you can also code it for how long it stays Hi and how long it stays Lo.

' pseudo code:

Rich (BB code):
Do While Pin2 = 1                 ' Check Pin2 status 
   Pin3 = 1                          ' Pin3= +5V to Opto Emitter (Anode)
      Pause 700                    ' Pin3= +5V for 700mS
   Pin3 = 0                          ' Pin3= 0V
      Pause 300                    ' Pin3= 0V for 300mS
   If Pin2 <> 1 Then              ' Check Pin2 status again
      Pin3 = 0                       ' If Pin2 is Low then make Pin3 Lo and ..... 
      Exit Do                         ' exit the loop
   End If
Loop
As I said in a previous post, this project does not need over-complication in hardware or code.
 

CDRIVE

Joined Jul 1, 2008
2,219
Hi Guido - Welcome to AAC.

I am not familiar with "memory wire". It would help a great deal if you could explain it's characteristics.
I extracted this information from Guido's posted link in his first post.
http://users.skynet.be/pro-rail/_private/fam/ukcafam3.htm

Using the information supplied .....
Typical length: = 5 cm to 15 Cm
Typical Voltage: = 1V to 3V
1 Volt for 5cm and 3V for 15cm

I deduce from this that a 5 centimeter length would need 1V nominal. At 200 mA that would = 5 Ohms or 1 Ohm per centimeter. They give no hint as to whether or not the resistance changes when hot, but I'm inclined to believe not so much.
 

SgtWookie

Joined Jul 17, 2007
22,230
OK, here's something for you; simple and cheap.

Click on the attached schematic. You may have to click on it again once the image comes up to see it full size and undistorted.

The memory wire is connected on one end to +5v, and the other end is connected to the IN terminal of an LM317 positive voltage regulator, which is connected as a current regulator.

R1 and R2 when paralleled work out to be about 6.67 Ohms total resistance. That should give the regulator about 190mA current flow from the IN to the OUT terminal. I'd rather the current be a bit on the low & cautious side than too much.

When used as a current regulator, the LM317 will drop about 3v across itself. With a 5v supply, this leaves about 10 Ohms maximum resistance for the rest of the circuit for it to be able to sink up to 200mA.

The regulator will dissipate from about 1/3 Watt to 3/4 Watt of power, depending on the resistance of the rest of the circuit. R1 should be a 1/2W resistor, R2 can be 1/4W

Q1, an IRLD014, is a really nifty little MOSFET in a 4-pin DIP package that can be controlled directly by logic levels. When on, it has a resistance of 0.2 Ohms; and it can sink up to 1.7A current.

R3 is a "safety net" - in case the control logic fails, the gate of the MOSFET is pulled to the same potential as the source terminal, turning it off.

R4 limits the maximum current of the PIC I/O pin to 18.5mA; this is necessary in case the MOSFET gate shorts to the drain or source terminals.

PWM is a wonderful thing, but it can get complex if the uC is controlling lots of other stuff. Might be better to just keep it simple.
 

Attachments

CDRIVE

Joined Jul 1, 2008
2,219
Yes Sarge, simple like that. ;)

Edit: Sarge, unless the square wave, (that you're generating in your schematic) is outboard of the PIC, it would use essentially the same code that I posted to generate it. The only difference would be the Pause Hi and Pause Lo durations.
 
Last edited:

SgtWookie

Joined Jul 17, 2007
22,230
Alberto,
Nice solution!

There may be a couple of problems though:
1) These "memory wires" may be various lengths, as they can be used for many things, such as crosspoint switches, siding switches, semaphore signals, and a wide variety of other slow animations that model R/R enthusiasts like to add. Since the resistance of the wire is dependent upon its' length, the controls would have to be grouped by the length of the wires, and each group would need its' own PWM ratio.

2) We don't know how experienced our OP is in programming PICs. While it's certainly possible to provide a PWM output via timing loops even without using a PWM controller output, the timing loops get to be quite critical. If he accidentally spent too much time in another routine doing something else, the wires could quickly get toasted from overcurrent.

While both of these concerns may be non-issues, they aren't exactly trivial. If all of the wires will be the same length/same resistance, your idea should work perfectly well.
 

Thread Starter

heunen

Joined Nov 26, 2009
6
To All,

Thank you all for the various solutions. Since I have to order some of the proposed components, I will try for now the solution of PWM (one channel for now). I will keep you informed...

Yes, indeed SgtWookie, that's my concern (point 1). That's why I initialy want to stay with the limited current source....

Thanks,

Guido
 
Top