Proper programming processes suggestions

I see I was wrong on my guess, looking at it now.

In your application, the binary setup will work file; I do like the Trigger/Clock channel too.

Also the number read is easily interpreted.

Yes after reading Wikipedia and Absolute Position Coding Method for Angular Sensor—Single-Track Gray Codes I thought that my system is simple enough and it works. KISS. I like the Gray code stuff though, years ago I wished I had known about it for a project I built a system for.
Back to converting the polling sketch you provided.

This my whole interrupt now, is this wrong?

// ISR conv Converts inputs to integer reading hall effect switches 1,2,4,8.
// Triggered on hall effect input on interupt pin 2 (trigger).

int conv()
{
value = 0; //Resets value to zero, stops accumulation of value growing
in_position = 1; // ok to read hall effect switches
checkSwitches();
}
checkSwitches() determines the value of the position. I don't even think I need in_position because the interrupt got triggered by being in position so calling checkSwitches() should be where it is supposed to be.

Don’t use interrupts.

Just scan the trigger channel every 20ms as shown in the example offered in post #28.

ok, I am also now scanning two other inputs that I use for direction of rotation determination, by determining which came first, I use the 20 ms timer for that, I can do the same thing with the trigger pin and go do the checkSwitches function at that point.
As an aside, I assumed that the motor that turned the antenna was DC, it is not. It is geared motor that may or may not change direction on a interruption of power, but it does have a somewhat limit switch which is a mechanical stop and if it hits it it can no longer rotate. Not sure yet if it reverses under those conditions. It does however randomly reverse on interrupting power, just not everytime as I thought. Further research is needed, but I shall continue on as I can work with this if necessary. I do have about 8.5 volts DC that needs to be filtered a ton. Thought you might like to know the new nuances. Ken

Maybe you can change the geared motor out for a DC geared motor.
:thinking:

What ball mice had was a roller on each axis turning a spoked wheel with 2 beam interrupts out of phase (When one lines up with spoke or gap, the other is over both) with each other. They tell movement and direction.

`[see -- How do they figure out direction?](https://www.explainthatstuff.com/computermouse.html#inside-ball)`

Hi,
If you go to an optical disk method, you can add more channels and get better turning resolution.

If you use Gray code, just detecting if the count goes up or down will tell you direction of rotation.

OR
You configure two channels as a quadrature encoder style, which each time you detect one channel go from LOW to HIGH you check the other channel state to see if it is LOW or HIGH, that will tell you direction.

Tom... :smiley: :+1: :coffee: :australia:

Thank you for the input, it has been so long since I did any of this type of thing, that I have forgotten a lot of the theory. your ideas all seem good alternatives especially You configure two channels as a quadrature encoder style, which each time you detect one channel goes from LOW to HIGH you check the other channel state to see if it is LOW or HIGH, that will tell you direction.

That was my new plan, two sensors in another ring that only told direction. However: As an aside, I assumed that the motor that turned the antenna was DC, it is not. It is geared motor that may or may not change direction on an interruption of power, but it does have a somewhat limit switch which is a mechanical stop and if it hits it, it can no longer rotate. Not sure yet if it reverses under those conditions. It does however randomly reverse on interrupting power, just not every time as I thought. Further research is needed, I have to reassemble the unit to test if it reverses when it hits the physical end of travel, I am betting it probably does as it would be useless in its application if it doesn't.
This has evolved from a simple idea to a big project. Don't they always?

"have a somewhat limit switch which is a mechanical stop and if it hits it, it can no longer rotate. Not sure yet if it reverses under those conditions." It Does reverse after it strains somewhat, pretty low torque system.

Hi,

Is this an actual antenna rotator?
If so then the motor will just stop.

Can you post make, model, of rotator assy or the motor.

It sounds like it is a 2 phase AC motor, the second phase is produced by a phasing capacitor.

Thanks.. Tom.... :smiley: :+1: :coffee: :australia:

"Is this an actual antenna rotator?
If so then the motor will just stop."

I will get a picture of it tomorrow, it is pretty small and enclosed within the antenna casing about 85 mm square and about 48 mm deep. when it hits the mechanical stop, it will after trying to go further it will reverse. I have been hesitant to open up the gearbox and motor assembly and see what is inside. Guess I will... It is hard to imagine what it looks like unless you see it, so I will take a few more pictures for you all. The whole antenna is only about 2ft by 1 1/2 ft, motor is part of the antenna. It is not normal 60Hz Ac, but some other frequency produced by the electronics in the antenna. I have a cheap $30 scope that I built and it is ok for showing waveforms but not so good for analysis.

Here are the pictures of the motor mechanism, 3 in total. I did not want to take it apart any further. I am also including the rotational disk I designed in Fusion 360 which includes the quadrature slots as well. The disk is 3mm thick, the holes are 2.5 mm in diameter and the sensor holes are 5 mm to accommodate the IR transmitter and receiver elements. The thickness of the sensor unit is 5 mm on each side so that only the top of the transmitter and receiver is exposed, hopefully reducing scatter.




Hi,
Thanks for the pics.
That motor should have a label on it back?
How many wires come out of the motor?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

When I had the motor out, I don't remember seeing anything on the other side that told me about the motor. I will look again. It has two wires going to it and when I put the scope on it there was about a 14 V p-p sine wave. It is 60 Hz. On the other hand, the 8.4 V is also a sine wave with the bottom sitting at about 0 V. My multimeter could read that as DC whereas the 14 V could only be read as AC on the meter.
There are only two wires.


Probably is AC with those cutouts and 60 Hz on the power inputs.

I thought I replied to you, but I may have just created a general reply