2
\$\begingroup\$

Short Version: How can one detect if a vending machine motor is in its home position?

Long Version: I am trying to make a circuit that would fit most of the motors used in the coil vending machines found in U.S. One of the requirements is to be able to detect if the motor is in its "home" position. This is done by having an actuator on the back of the motor that turns with the spiral. The actuator is round, with a section (about 75°) cut off, and connected with a straight line (making a D shape).This is done to press and depress a switch on a relay that, when depressed (the small missing part of the actuator), places a capacitor in parallel with the motor. I believe the capacitor is 470pf, but I am not sure.

This design was done with the thought in mind that one could detect if the capacitor is indeed connected in parallel or not, letting us know if the motor is in home position.

The practical use case is that as the motor turns, it can tell if its home, and when it does detect that it is home, it can stop, if configured to do so.

The problem I am facing is that I am not an EE by formal education (started teaching myself 2 years ago), so I am not sure I understand how I should be able to detect it.

What I have done so far is created a solution that does indeed detect reliably if the motor is homed, but it can only respond properly 250ms after the motor is stopped. This solution does not work, since the delivery of a product has this 80ms on 250ms off cycle creating a choppy spin/vend and weird experience.

I am hoping someone can give me guidance on what steps I can take or types of circuits that I can use to detect the home position, even right after the motor was spinning (up to 500us).

The design I have now is something like this: Between the high side power (24v) and the high side of the motor, I have a mosfet. That mosfet is driven by an mcu. I have tried PWM at 30KHz as well as just enable/disable, both seem to have same results. The motor low side is connected to another mosfet, that is also controlled by the MCU. There is a matrix of motors, if you are wondering my mosfets on both sides of the motor.

The detection circuit connects between the mosfet output and the high side of the motor. Through an overly elaborate set of resistor and zenner diode, then comperator circuit, I can figure out when the motor capacitor is there, at home position, because with a very short pulse (5 to 10 us) to the motor, the capacitor eats up the power, and my power output is never registered (comperator level is set to ~10V).

I'd be happy to provide any documentation of explanations for what I wrote. Again, I am not an EE major/graduate, so if my terminology is incorrect or confusing, I am sorry, and would greatly appreciate any correction or knowledge you are willing to share.

---Edit 1: Adding a simplified version of the circuit for driving motor, which includes the components used for generating the home signal. This does not have the detection circuit, that will be nextMotor with Homing PCB and MCU

---Edit 2: Adding the detection circuit, exactly as I have it now. This is result of having a simpler circuit with one comperator, zener diode, and handful or resistors, and adding on to solve for the issue of not getting expected results within the 250 ms time frame after spinning/stopping the motor. Since it's still not working, I can probably simplify this one, which is what I will do next. I figured people that know what they are doing can get a good chucke, so feel free to poke fun at it :-)

In this diagram C-RV is there to remove the voltage spike I would see after spinning the motor.. I assume it was from the inductance and/or inertia of the motor still outputting power, so I thought I would solve it by giving it a place to go. I verified this did indeed remove the voltage spike when I tried to pulse the motor for 5-10us to run the detection process.

The 12k resistor and zenner diode are there to limit the input into my comperator to 5.1v, since the line is a 24v one.

The 3.3k and 2.7k resistors are just voltage dividers for the comperator The 12k resistor on the first comperator is for forward bias. I am fuzzy on this topic and only know that it "worked" by testing it, I don't understand it fully.

What I think the circuit is doing is checking where there is no power being applied (6.2k and 1.1k resistor divider into hex schmitt with ~10ns propogation delay), but we had power just a bit ago (2x LM319 at 160ns total delay). There is the first AND gate to make sure that we are only getting the signal if we had the motor enabled.

The full-er view Full-er view

Close up of motor and detect partial

The close up of the detect detect-partial


After adding the requested details and not having any direction from here, I went searching elsewhere for the solution. For anyone else that is missing the foundation/begginer electronics theory and applications, the solutions to these types of circuits and much more can be learned from a wonderful book and it's lab manual companion. The book is "Art of Electronics" by Paul Horowitz.

\$\endgroup\$
  • \$\begingroup\$ You already have a switch, why not use it directly? \$\endgroup\$ – zeta-band Oct 18 '18 at 19:29
  • \$\begingroup\$ You really need to show us the schematic of your current setup. \$\endgroup\$ – Dave Tweed Oct 18 '18 at 19:58
  • \$\begingroup\$ There is a pretty classic windshield wiper circuit that works in a way that would work for you. A switch is open. A pulse to the motor starts its rotation. Once the switch makes it past the flat spot on the D it closes. The closed switch now in parallel powers the motor. After some time the pulse is removed but the motor continues to turn because the switch is providing power. When the flat spot in the D is reached the motor shuts off on its own because the switch opens. \$\endgroup\$ – vini_i Oct 18 '18 at 20:08
  • \$\begingroup\$ @vini_i: That still requires three wires to the motor. The whole point of this exercise is to do it in the context of a two-wire, matrix configuration. \$\endgroup\$ – Dave Tweed Oct 18 '18 at 21:18
  • \$\begingroup\$ That is correct Dave, I intend to rely on a two-wire configuration to make sure my HW is compatible with current machine configurations. \$\endgroup\$ – Lev Oct 18 '18 at 22:09
3
\$\begingroup\$

