I decided to build a new rotator controller to replace my Yaesu G400RC controller (but my design was made to work with virtually any rotator) to give me additional futures beyond the sole analogue position feedback of the G-400RC. I wanted the new design to be digital, have integrated PC control, hands off operation (pick your direction and then sit back) and have different modes of operation depending upon current operation style. I had previously built a rotator PC interface but not a full blown rotator controller, however my original code covered most of what I wanted to do except the LCD hardware and user inputs. This is a development in progress, since making it I’ve found I use the rotator controller differently to how I envisaged but I’ll cover that at the end.
I built the rotator controller around the PICAXE-20X2 chip which is far the best chip in Revolution Educations range and can be used in almost any design. It supports almost all PICAXE BASIC commands and has 16 hardware inputs/outputs, it also has loads of registers and code space. After using the PICAXE-20X2 chip on other projects I got my head round some of the advanced commands and my own limitations from when I done my original rotator PC interface on the PICAXE-28X1 chip.
My original premise was to split the rotator controller into modes, mainly to test how I would use each one and after using it I redesigned the code to make it an all in one but the modes were:
- Manual; standard control were the buttons change direction LEFT or RIGHT.
- Fast; this is like manual but the LEFT and RIGHT buttons move the desired heading faster than the physical rate of rotation and the antenna catches up.
- Preset; uses a dial (potentiometer) on the front panel to set a desired heading and the antennas track to that heading.
- PC Control, heading feedback to the PC works on all modes but setting the heading only works in Manual mode. PC control also supports L for LEFT, R for RIGHT and S for STOP – this can be used also to interface to additional non PC [other BXF project] controllers.
The PC protocol is based on Yaesu GS-232 and I’ve included support for AZ only (GS-232A) or AZ+EL (GS-232B), in the GS-232B all EL commands are ignored or answered with 0 degrees.
After deciding what I wanted from the new code I set about looking for a suitable rotator controller, or box, to house it into which I found in Friedricshafen in the guise of a KR-400 control box for EUR 30. It had a nice big south stop analogue meter in it but that didn’t worry me as I planned to use a 4×20 LCD (which I had bought off eBay). I cheated slightly by using a Wulfgang K107 LCD interface board (tech doc .pdf) to drive the LCD, this was for 2 reasons;
- It allows me to use serial to update the LCD instead of connecting all the parallel pins to the PIC so simplified the design, and
- The K107 LCD interface supports large character mode (as seen in the pictures) so allows me to use the full height of the LCD better (easier).
The final code doesn’t have modes but instead allows any input to move the rotator, I did drop the FAST mode as it was redundant and I didn’t use it much. The use now is you press LEFT or RIGHT to move in the desired direction, spin the preset to take you to the preset direction or press PARK* to take you to a pre-defined heading. Pressing LEFT, RIGHT or PARK at any point cancels the current movement and start the new one, so if I set the preset to 200 degrees and pressed PARK (which say was set to 120 degrees) then the rotator would cancel heading to 200 degrees and head to 120 degrees. The same is for the PC input, any PC input to goto a direction would override any current movement and head to the new heading set by the PC input. The PC can read the antenna direction at any time which does not effect the antenna movement.
* At present there is only one input used as a predefined heading, which I call PARK and have set to 120 degree, Europe from my QTH. The PICAXE-20X2 has 5 additional spare inputs in this project so it’s more than capable of having extra switches attached to these inputs and assigning them to additional presets in the code.
Outside The Case
There was not much modification required to the KR-400 box. I added an extra button on the front for PARK, originally for changing mode and on the back a 9-way D-type connector which I use for my rotator wiring as it’s much easier to disconnect, also all my other rotators use the same plug so they are all interchangeable. I also added a USB-B port on the back for PC interfacing, internally this goes to a USB<>Serial interface. Inside is where the main changes are.
Inside The Case
The original circuit and meter in the box was of little use so the first thing I done was to remove both. I left the transformer in along with the capacitor over the motor outputs which was also original, after that it was a new PCB with all the required circuitry and that was about it!
Calibration
The rotator controller needs calibrated. This is done in a simple way by either powering on the rotator controller holding the PARK button or if the MINOffset or DirCorrect EEPROM values are 0 (no values stored in EEPROM would be the case after programming). When in calibration mode the user is presented with step by step text based commands on the LCD to follow for calibration. You only need to do the calibration once after which MINOffset and DirCorrect values are stored on EEPROM and recalled on each power up.
The steps for calibration require the rotator to be moved fully LEFT (CCW) to 0 degrees (north) so the feedback pot in the bell housing reports its minimum value (MINOffset).
Pressing the PARK button saves this ADC value in EEPROM (MINOffset) which is then subtracted from ADC reads in the main code.
We then go RIGHT to 360 degrees (north) and save this ADC value (DirCorrect) which is used for the correction factor.
The ADC value is again saved in EEPROM when the PARK button is pressed.
Let me explain using my values. On my rotator 0 degrees (north) returns an ADC value of 22, this ADC value is subtracted from all other ADC reads in the code, the reason is 22 is 0 degrees so an ADC value of 32 would be 10 degrees (it’s not quite that linear but you get the idea). We then goto 360 degree (north) which in my case is ADC 953. ADC 953 is actually not yet right as we need to subtract the MINOffset value for the correct ADC for 0 to 360, we then need to convert to a correction factor.
To get the most accurate heading I sample the ADC value in the code 64 times. I use 64 [times] as this then fills a 16 bit register when sampling the ADC at 10 bits without the chance of it overflowing. The maximum ADC value at 10 bits is 1024 so 1024 * 64 = 65636.
As my max ADC value is 953 (remember my minimum value of 22) I need to subtracted this off so the real ADC value is 953 – MINOffset or 931. It’s the value of 931 which is loaded into the register 64 times meaning the register value is stored as 931 * 64 = 59584. I then divide this by 360 to get the correction factor. 59584/360 = 165.5. In PIC code we can only divide by full numbers so I take into account if the decimal is greater than 0.5 and if so I add a number to the correction factor to make it closer to the real value, if my result was 165.4 I would then use 165 but as it is 165.5 I instead use 166.
This means if I have an ADC value from the rotator of 546, I first subtract 22 (MINOffset) from it, leaving me with 524 which is sampled 64 times giving a register value of 33536 (in reality the ADC value of 546 could vary slightly on each of the 64 reads, one of the reason we average so many). I then divide 33536 by 166 (DirCorrect) and I get a heading of 202 degrees.
Did you follow?
Schematic
Download the schematic (uses ExpressSCH)
Pictures
Code
Old Design (PICAXE-28X1)
A long time back I decided I wanted PC control of my antennas, mainly for point and shoot, click on a heading in some PC software and start CQ’ing so that I wouldn’t have to think both about calling and antenna direction. For this I ordered an LVB Tracker from AMSAT UK but before it arrived I thought I’d have a go at making one myself using PICAXE, it worked but it was crude!
I have a Yaesu G-400RC rotator which is the one with a round controller for the display and uses a comparator circuit to ‘match’ the heading of the controller display with that of the rotator itself, the problem is the comparator swings from –15v to +15v and is non-linear. This meant interfacing to a PIC chip was possible (using an opamp) but as the voltage was non-linear it would not work so well.
My first attempt was using a PICAXE-28X1 chip which as good as a design it was I didn’t know PICAXE programming as much back then so didn’t fully utilise the chip, or code. Instead of using the hardware serial (hserin) inputs, which allows serial reception in the background while the code executes, I used the normal ones and had to set a serial buffer timeout which would expire if no serial data was received, during this time all the code execution stopped. Also due to my lack of familiarity of PICAXE code back then the code wasn’t really optimised, an example was lack of subroutines (Gosub) meaning there was lots of code repeated. There was no calibration routine so working out the actual heading was left to the user to calculate and enter the correction values, for the ADC value, direct into the code. I’ve not reproduced the code here as it’s in my mind redundant and outdated. But some of it was salvaged for this project. What I did end up doing though was to take some of the ideas and features from this code and turned it into my LVB Extender design, an add-on for the LVB Tracker, which could send serial commands to the LVB Tracker giving added extra features and automation to rotator system without the need for a PC.