Software > Software

New C library - testers required

<< < (3/50) > >>

Admin:
Just an update . . . I'll try implementing this on the Axon 2 within the next ~3 weeks, right after RoboGames. My crazy schedule chills out on like the 17th of this month.

Bandwidth and server usage is not a prob, I'm currently using like only ~7% of my alloted resources ;D

Resilient:
Edit: Solved my own problem, doing basic subtraction correctly is helpful to programming.

Resilient:
Ok, now I really am having a problem that cant be solved by simply doing subtraction right

I got the following code:


--- Code: ---// Place any #define statements here before you include ANY other files
// You must ALWAYS specify the board you are using
// These are all in the 'sys' folder e.g.
#include "sys/axon.h" // I am using an Axon
// Now include any other files that are needed here
#include "uart.h"
#include "rprintf.h"
#include "libdefs.h"
#include <stdarg.h>
#include "Sensors/Encoder/quadrature.h"
#include "Motors/Dimension/Sabertooth.h"
// Now create any global variables such as motors, servos, sensors etc

#define TIME_REDUCTION 250000 //converts us to 1/4 seconds

ENCODER l_encoder = MAKE_ENCODER(K0,E3,FALSE,64);
ENCODER r_encoder = MAKE_ENCODER(J6,C1,TRUE,64);

SABERTOOTH_MOTOR motor1 = MAKE_SABERTOOTH_MOTOR(FALSE, 128,0);
SABERTOOTH_MOTOR motor2 = MAKE_SABERTOOTH_MOTOR(FALSE, 128,1);

SABERTOOTH_MOTOR_LIST motors[] = {&motor1,&motor2};
SABERTOOTH_DRIVER driver = MAKE_SABERTOOTH_DRIVER(motors, UART2, 19200);


//Wheel circrumfurance 229mm
//Add your code here
//Global variabls
int16_t r_clicks = 0; // Total clicks travled
int16_t l_clicks = 0;
int do_once = 1;

//encoder stuff

TICK_COUNT r_prev_time = 0;//Time of the last encoder reading
TICK_COUNT l_prev_time = 0;
TICK_COUNT speed_calc_timer;

//pid stuff

int16_t r_target_speed = 0; // most recent speed in clicks per 1/4 second
int16_t l_target_speed = 0;
int16_t r_speed = 0; // most recent speed in clicks per 1/4 second
int16_t l_speed = 0;
int16_t r_integral = 0; // integrals
int16_t l_integral = 0;
int16_t r_previous_p = 0;
int16_t l_previous_p = 0;
TICK_COUNT r_prev_integral = 0;//Time of the last encoder reading
TICK_COUNT l_prev_integral = 0;



int16_t calculate_speed(char side);
int16_t pid(char side);
void go_speed(int16_t l, int16_t r);



// This routine is called once only and allows you to do any initialisation
// Dont use any 'clock' functions here - use 'delay' functions instead
void appInit(void){
// Set UART1 to 115200 baud
uartSetBaudRate(UART1, 115200);
// Tell rprintf to output to UART0
rprintfInit(&uart1SendByte);
uartSetBaudRate(UART2, 19200);
sabertoothInit(&driver);
}



// This routine is called repeatedly - its your main loop
void appControl(LOOP_COUNT loopCount, TICK_COUNT loopStart){
DRIVE_SPEED speed = 127;
if(do_once == 1)
{
speed_calc_timer = clockGetus();
do_once = 0;
}
if(clockHasElapsed(speed_calc_timer, TIME_REDUCTION) == TRUE)
{
act_setSpeed(&motor1,100);
if(speed > -127)
{
speed = speed-5;
}
}

}

--- End code ---

But no motor is turning. I would expect it to start at near full speed then go down and eventually reverse. It is also throwing a warning saying:

../webtst.c:23: warning: initialization from incompatible pointer type

for the SABERTOOTH_DRIVER driver = MAKE_SABERTOOTH_DRIVER(motors, UART2, 19200); line.

Any ideas here?

Webbot:
Hi Resilient - am away on business at the moment. So you may have to hangon until Tuesday. But will see if I can get time to have a look between meetings. Sorry..

Resilient:
No problem. I wrote my own function to use the simplified mode on the Sabertooth and that works, so getting it fixed is not critical.

I also tried directly copying and pasting your code from Sabertooth.h and tried running that and had the same result. Wheels just sit there.

So something isn't working right with the Sabertooth functions on the Axon. I am using UART2 (which I did remember to change in your test code in Sabertooth.h) :P

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version