You have the right idea — superimpose a high-frequency tone on top of the motor power, and measure whether or not this signal passes through the capacitor, on the assumption that the motor itself does not (because of the motor inductance).

The problem is that you need to reliably detect the presence or absence of that signal in an environment that includes all of the noise generated by the motor itself.

Without a circuit diagram, I can't begin to guess what's wrong with your current setup. All I can do is offer general suggestions.

To start with, you need to make your detection circuit as selective as possible to the tone's actual frequency. Second, you should probably add some sort of logic (microcontroller, perhaps) that will help eliminate glitches that still get through the filter.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thanks Dave! I will post schematic as soon as I make one.. later tonight or tomorrow morning. I am ultimately using an arduino due /SAM3XE / interrupt detection to detect the falling edge. I have oversimplified my current curcuit in my description, as it is now, I have 3 comperators and two logic AND gates, but also I am not sure I need it all (started to build on to what I had when I found this rogue waveform trying to detect within 250 ms after motor spins). So I want to first start from the ground and rebuild, making sure I am not adding anything extra (and wasting anyone's time). \$\endgroup\$ – Lev Oct 18 '18 at 22:07
0
\$\begingroup\$

This is a pretty bizarre circuit. The first detection stage is apparently the FD53B9D (which resists my Google-fu) and appears to be a current monitor. When the switch closes you get a brief current spike which the FD will detect and provide as a pulse back to the Arduino. That part is pretty clear, even without knowing exactly what the part is. Assuming, of course, that that part worked. I'm assuming that pin 6 was configured as an interrupt.

The rest of it, with the two comparators, is weird. I suggest that you go back and reconsider it. The first 319 is clearly looking to see if the motor voltage dips due to the motor hitting a stop and the rotor being locked, although that approach isn't going to work most of the time. But the feedback to pin 5 makes no sense at all. You want positive feedback, not negative, and the presence of the zener will effectively annul any feedback effects. I suggest that the feedback should go to pin 4, instead. The purpose of the second comparator is (I think) to detect if the 24 volt supply has completely failed. However, as presented, applying 24 volts through 56k to pin 9 may well kill the 319, regardless of the state of the first comparator. Ablsoute maximum input differential for the LM319 is +/- 5 volts, and this is wayyy greater than that. I suppose it's possible that 56k is enough input current protection that the IC won't actually die, but it's still a gross abuse of the part, and any permanent damage is squarely on the head of the designer.

Plus, of course, a permanently low 24 volt line is already detected by the 74LS14.

So, I can't really criticize the circuit (in the sense of troubleshooting it), since I'm not sure of exactly how you expected it to function. At any rate, I'm not surprised that it doesn't work. Editing your question to give a step-by-step description of your logic would help.

More fundamentally, why do you expect the motor current to drastically increase when the home position occurs? That seems to be the basis for your subsequent circuit. It may be true when the actuator hits a limit switch, but I don't see any reason why it would occur during normal operation. I'll grant the operation of the home switch and the insertion of the capacitor will have some effect, but I'd be very surprised indeed if it had any noticeable effect on the motor supply voltage.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ Thank you for looking at the circuit and I apologize for not making all of it legible. That part of the circuit is a MOSFET that allows the motor to connect to ground. This might look weird on unnecessary with just one motor, but the way these machines are wired are in a grid, with power being supplied through one of the rows (trays) and ground being provided through one of the columns (selections) of the vending machine. So each tray has to have a switch on the top of the motor, and another at the bottom. The part there at the bottom is FDS3890. \$\endgroup\$ – Lev Dec 3 '18 at 15:22
  • \$\begingroup\$ In the design I have in the original post, I had the first comperator there to detect if my pulse was coming out of the other side of the circuit -feeding a pulse at the top, letting pass through the motor that has been connected by selecting the proper FET (only one motor pictured here), and detecting if I get the pulse on the bottom. Logic was that if I do, no capacitor in parallel, so motor is home. But it did not work for 250ms after I had used the motor, so the second comperator and the AND gate was me trying to resolve that without understanding the fundamentals. Will update soon. \$\endgroup\$ – Lev Dec 3 '18 at 15:32
  • \$\begingroup\$ @Lev - OK, so the mystery part is a MOSFET. Then your first figure is horribly incomplete, since you show a cap and two diodes as the components connected to the home switch. With no other components shown, these CANNOT provide a home signal to the rest of the circuit, since they are not connected to anything else. That is why I assumed the MOSFET gate was an output of a sensing circuit. So, how did the original circuit work and why don't you want to use it? \$\endgroup\$ – WhatRoughBeast Dec 3 '18 at 16:52
  • \$\begingroup\$ The capacitor and diodes are connected as shown. They are placed in parallel with the motor by the actuator (all of this is part of the vending machine's motor PCB). How I am detecting if the capacitor is in parallel or not (ergo is the motor home) is by sending a quick pulse (square wave) to the motor and use my detection circuit (differentiator) to see if I have a spike. When I have a spike, motor is not home. When I dont, the motor is home because the capacitor charges (consumes the current). This approach works if the motor has not been on for at least 220ms. Does that make sense? \$\endgroup\$ – Lev Dec 3 '18 at 17:38
  • \$\begingroup\$ I have two places where I can connect to the motor circuit which includes the "Motor PCB" shown in my first image. \$\endgroup\$ – Lev Dec 3 '18 at 18:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.