solenoid circuit makes non-reprogrammable chips

Brian Z

New Member
Hey all,
I have built a circuit to fire a solenoid when an infrared beam is broken, but I need to reprogram my Picaxe 08m2 to make the delay that the solenoid stays engaged for. I can program a brand new 08m2, but when I try to reprogram the chip it says Hardware Not Found. I can reprogram the transmitter circuit fine, but my receiver Picaxe won't reprogram. The receiver works fine, even after I attempt to reprogram it, I just can't adjust the solenoid delay.

Other details:
I am using output c.4 to drive both a red led (with resistor) and the base of an N-channel mosfet transistor, which drives the solenoid.
I am using a diode on the solenoid to protect my mosfet.
I am powering the mosfet and solenoid with a 24v power supply.
I am powering the Picaxe with 3 AA batteries.
The 0v connection from the batteries is connected to the 0v connection for the power supply.
I am reprogramming the chip on a separate breadboard powered by a computer ATX power supply.
Chips that have not been in my solenoid circuit reprogram fine.

What could be going on in my solenoid circuit that is causing my Picaxe chips to become non-reprogrammable.

Thanks for any thoughts,
Brian Z
 

inglewoodpete

Senior Member
The problem is probably caused by something in your code that prevents your chip from regularly checking the download pin to see if there is a fresh program to download.

If you post your code we could probably point out what is causing the problem. (Or you can continue to use the hard reset method.)
 

SAborn

Senior Member
To follow on from what IWP said, it would also be worth posting a schematic of your circuit, as i have had transient spikes corrupt the code some how and i susspect the solenoid is sending spikes back through the power wires and effecting the picaxe, its best to sort the problem out and have a reliable system then just except it works most of the time.
 

Brian Z

New Member
Here is the code I'm using, and it works really well. The transmitter Picaxe 08m2 sends an irout signal every 10th of a second, and if the receiver 08m2 doesn't get the signal in just over a 10th of a second, it sends an output signal for about 15ms, which drives the mosfet, which actuates the solenoid, which hits the note on a glockenspiel.

The transmitter:
Code:
startup:
	pause 1000

Main:	

	irout c.2,1,1
	pause 100
	goto main
The receiver:
Code:
input c.2
low c.4

Main:
	let b0 = 0
	irin [120,ding],c.2,b0
	goto main
		
ding:
	high c.4
	pause 15
	low c.4
	
afterding:
	irin c.2,b0
	if b0 = 1 then main
	goto afterding
The transmitter 08m2 drives an infrared led through a transistor. The receiver reads it through an infrared receiver. I got them both at Sparkfun.

I'm teaching a week-long high-school level electronics course next week at the science museum I work at, and we are building an exhibit based on this circuit. We have a staircase with 8 stairs, and we are building 8 of these circuits and mounting them on that staircase, and each one will drive it's own solenoid to make a musical scale as you walk up the stairs. We are doing a bunch of other stuff too, like learning the basics of Ohm's law, the voltage laws, how parallel and series circuits work, how to read a resistor, how to read a datasheet, soldering, circuit board etching, etc. This will be our final project, and I want everybody to have some exposure to programmable microcontrollers.

This is our first ever class for high-schoolers (we mostly do grade school) and I guess our marketing efforts failed, because I only have 2 kids signed up. I wish I had somebody to teach me electronics dang-near one-on-one in high school. The other awesome thing is that my budget for the class was on the assumption that I was going to have 20 kids, so when I bought enough supplies for 2, I got to spend the amount needed to teach 20, so they get to take home some nice soldering stations, multimeters, solderless breadboards, a tv-b-gone, and just a huge amount of components.

Brian Z
 

inglewoodpete

Senior Member
Hi Brian, Thanks for posting your code. I now have a better idea of the situation.

The second "Irin" command is probably causing the lockups, preventing you from reprogramming the PICAXE. When used without a timeout parameter, the command becomes a "blocking" command: preventing the chip from checking its download pin.

If your code does what you want, then leave it like it is. The chip always checks its download pin when it boots up (restarts), so you have a way of changing the code if you need to (provided you remember the magic trick!!) I wish my programs were as small as yours ;).

Another way to reprogram the chip when it appears to be "locked up" would be to sent a few '1's (or any number) via the IR port after you have started the download from the PE. The processor checks its download pin in between each command.

Regarding the small number of takers is your electronics class, don't be downhearted. With the almost 1-on-1 teaching environment for you to share your interest in electronics and microcontrollers, the students have a much better chance of becoming "hooked" on a healthy hobby.

I started my interest in the PICAXE with the AXE092 "Schools Experimenter" in 2005. Periodically, I dig it out to try out a new idea. Only this week I used it to prototype an idea which may take me to Europe next year. Big things can come from small circuits!

Peter
 

erco

Senior Member
Brian: If you use a continuous signal compatible IR receiver like a TSOP4038, you can send simple IR pulses instead of Sony IR codes. Thus, you could use a 556 timer as a transmitter instead of a PicAxe. https://solarbotics.com/product/TSOP4038/

Also, if you align and baffle your IR beams, could probably use a simple unmodulated (steady) IR beam.

Good luck with your museum exhibit!
 

SAborn

Senior Member
Your stair case IR beam should not require a long distance beam, but should you want 10-20 meter beam than a handy hint ( which Westy and Dippy will shutter on) is to drive the IR led through a transistor with no current limiting resistor on the led (direct 5v power) as the duty cycle of the IR pulse will limit the power through the led, i have had a system running 24/7 for some years now with this system and no failure.
If you have ever tested the range of a IR remote for a TV against a current limited picaxe circuit, then you would notice the current limited circuit gives several meters range, where a TV remote gives 10's of meters range, the reason is the TV remote is often driven without a current limiting resistor to the IR led.

Its a view that will attract comments of "its not advisable" to do that, but it will work well and gives a long distance reliable beam.
 

Brian Z

New Member
One of the things I like about this setup is that it dings once, and then it doesn't do anything until the beam is unbroken then broken again. I tried several other methods of sending and receiving signals, and this one is far and away the easiest and most reliable. My original thought was that I would use a different Sony code for each step so they wouldn't interfere with each other, but then I realized that that wouldn't work, but now I can't remember why I thought that. I'm pretty sure the beams won't be able to see each other halfway back on the tread of each step. I'll cross that bridge when I get to it. I plan on using a single 08m2 to drive all 8 step IR leds through a mosfet, so I wouldn't be able to use different Sony codes anyway.

If it doesn't work these high school kids will get a great lesson in troubleshooting, which in my experience, is everything.
 

westaust55

Moderator
In line with the comments from IWP, try this code and see if that improves your ability to re-program without resorting to a Hard Reset" every time.
Code:
init:
	input c.2
	low c.4

Main:
	let b0 = 0
	irin [120,ding],c.2,b0
	pause 10
	pause 10
	goto main
		
ding:
	high c.4
	pause 15
	low c.4
	
afterding:
	pause 10
	pause 10
	irin [120,afterding], c.2,b0
	if b0 = 1 then main
	goto afterding
 
Top