Simple Analog/Digital to USB needed

Thread Starter

cbrooks999

Joined Jul 23, 2019
4
Hi All;

I need to build or purchase (pre-built preferred) a device that can measure the physical location of the rudder on my boat and make this information available via a USB connection on my laptop. The purpose here is to enhance a home built auto helm.

I can build the mechanics no problem but need assistance with the rest:

Option 1) Be able to measure distance (~1 foot hopefully with up to 1+ mm accuracy) via whatever means (laser? Transducer?) and translate the measurement into any digital form.

Option 2) I can set up a long slide POT (i.e. 100k Ohm) via mechanical means (less accurate but will do) and somehow translate this into a digital measurement read via USB

* Any recommendations here?
I’d like to keep my costs down if possible. I’m hoping there is a pre-built simple solution such as the magnetometer I used for compass heading.
Any assistance is appreciated.
Thx!
 

dendad

Joined Feb 20, 2016
3,253
There are quite a few options for the measurement. I feel the best would be an optical rotary encoder, with a center position home calibration sensor.
Then it could be read using an Arduino and output the reading via the USB port, seen as a com port on the PC.
Also, a differential hall sensor could be used, ultrasonic...
Have you used an Arduino before?

Some other folk may have more ideas.
 

Thread Starter

cbrooks999

Joined Jul 23, 2019
4
Thanks. I have not used an Arduino before but sounds like the right direction. Are you able to provide any detail? Would it be optical?
 

dendad

Joined Feb 20, 2016
3,253
Google "ASKmanual.pdf" for a good, but a little old, intro to Arduinos.
The Arduino is a simple micro controller family developed in an Italian school;, and is very widely used and has great on line support.
 

danadak

Joined Mar 10, 2018
3,785
Here is one possibility. Arduino tethered to PC via USB. Snap4Arduino IDE code, the blocks you drag
and drop into middle pane, controls the sprite on right side. Using the A/D in Arduino
your position sensor is read out and converted into a rotation of the sprite. Also the degrees
are spoken thru the PC speaker (you can add blocks to read a button to turn that on and
off).

I am new to block programming so this is not optimal, just an example.

upload_2019-7-30_8-49-39.png

What the IDE does is convert your block programming into Arduino C code and
upload it to Arduino. Note in this case because of speech and USB connection
at run time code is also done for the PC interface. But generally you do not write
C code, you just program with the blocks.

Your sensor needs to give Arduino a V proportional to rotation for this example.
Sensor does not need to be full 360 degrees or linear, you can handle that in
block coding.


Regards, Dana.
 
Last edited:

danadak

Joined Mar 10, 2018
3,785
An explanation of the programming -

upload_2019-7-31_6-37-18.png

The top block when clicked starts the program. That can be converted to when Arduino powers up start the program.

Block 2 runs the code over and over between its arms.

Block 3 gets the A/D value from pin 0

Block 4 converts the A/D value to degrees

Block 5 rounds the value of degrees to integer value

Block 6 Shows the value of degrees in the sprite window

Blocks 7 & 8 speak thru PC the value in degrees. Can be eliminated if you do not want this.

Block 9 turns the sprite to point like a compass

Block 10 a delay so loop of code does not update excessively

Block 11 resets sprite back to 0 degrees to get ready for the next rotation,
so it points ultimately to the correct position angle on screen.
'
Block 12 is for use at a latter time, a messaging block to other variables
and functions in Snap4Arduino

Block 13 is me trying to kill sounds being produced by text to speech capability. Ignore I have that there.


Regards, Dana.
 

Thread Starter

cbrooks999

Joined Jul 23, 2019
4
thank you!

I'm wondering if the Arduino can measure induction? i.e. If I had a metal shaft moving through a long cylinder wrapped in fine wire - would the Arduino be sensitive enough to measure this? That would solve a lot of problems.
 

danadak

Joined Mar 10, 2018
3,785
It would have to be converted to a 0 - 5V DC signal, or in code if its AC, do a pk-pk
measurement over a number of cycles to capture peak, and the AC signal offset to
2.5Vdc and scaled so that its a 0 - 5V pk-pk input to Arduino.

What is part number of sensor, URL to datasheet ?


Regards, Dana.
 

djsfantasi

Joined Apr 11, 2010
5,923
Arduino (and many other microprocessors) can measure one thing. Voltage.

To measure other analog parameters, the code running on an Arduino measures voltage and calculates something else. An external circuit is used to turn what is being measured into a voltage. For example, when measuring current, a known voltage is passed through a shunt resistor of a known value. Voltage across the resistor is measured and with Ohm’s Law, the current is measured.

So, how would you turn variable inductance into a variable steady voltage?
 

dendad

Joined Feb 20, 2016
3,253
A couple of analog Hall sensors with a magnet moving between than could work well enough if the movement was kept fairly small. A lookup table for calibration is then used.
 

Reloadron

