Polar Rotors and Servo Controllers 101

Status
Please reply by conversation.

melgarga

SatelliteGuys Pro
Original poster
May 11, 2008
834
0
SE Texas
I hope for this to be a continuous work in progress, and we can learn and accomplish something along the way. The more that play the more we will all learn.
I ordered that servo controller kit I mentioned in the G box thread. For anyone interested, I ended up getting it from here -
Code:
h[COLOR="Red"]XX[/COLOR]p://www.electronics123.com/s.nl/it.A/id.316/.f
The sales rep's name was Sue. Very courteous and professional. I told her a bunch of yall would be calling too!
I also picked up some 556s and sockets to build the PWM test rig.
I did not find what I was looking for in the remote control dept...........yet. I imagine something is commercially available, but cost eventually becomes an issue.
I had a couple of thoughts. One will require the assistance of our appointed PIC subject matter expert. If the PIC16C71-04/P has the room for the code to learn, and act on existing IR commands at our disposal, all that would be needed is to add a 38khz ir detector and supporting code. What do you think Cad? I'll post the code for the PWM unit at the end of this post.
The other idea I had involved some HW mods to our various STBs. I've been eyeballing the useless tv/vcr function on my remotes and wondering if I could intercept that control sig and route it to a jack on the back of the rx and use it as an input state [H or V] to the PIC. Things that make you go hmmmm........
Here's the code per the .pdf Cadsulfide. Please comment. It's all geek....er, uh, greek to me........lol
Code:
;KIT 102. SERVO-MOTOR DRIVER
dummy = 14h
flag = 15h
servo0 = rb.5
servo1 = rb.4
servo2 = rb.3
servo3 = rb.2
org 0
jmp start
org 4 ;Interrupt jumps here
clrb RTIF
setb flag.0
reti
start mov !ra, #255 ;Set ra to input.
mov !rb, #0 ;Set rb to output.
clr rb ;Clear port rb
mov dummy,#255
mov intcon, #0 ;Turn interrupts off.
mov adcon0,#AD_ctl ;Set AD clock and channel.
setb rp0 ;Enable register page 1.
mov adcon1,#AD_ref ;Set usable pins, Vref.
mov option,#00001000b ;WDT on, no prescale
clrb rp0 ;Back to register page 0.
setb adon ;Apply power to ADC.
setb go_done ;Start conversion.
not_done snb go_done ;Poll for 0 (done).
jmp not_done ;If 1, poll again.
mov counter2,adres ;Move ADC result into counter.
mov integer1,#3 ;Offset constant
mov integer2,#5 ;ADC multiplier
setb servo0 ;Output pulse to servo 0
call delay
clrb servo0
call pause ;ADC settling delay
clrb rp0 ;Ensure reg page 0
clrb chs1 ;Select channel 1
setb chs0 ; Ain 1
mov dummy,#255 ;Reload dummy variable
clrb adres ;Make sure
setb go_done ;Start conversion.
not_done1 snb go_done ;Poll for 0 (done).
jmp not_done1 ;If 1, poll again.
mov counter2,adres ;Move ADC result intocounter.
mov integer1,#3 ;Offset constant
mov integer2,#5 ;ADC multiplier
setb servo1 ;Output pulse to servo 1
call delay
clrb servo1
call pause
clrb rp0 ;Ensure reg page 0
setb chs1 ;Select channel 2
clrb chs0 ; Ain 2
mov dummy,#255
clr adres
setb go_done ;Start conversion.
not_done2 snb go_done ;Poll for 0 (done).
jmp not_done2 ;If 1, poll again.
mov counter2,adres ;Move ADC result into counter.
mov integer1,#3 ;Offset constant
mov integer2,#5 ;ADC multiplier
setb servo2 ;Output pulse to servo 2
call delay
clrb servo2
call pause
clrb rp0 ;Ensure reg page 0
setb chs1 ;Select channel 3
setb chs0 ; Ain 3
mov dummy,#255
clr adres
setb go_done ;Start conversion.
not_done3 snb go_done ;Poll for 0 (done).
jmp not_done3 ;If 1, poll again.
mov counter2,adres ;Move ADC result into counter.
mov integer1,#3 ;Offset constant
mov integer2,#5 ;ADC multiplier
setb servo3 ;Output pulse to servo 3
call delay
clrb servo3
sleep
jmp start ;Time out after 18 msec
; The number of loops this delay routine makes is dependent on the result of
; the AD conversion. The higher the voltage, the longer the delay.
delay clrb rp0 ;Page 0
mov intcon,#10100000b ;Enable RTCC interrupt
;****************** Fixed delay part of routine ****************
delay1 mov RTCC,#55 ;Fixed delay
wait1 jnb flag.0,wait1 ; of 200 till interrupt
clrb flag.0 ;Flag set on interrupt
djnz integer1,delay1 ;Three times through
;****************** Variable delay part of routine **************
sub dummy,counter2 ;RTCC counts UP!
load mov RTCC,dummy ;Load RTCC
wait2 jnb flag.0,wait2 ;Note infinite loop
clrb flag.0
djnz integer2,load ;Five times through
mov intcon,#0 ;Disable interrupt
ret
pause mov counter1,#120 ;Adds a short settling
settle djnz counter1,settle ; time to the ADC
ret
*************************************************************
Here is the pic of the 556 based servo test rig, courtesy of Tom Dickens -
 

