Pulse counter for antenna rotator

Discussion in 'The Projects Forum' started by BobW55, Dec 16, 2010.

  1. BobW55

    Thread Starter Active Member

    Jul 22, 2008
    43
    0
    I am using a Quad encoder from a mouse to give me feed back on the position of my antenna rotor. I have already done the math to figure out how many pulses (320) = one degree of movement. I need PIC and 2 line LCD recommendations for something to convert the pulses into displayed degrees of rotation. It would be nice if it remembered where it left off if powered down. I can do bread board construction pretty well. Circuit design I know nothing about. I know I will have to pick up a pic programmer as well

    Bob
    K8POS
     
  2. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Do you know any programming languages such as C or BASIC?

    Reading a quadrature encoder is a task there is a good deal of source code around for in different languages.

    Many PICs currently available have a good sized chunk of EEPROM/flash that a program can read/write so information is saved between power cycles.

    The part people usually have issues with is getting the first program to actually be compiled and transferred to the uC (microcontroller), and after that, the timing in writing to an LCD.

    With a little more information, a solution can be found for this relatively easily. I'd suggest getting the PIC Kit 2 programmer and A PIC LCD Development Board Total cost would be $35 for the programmer and $50-ish for circuit board linked above.

    You could also use a bare PIC, make your own PC Board, but the PIC Kit 2 or PIC KIT 3 programmer would still be needed. There are clones that work off serial or parallel port, but the Microchip PIC Kits are the most reliable.

    --ETA: Here is another board, it is more compact, and you need to supply your own PIC ($4-$10 ), such as the 18F4550 that may be overkill for this project, but the LCD has a 40 pin socket, and this one is a common 40 pin, along with the 16F877. Both have a lot of code for them around, along with power and I/O to spare for your project.
     
    Last edited: Dec 16, 2010
  3. BobW55

    Thread Starter Active Member

    Jul 22, 2008
    43
    0
    I am not so worried about the programmer or the code writing. It is in making a schematic for all of it. I am sure down the road I will need help programming. I just about have a good regulated 5 volt power supply built. I need help with encoder power, pic and lcd part of the circuit. I have been looking around at some various kits, but most are frequency counters or not made to work with up down (CW CCW) pulses.

    Bob
     
  4. MMcLaren

    Well-Known Member

    Feb 14, 2010
    759
    116
    Hi Bob, K8POS,

    Most of the antenna rotators I've come across have a potentiometer inside that's used for position information. May I ask which rotator you're using, Sir?

    Happy Holidays everyone.

    Regards, Mike, K8LH (Westland, MI)
     
  5. BobW55

    Thread Starter Active Member

    Jul 22, 2008
    43
    0
    Mike,
    This is a TV antenna rotor from Phillips. I just use it for my VHF/UHF antennas. But I got tired of it getting out of sync all the time. I rebuilt the power supply to the motor and took out the mechanical stop so I can drive it past 360 degrees. Now I just need a way to tell me where it is pointed.
    The original controller worked off a oscillator to control how long the motor was energized for but would easily get 10 degrees or better out of sync.

    Bob
     
  6. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    The LCD PIC Demo boards I linked above have header pins or jacks for all of the I/O ports on the PIC.

    The encoder could be powered by the same power 5VDC Regulated supply you use to power the Demo board. Put the Encoder outputs on PortB. You can add a couple more buttons on PortB since the encoder lines are only 2 or 4, leaving 4 to 6 pins of PortB available. The LCD is most likely connected to PORTC.

    I don't suggest using PortA, as it has many Analog functions, comparators, ADC, etc, that need to be disabled in code for things to work. Using the "digital" ports, it is pretty straightforward.

    The demo boards are all assembled on a neat circuit board, the LCD is already attached, and they come with source code to write to the LCD. The only missing ingredients are a regulated 5VDC power supply, and the inputs from the encoders.

    After that, it is all software, no other hardware needed.
     
  7. BobW55

    Thread Starter Active Member

    Jul 22, 2008
    43
    0
    Very nice board, almost over kill for what I am trying to do. Will have to see if the LCD can be remotely mounted. It did get me looking at some of the basic development boards. There are so many to choose from. I think my eyes are going buggy from all the googling I have been doing.
    :eek:
     
  8. SgtWookie

    Expert

    Jul 17, 2007
    22,182
    1,728
    Googling can definitely lead to bug-eyed syndrome. ;)

    The PIC16F877/877A is basically on it's way out the door.
    The PIC16F887 is a newer (and much cheaper) MCU that has similar functionality, and doesn't require a crystal oscillator - but you can use one if so desired.

    If you are going to want the LCD mounted remotely from the MCU, you might consider a serial LCD. Otherwise you'll have a rather large cable to string all over.

    Even if the MCU keeps track of the quadrature encoder output count, it still might skip a beat over time due to antenna movement when the system is powered down. It would be a good idea to have a "home" or zero degree indication so that it can reset the zero count without having to do a lot of fiddling around.
     
  9. BobW55

    Thread Starter Active Member

    Jul 22, 2008
    43
    0
    I have a reed switch setup that will just light an LED when the rotor is in a home position (north). I was planning on using a simple push button on the control panel to tell the pic to zero out or home the display.
    My hopes, if I ever get this all figured out is to have a display that will read from -90 degrees (pointing west) to +450 degrees (pointing east) with zero or north as the starting point. I have enough free cable to allow this amount of rotation. I don't mind having to hold down the switch to move it for now, but would be nice to let the pic eventually control relays and let it do the moving. (would need second input to tell it where to go)
    I have seen some projects to do what I am wanting to do, but usually via computer (PC) control, Id like this to be stand alone.
     
  10. KMoffett

    AAC Fanatic!

    Dec 19, 2007
    2,574
    230
    Do you have room in the housing for a small (?), 3-turn pot? Geared to the shaft, it would give you the angular range you need and an analog output proportional to the absolute position. A PIC could offset and scale this to give you a -90° to +450° reading. It could also prevent you from overshooting and over-wrapping your cable.

    Ken
     
  11. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    Looking at that second demo board again, the 40 pin PICs are overkill. You would be fine with something like a 16F627 or 16F628(A) PIC, they have internal oscillator, and enough I/O to write to LCD and read the inputs you want. You would spend most of your code disabling unused internal peripherals compared to actually doing what you'd like.

    The problem with the 16F series is essentially programming, it's mostly done in assembly unless you buy a compiler, like MikroBASIC or BoostC / BoostBASIC. When you switch to the 18F series, the price goes up a few cents for the same pin count, but the Microchip C18 compiler is free for projects your size. Actually, the demo versions of BoostC and MikroC would work fine, as you wouldn't be hitting the "free" compiler memory limit with this project.

    Microcontrollers are a whole new world. It is easier and quicker with feedback to get a PicKIT and a demo board with most of what you want on it, then learning the code. That way the only unknown is your code. Those who have tried to build their own programmer, then write the code in assembly, and then try to make it work on a home made protoboard often have so many problems they get "turned off" microconrollers before they even get started.

    The above is why I would strongly suggest a pre-made board with the LCD on it, or even something like the EasyPIC series of "big" demo boards that support any PIC and have lots of on board I/O devices.
     
  12. BobW55

    Thread Starter Active Member

    Jul 22, 2008
    43
    0
  13. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    6,357
    718
    The Junebug would be a good choice. Though I don't have one, support seems to be excellent by member blueroomelectronics

    As you've found, it is nearly impossible to even have all the compilers available, let alone all the dev boards. As long as the I/O lines are brought out to headers you can use for the LCD and encoders, and the ICSP jack is onboard, nearly any dev board will work. Just remember to get the PICKit 2 or 3, you won't regret that.
     
  14. KMoffett

    AAC Fanatic!

    Dec 19, 2007
    2,574
    230
    You might consider a PICAXE microcontroller as a cheap alternative. It's a PIC with a built in Basic Interrupter. Slower than native PICs, but your application does not require speed. Free BASIC program editor. Only a serial cable, 2 resistors, and a 3 to 5VDC supply to program it. Many flavors from 8-pin to 40-pin. The 8-pin is ~$3.50. It has 1-output, 3 reversible I/Os, and 1-input...and onboard 10-bit A/D converters. For your purpose... a pulse or analog input, SPDT center-off switch and and an h-bridge for run/direction, and a serial out for an LCD.

    http://www.rev-ed.co.uk/picaxe/ and a very helpful forum http://www.picaxeforum.co.uk/

    Ken
     
Loading...