Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 15 of 15

Thread: Reading a 5K pot from a distance of 15 meters

  1. #1

    Reading a 5K pot from a distance of 15 meters

    In a project for a granite cutting machine , I need to measure the position of the cutting head using a 5K multiturn pot.

    I chose the Teensy3.2 because of the 12 Bit analog resolution. The grinding head position has a span of 1500mm and since I have 4096 bits to represent this each bit will represent 1500/4096 = 0.366mm which is also 3000/4096 = 0.732mV. Good enough.

    But I am a bit concerned about the distance between the 5K pot and the Teensy3.2 - its about 15m long. I am planning to use a 3 core shielded cable ( refer attachment ) and ground the shield to the 0V of the power supply.

    The environment is not electrically aggressive - meaning there are no VFD or high power electric motors.

    So will this arrangement work reliably as planned or I need to take some more precaution against electrical noise ? Why I am so concerned is the cutting head is a heavy mass of around 1200 kgs and any unwanted jitter in measurement would shake up things badly.

    Any better ideas ??

    Click image for larger version. 

Name:	Teensy3.2_Setup.PNG 
Views:	244 
Size:	336.5 KB 
ID:	10395

  2. #2
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,885
    It's an interesting question, but suspect that getting a reliable and repeatable position out of the pot will be tricky. Keeping the enviroment around the pot stable to prevent corrosion etc will be important for this to work the same way in succession.

    The normal solution for things like this is rotary encoders and an end stop, which are much more robust but does mean you need some form of zeroing process at the start which I can see as being exciting with 1200kg. Another option is to get a single channel ADC break out and fit that in the same location as the pot, though even then getting reliable digital data down a 10 meter cable is an interesting ask.

    Given the cost of the machine and the cost of a Teensy or even some other micro controller would suggest you really want to build a scale model and actually test this before you commit to full scale. A simple place to get the parts would be to pull apart a hobby servo and build up your own controller for that hardware

  3. #3
    Quote Originally Posted by GremlinWrangler View Post
    It's an interesting question, but suspect that getting a reliable and repeatable position out of the pot will be tricky. Keeping the enviroment around the pot stable to prevent corrosion etc will be important for this to work the same way in succession.

    The normal solution for things like this is rotary encoders and an end stop, which are much more robust but does mean you need some form of zeroing process at the start which I can see as being exciting with 1200kg. Another option is to get a single channel ADC break out and fit that in the same location as the pot, though even then getting reliable digital data down a 10 meter cable is an interesting ask.

    Given the cost of the machine and the cost of a Teensy or even some other micro controller would suggest you really want to build a scale model and actually test this before you commit to full scale. A simple place to get the parts would be to pull apart a hobby servo and build up your own controller for that hardware
    The first concern of corrosion to the pot is already addressed as I am using a Bourns pot which is inside a weather proof enclosure.

    Rotary encoders would have been a solution but for the need to "Home" in every time they power down.

    Purely from a electrical noise angle you think I will stand to gain if I raise the supply to the Pot to about 10V and again scale it down by a factor of 3: 1 before feeding to the analog pin ? Or maybe I can get many samples and then do a moving average or find the Median to eliminate the noise ?

  4. #4
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,069
    At 15m long, I suspect the best solution is to use two Teensies. One that is located as close as possible to the machine, and other in your control arena. You would connect the Teensys with RS-485 or similar error correcting serial protocol (including using hardware flow control CTS/RTS), and if you need it, ramp up the serial speed as fast as you can get. The teensy at the drill would do a reading, and send 2 bytes, while the other reads 2 bytes (perhaps add a simple protocol for start/stop, other things).

  5. #5
    Quote Originally Posted by MichaelMeissner View Post
    At 15m long, I suspect the best solution is to use two Teensies. One that is located as close as possible to the machine, and other in your control arena. You would connect the Teensys with RS-485 or similar error correcting serial protocol (including using hardware flow control CTS/RTS), and if you need it, ramp up the serial speed as fast as you can get. The teensy at the drill would do a reading, and send 2 bytes, while the other reads 2 bytes (perhaps add a simple protocol for start/stop, other things).
    Teensy with RS232 is known and can do. But directly RS-485 ? Unless I use an external 232-to-485 converter can I go this way ??

  6. #6
    Senior Member
    Join Date
    Apr 2013
    Posts
    1,885
    A teensy can't technically do RS232 since that'd be well out side the voltage spec. The UART can go 3.3V TTL. As far as I know to get RS-485 you use conversion devices/differential op amps to get your balanced signal. Though given what you are doing here it wouldn't be impossible to bit bang the serial out on two pins and then use a standard opamp as your input at the far end. Depends how much engineering you want on it.

    Increasing the voltage and using a divider will gain you a bit, since the noise on the cable will also be dropped by roughly 75% in the divider but you also adding adding effective impedance to the input (teensy is now fed from two restive dividers in a chain), not a huge deal starting with a 5K pot but still something to watch for. If you go for say 1k and 4k divider then you end up with some interesting math in parallel resistance as the pot travels (mid point in travel will be 2.5k and 2.5+4k in parallel therefor not middle electrically). And if you go much above 10K total resistance between Teensy and supply you start the skew the results as well as the ADC is starved of current to actually read. Normally if you want to get an analog signal a serious distance you would try to send a controlled current (say 10ma/volt) through the noise prone/long cable but I think that adds too much hardware at the far end in this case. Would have been the old school solution for this sort of problem in analog control. That and resolvers/syncros, but you really don't want to be adding a couple of amps of 26V 400hz AC power to this design.

    Still a question if the Teensy+10k pot will actually give you the repeatable precision you want, and I think only some testing will get that answer.

  7. #7
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,069
    Quote Originally Posted by MogaRaghu View Post
    Teensy with RS232 is known and can do. But directly RS-485 ? Unless I use an external 232-to-485 converter can I go this way ??
    I meant using an appropriate converter. You could eliminate the 485 and do the error correction in the Teensy/Teensy connection, but it is simpler if you don't have to do the error correction/etc. in the Teensy side of things.

    Note, I'm a software guy, not a hardware guy, but I suspect at that distance you have to deal with noise in the communication channel, either via hardware that does the checking out of band (rs-485) or in software. I would suspect that trying to do an analog signal over 15m without error correction is just asking for trouble.
    Last edited by MichaelMeissner; 04-24-2017 at 01:08 PM.

  8. #8
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,250
    Quote Originally Posted by MichaelMeissner View Post
    I meant using an appropriate converter. You could eliminate the 485 and do the error correction in the Teensy/Teensy connection, but it is simpler if you don't have to do the error correction/etc. in the Teensy side of things.

    Note, I'm a software guy, not a hardware guy, but I suspect at that distance you have to deal with noise in the communication channel, either via hardware that does the checking out of band (rs-485) or in software. I would suspect that trying to do an analog signal over 15m without error correction is just asking for trouble.
    I would like to support Michael's comment and add: the use of Teensy lets you build 'smart' systems, here 'smart poti' and communicate digitally via wire or even wireless.
    Put the teensy local (close to poti) and use digital comms for start, top, read, calibrate etc. Obviously, you need to program teensy properly, as you should do end-to end testing properly!

  9. #9
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    5,679
    Yes, Michael is right, something like this is a good solution.
    Apart from this, I'd use a shielded cable for the digital connection, too. Maybe a CAT6?

    Edit: And i guess, a slow bitrate is sufficiant. Don't go higher than required!
    Last edited by Frank B; 04-24-2017 at 08:47 PM.

  10. #10
    Quote Originally Posted by MogaRaghu View Post
    But I am a bit concerned about the distance between the 5K pot and the Teensy3.2 - its about 15m long.
    It's also possible to convert 0-5V voltage to 4-20mA current, which is more stable over long distances.

    Here are a few examples of voltage-to-current converters:

    http://www.szsunyuan.com/uploadfile/...0mA%20V2.0.pdf
    Click image for larger version. 