Attachments

  • servo2.gif
    servo2.gif
    3.7 KB · Views: 866
Last edited:
Mel, Great post! You'll end up like Linuxman & Anole with Ham radio if you start playing with small micro's!

Your listing is in assembly, very compact, very fast, a lot of work. It will take some time to learn. The Microchip web page has a lot of code development tools free for the downloading MPLAB Integrated Development Environment .

I also use the MElabs Basic compiler microEngineering Labs - Development tools for Microchip PICmicro MCUs including PicBasic and EPIC programmer , you can plug working assembly code into it, a solid compiler and only $99 for the starter version.

I recommended the Basic stamps only because they have a built in interpeter, they are way more expensive in the long run than generic PIC's, but are a good starting point.

For the extra dollar or two per chip, get the 'F' version for flash, programming is an endless cycle of writing code, downloading it to the target, watching it crash, fixing the code, downloading it to the target, hopefully it works, etc. Flash lets you reprogram the same chip hundreds of times instead of only once.

A hint on prototyping, use sockets on bare perfboard, and wire your connections with 30awg kynar wire wrapping wire, easy to weave through the holes and easy to rewire if you change your mind or get an oops. Jameco, Digikey, Marlin P. Jones, and Allelectronics are good resources.

Also check out ExpressPCB - Free PCB layout software - Low cost circuit boards - Top quality PCB manufacturing great free pcb software, once you get something you like running well, you can make lots of copies cheap.
 
Oh, I've been around a while, just not in the micro scene. Got my Novice in '76, Advanced a little later and finally upgraded to Extra in '88. All before the code free ruling, which I think was another poor decision on the FCC's part. Extra is more about rules & regs than theory, which make sense if your going to be a VE.
I've played in basic in the trash80 and Vic 20/C64 days. Never went CoCo, My first XT had dual 360 floppys and later I acquired a 5 MEG! hd........lol. Still got it around here somewhere, just waiting to buy me a boat so I have a use for it again.......lol. Heck I've still got a couple of C64s a Vic, a couple of 128s an Apple or two and even an old TI99 somewhere. One of the first things I did when I got the 64 was to build a CW i/f for the expansion port. hooked it up to the 101EE and started copying cw on the screen. Back then that was COOL!
I dabbled in 6502, 6805 and Z80 assy, but never did anything remarkable. Wrote a random cw generator/trainer from scratch, very sloppy but it worked. I'm comfortable in the asm/dis environment, give me a list of opcodes and an I/O & reg map and I'll figure out the rest.......lol. C++ confuses me, too abstract. I've used some (i386) compilers to compile others work, but havent taken the time to get to know C++ or any other HLL for that matter.
Thanks for the links to all the info, regarding the Stamp & interpreter, my point of reference is the CBM C64 and it's basic interpreter. Is that a valid analogy?
In PIC terminology, F is for flash, which I do understand EEPROM and principals, so what's the 'C'? I admit I've not looked into anything regarding PIC or micros in general, it has really only peaked my interest since we started down the PWM/servo path. I should prolly get me a PIC for Dummies and take a stab at a code revision for the IR addition to this kit, if there's even room for it. If I take a stab at it and can throw something together, perhaps you can show me the error of my ways if I cant get it going.
Thanks again for the reply and the links. I imagine I'm not done leaning on you if this all materializes like I hope.
 
