Absolute Position Encoders are Crazy

Поділитися
Вставка
  • Опубліковано 25 сер 2024
  • This strange-looking disk is incredibly useful in determining the absolute position of a rotating disk. I plan to use it to create an anemometer, which is a device used for measuring the wind's speed and direction.
    I hope you found this video interesting! If you did, please consider checking out my other videos :)
    #encoder #windmill #anemometer #diy #3dprinting #3dprinter #3dprinted #creality #ender #ender3 #prusa #wind #windpower #homemade #fdm #manufacturing #engineering #engineer #electronics #electricalengineering #microcontroller #arduino #arduinoproject

КОМЕНТАРІ • 1,9 тис.

  • @sexynerd34
    @sexynerd34 Рік тому +3861

    That disk is a really interesting visualization of binary

    • @christophersfactory
      @christophersfactory  Рік тому +190

      I agree! It almost seems more intuitive than other methods of teaching binary.

    • @Scotty-vs4lf
      @Scotty-vs4lf Рік тому +30

      @@christophersfactory im not sure what the normal method of teaching would be cuz i taught myself years ago but i could see someone learning with this

    • @ferry6700
      @ferry6700 Рік тому +8

      That disk basically just one and zero but somehow my brain not hurt looking at that 😭

    • @Pistonrager
      @Pistonrager Рік тому +12

      They use this design to make rotary switches with multiple states. Each ring doubling the states. 1,2,4,8,16,32...

    • @Eduardo_Espinoza
      @Eduardo_Espinoza Рік тому

      Mind blown 🤯

  • @FelonyVideos
    @FelonyVideos Рік тому +674

    I am impressed that so many people knew about grey code, and why it is necessary for this application.

    • @christophersfactory
      @christophersfactory  Рік тому +130

      I am too honestly. I’m also impressed that I did enough research for this video to build a working prototype and had never even heard of it, but literally everyone else had 🤣

    • @jabberwocky1707
      @jabberwocky1707 Рік тому +29

      @@christophersfactory
      Lots of electronic/digital techs about here it seems.
      - The way things are with the 'throw away society', possibly lots of former/retired/ unemployed techs. 😞

    • @FelonyVideos
      @FelonyVideos Рік тому +20

      @@jabberwocky1707 20 years at NASA in robotics, but not a tech. ;-)

    • @jabberwocky1707
      @jabberwocky1707 Рік тому +4

      ​@@FelonyVideos
      Design Engineer then, or Project Management, or ...? Just wondering, don't need to be specific.
      - You didn't have anything to do with those outstanding Mars rovers that went *_way_* beyond their original mission length?
      - Maybe grey code is 'old hat' as there are possibly other methods to achieve position measurement?
      - One method IIRC used for 3D sight positioning determination for HMSD (helmet mounted sighting devices) to aim missile/gun 'by eye', used pulsed magnetic fields of different frequencies so the axes (2 or 3?) can be discriminated from each other.

    • @FelonyVideos
      @FelonyVideos Рік тому +16

      @@jabberwocky1707 first analyst, then designer, the project manager, then department manager, then independent consultant.
      The supercomputer that we ran our simulations on was the best in the world at the time- it had an unheard of 64k of core memory. 😂

  • @ghostinmatrix
    @ghostinmatrix Рік тому +123

    You should consider swapping to gray code to avoid synchonization issues between the bits. Otherwise you might run into miscounts.

    • @michaelbuckers
      @michaelbuckers Рік тому +5

      The cool part is that the patterns are actually the same. Just by cleverly shifting them, you can make it such that only exactly 1 bit changes at a time. This eliminates read timing errors due to bits not physically toggling exactly simultaneously. Though this specific disk contains clock pulse ring which through additional hardware also eliminates read timing errors.

    • @JohnIdlewood
      @JohnIdlewood Рік тому

      I suppose, not every gray code is easy to 3d print

    • @michaelbuckers
      @michaelbuckers Рік тому +3

      @@JohnIdlewood Gray codes are easier to 3d print actually, because only 1 hole can appear at a time and everything else is still solid.

  • @TwisterKidMedia
    @TwisterKidMedia Рік тому +83

    Yes. Most directional anemometers use a potentiometer. Lowest resistance value is set to north and you can calibrate direction based on the resistance.

  • @jwstolk
    @jwstolk Рік тому +541

    You should use gray-code for the disk and convert to binary in the microcontroler. Your binary disk needs multiple sensors to switch exactly at the same time, which will never happen in practice. Gray-code only has one bit change for each angle so the sensor data is always consistent.

    • @lezbriddon
      @lezbriddon Рік тому

      WHS

    • @Crlarl
      @Crlarl Рік тому +5

      I approve this message.

    • @martongilicze8378
      @martongilicze8378 Рік тому +12

      Came to say this!

    • @anonymouscommentator
      @anonymouscommentator Рік тому +14

      plus in grey code you always know where you are right now even if the disk stops between 2 segments (it will either put out the left or the right portion of where it stops). here in this disk the sensors will give out arbitrary values and you wont be able to know which portion you are on right now

    • @Piccodon
      @Piccodon Рік тому +2

      Compass sensor. CDS cells old hat analog. Too many wires and sensors.

  • @juliusfucik4011
    @juliusfucik4011 Рік тому +1001

    There is a simpler way, but please continue. I want to see it work.

    • @jeromewink557
      @jeromewink557 Рік тому +65

      Yeah. Watched then and started laughing. I do think it will work but I remember in College they said unread better to use a different encoding order wherein no more than one bit changed per step.
      Am I on the right track?

    • @MarbleStarry
      @MarbleStarry Рік тому +76

      ​@@jeromewink557Yes you are on the right track! With regular binary encoding, multiple bits will change on each angle and unless all of the sensors switch state at the EXACT same moment, there will be wildly off false readings during the transition between angles. That specific order of code where only one bit changes per angle is called Gray code, or Gray encoding. :3

    • @jeromewink557
      @jeromewink557 Рік тому +5

      @@MarbleStarry which now that you have said that and I think about his design he’s going to need layer outside his ring with holes offset from the reading that he can use as a trigger. Or he needs to offset his LSB to slightly trail the rest of the disc and use it’s bounced been logical 1 and 0 as a trigger to read the value.

    • @frankens43
      @frankens43 Рік тому +16

      Make the outer ring of dots a smidgen smaller, and make a latching circuit to enable 'valid position' detection during the rotation. This would eliminate transitional errors. Also, key the center of the hole so the shaft is fixed to the shaft in a way that cannot slip or be out of alignment.

    • @oscargr_
      @oscargr_ Рік тому +11

      ​@@frankens43 I was thinking the outer holes were there exactly for that purpose.
      Trial and error will show they are small enough.

  • @rewolff2
    @rewolff2 Рік тому +309

    Use gray code: now say between "south" and "south-southwest" all bits will change. In practice that doesn't happen exactly at the same time. Thus you'll get a bunch of other directions when the vane goes between those two states. Gray code has only ONE change every transition, thus when it is somewhere in the middle between two states, it'll show one or the other but not a totally different state.

    • @GordieGii
      @GordieGii Рік тому +7

      And there is a simple circuit that will convert gray code to binary.
      Also you can save some diameter by putting the sensors for the highest bit and second highest bit on the same ring, but 90 degrees apart.

    • @MorsDengse
      @MorsDengse Рік тому

      Why you have the sync in the outer ring ...

    • @GordieGii
      @GordieGii Рік тому +4

      @@MorsDengse If gray code is used you don't need sync. The outer ring could be used to double the resolution, or eliminated to make it more compact.

    • @MorsDengse
      @MorsDengse Рік тому +1

      @@GordieGii Im certainly not disputing that, just noting why the outer ring is there, as it wasnt mentioned.
      On another note. No one in their right mind would use such a contraption today : )

    • @GordieGii
      @GordieGii Рік тому +4

      @@MorsDengse The sync signal is an obvious solution for someone who is ignorant of the existence of gray code, which the OP admits he was.

  • @suddeneevee9441
    @suddeneevee9441 Рік тому +14

    My first thoughts for angle sensing would be a magnetic sensor. Not exactly sure what they are called, but they used the Hall-effect to sense the magnetic field.

  • @xenontesla122
    @xenontesla122 Рік тому +1363

    Cool! A Gray code encoder might be more durable.

    • @christophersfactory
      @christophersfactory  Рік тому +385

      Wow! I can't believe I've looked into these encoders this much and haven't seen a Gray Encoder. That looks dope, thanks for the heads-up!

    • @savagesarethebest7251
      @savagesarethebest7251 Рік тому +120

      Grey encoding was my first thought, then I saw that it was binary ^^

    • @GordieGii
      @GordieGii Рік тому +25

      @@christophersfactory You could go with just 4 sensors. 2 grey code for the four compass points and the other 2 for quadrature (incremental) in between. But then you would have to implement a quadrature decoder. (circuit or software)

    • @xXIkaron
      @xXIkaron Рік тому +22

      ​@@christophersfactory Another thing that'd be much easier to manufacture would be essentially a potentiometer. To the shaft, add a disc with an inner and outer copper brush (a little bent strip of copper will work), connected with copper wire. Add a second (fixed) disc on a bearing, on it, have a copper wire/plate circle that the outer brush fully touches, regardless of rotation. On this outer ring you put some input voltage. For the inner ring, use graphite or resistive wire or so. Make sure this ring has a tiny break in it Connect a copper wire to this ring at the break. Now you can measure the resistance between the two wires dependent on axis position. Make a voltage divider with a resistance that fits your purpose. If your ring has a resistance from 0-100kOhm for example, you could choose a 10kOhm resistor to divide with to get an output voltage between 0 and 89%. You can read this on an analog pin and by measuring different points (careful: Not linear!) you can create a map/approximating function that calculates angle from voltage.
      Imo easier to build and you can make it much smaller and can be useful if you have few digital pins available. Downside is, you need an analog input or ADC. Also, the longevity will be much shorter than your photo resistor approach which is why I think your approach is better for your use case. Just be aware that the accuracy is fully determined by the angle of the slots on the outermost ring, which in your case is ~3 degrees. You can also get significant jitter if the direction changes on a boundary of a slot, meaning your readings could look like 3°,6°,3°,6° even if the actual direction barely changes. If that is good enough for you, perfect!

    • @namibjDerEchte
      @namibjDerEchte Рік тому +17

      ​@@xXIkaron potentiometers are kinda ugly for this, especially compared to photodiodes.

  • @der.Schtefan
    @der.Schtefan Рік тому +109

    You should swap the encoding out with a Gray encoder. Those rearrange the binary numbers so that each transition always only changes one bit, instead of binary where multiple bits flip. This is used for disc encoders to prevent intermittent wrong signals when multiple bits flip and not all sensors are crazy perfect aligned (which they never are)

    • @Dysan72
      @Dysan72 Рік тому

      also is should allow for a more supportive structure.

  • @siavachgmailcom
    @siavachgmailcom Рік тому +6

    The main issue with this approach js the noise. If your bits don’t flip at the same time, you will read a bunch of odd angles during transitions. There are ways to fix that though. Easiest is to reorder the numbers so that only one bit changes at each transition. It is easy to build that sequence recursively for any number of bits. You might want to look up Hamming Distance. It is used in error detection and correction.

  • @thegeek3295
    @thegeek3295 Рік тому +13

    To determine direction you only need to signals A & B slightly offset by ~20 deg. And two LDRs.
    If you see AB..AB..AB.. thats one direction, if you see BA..BA..BA thats the other direction. And by counting A only you can also determine RPM / speed based on the circumference at location A.

    • @treelineresearch3387
      @treelineresearch3387 Рік тому +2

      That (incremental encoder) just tells you what direction the encoder has moved, not where it is. You can track an incremental encoder to kinda fake an absolute one with a dead reckoning sort of mechanism, but absolute has advantages like it just telling you the state (position) without needing any zeroing/calibration, and not needing any memory to track the absolute position from step deltas.

    • @DejitaruJin
      @DejitaruJin Рік тому +1

      @@treelineresearch3387 That is true, but the stated intent in the video was just determining direction of rotation.

    • @jamesharrell4360
      @jamesharrell4360 Рік тому +1

      ​@@DejitaruJini thought he was just looking for the angle of the wind and not the direction of rotation.

    • @DejitaruJin
      @DejitaruJin Рік тому

      @@jamesharrell4360 After re-watching, yeah, I retract my statement; my mind interpreted "direction" as in _motor_ direction (where you'd usually find such an encoder disc) instead of _cardinal_ direction. I imagine the commenter at the top of this thread made the same mistake.

    • @johndododoe1411
      @johndododoe1411 Рік тому

      When I built one in class, I used two offset sensors on a one bit wheel for direction and change, plus a third sensor for passing North . The wheel was 2D printed on transparent plastic, 3D printing neither needed nor invented . A reflective paper disc would have been even simpler, but the class was focused on writing the code .

  • @sburgh014
    @sburgh014 Рік тому +27

    You should have used grayCode instead of simple Binary. Therfore you don't have errors on the boundaries, which you will probably have now if the angle is near the pattern change..

  • @NurchOK
    @NurchOK Рік тому +67

    Gray code is also recommended to make sure only 1 bit changes during a transition

    • @budderguy2128
      @budderguy2128 Рік тому +1

      I was going to mention it as well, that one bit change per digit is really useful on stuff that moves quickly. They use it a lot for government radar dishes because of the reliable speed and precision they provide.

  • @ZOCCOK
    @ZOCCOK Рік тому +1

    For those who are wondering what "Grey Code" is:
    Grey Code is a binary system (1,0) where only 1 bit changes between each step/element (Only 1 change, unlike normal binary which can have multiple changes between each step/element).
    Example:
    Binary: Grey Code:
    7 = 0111 7 = 0100
    8 = 1000 8 = 1100
    As one can see, in Binary, 4 bits change when it goes from 7 to 8 (First Zero changes to a 1, and the last three 1's change to 0); Whereas in Grey Code, only 1 bit changes when it goes from 7 to 8 (Only first zero changes to 1)

  • @VonSchpam
    @VonSchpam Рік тому +3

    An easier way to tell which way the wind is blowing?
    I put a rag on the end of a stick. I call it my Fluctuating Lateral Air Gauge or FLAG for short.
    ;)
    But the binary thing is pretty cool too.

  • @JoshuaTuttle18
    @JoshuaTuttle18 Рік тому +50

    Incremental encoder with a and b signals with proper offsets. Uses a 3rd of hardware and is easier to print and fabricate. Obviously what you did is really cool. Nice job

    • @Graham_Wideman
      @Graham_Wideman Рік тому

      How will the microcontroller know the absolute direction of the weather vane?

    • @oscargr_
      @oscargr_ Рік тому +3

      ​@@Graham_Wideman You re absolutely right.
      If it was on a motor, you could add a calibration vane , but this is supposedly free rotating in the wind.
      You re not going to wait for a specific wind direction after every time you power this thing.

    • @mikoaj2323
      @mikoaj2323 Рік тому

      Yeah but after losing power in the system you no longer know the position of the encoder, also incremental encoders are loosing steps. It's good for some aplications like encoder in 3d printer for screen control, but it won't work in getting position of stepper motor in 3d printer for example, it's too unreliable.

    • @merendell
      @merendell Рік тому

      One issue with incremental is it only counts steps and does not give absolute position. Fine if you can A capture all the steps and B calibrate every time power goes out. However on power up the system has no idea what direction its pointing and just starts at 0. if you normaly consider 0 as north but you boot it up while wind is west its going to tell you its north.
      Advantage of an absolute encoder is it does not mater what state its in. If its outputing a 10 and you know 10 = west it just works. you only have to figure out the alignment once.

    • @drozcompany4132
      @drozcompany4132 Рік тому +1

      @@merendell He said he wanted direction, not position.

  • @A_Terrible_Person
    @A_Terrible_Person Рік тому +87

    there is a simpler way it's called a wind sock but this is awesome

    • @egg5802
      @egg5802 Рік тому +6

      The idea is to be able to know the wind direction without looking outside or being within range of sight of the measuring device (and maybe as cheaply as possible?).

    • @Mynameisnunyabusiness
      @Mynameisnunyabusiness Рік тому +9

      Windsock and camera. Encoders are expensive because they’re typically used on servos/robotics.

    • @robertball3578
      @robertball3578 Рік тому +8

      Old school was a segmented ring with only one section energized and a series of contacts around the perimeter. The contact with power lit a bulb to show the wind direction. You don't need half degree resolution and hundred dollars in parts of the input is a wind vane.

    • @maskarovortzy6947
      @maskarovortzy6947 Рік тому +3

      wind sock on a potentiometer...

    • @MrRickkramer
      @MrRickkramer Рік тому +2

      Wet finger works or looking at foliage or water…

  • @t3hpwninat0r
    @t3hpwninat0r Рік тому +1

    if you just want to tell which DIRECTION the wind is blowing, have a transparent disc with a gradient printed on it. the resistance will either gradually increase and then suddenly drop and start over, or do the reverse. you could also tell the speed by how often those restarts happen and it will be more accurate because it happens only once per cycle.

    • @wedmunds
      @wedmunds Рік тому

      Or just a potentiometer :)

  • @X4Alpha4X
    @X4Alpha4X Рік тому +2

    Since photoresistors dont output a discrete voltage, why not just have a spiral inside the disk so you can get an analog reading from the row of resistors? So like 0 degree rotation would mean the furthest diode is the lowest, and 359 degrees the closest diode, the middle diode 180 degrees, etc

  • @volo870
    @volo870 Рік тому +2

    The simpler way is a variable resistor, but your solution has its merits.
    Back in the day, Amiga mice worked using similar principle, but two bits was enough - six bits is an overkill.

    • @wedmunds
      @wedmunds Рік тому

      An elegant solution, but it will have to be an endless potentiometer as the wind direction is not guaranteed to never make full rotations

  • @wilurbean
    @wilurbean Рік тому +28

    Yes, you can use a single photo resistor and vary the thickness of the disk. So a single circle, progressively thinner, single LED pointing towards the resistor. Thickness of the disk blocks more or less light.
    You could use more circles for more granularity, in the same vein of what you have.
    You could probably achieve the same effect with a thin, single, or double layer on the bottom and use pin holes. So 120 deg with no layer, 120 deg with one layer, 120 with two layers (on the bottom). Instead of having large holes around the edge, each 120 deg segment has 12 sub sections where it's made of 0-11 pin holes. The light goes through the pin holes, hits the bottom layer, diffuses and creates a uniform but unique amount of light.
    You could also use different colors of filament and different LEDs. Green filament absorbs mostly green light. So if you pointed an rgb led at the diffusion. Layer, a green filter would leave rb, red filter gb, blue - rg

    • @D3nn1s
      @D3nn1s Рік тому +3

      Very smart use simple mechanics instead of complex digital methods. Basically bulletproof. Unless it would be subject to dirt or he plans to use sunlight for it. Wouldnt work then either

    • @223556762308
      @223556762308 Рік тому

      Elegant solution.

    • @wilurbean
      @wilurbean Рік тому

      ​@@D3nn1sI think this is the first time I've ever seen an old comment and wasn't disappointed in myself

    • @D3nn1s
      @D3nn1s Рік тому

      @@wilurbean in yourself? Did you come across the same ahort again while scrolling or what?
      Your comment was very smart or sensible, so yeah :)

  • @warlorddelta8
    @warlorddelta8 Рік тому +1

    I've often found that in any gust of wind, there can be a flag placed within its path to best indicate its direction.

  • @Sidman723
    @Sidman723 Рік тому

    This many positions is good for telling exactly what position the disc is at. Also can be used to tell direction and speed at which the direction changes. Very nice.

  • @7bitscience
    @7bitscience Рік тому +7

    I had also been interested in making my own anemometer at one point, but I felt that these ones where you measure something spinning might not hold up well. I did some digging and found out about ultrasonic anemometers. Because sound is transmitted through air and wind is air moving, that can make a sound wave travel faster or slower depending on the direction, I think. So the idea is that you could take two of these transducers, aim them at each other, and see how long it takes for the sound to travel between them, at least that's how I think they work. If you add another pair perpendicular to the first pair, then you can calculate the vector of the wind direction. You could even add another pair facing vertically and measure the wind in three dimensions.
    I think these seem better than traditional anemometers because normally there would be some resistance to getting something spinning, so there would be a minimum speed that you could measure, but I think that an ultrasonic anemometer would be able to measure a lower wind speed.
    I never actually did anything more on this project than research, but it will be neat to see what you do next.

  • @MrEdwardhartmann
    @MrEdwardhartmann Рік тому +8

    We used very similar encoders like this in some navy equipment accurate to .1 degree. They were plated on a glass disk. And it used gray encoding to simplify timing. The key to gray encoding is that only one bit changes between each number.

    • @microcolonel
      @microcolonel Рік тому +1

      Gray coding also helps with analog resolution. On optical encoders, you can read partial activations and get better instantaneous velocity readings (where you would otherwise need to integrate).

    • @MrEdwardhartmann
      @MrEdwardhartmann Рік тому

      @@microcolonel I like the "self clocking" aspect of the gray code the most. A simple "or" gate of all the inputs, and you have your clock. No need to an extra clock input. On the design in this video, I think the holes on the outside edge are for clocking. But since that input needs to be narrower than the data bits, it just takes up more room and results in less resolution. In the same size disk with the same size bits, you could get at least one more digit of resolution if you changed the clock bit to a data bit.

    • @RiverMersey
      @RiverMersey Рік тому

      Yes, rather than 3d printing this, it might be laser printed onto plastic sheet meaning it could be smaller, use a greater number of bits

    • @ahaveland
      @ahaveland Рік тому

      I think this is mounted horizontally to give an absolute bearing of the wind. This is not connected to the blades to measure rotational velocity.
      The binary code changes in direct relationship to the angular position.
      No timing involved.

    • @MrEdwardhartmann
      @MrEdwardhartmann Рік тому

      @@ahaveland Sorry, you miss understood what I was talking about. I was talking about clocking in multiple binary bits into some type of reader, like a microprocessor. If you study this wheel, there are 5 data bits and one clock bit on the wheel. The holes on the outside edge are the clock bits. When one those holes allows light to illuminate the sensor under it, all the other sensors should also be in position for reading, so the pulse caused by the hole can be used to clock in all the other bits. You can't just use the data bits themselves because more that one bit can change between one position and the next, but with gray code, only one bit ever changes, so you can use the change of data bits to act as the clock. All you need is a simple multi input 'or' gate connected to each input or a little code in the micro you are using. So, on the same size wheel, you can use that clock bit position as an added data bit and get 6 bits of resolution instead of 5. Wikipedia has a good discussion on gray code if you are interested.

  • @JeanFrancoisDesrosiers
    @JeanFrancoisDesrosiers Рік тому +1

    There is math solution for optimal mecanical - numerical encoding. Gray code. If the disc was using piercings according to gray you can easily also determine speed and direction of the disk. With already available code.

  • @scottpearson9846
    @scottpearson9846 Рік тому +1

    Yes. You could have simply taken a senor and a wind sail. The wind sail turns when filled with air, showing you where the wind is coming from.
    I think they normally use a sock type one for this device.
    This thing you made would be good if you had a gear box for wind. You could have it swap gears as it moved to each faster ring on the sensor.
    You didn't make a directional input, but a speed tracker

  • @angelorf
    @angelorf Рік тому +5

    Don't forget to add a back light for consistent lighting conditions and add a north sign to the design so that you can mount it aligned with a compass.

  • @louielunch3172
    @louielunch3172 Рік тому +3

    Only 2 optical sensors are needed to determine direction. Both located on the outer set of holes. Place them 1.5 x the hole distance apart.
    If sensor A goes high when sensor B is high you going CW. If sensor A goes high when sensor B is low your going CCW.
    This is how optical encoders function.

    • @RobertLockhartMakesGames
      @RobertLockhartMakesGames Рік тому

      Came to say the same

    • @christophersfactory
      @christophersfactory  Рік тому +1

      Yes, what you have described is a rotary encoder, but without any absolute reference it cannot tell you anything useful other than when it is spinning. Without a reference, you’d have to calibrate it every time it starts, and you’d have to ensure it never loses power, otherwise you’d have to calibrate it again.
      The idea with an absolute position encoder is that it can always tell which direction it’s facing based on the physical layout of the disk. As long as it doesn’t get moved, 00000 will always be north, for example. I have another anemometer I made with a rotary encoder used in tandem with a limit/end switch. The switch gives it a reference, so that it can say, “Alright, any time my rotation closes that connection, I am facing north.” From there, the rotary encoder can tell how many clicks from that reference it has spun. It would still need to calibrate by making at least one full spin every time it turns on, though.

    • @RobertLockhartMakesGames
      @RobertLockhartMakesGames Рік тому

      @@christophersfactory It counts stripes as they go by. It knows how many stripes are around the perimeter, so as long as it knows which direction it started in (sometimes encoders have a 3rd sensor for this) it can tell you what direction it's facing now. So that's a maximum of 3 sensors for arbitrary precision, rather than needing log2(precision) sensors.

    • @camforman
      @camforman Рік тому

      Good idea but as people below point out you need an absolute reference. One way to do this would be to add a 3rd 'home' sensor on a second track. This would be easier and cheaper but would leave you with garbage data between power failures and when the wind passed through north again. Another option is a single track grey code (see Wikipedia on Grey code) it would require an extra sensor for the same precision but could be done with a single but elaborate track instead of the 5 or 6 here

  • @veitforabetterworld
    @veitforabetterworld Рік тому

    One possible improvement: use gray code to encode the binary number. Gray code not just makes it easier to 3d-print, it also reduces the error, if any sensor has a wrong reading

  • @SupernovaSpence
    @SupernovaSpence Рік тому +2

    Indeed, there are waaaaaayyyy simpler ways but like everyone else says, please keep going.

  • @JDWatkins
    @JDWatkins Рік тому +8

    Easier ways, sure.. More interesting... Probably not. I have a question though. Are you going to create a compete weather station? You need to keep us updated.

    • @christophersfactory
      @christophersfactory  Рік тому +2

      Thank you!! Yes, a complete weather station is definitely in my plans. I’m trying out a whole bunch of different things right now to see what I think is promising. Glad you’re following along. Eventually, when I’m living in a larger space, I would love to have a self-powering, IoT weather station. Probably a little too ambitious for this little balcony though. 🤣

  • @awakened-planet
    @awakened-planet Рік тому +15

    Yes you should simply just connect the weather main to a potentiometer and then read the resistance and set each direction to its resistance value and write a simple interpolation that way you only need one component rather than several photo resistors and a binary disc

    • @indian.techsupport
      @indian.techsupport Рік тому +4

      A pot has way too much mechanical resistance for his application

    • @AchievedZeus574
      @AchievedZeus574 Рік тому +3

      That won't allow for an infinite 360° rotation. The correct part would be a rotary encoder

    • @maquez650
      @maquez650 Рік тому +3

      @@AchievedZeus574 360 degrees potentiometers exist

    • @TheOfficialOriginalChad
      @TheOfficialOriginalChad Рік тому +1

      @@maquez650 yes 360 does, but not infinite. When the pot reaches its limit you can’t nicely ask the wind to change directions.

    • @D3nn1s
      @D3nn1s Рік тому +1

      @@TheOfficialOriginalChad how do car stereos/climate controls etc work then? I guess they would need constant power in order not to loose their position, but that should work.

  • @BurnabyAlex
    @BurnabyAlex Рік тому

    using Gray code lets you have an absolute encoder where only 1 bit changes at a time, which fixes the errors you would get on the edge case where 2 bits may have fuzzy edges read by the optical sensors.

  • @jeffsaxton716
    @jeffsaxton716 Рік тому

    I worked at a steel rolling mill and was in charge of the automation. The system was circa 1970 and used a couple dozen of these. They were high resolution and each one cost around $12,000.

  • @BooBar2521
    @BooBar2521 Рік тому +10

    You basically need only one of your rings and two light gates. Your ring hast to be in the pattern 101010. Based on wich of your light gates turned on or off first you can say in wich direction it turns. And you can count the wind speed as well. In German we call this thing "Drehgeber"

    • @crion98
      @crion98 Рік тому +2

      In english it is a rotational encoder

    • @psywiped
      @psywiped Рік тому +1

      Sounds like he's going for absolute direction and not just left or right.

    • @Jason-hz2jy
      @Jason-hz2jy Рік тому

      @@psywiped he can get absolute direction by measuring it and than calculating the new position with every turn the

    • @psywiped
      @psywiped Рік тому

      @@Jason-hz2jy what if it lost power or steps?

    • @darwinboor1300
      @darwinboor1300 Рік тому

      This will not tell direction since the code from any starting point will be either 1010... or 0101... depending on the starting point. Simplest solution would be analog using a circle of wedges. Increasing signal over time implies one direction and decreasing signal implies the opposite direction. Also provides direction with smaller fractional movements.

  • @Michael_Galgano
    @Michael_Galgano Рік тому +7

    I think a wind sock and a pair of eyes have done a good job over the years but go for it!

    • @Ed70Nova427
      @Ed70Nova427 Рік тому +1

      Exactly and add a camera with a solar panel if its location is out of sight. Even using an old farmers barn wind vane with a camera looking down and at a pointer and dial.

  • @klo1679
    @klo1679 Рік тому

    It’s also a very good representation on how a digital storage disk works.

  • @hlavaatch
    @hlavaatch Рік тому +1

    1) You need gray code not plain binary, otherwise you will get nonsense codes at boundaries.
    2) Photoresistors are probably too slow to react for this purpose. Try phototransistors or photodiodes as a sensor

  • @Ravenscaller
    @Ravenscaller Рік тому +61

    Well OK I see what you are doing but you could just wet your thumb and hold it up in the wind. Simple hu. LOL

    • @christophersfactory
      @christophersfactory  Рік тому +12

      Haha. A good idea to be sure. I’d love to see an Arduino sensor that can read a windy, wet thumb though 🤣

    • @yarnsags
      @yarnsags Рік тому +1

      ​@@christophersfactory You can for speed. See hot wire anemometers.

  • @grapes008
    @grapes008 Рік тому +3

    I think you should use reverse photo diodes in reverse polarity instead of LDRs. Oh you could also just use a magnetic rotary encoder. Most have a very high Resolution

  • @domi-no1826
    @domi-no1826 Рік тому

    The disc seems to be counting up, so each value will say where the wind is
    (Edit)
    It can track 16 positions and speed using the outer dots. By counting 0-15 twice for 180°. It seems like a good measure
    0 n/s
    2 nne/ssw
    4 ne/sw
    6 nee/sww
    8 e/w
    10 see/nww
    12 se/nw
    14 sse/nnw
    16 s/n

  • @aerodigital
    @aerodigital Рік тому

    You only need two points on a disc to tell which direction it is spinning. This disc would only be necessary if you needed to provide data instead of a simple rotation signal. You still have to implement to your use case.

  • @no1bandfan
    @no1bandfan Рік тому +4

    A recently licked finger: *I’m gonna end this whole man’s career!*

  • @christophersfactory
    @christophersfactory  Рік тому +220

    These are normally very expensive (amzn.to/3jEGN9r) hence trying to make my own :)
    Be sure to check out part 2, where I took your suggestions into account! ua-cam.com/video/lwLOwk8zhh4/v-deo.html

    • @taintedsasquatch398
      @taintedsasquatch398 Рік тому +14

      Hall effect sensor.

    • @vogonjelc
      @vogonjelc Рік тому +27

      Great job but check Gray code. It might be better then put binary pattern you have there

    • @Joshinken
      @Joshinken Рік тому +10

      Yes when you get one thats made for 3000rpm they tend to cost quite a lot, but you can also get one for 10-20 bucks

    • @Joshinken
      @Joshinken Рік тому +2

      @@taintedsasquatch398 thats an amazing solution that absolutely doesnt do anything, you can’t just slap a hall effect on something and have that work all of a sudden

    • @Graham_Wideman
      @Graham_Wideman Рік тому +5

      @@Joshinken An absolute position encoder can be more expensive than a relative encoder. The former incorporates a disk with 8 to 12 or more tracks, whereas the latter only need two tracks and a special zero mark that the system has to find each time it starts up -- not really practical for a weather vane.

  • @KarriKoivusalo
    @KarriKoivusalo Рік тому

    Interesting project! My design choices would be gray code encoding, arc slots instead of completely open and connected sectors for better mechanical integrity and an electro/photoetched brass or stainless steel disc.

  • @BrettDalton
    @BrettDalton Рік тому

    Rotary encoders can be built with only 2 rings and a switch to know the start position. Offset of which ring switches first can tell you a direction.

  • @rajveersingh2056
    @rajveersingh2056 Рік тому +1

    Well, this is smart,
    However, all you need to detect is the rotation of the wheel, for that, you can simply use a potentiometer, and depending upon the value of resistance detected, you can find out what direction the wind is blowing.

  • @klausl.2212
    @klausl.2212 Рік тому

    That's one of the mechanisms in an elevator-door-controller (open normal speed, low speed, open-position)
    Close normal speed, low speed, close-position

  • @jared_s2
    @jared_s2 Рік тому

    in cnc machines this is how servo motors keep track of their "reference position" and how the motors know how many revolutions to turn to move spindles, turrets, and other axes.

  • @LordPhobos6502
    @LordPhobos6502 Рік тому +1

    You can buy rotary encoders to do this sort of job, or use a directional magnetic sensor (e.g. AS5600) with a magnet on whatever spins. The magnetic sensor will be more reliable than a photosensor.
    If you want to continue the diy approach, I'd use slits instead of holes around the outside :)

  • @flurng
    @flurng Рік тому

    Another alternative would involve a more "analog" approach: create your disk with a single "slit" that gets progressively wider as it rotates in a given direction. Next, shine a light onto the disk, then through a lens which focuses it onto a single photoresistor. Now, simply read the resistance of your device to determine its position.

  • @iancockrell5920
    @iancockrell5920 5 місяців тому

    You can use an incremental encoder to measure the direction as well. One photoresistor (out of 2) will always lead or lag behind the other. You simply measure at the falling edge of one bit. If the other is a logic high, you are spinning one direction. If the other is a logic low, you are spinning the other direction.

  • @dfoster9445
    @dfoster9445 6 місяців тому

    def an easier way to find the direction, but it's awesome for absolute positioning.

  • @GRAHAMAUS
    @GRAHAMAUS Рік тому

    Look up Gray Code and make your encoder with a Gray code for the number of bits you want. That way, only one bit changes with each position, making the encoder much less prone to false outputs as it moves from one state to the next. It should also make it easier to print and more robust.

  • @sharkzilla6747
    @sharkzilla6747 Рік тому +1

    That looks exactly like the things R2-D2 uses in starwars

  • @Philip_Millies
    @Philip_Millies Рік тому

    There might be a simpler way but I like this way because you could use it to get more info, not just direction. A second thing you could get from it would be the speed of the wind.

  • @fummy33hotmail
    @fummy33hotmail Рік тому

    A propeller attached to a motor. The polarity would change depending on the wind direction as well as being able to tell you the intensity

  • @lariwoo
    @lariwoo Рік тому +1

    urinate into the air, if you stay dry the wind is blowing away from you, if you get wet the wind is blowing towards you. one of the first life lessons;)

  • @repalmore
    @repalmore Рік тому

    Yes, you over thought it. Slotted disk with two slightly offset opto sensors. Direction can be determined by which drops first and speed by counting one of them.

  • @bobbybob5182
    @bobbybob5182 Рік тому +1

    you could have just used a HMC5883L magnetometer module to track the horizontal rotation by using the module as a digital compass

  • @DiThi
    @DiThi Рік тому

    If you don't need the absolute position, just having stripes and 2 sensors (offset by half step) works pretty well. Each change is a step. The 2nd sensor is used to determine direction (whether the change is equal or opposite). That's how old ball mice and current mice wheels work. If you DO need absolute position you can just add another sensor with just one signal in one spot of the wheel. Absolute encoders (like gray codes) are ideal for not losing the position if you lose power, but I can't think of many uses where you really need that.
    Another way to have absolute position is to have a 2 axis magnetic sensor with a magnet on top of it. The resolution in this case depends on the ADCs used. Some sensors have the ADCs already included with some other features, like with the chips AS5147 or AS5047P which are designed for this purpose.

  • @joshd2013
    @joshd2013 Рік тому

    The simplest way to see what way the wind is blowing is just to go outside and feel what direction it's blowing from

  • @ericanderson2482
    @ericanderson2482 Рік тому

    I like an analog solution to this, but it might not have the consistency or precision you want. I use an infinite turn pot and an AtoD converter. The pot will give different resistance depending on the turn. It takes some training to fill a table with the resistance values for the angles you care about.

  • @DJvvAZZ
    @DJvvAZZ Рік тому

    I used to work at a commercial broadloom carpet factory. We had many old looms, one still used giant punch cards to tell solinoids when to hit the brakes on the yarn selection lift. Anyway, one of these machines was retro fitted with a computer spitting out each line as needed to the loom, resulting in stunning one off designs (ceaser's head in Vegas is partially woven by me). We had a photo sensor like yours, but as a rectangle that had a binary data as the yarn lift happened, which could be deteced by a control box, to brake at a point the software says.

  • @Micro-Motive
    @Micro-Motive Рік тому

    For direction only (a relatively static value), i.e. Wind vane, an encoder with the required resolution (number of bits) is all that is needed.
    All holes, segments are not required, outer ring used to "gate" the other "bits" to present binary value/byte/word to microcontroller.
    To reduce the number of input pins required on the microcontroller, use a "parallel in - serial out shift register"
    Use LED Photo Diodes and Emitters shielded/enclosed from ambient light.
    Photo-resistors are slow analog components better used to measure analog light levels.
    To inplement direction and speed, use dual edge-triggered optocouplers with an encoder disc with a missing pulse.
    Correctly spaced Optocouplers provides direction from the edge timing and the "missing-pulse" provides a counter reset, speed comes from counting pulses/sec.
    The difficulty occurs from measuring two different values, direction and speed, using either independent or interdependent sensors and software code.

  • @keirstitt8277
    @keirstitt8277 Рік тому

    Use grey code. Not only will you only get one bit change per rotation, but mechanically the disk will be a lot stronger because its material will be better distributed.
    It will also be better ballanced if your spinning it with speed.

  • @aterxter3437
    @aterxter3437 Рік тому

    I began working on a simple model in openscad, about the binary coding, there exist an other version that uses gray's binary coding : you only change one bit each time you increment the number, it's a little bit more complex to process but generally way more precise.
    Also, I wouldn't use a photo-resistor, but instead a photo-transistor, the photo transistor either conducts as a diode or blocks current as an open breaker. you would just have to plug it between ground and an input pullup of an arduino for example to get a more accurate reading

  • @thepresident2781
    @thepresident2781 11 місяців тому

    I think a stack of magnets and a hall effect sensor can be use to precisely track the angle of wheel, that would be more solid state approach.

  • @itRemindsMeThatItNotSoBad
    @itRemindsMeThatItNotSoBad Рік тому

    This one of the simplest and cheapest implemented to solve the problem 👏👏👏

  • @CostlyFiddle
    @CostlyFiddle Рік тому

    Put 2 sensors about 5mm apart. Have a spinning disc with equally spaced holes. Whichever sensor detects the hole first determines the direction. You can also get speed data from this.

  • @papyr4451
    @papyr4451 Рік тому

    A much simpler solution would be using an apsolute encoder that uses a magnet and a magnetic field sensor, you would get a lot more detail and it would fit within a smaller footprint. You just attach the magnet to the weathervane so it can rotate and put the sensor close enough to the magnet to read it’s poles

  • @mittelwelle_531_khz
    @mittelwelle_531_khz Рік тому

    The crucial part is the outer ring with the equally spaced holes as it tells you when the readout is actually valid. Otherwise, if two of the inner rings go form hollow to filled you might get a grossly wrong reading.
    AFAIK there are other ways to code absolute positions where only one bit changes for each increment. Of course they don't give you the binary value directly, you have to feed it through a deciding algorithm or table.

  • @mikemitchell7001
    @mikemitchell7001 Рік тому

    Easier way is it encode a shift in frequency, put the holes progressive closer together. One direction will give an FM chirp up, the other down. Pretty easy to decode with a timer input. You only need one track or bit this way.

  • @prentishancockgardening
    @prentishancockgardening Рік тому

    It's called a binary encoding wheel. 8 codes per quadrant. 32 codes represent 360 degrees. Therefore each code represents 11.5 degrees of rotational position resolution.

  • @1stUniqueName
    @1stUniqueName Рік тому

    On propellers axel install a stick that is loosely connected to the axel .
    When the axel rotates clockwise the stick also moves in that direction and touches a micro switch or blocks a light sensor.
    When the propeller moves anticlockwise the stick touches the others sensor.

  • @rudylikestowatch
    @rudylikestowatch Рік тому +1

    You could do it with 2 bits like the ball trackers in old computer mice.
    The controller counts each forward or backward step and adds them up to a complete revolution. Precision depends on the gearing from the weathervane to the 2 bit wheel.
    Edit: Gearing might add complexity.

    • @owlstead
      @owlstead Рік тому

      Disadvantage is that if the orientation is ever lost then you're in trouble. You'd need to actively keep track of the orientation.

  • @stephenmerkel7402
    @stephenmerkel7402 Рік тому

    Depends on if you want an absolute encoder, but you could probably use a continuous rotation potentiometer to get an analog voltage for position (like set South to be 0v and 10v, and North is 5volts, etc). A reed switch could also be added close to South position, to tell if to are at South. No explicit need for a microcontroller then, unless you want to swap the voltage readout to words for the directions instead of having a chart with voltages that equal the directions. Just depends on if photoresistors are much cheaper than potentiometers, since you only need one sensor instead of several.

  • @telgars
    @telgars Рік тому

    Cool introduction to absolute digital encoders. As everyone else said, a gray code is better. Someone else mentioned a relative encoder, where you know the direction and quantity of motion but not exact position without calibration.
    Well my friend did a thesis at University making a hybrid, where you know relative motion, and after a small number of moves you know absolute position. It involves creating a gray code sequence that has unique subsequences. Lots of graph theory and stuff.

  • @mbizac9259
    @mbizac9259 Рік тому

    you could try to use gray encoding, so only 1 bit changes its value at a time, preventing glitches during readout, caused by multiple unsynchronized bit flips.

  • @maxb3248
    @maxb3248 Рік тому

    I think there are many far simpler ways to see which way the wind is blowing, like a sock, but this is definitely a very clever method, and I quite like it.

  • @Fordi
    @Fordi Рік тому

    You're going to have issues where the bits don't flip simultaneously, due to imprecision. You can guard against this using Gray encoding (a binary encoding where only one bit flips at a time).

  • @user-pr6ed3ri2k
    @user-pr6ed3ri2k Рік тому +1

    i quickly realized that the disk looked like binary the moment the vid started lol

  • @oleglyan
    @oleglyan Рік тому

    You could print a gradient of black on a plastic film with laser printer, cut the disc out, where thermalpaint is spread by rotation 0-360° gradually. You could use that analog light transperancy for 1 analog sensor instead of 6 discrete 0/1 binaries, which is smaller and lighter

  • @MaxKielland
    @MaxKielland Рік тому

    Just grabb an encoder that gives you two pulse trains (A & B). This gives you pulse + direction. Most microcontrollers already have direct support to decode this kind of encoder. You basically only need a "home" position to calibrate when you start up, then it will not be needen and the absolute position can be calculated by counting pulese according to the direction. A microcontroller may do this for you, in hardware, as well.
    This was how old mechanical mouses worked, with way better accuracy than your binary wheel.

  • @OddlyIncredible
    @OddlyIncredible 5 місяців тому

    If you only need direction/speed and not any sort of position/angle data, a simple phase encoder would be adequate and probably simpler to implement and more reliable - typical phase encoders will have two rings with detection points that are offset so that one ring "makes or breaks" (e.g., interrupts light or not) before the other when rotated in one direction and after in the other. If the rings are A and B, and A is offset relative to B clockwise by 5 degrees, clockwise rotation would have B fire then A and counter-clockwise A then B and a circuit could see which one fires first to determine the direction of rotation. Pulse counts can also be used for rotation speed (RPM).
    Also, instead of using optics, magnets in a wheel and Hall effect sensors might be more reliable as the circuitry could be coated or even potted.

  • @LarryAllenTonar
    @LarryAllenTonar Рік тому

    Yes -- use Grey code encoding on printed transparency -- you get one more bit of precision and only one bit changes at a time

  • @aaryananand7288
    @aaryananand7288 Рік тому +1

    Magnetic encoders or Hall effect sensors would’ve been way more compact…

  • @foogod4237
    @foogod4237 Рік тому

    Another approach (not necessarily better or worse, depends a lot on the other circuitry you're hooking it up to) would be to use an off-center-mounted magnet and 3 or 4 static hall sensors to detect its position. If you feed the inputs to an ADC, you can precisely calculate the orientation of the wheel/shaft by comparing the relative strength of the magnetic fields between the different sensors.

  • @speedy0_FPV
    @speedy0_FPV Рік тому

    this is used in a lot of servo type motors today, an example is an industrial robotic arm. There is another way (cheaper way), you can use 5 different coils,
    one in the middle, 4 on the outside (for 360°) , if you apply power on the middle coil, it generates an electromagnetic field around it, each coil then will receive a different amount of this magnetic field, and converts it back to electricity, by measuring the voltage, you can calculate the exact angle.

  • @PotatoClips
    @PotatoClips Рік тому

    if you only care about the direction, this can be accomplished with only one ring and time, or with two rings independent of time. for a single ring, you can have the increments increase as you turn clockwise. if youre current reading takes longer or shorter than the last, you'll know which direction its moving. if you use two rings, you can have two gaps staggered by half an increment and know which direction its going based on the rise-fall sequence of the rings. (ie fall-outer, fall-inner, rise-outer, rise-inner for cw, and vise versa for ccw)

  • @williamporter3806
    @williamporter3806 Рік тому

    You could also use a potentiometer and read the resistance. Zero ohms for zero degrees, 10000 ohms for 359 degrees.

  • @TheConceptBoy
    @TheConceptBoy Рік тому

    Just a single compass sensor would do the trick. This is more for those interested in proof of concepts. Also you'd be reliant on a source of light. So no tracking at night unless you provide your own.

  • @JozsefSzaszFabian
    @JozsefSzaszFabian Рік тому

    The basic idea is good, however the readings will be mostly buggy and random. You should use grey code (instead of the normal binary sequence from 0 to 1f) where only one bit changes at a time.

  • @krzysztofmazurkiewicz5270
    @krzysztofmazurkiewicz5270 Рік тому

    For an encoder like this i would propose using a Grey Code. Its a variation of binary BUT each neighboring number/value differ only by 1 bit. This makes detection more efficient and less susceptible to readout errors. Also of you use all the bits on the wheel you do not need all that much valies as only few readouts should tell you the direction of the spin. Unless you also require some precision on the actual orientation of the code wheel and studd attached to it

  • @pepemotion
    @pepemotion Рік тому

    This is cool but to your question. If you only care about direction and speed a simpler way with the same technology would be to use only 2 points of measure, regular spacing between the gaps, and measure time differentials. Or a magnet and 2 hall sensors so you can use it at night/under cloud cover/inside.

  • @yellowbrick902
    @yellowbrick902 Рік тому

    If you’re just looking to get direction and speed, you only need 2 bits of resolution.
    Look up the pulse train shown in the data sheets for off the shelf rotary encoders to get a sense of reading and resolution.
    You can also find a real world example in the old school Lego Mindstorms rotation sensor from 20 years ago

  • @shinrakishitani1079
    @shinrakishitani1079 Рік тому

    I reckon a rotary encoder mounted wind vain would've saved you a lot of trouble, that said still an interesting way to approach it

  • @ryanmcgowan3061
    @ryanmcgowan3061 Рік тому

    You can make it much more accurate by attaching a gear to it so that it spins at a known ratio. One more mechanism would need to detect which quadrant it is in. Theoretically, you could measure down to whatever the lash of the gear is. Given very tight gearing, it's possible to measure millionths of a degree. Another way would be a clear plate with opaque carbon encoding, a light source, and a magnifying lens.