Can a picaxe pin be set to a state, rebooted and remain in the state it was set to

JPU

Senior Member
Thanks and thanks again for looking:

I have a circuit that when powered using a momentary switch, causes a couple of transistors, N-mosfet and 14m2 picaxe to stay on until a switch is pressed again to shut down the circuit. (If your interested here is the circuit hyperlinked to this text and found at the end of the thread) The N-mosfet is used to sink a larger load attached to the same supply.

The circuit works well and does the job, until I connect the load to the board which should only be live when grounded by the Mosfet. However, Once I connect the load to the circuit there is a leak through one of the loads pins, (which is connected to C.4 pin on the the 14M2 for later use) to ground and so the load turns on even though the mosfet has not sunk the load yet. I need the load to be connected to c.4 on the 14m2 pin for use later and so I cant disconnect it. However when I physically disconnect the pin to test, everything works perfectly and the load turns on as expected when the mosfet is activated.

So the problem is that the c.4 pin on the 14m2 seems to connect to ground by default even when the 14m2 is off. Should this be the case? If so is there a way I could set this pin to not connect to ground, but it would have to remain in this state even when the picaxe is off.

Thanks for looking and helping.
 

srnet

Senior Member
So the problem is that the c.4 pin on the 14m2 seems to connect to ground by default even when the 14m2 is off. Should this be the case?
Yes, the protection diodes on the pins means the pin acts as a ground connection when PICAXE power is removed.

There is one pin without the diodes, but thats an input.
 

hippy

Technical Support
Staff member
You could perhaps run C.4 output through a diode to the MOSFET gate, but I am having trouble understanding how C.4 being low or pulled-towards 0V is activating the MOSFET. And if you used the diode, you would need a pull-down resistor to 0V anyway.

It would probably be worth drawing exactly what you circuit is.
 

JPU

Senior Member
Hi Hippy

Its not activating the mosfet and the mosfet is behaving as it should. However, "my load" is in fact a secondary daughter board which is mounted onto a main PCB. The main PCB has the 14m2 and transistor switch circuit on it but the 14m2 is also used to control the daughter board later when it is made active by the mosfet. The secondary PCB is only active or at least should be when the mosfet sinks the daughter board. But the daughterboard is becoming activate as soon as power is applied to the circuit due to the c.4 pin grounding the daughter board.

Sorry confusing, I know. This is what happens when "back shed electronics" gets out of hand, LOL.
 

AllyCat

Senior Member
Hi,

In that "other thread" you didn't say anything about the "Load" being an active circuit with "signal" connections to the PICaxe (and the schematic diagram didn't, and doesn't, show any) !

The problem is that you've used a "Low Side Switch", so when it is "open", the whole (Load) circuit rises to 30 volts (or tries to). Any interface signals will need to be "30 volt tolerant" and that certainly doesn't apply to ANY PICaxe pins.

You might be able to use resistor divider chains for any signals from the "Load", and maybe external NPN transistors (similar to that in the "keep alive" circuit) for control signals going to the "Load".

Cheers, Alan.
 

Goeytex

Senior Member
So the problem is that the c.4 pin on the 14m2 seems to connect to ground by default even when the 14m2 is off. Should this be the case? If so is there a way I could set this pin to not connect to ground, but it would have to remain in this state even when the picaxe is off.
When the 14M2 is off pin c.4 is floating. It is also floating at power up until it is made an output. If the gate of a mosfet is allowed to float, it will conduct. You may be able to solve your problem by adding a pulldown resistor from C.4 to ground. I generally use a 47K resistor, but a value from 10K to up to 100K should work ok.
 

JPU

Senior Member
Hi

Thanks, I did fail to detail exactly what the load is and how it connected. I had assumed that the load could be treated as a completely separate unit as if it were just being switched on/off by a relay when required. The load has a positive and negative input and then a number of pins from it. However the load is a far more complex thing than I could ever understand and I should have known this would not be as simple as that!.

Since starting this project and after bread boarding it, I have realised my mistake and maybe I should have stuck with Hippy's original suggestion of using a relay to control the whole thing. However I have got carried away with the possibilities that integrating a mosfet and using the Picaxe bring to my project, things like "auto off" when not used for a period of time.

The circuit you helped me with and when combined with the "Load" do work. I can do without the c.4 pin as it only reads an analogue voltage from the load which represented RPM of the device being controlled. (set to a range of range 0-5V)

Question:
As c.4 is the only problem pin, perhaps there is a way I could switch of this circuit ie c.4 to RPM output on load, until the mosfet is activated?

Cheers




It would have been nice if there had been an easy fix for this grounding.,
 

hippy

Technical Support
Staff member
Perhaps a diode on C.4 will help, or a current-limiting resitor. Hard to tell without seeing a full circuit with all power rails included.

As it is it does sound like a parasitic power issue. Current flowing into the slave board V+ then somehow into C.4, then either to 0V or possibly the mainboard V+ via the internal clamping diode.

If it's the later; using an input without a clamping diode won't solve the problem and is more likely to blow the mainboard PICAXE up.
 

AllyCat

Senior Member
Hi,

maybe I should have stuck with Hippy's original suggestion of using a relay to control the whole thing.

It would have been nice if there had been an easy fix for this grounding.,
Yes, a relay would have been easier to implement (or convert to) High-Side switching. But for switching 10 Amps, a FET does have definite advantages.

Often, one could use an OptoCoupler to isolate the circuits, but that's not easy for an "accurate" analogue voltage such as for measurement of RPM. A simple solution might be to use a miniature relay (perhaps a reed type) to switch (i.e. isolate/connect) just the RPM signal. Or, as hippy suggests, use a diode to isolate the signal: Cathode to the RPM signal and Anode via a few kohms to the PICaxe supply rail (Vdd). The diode is reverse-biassed when the "Load" is off (i.e. at 30 volts) and pulls the anode down below Vdd when the Load is active.

But a problem is that the diode has a forward drop of around 600 mV (or a Schottky diode would be nearer 300 mV), so the RPM signal will be correspondingly too high. You might "fix" that in the software or could use an NPN emitter follower which has a similar (but complementary) voltage drop: connect Collector to Vdd, Base to the diode anode and Emitter to pin C.4 and a resistor of a few kohms pulling (the pin+emitter) down to ground. Exact details would depend on the source impedance and maximum voltage swing of the RPM signal (a high impedance, or a full swing from 0 to 5 volts, would be easier with a relay!).

Cheers, Alan.
 
Last edited:
Top