Oh great... I just blew the dust off my 1987 copy of "Using Assembly Language"...
Wonder if I'll ever be able to get all the Visual & .NET garbage out of my head long enough to remember what I was doing in college...
I'm more than willing to help on this where I can - gosh I've forgotten most of this stuff...
 
Mel,

The 'C' is for the OTP (one time programmable) versions. The 16F84 is my current fav. The PIC's a remarkable little jellybeans, you can do a lot of stuff in only 1K of code space. I've used them for DC motor control (PWM function in basic), Built a solar panel calibrator with one, annunciator panels (serial lcd), doing a RC servo should be a fun project. The 555 timer circuit should work, but won't be real stable.

We date from the same time period. I've done 8051 & 8088 code, did some VisualBasic code for machine control, but never learned to write C (!@#%%^). As Steve Ciarca once said "My favorite programming language is solder"

I remember back in the day, I was a member of the Heath Users Group, one of out members used a COCO with a thermistor sensor on the the joystick port to sense temperature in his shop and open & close a damper on his wood burner.
 
After I made that post I went a googlin' and determined several things, one of which was the C designator being for OTP. That ends the chances of using the micro shipped with the kit to add any ir routines, but I did find a compatable 'F' unit that looks to be promising. Microchip even publishes a migration paper for the PIC16C716 to PIC16F716. A few chances, but a quick look doesnt reveal any conflicts with swapping in the flashable unit.
A 38khz detector, a snapshot of the binary values of desired ir codes (we only need one if we are only going to toggle H/V), I think Girder can capture that. So FW wise we declare it (variable), scan the ir input, (it will be serial so......that could get interesting) compare it to the stored value of the variable and toggle...........what? Actually I suspect we will only need the small part of the string that is unique, after all we are picking one command not decoding the whole set.
The micro code is written to take advantage of the ADCs. The HW solution would be to use outputs to pull up or down a fixed value resistor of the appropriate value on the ADC input. PRESUMABLY, FW wise one could toggle the correct values in the ADC reg and let the program contiue as if it were an actual input. I would guess that if a bit is programmed as an input, the 'real' value would overwrite any value placed in it's reg internally. So point the proggy to the GPRs and use them instead? Prolly a lil more code needed as well to insure a toggle command would produce only one change in state per button press.
I'm anxious for it to get here, but I'm going to go ahead and order the "F" unit so I'll be ready to move to the next level. I feel pretty confident this will work as a manual control, so getting the couch potato mode working is the challenge.
 
Feed the Monster
My new toys arrived today, but it looks like I wont have time to play until this weekend. Has anyone else decided to test this or another design for the project?
I've done some additional searching regarding ir control and come up with several PIC based sources with various add'l features, but it all adds to the cost. None are based on the same PIC, and none appear to have the code available without purchase. Actually, I am presuming that the code is retrievable, possibly even available on request, but I havent gotten that far. Is it possible to be locked from being read Cadsulfide?
It is more cost effective and realistic to merge the code from both the PWM and ir cortrol functions to a single micro based unit. As Cad pointed out porting between units in then same family appears to be a minor retrofit in most cases. Prototyping is always more expensive than production, hence "Feeding the Monster" so after I prove, or disprove that the PWM unit will work for our purposes, I will choose a suitable ir system and attempt to marry the two modules, with the ultimate goal being an intregrated unit. Once it is established what micro, code and configuration works, a plan will be available for those interested in building a stand alone unit that can be run from a universal type ir remote.
Here's some stuff I've dug up for the ir side if anyone would care to look it over -

