P2 Edge Goes For a Ride
Items used to build the RoadSteer:
- P2 Edge
- Flat Edge Adapter Board
- 5 Volt Regulator
- 3 Volt Regulator
- Parallax WiFi Module
- 2 NEMA 17 Motors
- 2 A4988 Motor Drivers
- X8R RC Receiver
- 11.3 Volt Battery
- 5mm to 12mm Adapters
- 2 Rubber Wheels
- RoadSteer 3D Printed Frame
- Plastic Spoon
- 10 M3 8mm Socket Screws
- 2 M4 Screws
- RC Radio
Code used to drive the RoadSteer:
#include <math.h> #include <stdio.h> #include <propeller.h> #include "Stepper.h" #include "Sbus.h" #define SM1DIR 10 #define SM1STEP 9 #define SM1ENABLE 8 #define SM2DIR 13 #define SM2STEP 12 #define SM2ENABLE 11 #define X8R 36 #define DMax 1740 #define DMin 178 #define SMax 1811 #define SMin 184 int main(int argc, char** argv) { int Dr, Sp; int left, right; int Ls, Rs; left = Stepper_Start(SM1ENABLE, SM1DIR, SM1STEP); right = Stepper_Start(SM2ENABLE, SM2DIR, SM2STEP); Stepper_Direction(right, 1); Sbus_Open(X8R); _waitms(1000); Sbus_SetScaled(1, 256, 1811); Sbus_SetScaled(2, 184, 1811); Sbus_SetScaled(3, 196, 1796); while (1) { Dr = Sbus_GetScaled(1); Sp = Sbus_GetScaled(2); //printf("Dr: %d, Sp: %d\r\n", Dr, Sp); if (Sp < 1000) { Sp = 0; Dr = 0; Stepper_Enable(left, 0); Stepper_Enable(right, 0); } else { Stepper_Enable(left, 1); Stepper_Enable(right, 1); Dr = 1500 - Dr; if (abs(Dr) < 30) Dr = 0; Sp = 1500 - Sp; if (abs(Sp) < 5) Sp = 0; } Ls = Sp >> 2; Rs = Sp >> 2; Ls = Ls + Dr / 4; Rs = Rs - Dr / 4; if (Ls > 0) Stepper_Direction(left, 0); else Stepper_Direction(left, 1); if (Rs > 0) Stepper_Direction(right, 1); else Stepper_Direction(right, 0); //printf("Left: %d, Right: %d\r\n", Ls, Rs); Stepper_Speed(left, abs(Ls)); Stepper_Speed(right, abs(Rs)); _waitms(1); } }
Libraries used:
- SBUS Receiver
- Stepper Motor Driver
Next, I want to replace the Stepper motor driver with a Step driver and remove the SBUS receiver and build a LOGO language program to control the robot with LOGO commands. With the accuracy of the step motor, it should work pretty well.
Mike
Comments
Nice !! A big Stingray.
Looks awesome, Mike! I'm getting cold just watching your extreme icy terrain. Somewhat different from here in southern California.
Like the spoon