I'd like to do this for a couple of reasons - the motor is ridiculously powerful and destroys it's limit switches on a regular basis (I've tried 3 or 4 different types - the weather is also a factor in their demise). It's driving a large wooden gate that carries a large amount of momentum. It would also provide a handy extra safety function whereby the gate will halt if it hits a car, person etc.
My question is - has anyone tried this? Am I going to be able to get near? I realise I'm going to have to be careful to have it ignore the initial spike when the motor starts moving. The motor is being controlled via PMW - I guess I'm going to have to smooth the input to the sensor with a capacitor. Do you think I'll have too much noise because of the PMW?
Yes I have used this technique with small DC motors and it works quite well. However I have not used the current sensor you posted I use a series resistor and monitored the voltage across it. It sounds like you have quite a powerful motor.
destroys it's limit switches on a regular basis (I've tried 3 or 4 different types - the weather is also a factor in their demise)
What sort of limit switch have you tried?
There are several alternatives apart from the normal micro switch.
Reed switch with a magnet on the traveling bit.
Opto slot switch (lots of scope for over run here)
Proximity switch.
All these are much more weather prof than a mcro switch.
I've only tried micro-switches to be honest. I've tried ones with a roller and ones with the big springy thing on. All IP67 and all dead in a year. Your suggestions are all great ideas - however I'd love to reduce the component count - less to break.
The motor is 370w@24v. It's geared down massively and has a gigantic amount of torque (think it's intended purpose was as a winch motor on a 4x4). It's rated for 12v or 24v. It drives the gate from the end with a wheel and pneumatic tyre in contact with the ground. It's been running for the last 3 years. It probably needs maintenance 2-3 times a year. Which from my limited experience with commercially available systems - aint half bad. However it runs on a very, very basic electrical system. Basically 4 relays + some fuses. Two SPDT's to control motor direction. Then another 2 relays that shut the motor off when a limit switch is hit. The time has come to replace this with something more sophisticated. I'm pretty much done now. It's all in a nice enclosure and 95% of the code is written. Just waiting for that sensor to arrive I'll post up some pics soon.
That's part of the reason for the whole project - the speed controller will have cut the speed to about 20% for the last couple of seconds of travel so at least the momentum will be reduced.
Well I burnt my contoller out almost all of the operation was great - my arduino code smoothly accelerated the motor up and ramped it down. It even detected the over current to an extent. Unfortunately the detection of overcurrent is somewhat erratic. The values I'm seeing are all over the place. At a steady speed I'm seeing values varying by around 15 amps! the value jumps around like crazy. Now I suspect that this is being caused by it measuring current being dished out by a PWM controller. So if I grab a sample duing a trough - I get a low value and so on. I think I need a capacitor on my sensor. I need to measure current maybe 10 times a second max. The sensor IC has a resistance of 1.7KOhms. It already has a capacitor of 1nF. My calculations give a 10uF cap for a cut-off of 9.36Hz. I'm guessig that this might make it ridiculously slow in responding so perhaps a 2.2uF cap which would give me 42Hz. Anybody see any problems with this?
I've ordered replacement mosfets for my controller by the way
You might need to incorporate the limit switch back into the setup as a safety factor. You could make one for the 24v wiring out of spring closeline pin with a big rectifier diode across it to allow reverse movement until the linit switch is again closed.
Got my motor controller back up and running the mosfets were shorted across all three terminals. Looked perfectly fine on the outside - must be complete slag inside. I've added a thermal switch next to one of the mosfets on the heatsink that will trip and cut the control signal down to ground if the temp gets above 40c - probably a bit conservative... but hey.
My big bag of caps didn't gave a 2.2uF of a sufficient voltage rating so I went with a 3.3uF tantalum. Had a bit of a play using a couple of car lamps and it's very stable
So, as I read it you're looking to use a current sensor in place of an 'end of travel' limit switch to cut power to the motor as it's destroyed limit switches in the past?
Why not go for a simpler approach - use a light sensor or proximity sensor instead of a physical limit switch? That way you still have flexibility to reposition as needed, and it's a 'hard' input you can immediately detect as present or not.
Or am I missing something here?
Dave, something I would do is not to trust the Arduino 100% on this gate device; add actual limit switches in, but adjust the Arduino so that its limits are inside the limits of the limit switches (does that make sense?). That way, if for whatever reason the Arduino fails to detect the limits, you don't have the motor dying or catching on fire or something.
I am facing a similar problem myself with a robot I am developing; the fact that it will be semi-autonomous complicates things - I am trying to make its steering control system as safe as possible (to itself and others); I have software-based limits (basically right now an on-board potentiometer to measure the angle of steering and a simple software window-comparator; I plan on upgrading it to a PID later), but I am going to install real hardware limit switches so that if something drastic happens, the system won't go out of control and destroy itself or catch on fire.
Just something to consider.
BTW - what are the limit switches you were using? Are they industrial outdoor grade switches, or just something from the corner hardware/electronic store? You might look into something from Grainger or McMaster-Carr ($$$), if that isn't what you were already using...
Thanks cr0sh - I appreciate what you're saying and I may well resort to limit switches.
It has a thermal cut out bolted to the heatsink next to one of the mosfets (a very conservative 40 celcius) which cuts the speed to 0, plus resetable overcurrent breakers. The structure of the gate is capable of handling the maximum deliverable amount of torque (the wheel spins first - like a very poor mans clutch). Due to the gearing of the motor and the sheer power of the thing in relation to the application, it never really breaks a sweat. The first point of failure is always the electronics/relays.
Well got it up and running yesterday. All installed. Few bugs I need to iron out in user interface but in terms of basic function it's working well. The current sense stops when the it reaches the end of travel within 0.5 seconds and it stops quickly when I stop it mid travel by hand. The ramp function works very well
Quick question. The current goes out of scale at full speed. If I change my circuit so that instead of all of the current going through current sensor I provide two paths:
in ___________________
------| Curren Sense board |
------|___________________|
out
in ___________________
---[ch9516]--|Curren Sense board |
---[ch9524]--|___________________|
out
I would have thought with this configuration I would get less than 50% of current flowing through the sensor. I don't really care about having a meaningful figure in terms of Amps.