This is a very enhanced system that can be expanded well beyond our needs to a number of additional ir command controls. Could be VERY cool for a variety of things one may want to couch potato control.
Code:
h[COLOR="Red"]XX[/COLOR]p://www.tauntek.com/tinyir2-learning-ir-remote-control-receiver.htm
pros - 12 discrete or 22 mux'd outputs, ir learning mode, remotable[ off main pcb] ir detector
cons - pricey for the scope of our project, but value added if the extra output can be utilized.

Here's one that could be tweaked for our purposes, or glean out the cool A/V control features and add them to our "monster" or pretty cool just as it is for non HD A/V control features. Links to schematic, source, etc are on page 2 It's not a kit, so construction would be beyond beginner level skills.
Code:
h[COLOR="#ff0000"]XX[/COLOR]p://web-ee.com/schematics/video/remote-controlled-av-switch/

This looked good at first, but when shipping [to Texas] more than doubled the cost, and had less features than #1 above, overall I dont consider it a value. Might work for someone that can get it for at or near 12 buck for the kit + detector.
Code:
h[COLOR="#ff0000"]XX[/COLOR]p://www.rentron.com/remote_control/IR-D14.htm
This is just a small sample of info on PICs and ir control. Anyone find something in this vein that looks promising , post it up and lets kick some ideas around.
So there's the latest guys. Step one is to define the servo parameters, then marry the modules, and finally merge to a single micro based design if possible. We have the grands every other weeekend, and this is the off week, supposedly....lol, so I hope to have something to report. If anyone else has successes or failures to report chime in, this may not be 'cost effective' but it should be enlightening and fun, besides, what else are you going to do, actually watch TV?.........that stuff lowers you IQ
 
Tons of PIC forums out there, you should be able to find example code for free for just about anything. The Microchip lineup has everything from small & cheap to all-inclusive & spendy. Pretty easy to network two processors together using I2C while developing. With 1 &2 K of code space you can do a lot, but can run out of room. I'll do some poking around for some snippets to post.

Mel, you're gonna get hooked I can just tell :)
 
Aliens!!! you are all Aliens !!!

I read every post so far in this thread and I did not understand one concept! I am glad that you guys do. My reaction reminds me of the reaction of others a few years ago when we were discusing diode steering of satellite antennas for the 747 airplane. Chuck went on to complete the developement, but I did understand the first few steps of that!

Keep up the good work.
POP
 
Feed the Monster
. Actually, I am presuming that the code is retrievable, possibly even available on request, but I havent gotten that far. Is it possible to be locked from being read Cadsulfide? [/qoute]

Yes you can turn code protection on, more of use to commercial developers.

If code protection is not being used, you can download the pic, assembly listing only, if code protection is on ...no-go

Buying a compiler is a good thing, buying code libraries for a hobbyist is not.

Tons of mostly bug free code out there, the flash chips are great for crash & burn programming.

Our pals in Japan have developed complete IR reciever modules...inexpensive and robust, found in most every Tv and STB, way better than rolling your own.

http://www.vishay.com/docs/80069/circuit.pdf

IR RECEIVER MODULE FOR REMOTE CONTROL | AllElectronics.com

IR DETECTOR MODULE | AllElectronics.com

Digi-Key Part Search

Driving an IR led for a custom remote is in the same arena as your ~1-2 Ms pulse train for the polarization servo.

I remember reading an application note at one time also about using a pic to decode diseqc commands on the eutelsat site.

Eutelsat satellite fleet :: Earth Segment :: Earth Stations




but it should be enlightening and fun, besides, what else are you going to do, actually watch TV?.........that stuff lowers you IQ

My 12 year old can find nearly endless mindless programming on FTA, it's bubble gum for the mind. Aren't dad's supposed to do just about ANYTHING for their daughters?
 
