Shop OBEX P1 Docs P2 Docs Learn Events
Solutions of the troubles with the PropStickUSB to controll a Servo with 2 Butt — Parallax Forums

Solutions of the troubles with the PropStickUSB to controll a Servo with 2 Butt

nomadnomad Posts: 276
edited 2007-02-12 12:05 in Propeller 1
hi everybody

in my last postings, i have big troubles
to control 1 servo with 2 buttons.
yesterday i have hard testings:
- 1. look at my yesterday-postings
···· - LedOnOffPx.spin
···· - simulateServo1.spin
now: today i make new tests for
···· running the servo.
The results:
1) test of simulateServo1.spin with propstick = ok
2a) compare between simpleServoStick1.spin (1a)
··· and
··· servo4.spin (2a)
··· - in (1a) in the sourceCode: is this statement
········ CON
··········· _CLKMODE = XTAL1 + PLL16X···· 'Set to ext crystal, 16x PLL, 80MHz Clock
··········· _XINFREQ = 5_000_000········· 'Frequency on XIN pin is 5 MHz
··· - in (2a) no statement
2b) compare between servo4.spin (1b)
··· and
··· servo4_demo.spin (2b)
··· result: (1b) no statement.
··········· (2b) with statement
3) now testing simulateServo2.spin with the statement
·· - CON
··········· _CLKMODE = XTAL1 + PLL16X···· 'Set to ext crystal, 16x PLL, 80MHz Clock
··········· _XINFREQ = 5_000_000········· 'Frequency on XIN pin is 5 MHz
·· - RESULT: - with the new statement··· = NOT RUNNING
············ - without the new Statement = RUNNING
4) WRITE NEW CODE = SimulateServo3.spin

Now i write this new code with:
·· - p0 is for the servo-Pulse·
·· - p1 is the Button S1 control the pulse +···
·· - p2 is the Button S2 control the pulse -
·· - schematics ServoPulse = P0 -> 4.7K -> to servoSignal
···············
·· - button-circuit: as my servoTestBoard_NEW.jpg
···· s1·· pin 1 = gnd····· -> 4.7K ->· to board VSS (p29)
········· pin 2 = +3.3volt········ ->· to board VDD (p32)
········· pin 3 = signal·········· -> to boardPin p2
···· S2·· pin 3 = signal·········· -> to boardPin p3
········· pin 2 = +3.3volt->······ -> to board VDD (p32)
········· pin 1 = gnd -> 4.7K····· -> to Board VSS (p29)

Remarks: on 11.02.2007

- while the 1.test == run & ok without new code
· - new code
"
··· CON
······ _CLKMODE = XTAL1 + PLL16X···· 'Set to ext crystal, 16x PLL, 80MHz Clock
······ _XINFREQ = 5_000_000········· 'Frequency on XIN pin is 5 MHz
"
RESULT:· - WITH NEW CODE-STATEMENT = system NOT RUNNING·
············ - WITHOUT NEW CODE-STATEMENT = system RUNNING

1.tests: with this new code
--- simulateServo3.spin
VAR···· long· pulsetime, periode, timebase

PUB Main | new_periode
· periode·· := ((clkfreq / 100_000) * 2000)······ '20ms
· pulsetime := ((clkfreq / 100_000) * 150)······ '1,5ms·
·
· dira[noparse][[/noparse]0]~~·· ' Pin0 set output
· outa[noparse][[/noparse]0]~··· ' Pin0 set low
· dira[noparse][[/noparse]1]~··· ' Pin1 set input (button s1)
· dira[noparse][[/noparse]2]~··· ' Pin2 set input (button s2)
· timebase := cnt
·
· repeat
·····································
··· outa[noparse][[/noparse]0]~~········································· 'generate servopulse
··· waitcnt (timebase += pulsetime)
··· outa[noparse][[/noparse]0]~
···
··· if ina[noparse][[/noparse]1] == 1···································· 'if button pulsetime + 0,1ms
····· pulsetime += (clkfreq / 100_000)
··· if ina[noparse][[/noparse]2] == 1···································· 'if button pulsetime - 0,1ms
····· pulsetime -= (clkfreq / 100_000)
·····
··· new_periode := periode - pulsetime················· 'periodendauer - pulsdauer
·····
··· waitcnt (timebase += new_periode)·················· 'wait for periode end
·
RESULTS: - 1.TIME THE SERVO IS RUNNING WITH 2 BUTTONS ==· OOK AND JUPEEE············
So the fault with a PropStickUSB :
is this:
··· CON
······ _CLKMODE = XTAL1 + PLL16X···· 'Set to ext crystal, 16x PLL, 80MHz Clock
······ _XINFREQ = 5_000_000········· 'Frequency on XIN pin is 5 MHz

only one questions: why ????
have somebody a idea ???
On the PropellerDemoBoard with this code-statement·== servo is running
on the PropellStickUSB (no external Clock) without this code-statement
== servo is running

have somebody a idea ???

many thanks to inversi and everbody for the help.
greetings
nomad···········
··

Comments

  • inserviinservi Posts: 113
    edited 2007-02-11 11:13
    Hello,

    The crystal installed in your PropellStickUSB is probably not runing at 5 Mhz.

    The compiler ( or interpreter) calculate clkfreq from the value of _CLKMODE and _XINFREQ
    _XINFREQ must match with the crystal realy instaled, then all is perfect. But if it's not the case, clkfreq take a bad value and the timing calculation ( clkfreq ) is wrong.

    If you are not initializing _CLKMODE and _XINFREQ then the Propeller use an internal osciliator and calculate clkfreq corectly.
    This is why the timing is right witout _CLKMODE and _XINFREQ initialisation with your PropellStickUSB.

    In my board, your program simpleServoStick1.spin is workink as well with the Clock declarations and with out this.

    dro

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    in medio virtus

    Post Edited (inservi) : 2/11/2007 11:17:43 AM GMT
  • nomadnomad Posts: 276
    edited 2007-02-11 14:40
    hi inservi,

    thanks for your answer.
    tomorow i am looking with my distributor in switzerland,
    for the correct clock-declarations for my propstick.
    thanks a lot.
    but, i am verry happy now, that my servo & the propstick running.

    greetings
    nomad
  • Stan671Stan671 Posts: 103
    edited 2007-02-11 17:12
    The PropStickUSB has a 5 MHz oscillator in it.· So, the following statements are correct and should appear in the beginning of all of your Spin programs:

    CON
    
      _clkmode = xtal1 + pll16x 
      _xinfreq = 5_000_000
    


    You certainly could have a defective chip.· It might be a good idea to just try a VERY simple test program that blinks a LED once per second.· Ths would test the timing settings and prove to you that the chip is actually running.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Stan Dobrowski
  • nomadnomad Posts: 276
    edited 2007-02-12 12:05
    hi stan,
    thanks for your answer.
    i have testing the stuff.

    results: its the same!!

    but i think, my stick is NOT devective.


    last week i have the same problem with a another Stick,

    but for me, in the moment, is the situation OK,
    the propStick running with my 2 buttons and a servo and
    i am happy.

    i think this problem is possibly a big hocuspocus....jumpin.gif

    greetings
    nomad
Sign In or Register to comment.