Two Rotary Position Sensors

Hi All,

My project uses a dc motor to drive a lead screw, which pushes a plunger to push a syringe. This needs to be in a small wearable size case. I need a way to count the turns or the angle of the turns so I can make the plunger move in several equal increments over time. This is so it can dispense several equal doses out of one syringe load.

I found an old post which fits the bill. viewtopic.php?t=34065

However, as I’m a newbie, there isn’t enough detail. All I know is it can but done, but how?

I was able to get things set up (incorrectly) in series with two Murata rotary position sensors going to A0 on my Arduino. I was able to get an output on the serial monitor using the code from the Arduino project book #5 Mood Cue (uses a potentiometer).

However, I actually need to set them up in parallel. I know how to physically wire it up, but I’m stumped on the code.

Any help would be appreciated.

I can’t help you with code, but I think you’re using the wrong kind of sensor. A potentiometer would tell you what angle you’re at, but isn’t going to be able to tell you how many turns your lead screw has turned. Also connecting those in series or parallel isn’t going to work because they will interfere with each other.

I think you’d be better off using an encoder to count portions of rotation. For example, if you used an encoder that pulses 200 times per rotation, you would just count pulses while the motor was running and every time you hit 200, you know the lead screw has turned one complete revolution. Need to turn 1/4 revolution? Just count out 50 pulses. In addition, with the right encoder, you will know what direction the screw is turning as well. :slight_smile:

For code, searching “Arduino rotary encoder” should turn up plenty of examples.

I’ve looked at rotary sensors but that doesn’t seem quite right. This is not for partial turns, it’s for many turns. Like 20 turns that gives you 1/8" in linear movement. The guy in the link I posted has done it. Another guy with a similar project to mine has done it. The manufacturer of the rotary position sensors has a data sheet showing dual sensors with a parallel hookup, but no info on coding. See slide #14 - https://www.digikey.com/en/ptm/m/murata … s/tutorial

So I know it can be done, just not how to do it. I’ll try asking the guy with the similar project too. I didn’t realize this was such an esoteric thing that people on Arduino boards wouldn’t be familiar with it. No wonder I’ve had trouble finding info on it.

Hi Fred.

I’ve not ever seen a hookup like that, but it makes sense. The sensors are not really in parallel, there’s two specific outputs. What you’re seeing is the analog equivalent of a digital rotary encoder. It’s a novel approach though and not one I’ve seen as most sensors of this type have a finite number of degrees they can be turned before hitting a physical limit. The sensors you describe can keep turning indefinitely.

I don’t have any information on coding this, but you’d want to do two analog reads and monitor how they change over time to determine the speed and direction your shaft is turning. By taking a snapshot of each analog read, you could calculate the angular position of the shaft. You would still need to start from a know position to figure out exactly how far the lead screw has turned though.

Thanks for the info!