Dont feel alone POP, I'm not far passed the concept comprehension level myself.........lol. I've got to have a mental map of the uP's memory and regs, and be able to translate the somewhat cryptic mnemonic commands into 'real words' from [my] memory. I'm not there yet with this one, and it's been a long time since I've looked at the uPs I did take time [back then] to learn. I've noticed over the years, it seems sometimes, I've hit a 'learning wall'. I believe I've identified it as CBT challenged. I have a very hard time studying computer based media. GIVE ME A BOOK! Too oldschool I guess..............lol. I can read articles, papers, news etc, and comprehension is fine, but when I need to 'flip back and forth' to reference info I've already covered, it seems I get sidetracked in the act of looking for it,and loose my train of thought. I printed much of the PIC datasheet and other info to study. It is still a task to wade thru the irrelevant, and 'already understood' text to get to the unknown parts.
.....then theres the whole 'man, I've GOT to go update the 'scrip for my bi-focals' thing .......gonna look into that TODAY..........lol
Cad -
I already had those exact links in the bookmarks and pretty well perused for the subject matter. You know what they say..."Great minds" and all.......lol. Lots of info in them. I've dl'd & printed the 16F716, 84/A, and 87/88 .pdf's and one detailing the 8 bit instruction set as well. Lots to absorb and compare. Should give me some insight for transcoding [ i/o functions/regs mapping] any relavant code I find across specific uPs. Guess I just hate the idea of having to start at the "Hello world" level.....lol. I have other links that present ir projects, but nothing that meshes correctly with our needs.
For vendors, I've gone with Mouser for nearly everything. Futurlec has some useful stuff from time to time as well. The multi-function 87/88 based ir kit
Code:
http://www.tauntek.com/tinyir2-learning-ir-remote-control-receiver.htm
has the lock bit set, so no go on access to patch and modify the code to include the 716 based PWM kit functions.
Code:
http://www.electronics123.com/s.nl/it.A/id.316/.f
For the scope of the project, I suspect the two could be interconnected with little effort, but it effectively doubles the cost of the finshed unit. Feeding the monster can be value added but is not cost effective if the extra functions are unnecessary. I've yet to come across any published ir code that looks readily patchable to the PWM unit. Operative word is YET!
.....now if we added diseqc to the mix what ELSE could we do..........hmmm. Oh well, lets get some air in the tires before we bolt on the supercharger..........lol
Of course this is all theory until the code is flashed and the unit is powered up. It is approaching the time for me to decide on some programming HW + SW. There was some you linked to in one of your 1st posts.
Yes it is amazing and unfortunate all the mindless content flooding the media outlets these days, and it seems children are the primary target, or are at least a magnet for it.
Do almost anything for..........lol, funny you say that, the 5 year old grand is my shadow. Whatever I'm doing she has to be right up in the middle of it. I can see a future engineer in the family.....if I have anything to do with it at least.
Well, back to searching and studying..........
 
Last edited:
Mel;

My reading glasses seem to be getting weaker too.
Kids and grandkids do keep you young.

You're right, crawl first, run later. Turning the servo left/right with two pushbuttons would be step 1.
 

Attachments

  • my child may be a genius.doc
    30 KB · Views: 291
That was a great read...disappointing tho.
I can't seem to get my boys interested in anything (other than buttons on a video game controller).
Although, the 17 year old has suddenly taken a keen interest is audio engineering (at least in the trunk of his car) - but I think the array of 10, 12 & 15" speakers in his car are more to irritate myself and his mother than anything else....!
 
Good read Cad. Yes, I remember comming across some info (Discovery ch maybe? I do actually watch a lil tv now and then.....lol) relating to human learning processes and age. Essentially, there was an age breakpoint in the effectiveness of instructional teaching vs hands on experience related teaching. That point was somewhere in the mid teens as I recall, but as the article pointed out there are anomilies. I dont know if my lil 'anomaly' will continue to be interested in such concepts as she grows, but I hope so. They do indeed inspire one to not to allow being older to be old.
As for my learning curve........yeah, I know......"Hello world".......or pretty close to it....lol
14karat -
There seems to be a mass of those 'engineers' these days. I have one about 2 miles away I have repeatedly reminded of how far that VLF AF travels and how annoying it is. I think it finally sunk in when the Dep. Sherriff cited him for disturbing the peace. You might give yours a heads-up that any citations come out of his pocket, and lots of incorporated areas have ordinaces on the subject.
It may be cool to be unique, but it is not cool to be inconsiderate and obnoxious.
Personnaly I believe it should be an FCC violation, just as any other interfering airwave emmission, but prolly wont happen.
I also have a grand that is a PS II/PSP junkie. Literrally, addicted and obsessed. I put that on his mom and dad, aka electronic babysitting in his early youth. Although, he is good, and has hand-eye coordination, learning to pilot an F16 in a dogfight or a UAV would likely be a breeze.
Back on-topic, I've come across some more public PIC ir and PWM coding, and am looking into a compiler and dev board(s). If I've got to buy something, it might as well work on the larger DIPs too, if I decide to go there someday.
 
