Skip to content

Commit

Permalink
Run up to 4 fb360 servos sans jitter (close issues 93 & 94)
Browse files Browse the repository at this point in the history
Issues closed:
servo360 - increase number of servos supported #93
#93
servo360 - remove remove jitter from servo signal #94
#94
  • Loading branch information
AndyLindsay committed Sep 18, 2017
1 parent 994e8e8 commit 2cee4f8
Show file tree
Hide file tree
Showing 25 changed files with 457 additions and 80 deletions.
35 changes: 35 additions & 0 deletions Learn/Examples/Devices/Motor/Servo360/Set Angles 1 servo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Set Angles.c
Turns to and holds positions.
Behaves like a standard RC servo when it reaches a given angle.
*/

#include "simpletools.h"
#include "servo360.h"

int main()
{
// Connect is required before control. The first argument is the I/O pin
// connected to the white control line, and the second is the I/O pin connected
// to the yellow feedback line.
//servo360_connect(12, 14);
servo360_connect(13, 15);
pause(1000);

//servo360_angle(12, 0);
servo360_angle(13, 0);
pause(1000);

//servo360_angle(12, 45);
servo360_angle(13, -45);
pause(1500);

//servo360_angle(12, 360 + 45);
servo360_angle(13, -360 -45);
pause(2500);

//servo360_angle(12, 0);
servo360_angle(13, 0);
pause(1000);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Set Angles.c
>compiler=C
>memtype=cmm main ram compact
>optimize=-Os
>-m32bit-doubles
Set Angles 1 servo.c
>-fno-exceptions
>defs::-std=c99
>-lm
>-m32bit-doubles
>BOARD::ACTIVITYBOARD
>compiler=C
>defs::-std=c99
>memtype=cmm main ram compact
>optimize=-Os
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Set Angles 2 servos.c
>compiler=C
>memtype=cmm main ram compact
>optimize=-Os
>-m32bit-doubles
>-fno-exceptions
>defs::-std=c99
>-lm
>BOARD::ACTIVITYBOARD
42 changes: 42 additions & 0 deletions Learn/Examples/Devices/Motor/Servo360/Set Angles 3 servos.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Set Angles.c
Turns to and holds positions.
Behaves like a standard RC servo when it reaches a given angle.
*/

#include "simpletools.h"
#include "servo360.h"

int main()
{
// Connect is required before control. The first argument is the I/O pin
// connected to the white control line, and the second is the I/O pin connected
// to the yellow feedback line.
int s1 = servo360_connect(12, 14);
int s2 = servo360_connect(13, 15);
int s3 = servo360_connect(16, 6);
//int s3 = 0;
print("devcount = %d, s1 = %d, s2 = %d, s3 = %d\r", s1, s2, s3, devCount);
pause(1000);

servo360_angle(12, 0);
servo360_angle(13, 0);
servo360_angle(16, 0);
pause(1000);

servo360_angle(12, 45);
servo360_angle(13, -45);
servo360_angle(16, 45);
pause(1500);

servo360_angle(12, 360 + 45);
servo360_angle(13, -360 -45);
servo360_angle(16, 360 + 45);
pause(2500);

servo360_angle(12, 0);
servo360_angle(13, 0);
servo360_angle(16, 0);
pause(1000);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Set Angles 3 servos.c
>compiler=C
>memtype=cmm main ram compact
>optimize=-Os
>-m32bit-doubles
>-fno-exceptions
>defs::-std=c99
>-lm
>BOARD::ACTIVITYBOARD
47 changes: 47 additions & 0 deletions Learn/Examples/Devices/Motor/Servo360/Set Angles 4 servos.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
Set Angles.c
Turns to and holds positions.
Behaves like a standard RC servo when it reaches a given angle.
*/

#include "simpletools.h"
#include "servo360.h"

int main()
{
// Connect is required before control. The first argument is the I/O pin
// connected to the white control line, and the second is the I/O pin connected
// to the yellow feedback line.
int s1 = servo360_connect(12, 14);
int s2 = servo360_connect(13, 15);
int s3 = servo360_connect(16, 6);
int s4 = servo360_connect(17, 7);
//int s3 = 0;
print("devcount = %d, s1 = %d, s2 = %d, s3 = %d, s4 = %d\r", s1, s2, s3, s4, devCount);
pause(1000);

servo360_angle(12, 0);
servo360_angle(13, 0);
servo360_angle(16, 0);
servo360_angle(17, 0);
pause(1000);

servo360_angle(12, 45);
servo360_angle(13, -45);
servo360_angle(16, 45);
servo360_angle(17, -45);
pause(1500);

servo360_angle(12, 360 + 45);
servo360_angle(13, -360 -45);
servo360_angle(16, 360 + 45);
servo360_angle(17, -360 - 45);
pause(2500);

servo360_angle(12, 0);
servo360_angle(13, 0);
servo360_angle(16, 0);
servo360_angle(17, 0);
pause(1000);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Set Angles 4 servos.c
>compiler=C
>memtype=cmm main ram compact
>optimize=-Os
>-m32bit-doubles
>-fno-exceptions
>defs::-std=c99
>-lm
>BOARD::ACTIVITYBOARD
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
IR Roaming.c
Use IR LED and IR receiver pairs as object detectors for robot roaming.
http://learn.parallax.com/activitybot/roaming-infrared-flashlights
*/

#include "simpletools.h" // Library includes
#include "abdrive360.h"

int irLeft, irRight; // IR variables

int main() // Main function
{
low(26); // D/A0 & D/A1 to 0 V
low(27);

drive_setRampStep(12); // Max step 12 ticks/s every 20 ms
drive_setMaxVelocity(FOR_SPEED, 96);


while(1)
{
freqout(11, 1, 38000); // Check left & right objects
irLeft = input(10);

freqout(1, 1, 38000);
irRight = input(2);

if(irRight == 1 && irLeft == 1) // No obstacles?
drive_rampStep(128, 128); // ...full speed ahead
else if(irLeft == 0 && irRight == 0) // Left & right obstacles?
drive_rampStep(-128, -128); // ...full speed reverse
else if(irRight == 0) // Just right obstacle?
drive_rampStep(-128, 128); // ...rotate left
else if(irLeft == 0) // Just left obstacle?
drive_rampStep(128, -128); // ...rotate right
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
IR Roaming at slower speeds.c
>compiler=C
>memtype=cmm main ram compact
>optimize=-Os
>-m32bit-doubles
>-fno-exceptions
>defs::-std=c99
>-lm
>BOARD::ACTIVITYBOARD
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Test Encoder Connections.c
Load to ActivityBot EEPROM. PWR to Position 2.
Gently turn each wheel by hand. Right wheel
blinks P27 LED, left wheel blinks P26 LED.
If not, encoders are not seeing wheel spokes.
Go to Extras/Troubleshooting section of tutorial.
http://learn.parallax.com/activitybot/test-encoder-connections
*/

#include "simpletools.h"
#include "abdrive360.h"

int main()
{
low(26);
low(27);
while(1)
{
int ticksLeft, ticksRight;
drive_getTicks(&ticksLeft, &ticksRight);
set_output(26, ticksLeft % 2);
set_output(27, ticksRight % 2);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Test Encoder Connections (1).c
>compiler=C
>memtype=cmm main ram compact
>optimize=-Os
>-m32bit-doubles
>-fno-exceptions
>defs::-std=c99
>-lm
>BOARD::ACTIVITYBOARD
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
Forward Stop Face Right.c
http://learn.parallax.com/activitybot/go-certain-distances
*/


#include "simpletools.h"
#include "abdrive360.h"

int main()
{
/*
#ifdef _console_
console_start();
suppressFbDisplay = 0;
#endif
*/

drive_goto(192, 192);
servo360_connect(16, 6);
servo360_speed(16, 90);
drive_goto(-28, 28);
drive_goto(28 * 2, -28 * 2);
drive_goto(-28, 28);
drive_goto(-192, -192);
servo360_speed(16, -90);

drive_goto(192, 128);
drive_goto(-192, -128);
drive_goto(128, 192);
drive_goto(-128, -192);
servo360_speed(16, 0);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
drive_goto tests 3 servos.c
>compiler=C
>memtype=cmm main ram compact
>optimize=-Os
>-m32bit-doubles
>-fno-exceptions
>defs::-std=c99
>-lm
>BOARD::ACTIVITYBOARD
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

#include "simpletools.h"
#include "abdrive360.h"

int main()
{
drive_setMaxVelocity(FOR_GOTO, 96);
drive_goto(192, 192);
drive_setMaxVelocity(FOR_GOTO, 64);
drive_goto(-28, 28);
drive_goto(28 * 2, -28 * 2);
drive_goto(-28, 28);
drive_goto(-192, -192);

drive_setMaxVelocity(FOR_GOTO, 32);

drive_goto(192, 128);
drive_goto(-192, -128);
drive_goto(128, 192);
drive_goto(-128, -192);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
drive_goto tests with setMaxVelocity (1).c
>compiler=C
>memtype=cmm main ram compact
>optimize=-Os
>-m32bit-doubles
>-fno-exceptions
>defs::-std=c99
>-lm
>BOARD::ACTIVITYBOARD
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include "simpletools.h"
#include "abdrive360.h"

int main()
{
drive_setMaxVelocity(FOR_GOTO, 96);

drive_goto(192, 192);
drive_goto(-28, 28);
drive_goto(28 * 2, -28 * 2);
drive_goto(-28, 28);
drive_goto(-192, -192);

drive_setMaxVelocity(FOR_GOTO, 32);

drive_goto(192, 128);
drive_goto(-192, -128);
drive_goto(128, 192);
drive_goto(-128, -192);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
drive_goto tests with setMaxVelocity.c
>compiler=C
>memtype=cmm main ram compact
>optimize=-Os
>-m32bit-doubles
>-fno-exceptions
>defs::-std=c99
>-lm
>BOARD::ACTIVITYBOARD
Loading

0 comments on commit 2cee4f8

Please sign in to comment.