Joined Jan 15, 2015
4,878
I have to agree in that if I wanted to know the position of for example a shaft be it a rudder shaft or any other type shaft my first choice is a rotary encoder be it an optical encoder or other type. You may wish to think of things this way. An encoder is merely a type of sensor. In this case you want to sense the position of a rudder. The use of a rotary position sensor is just one of several ways to go about this.

The output of a sensor is a signal which can be any of several types, it can be a voltage, a current or a number of pulses but the idea here is your rudder will have a range of travel. Just as an example from port to starboard let's say 180 degrees of travel with the midpoint being 90 degrees so we could say 90 degrees is a zero and as we steer port or starboard the rudder moves a given number of degrees between zero and ninety. We could even say port is (+) and starboard is (-).

Once you have a sensor chosen for a particular task you may or may not need to "condition" your sensor output from a signal we have to a signal we want. Sometimes the signal conditioning is done in the sensor for us. The end result is we have a signal which is easy to measure and directly proportional to the units we wish to measure.

So what you need to do is think about how much travel your sensor will have and what engineering units you want your sensor to display. Just as an example degrees of port or starboard rudder. Based on that you choose a sensor for the purpose. Make sense?

Then using a micro-controller is one of several ways to go about displaying your data. The Arduino comes up frequently because it is really pretty easy to program and there are literally hundreds of code sample solutions online which with some minor effort can be modified.

Ron
 

danadak

Joined Mar 10, 2018
3,785
Arduino (and many other microprocessors) can measure one thing. Voltage.

To measure other analog parameters, the code running on an Arduino measures voltage and calculates something else. An external circuit is used to turn what is being measured into a voltage. For example, when measuring current, a known voltage is passed through a shunt resistor of a known value. Voltage across the resistor is measured and with Ohm’s Law, the current is measured.

So, how would you turn variable inductance into a variable steady voltage?
Several ways -

1) Excite with sine (produced by Arduino) and measure resonance. That allows you
to measure L which is related to position.

2) Excite with fixed AC signal, use Arduino to compute Avg, RMS, Pk, anyone of
these, again this is related to position.

3) Use in an Osc and measure Freq.....

4) Reflected light off shaft position.....

Regards, Dana.
 

djsfantasi

Joined Apr 11, 2010
5,923
Several ways -

1) Excite with sine (produced by Arduino) and measure resonance. That allows you
to measure L which is related to position.

2) Excite with fixed AC signal, use Arduino to compute Avg, RMS, Pk, anyone of
these, again this is related to position.

3) Use in an Osc and measure Freq.....

4) Reflected light off shaft position.....

Regards, Dana.
I am totally aware of the options you present. But all of them are counting digital pulses or measuring voltage. Meaning there are standard coding methods for every case.

My point was just that a microprocessor cannot measure inductance directly. It can count pulses (over a given time in most cases. As BobTPH pointed out...) Or, let’s say it together, Voltage (within a specific range).

Taking one case for example, in #2, how are you computing the various values? Average of what? Voltage readings over time. RMS of what? Peak values of what? Voltage!

One of the most important techniques to learn in computing is mapping one set of values to another. Many people learn multiple coding techniques in order to accomplish this. The takeaway idea I hope you see is that a) different problems can be seen as simply the same problem - mapping! And b) mapping coding techniques are independent of the mapping desired. And if one learns the genetic techniques, it will serve you for many different situations.

For example, there is the linear function... even apparently complicated mappings can be solved with y=mx+b There is the range function. If x is in the range of x1-x2, then y={y1,y2,...yn}. In some cases, this can also be solved by y=mx+b. Then, there are inversion mappings, y=m*(max(x)-x)+b.

I don’t know if I’ve listed all possibilities, but think I’ve provided enough examples. There are standard model coding models to cover most every situation you will encounter!
 

djsfantasi

Joined Apr 11, 2010
5,923
Thanks. I have not used an Arduino before but sounds like the right direction. Are you able to provide any detail? Would it be optical?
So, gentleman, I’m done ranting...

The free Arduino Integrated Development Environment (IDE) lets you write code and upload it to several microprocessors including all Arduino models.

The code for what you need is not difficult. Read a sensor, calculate what the data represents and output to the device that needs it.

The sensor is critical. I agree with the others that a rotary encoder is your best bet!


You likely can use one of the smaller Arduino models (like the Nano) as it looks like you need one input and one output pin. An ATTiny45 might be all you need, but you’d also need a programming system. Which could be another Arduino (UNO R3) or a stand-alone product (SparkFun programmer).

Or if you need a pretty formatted output, s full Arduino UNO R3 could be used.
 

danadak

Joined Mar 10, 2018
3,785
D’oh! Of course it can measure time. Good point!
And many UPs these days can measure T, they have one in the die as part of the
V reference.

Possibly radio active field flux via counting damaged memory cells......

Or, let’s say it together, so many more measurements, so little time.....


Dana.
 
Top