I have been too busy to work with the P2 for several months now but I have jumped back in a couple weeks ago !! (Whoot!!)
I’m using TAQOZ in ROM to control servos.
I have 2 different servos:
-A FITEC 180 deg micro servo
-A Parallax Feedback 360 continuous rotation servo
I boot the board and check the sysclock by typing “CLKHZ .”
It outputs “80000000”.
I calculate the 50 Hz PWM frame using:
Clock / 50 Hz = Frame (in clock cycles)
80,000,000 / 50 = 2,400,000
I want some accuracy in defining the Pulse so I want the Frame to have 1000 clock cycles.
I now need to calculate the Offset Multiplier value:
Frame_at_Full_Speed / Desired_Frame_Size = Offset_Multiplier
2,400,000 / 1000 = 2400
Now I have everything I need to talk to the servo.
Here’s what I now type:
6 PIN —set the pin to use
: S 1000 2400 PWM ; — Define test word “S” to quickly talk to servo
25 S —Send a PULSE of 25 to the servo (25 1000 2400 PWM)
To automate testing the pulse width range, I wrote a little program to go through the whole range:
1000 1 DO I S I . 10000 1 DO I 2 + DROP LOOP LOOP MUTE
Here it is again with some white space:
6 PIN —Set PIN to use
1000 1 DO —Start Loop
I S —Sends pulse to servo
I . —Prints the loop index (pulse) value
10000 1 DO I 2 + DROP LOOP —this is a time wasting loop
LOOP —Return to start of Loop
MUTE —Turns off smart pin PWM mode
This did NOT work !?!
After extensive experimentation I found that assuming the clock speed to be 20 MHz works perfectly.
: S 1000 400 PWM ; —Recalculating the Offset Multiplier to 400/20MHz works.
I have a perfectly responding 180 deg servo now :-)
Moving on to the Feedback 360…
I’m “close” but I still can’t get this to work properly.
Assuming a clock speed of 2MHz (40 as Offset) gets the closest I can get but it is still not correct.
As I run my pulse test program, the servo actually turns the correct direction with small pulse numbers and the opposite direction with large pulse numbers. As it should but it is still very jittery and the speeds vary a lot so it is still not getting a properly aligned 50Hz frame.
Why do I have to adjust my Offset values to something other than 80MHz?
What speed does the board actually run at from boot up?
Is CLKHZ showing me the SysClock?
Are there any other insights that anyone can provide?
Thanks in advance !!