Determining Direction of Travel

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
n1mie
 
Posts: 11
Joined: Sun Jul 29, 2012 11:58 am

Determining Direction of Travel

Post by n1mie »

I have a project that I'm planning but have hit a little road block. I am certain this can be solved, but I'm not sure how to proceed. I looked through the archives and did find a potential solution, but it looks more involved than may be required (voltage divider network). Any help would be greatly appreciated.

I am looking to track the position of a motor controlled element. The motor is 12vDC and can be driven with either polarity (resulting in up or down movement). Each time the motor completes a revolution, two pulses are received (one each half rotation). The pulses don't allow me to determine the direction of rotation. The direction of rotation can be determined by the polarity of the voltage applied to the motor. I don't need to know the voltage, only polarity. Ultimately I'll be controlling the motor with the Arduino, but I don't want to go there initially (that brings it's own challenges, like the DPDT relay to replace DPDT switch).

Thanks.

User avatar
n1mie
 
Posts: 11
Joined: Sun Jul 29, 2012 11:58 am

Re: Determining Direction of Travel

Post by n1mie »

Hmm. Just had a thought. I could monitor the voltage with a normal voltage sensor after passing through a diode to prevent applying reverse voltage. Then my counter will look at the pulses. If pulses are received with sensed voltage then it's going one direction. If pulses are received with no sensed voltage then it's going the other direction. Simple and doesn't require any additional equipment except for a diode.

Thoughts ...

blbeggs
 
Posts: 12
Joined: Tue Feb 21, 2012 8:44 pm

Re: Determining Direction of Travel

Post by blbeggs »

Your solution sounds pretty ingenious. Usually simple like that is better. However once you get the Arduino hooked up you could use an H-bridge to control direction of the motor and then you would know what way the motor is going because you told it to go that direction. However not knowing the full details of your project, this may not apply.

User avatar
philba
 
Posts: 387
Joined: Mon Dec 19, 2011 6:59 pm

Re: Determining Direction of Travel

Post by philba »

Here's what I understand your problem to be: you want to determine the direction of a motor that something else is controlling. The power to the motor is reversed to change direction.

Your scheme will work but it presumes that you will always have at least a half revolution (to get a pulse). So, a (slightly less than) half revolution forward followed by a (slightly less than) half revolution backward will look like a half revolution backwards when it's a net zero revolution. Maybe it's not an issue but it's hard to tell from your description. If it's not, I'd use an optoisolator. it's a good idea to isolate the motor's voltage from the digital inputs as you can see big spikes due to back EMF

You don't say what the pulses you get are from and I would look into that first. You sure it's not some sort of quadrature encoding (two signal lines)? Assuming you are correct (can't determine direction from the pulses), I would use 2 optoisolators across the motor power terminals, each going a different direction with a blocking diode to prevent reverse polarity to the LED. You would feed the collector (pulled high) from each of the opto's phototransistor into an arduino pin. If both are high, no power is being applied. If one is low, that polarity is being applied. Pretty cheap to do. If you need more details on using the optos, let me know.

User avatar
n1mie
 
Posts: 11
Joined: Sun Jul 29, 2012 11:58 am

Re: Determining Direction of Travel

Post by n1mie »

I suppose it doesn't have to be a secret. I am an amateur radio operator (username here is callsign). My project relates to an antenna on my vehicle. I am using what we call a "screwdriver" antenna. It features a coil in the middle which is used to tune the antenna to the desired frequency. Currently I use a DPDT switch to apply 12vDC (~0.8A) to the motor to do the tuning. By choosing which position (center is neutral, one side is up, the other is down) I use on the switch, I choose which direction the motor rotates and thus whether the antenna is lengthened or shortened (electrically). The antenna has two reed switches that pick up when the motor turns (one each half revolution). As I tune the antenna I periodically transmit and watch the SWR (standing wave ratio) to determine when the antenna is tuned. Given the current and voltage range of the motor, I anticipate using a relay (or several) to control the motor when I get there.

Stage 1:
I tune as now except that I have a visual feedback as to the coils absolute position. This will allow me to, over time, learn which positions correspond to which frequency. In other words, I might determine that 100 turns corresponds to the 40m band. That would allow me to drive the antenna to that position prior to keying the transmitter (I would still key briefly to verify that tuning was correct, and still possibly fine tune).

Stage 2:
The tuning is controlled by the Arduino via switch(es). All else is like stage 1.

Stage 3:
The Arduino is programmed to allow selecting the desired frequency range (antenna position) and automagically drives the antenna there. This would likely either be (a) a menu system with an LCD screen or (b) an array of buttons. Currently there are 9 bands (frequency ranges) for which I anticipate wanting to tune the antenna. Some bands may require more than one position due to the characteristic SWR curve for that band. So an array of buttons may not be realistic.

Unknowns:
1. How long the reed switches are closed.
2. Whether a reed switch can remained closed after the motor stops.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”