Name:	www.szsunyuan.com - ISO V-4-20mA - 4-20MA LOOP POWERED CONVERTERPJw.jpg 
Views:	71 
Size:	38.7 KB 
ID:	10416

    http://www.ebay.com/itm/Voltage-to-C...-/272593999923
    Click image for larger version. 

Name:	eBay - Converter 0-5V to 4-20mA - s-l500.png 
Views:	176 
Size:	271.8 KB 
ID:	10417

    XTR115:
    http://www.ti.com/lit/ds/symlink/xtr116.pdf
    Click image for larger version. 

Name:	Teensy Forum - XTR115 0-2,5V to 4-20mA.png 
Views:	128 
Size:	17.3 KB 
ID:	10419

    NB: Such converters typically need 12V or 24V supply voltage, not 5V.

    To read 4-20mA current signal with Teensy:
    https://forum.pjrc.com/threads/30325...highlight=20ma

    And finally some general information about 4-20 mA current loop:
    https://www.google.no/search?q=4-20ma+current+loop

  11. #11
    Senior Member Constantin's Avatar
    Join Date
    Nov 2012
    Location
    In the yard with a 17' Dia. Ferris Wheel
    Posts
    1,408
    FWIW, I would also go down the path of the RS485 route. Shielded Cat6 cabling sounds like a good plan, i.e. 5V and GND on 3 pairs, the remaining pair using RS485. I'd go for a slew-rated RS485 like the ISL ISL83483/88) and EasyTransfer from Bill Porter to transfer the data.

    That way, you'll benefit from minimal voltage drop on the power supply side and easy implementation (i.e. serial). Plus, if higher resolution ever becomes a necessity, simply add an external ADC to that potentiometer. However, for now I'd simply use a capacitor from analog input to AGND.
    Last edited by Constantin; 04-25-2017 at 09:40 PM.

  12. #12
    The advice above comes from the most experienced + knowledgable + helpful in the Teensy world, so I am intrigued as to why Can Bus has not been mentioned?
    I've moved my work from 6x arduinos with RS485 comms to 5x teensy's with CanBus, and have never looked back. The controller for Can Bus is free on teensy 3.2, the transiever chips are 1, and breakout boards with transciever + termination and slew-rate resistors are available on the bay for ~2.
    Where does RS485 win over Can?

  13. #13
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,069
    I suspect many of us have never used CAN, but it sounds like it would do the trick. The important thing is you use something with error correction and can deal with long wires. Whether it is RS485 or CAN or roll your own protocol, it should be better than assuming an analog read will work on a 15m wire.

  14. #14
    Senior Member
    Join Date
    Jul 2014
    Posts
    2,250
    Where does RS485 win over Can?
    So I looked up http://www.electronic-products-desig...s/can-vs-rs485
    and found as resume':
    RS485 is very simple to implement, very robust from a data integrity as it crosses the wire point of view and very versatile.

    CAN is much better from a higher level protocol point of view and its ability to handle faults and collisions, but is harder to implement in software if a high level library is not available for your platform. *CAN is not so suited to applications where large*blocks of data need to be passed.

  15. #15
    Senior Member Constantin's Avatar
    Join Date
    Nov 2012
    Location
    In the yard with a 17' Dia. Ferris Wheel
    Posts
    1,408
    Sounds like RS485 makes more sense then. There should be zero collisions on this circuit since the teensy at the cutting end will simply be sending a stream of DAQ numbers. Another option is to have the cutter only send data on demand from the controller.

    All collisions on a two-host system can be avoided by going to a full-duplex RS485 signal between the two. Only downside is that will cost you an extra pair of wires.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •