Shop OBEX P1 Docs P2 Docs Learn Events
Beta testing thread for Servo Controller Tiny11 — Parallax Forums

Beta testing thread for Servo Controller Tiny11

metron9metron9 Posts: 1,100
edited 2007-06-20 16:57 in General Discussion
I was playing around with my new Dragon programmer for Atmel chips and decided to use the high voltage serial mode to program a tiny11.

I made a chip that has one input and one output.

The input is mirrored to the output pin and the pulse width is then output every 20mS

So, all you do is put it inline with the signal line of a servo. Send one pulse and it takes care of the rest.

For those of you that have programming tools for atmel chips, here is the code. It should work fine on tiny 12's and 13's as well as 45's etc.

The tiny 11 has one advantage for a device like this however as it's only .25 cents a chip.

When the pulse is being timed on input, the timer is reset to 30mS so that it is possible to control the servo transparently as the first automatic pulse is generated 30ms after the pulse is read.

I would be happy to program chips and mail them to anyone for $1.00 per chip. Hey I can't work for free all the time, I gotta eat, now where are those hot pockets anyway...



.include "tn11def.inc"

.def     temp        =    r16
.def    pulseH        =    r17
.def    pulseL        =    r18
.def    timeflag    =    r19
.def    MStime        =    r20
.DEF    PULSEHB        =    R21
.DEF    PULSELB        =    R22
.DEF    INTTEMP        =    R23

.equ    _mstime        =    80

rjmp    RESET        ; Reset handler
rjmp    EXT_INT0    ; IRQ0 handler
rjmp    PIN_CHANGE    ;Pin change handler
rjmp    TIM0_OVF    ; Timer0 overflow handler
rjmp    ANA_COMP    ; Analog Comparator handler


RESET:



ldi mstime,_mstime
ldi temp,3
sbi ddrb,0



LDI temp,(1<<TOIE0)
OUT TIMSK,temp

ldi temp,(1<<INT0)
out GIMSK,temp
ldi temp,(1<<ISC01)|(1<<ISC00)
out MCUCR,temp


SEI
main1:
LDI temp,(0<<cs01)|(1<<cs00) ;CK/8
OUT TCCR0,temp
MAIN:
CBI PORTB,0
SBRS TIMEFLAG,0
RJMP MAIN
LDI TIMEFLAG,0
MOV PULSEL,PULSELB
inc pulsel
inc pulsel
LDI temp,(0<<cs01)|(0<<cs00) ;CK off
OUT TCCR0,temp
PULSELOOP:
nop
nop
nop
cpi pulsel,0
BREQ MAIN1
PL1:
DEC PULSEL
breq MAIN1
SBI PORTB,0
RJMP PULSELOOP


EXT_INT0:    ; IRQ0 handler
sbi portb,0 ;set pin high
clr pulseLB
clr pulseHB
int0loop:
NOP
NOP
NOP
NOP
NOP
NOP
sbis pinb,1
rjmp int0done
inc pulseLB
rjmp int0loop
int0done:
cbi portb,0
LDI MStime,120
LDI INTTEMP,(1<<INTF0)
OUT GIFR,INTTEMP

RETI

PIN_CHANGE:    ;Pin change handler
RETI

TIM0_OVF:    ; Timer0 overflow handler
DEC MStime
BRNE NO
LDI MStime,_mstime
LDI TIMEFLAG,1
RETI
NO:
RETI

ANA_COMP:    ; Analog Comparator handler
RETI





▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Think Inside the box first and if that doesn't work..
Re-arrange what's inside the box then...
Think outside the BOX!

Post Edited (metron9) : 6/7/2007 5:57:52 PM GMT

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2007-05-23 11:47
    Metron,

    So, if I understand you correctly, you send the chip a particular pulse and the chip then keeps repeating it until it gets a new pulse?

    Have you got any 'scope shots of input and output? If it works like I think it does, I'd be interested in a few.

    BTW, never apologize for being paid for work done!!

    Regards,

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tom Sisk

    http://www.siskconsult.com
    ·
  • BeanBean Posts: 8,129
    edited 2007-05-23 11:53
    Metron9,
    · You stole my idea tongue.gif

    · I was going to do the same thing with a PIC10F200, but you beat me to it.

    · I guess great minds think alike.

    · $.25 per chip, dang that IS cheap. [noparse][[/noparse]edit] Where do you buy them for $.25 ?

    P.S. You said they·were .25 cents,·I assume you·mean .25 dollars. Gotta watch that. Did you ever hear that verison phone call. Funny...

    Bean.
    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com


    Post Edited (Bean (Hitt Consulting)) : 5/23/2007 12:01:26 PM GMT
  • metron9metron9 Posts: 1,100
    edited 2007-05-23 14:50
    Hey Bean, It sure would be fun to collaborate with you on a difficult project. The more difficult the more fun it would be.

    I had this concept in mind for a while, when I finally hooked up the chip to design the program it actually took me 3 days before I wrote any code, I pondered the best way to do it given a 1MHZ chip speed (internal oscillator) When my brain finished designing the code mostly while I was asleep it took a couple of hours to fine tune it and test it with an actual servo. Since this chip only has one timer I used it for the 20ms delay time. Then I used code that takes 11us per iteration to allow (11 * 255) = 2.805mS maximum pulse width. Longer pulse widths will wrap around.

    I just thought of a way to turn it on and off. Since puls widths of less than 200us are not needed for servos, I will add an off switch using 50us to turn the unit off. I will add a sleep mode as well in the off state. It may take two pulses to be accurate when waking up.


    The price is actually .35 cents at digikey per hundred. I had an old tube that I had written .25 cents on.

    Stamptrol, attached is a scope plot. The pulswidth(pos) on the test listing shows 1.490mS and 1.495 mS for a pulseout 5,750 basic stamp command. The red line is the basic stamp, the blue line is the generated output. Notice the 30mS delay before the first pulse is generated and the mirrored output of the blue line during the pulse read. The timer gets set back to 30mS for every pulse that comes in. Not sure if this should be extended to more time. I don't work much with servos so I don't know how long the maximum refresh rate can be. I have set it to 20mS for the continuing pulses.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
    889 x 798 - 28K
  • DgswanerDgswaner Posts: 795
    edited 2007-05-23 15:32
    what does it take to connect this to a servo? are any other components required? I would be interested in some if you could provide a parts list and schematic.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    A complex design is the sign of an inferior designer. - Jamie Hyneman, Myth Buster
  • metron9metron9 Posts: 1,100
    edited 2007-06-03 22:25
    For the sample servo chips I sent out.
    Here is the servo co-processor connection diagram. From the stamp to the INPUT and from the OUTPUT to the servo.
    Run the chip at 5V, +5V at the VCC and ground at GND

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
    423 x 296 - 20K
  • bambinobambino Posts: 789
    edited 2007-06-07 17:22
    On pins 1,2,3 and 7, do you reccomend float or Ground!
  • metron9metron9 Posts: 1,100
    edited 2007-06-07 17:28
    Pin 1 is the reset line so grounding it will reset the chip. It has internal pullup so float is fine. If you have reset problems a 10K resistor to VCC is typical with a capacitor if your voltage is noisy enough to drop below 2.7V but I have never had problems with it.

    Pins 2 3 and 7 are internally set to INPUT with no pullups and should not be a problem to leave them float. Tying them to ground can also be done. On a circuit board i usually just bring the unused pins out to a junction so in the future they can be used for something if I reprogram the chip.

    Looking forward to hearing about your testing.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • bambinobambino Posts: 789
    edited 2007-06-07 17:42
    Thanks,
    I'll try it this weekend.
  • bambinobambino Posts: 789
    edited 2007-06-11 16:01
    Very jealous!
    This is a great app!
    The only thing I noticed that might be a potential problem is the actions of the chip when I reset the propeller.
    When I reset the propeller or download a fresh program into ram the chip does an erotic dance with the servo that lasts anywhere from 5 to 10 seconds before releasing the servo. It does not appear to be pushing the servo to extremes but it did scare me a little when it danced off my desk.
  • metron9metron9 Posts: 1,100
    edited 2007-06-11 16:59
    The pin you use on the prop for programming is most likley the pin you are useing to run the servo chip. Move it to another pin and that should take care of it.

    I had thought about using another pin for an ON Off switch, that could be done, but would take another pin from the prop. or you can switch the power to the servo chip on and off as well. You will have to send another pulse to get it going again. i could save the last pulse and output it when powered up as well.

    So many ways, let me know what you think about these ideas.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • bambinobambino Posts: 789
    edited 2007-06-13 18:45
    I think the idea you had in your post to Beau about the 50uS pulse was pretty good.
    And the wrap around idea surprised me a little. I did not intend to over pulse the servo but when I did it went into a full sweep the other way. I once had a Ping((((( attached to this servo, programmed to scan for local objects and then follow them. The wrap around would have served well there.
  • metron9metron9 Posts: 1,100
    edited 2007-06-13 20:02
    Oh the 50us turn off I think is implemented in the one you have bambino. Give it a try.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • bambinobambino Posts: 789
    edited 2007-06-15 14:49
    Will do!
    I probably would have already, but it didn't sink in first time I read this post.
  • metron9metron9 Posts: 1,100
    edited 2007-06-20 16:57
    Just thinking about the servo chip while I am printing at work, I thought of an idea.

    Since the tiny11 internal oscillator is voltage dependent , 2.7V to 5.5V You could send it a pulse to center the servo with a voltage of 4.1V. Then vary the voltage from 2.7V to 5.5V to move the servo. not sure as I sit here what the range would be but it might work for some applications.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
Sign In or Register to comment.