Mel;

You only need three pins to program most pics. Microchip sells some very nice development packages (with usb programmer) for around $100. I payed about $700 15 years ago for a dataman s4 still works, but I have to keep a PC with a serial port to use it.

Check out Circuit Cellar - The Magazine for Computer Applications been a subscriber for 25 years or so lots of pic resource links.

A $10 wireless breadboard from RS, or some perfboard and wire wrap wire will get you farther than a fancy development board. ME labs basic is what I have, am well pleased with it microEngineering Labs - Development tools for Microchip PICmicro MCUs including PicBasic and EPIC programmer .

Do you have a scope? If not don't worry, but it is very nice thing to "look under the hood" with.
 
i have not yet learned everything, its why i am still alive

Seems a little complicated to me. I'm able to only use a few caps, resistors, and a 555 timer, and can control a servo, as built onto a servo is the decoder that is run by such. I wondered why you want to get all the way to a microcontroller, and then use it, but now that you mentioned going commercial with a product, i can understand. The problem with software is overhead, and the less a machine has to do, the easier it can do what it wants. What if you only controlled, "say a variable resistor", and "on off"; with your controller, and use the 555 to accomplish the task of sending the signals?

Whoops! I'm bad, after finally seeing your picture (it wouldn't load), hey, that is a 556 timer you have!

My problem with these softwares is making the "time" match the "machine" as it is running on one machine faster than another, and so forth. Each computer I run them from is running just a little different speed, which messes up my hardwired coding, just as each remote code sent, run from one computer or another, with the outside device the same (IR sender), makes the code need to change. I was told with a little math in my programs, and info received from the computer it is running on (registered board timing), I could make it match, but never went that far afterwards, as it was just easy for me to turn the var resistor to get the correct code from the emitter, but not remote control it. My blaster program will do what i want, but only from my one computer i put the wait states from, in debug, my bad.

Good luck!
 
Last edited:
Seems a little complicated to me. I'm able to only use a few caps, resistors, and a 555 timer, and can control a servo, as built onto a servo is the decoder that is run by such.
...
My problem with these softwares is making the "time" match the "machine" as it is running on one machine faster than another, and so forth. Each computer I run them from is running just a little different speed, which messes up my hardwired coding, just as each remote code sent, run from one computer or another, with the outside device the same (IR sender), makes the code need to change. I was told with a little math in my programs, and info received from the computer it is running on (registered board timing), I could make it match, but never went that far afterwards,
... <snip>

That's the reason for using a PIC processor. ;) It's a little more complex, but it has an on-chip clock that is quite accurate, and can eliminate the external dependencies for delays, etc. Once it is calibrated for a (for example) 1.0 ms pulse, that's what you get, whether or not your command was just right. Call for a 2 ms pulse & you got it! I am just getting into playing with PICs, even though I am of the same vintage as Melgarga and Cadsulfide. In fact, I recognised everything Mel said (in post #3) except I had a Coco (with a tremendous 16K of RAM) but no C-64. Then spent many years in the care and feeding of a PDP11-70 & PDP11-84 by DEC (Digital Equipment Corp, R.I.P.) and a Varian R-620i. Also an Amateur Extra Class, but spend too little time on the air. Too many other projects, I guess.

Of course, you're commenting on a two-year-old thread, so it may have been dropped for another project.
 
Last edited:
Status
Please reply by conversation.

"THE MAPS", Where is the interpretation of what is what?

Sumertime Lightning and 4DTV

Users Who Are Viewing This Thread (Total: 0, Members: 0, Guests: 0)

Who Read This Thread (Total Members: 1)