Don't ad-block us - support your favorite websites. We have safe, unobstrusive, robotics related ads that you actually want to see - see here for more.
0 Members and 1 Guest are viewing this topic.
Looks great so far.But I am trying to resolve an issue I am having with Roborealm and want to try tweaking the rprintf function (see http://www.societyofrobots.com/robotforum/index.php?topic=7880.0) but am a little unclear as to how to do this because of the precompiled libraries.If I change the rprintfs.c in your library folder nothing changes (because of the precomiled bit), but if I include a modified version of rprintfs.c in my folder and include that in the AVR Studio source files, it complains about the .elf file not being found (This I don't understand).ThanksJustin
// 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 secondsENCODER 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 variablsint16_t r_clicks = 0; // Total clicks travledint16_t l_clicks = 0;int do_once = 1;//encoder stuffTICK_COUNT r_prev_time = 0;//Time of the last encoder readingTICK_COUNT l_prev_time = 0;TICK_COUNT speed_calc_timer;//pid stuffint16_t r_target_speed = 0; // most recent speed in clicks per 1/4 secondint16_t l_target_speed = 0;int16_t r_speed = 0; // most recent speed in clicks per 1/4 secondint16_t l_speed = 0;int16_t r_integral = 0; // integralsint16_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 readingTICK_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 insteadvoid appInit(void){// Set UART1 to 115200 bauduartSetBaudRate(UART1, 115200);// Tell rprintf to output to UART0rprintfInit(&uart1SendByte);uartSetBaudRate(UART2, 19200);sabertoothInit(&driver);}// This routine is called repeatedly - its your main loopvoid 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; } } }
//Takes values between 0 and 127 for motor speedsvoid sabertooth(uint8_t m2, uint8_t m1) { uartSendByte(UART2, m1);//send a command for motor 1 uartSendByte(UART2,m2+128);//send a command for motor 2 }
#include "Sensors/Distance/SharpIR_GP2D120.h"#include "sensor.h"
GP2D120 ir_r_f = MAKE_GP2D120(K5);GP2D120 ir_r_r = MAKE_GP2D120(K6);
Webbot, how is the I2C slave going? did you have a chance to work on it?I need to start testing the motor controller and without the library I can't do it. I have tested part of the controller code on Arduino, using their Wire library, but that doesn't fit in the tiny2313. So I have 2 options: use avrlib or bascom. Altho Bascom has a demo version that can program the tiny2313, I don't want to pay $15 for the hardware I2C Slave library. There is a third party hardware library for Bascom in (written in ASM) but it's in german and I can't understand how to use it. I could use the software library, but it takes too much space I can use for control code. I have no experience with avrlib yet so I don't know if I2C takes a lot of space in the flash and how to set it up to work as a slave.Please let me know of your thoughts on this matter.Thanks a lot.
The main difference is my currently supported chips support I2C/TWI, SPI etc whereas ATtiny2313 uses Universal Serial Interface a kind of superset of stuff including I2C so would need some special handling anyway.
Just being a pain but 'why did you settle on the tiny2313, build the board, and then worry how to write the s/w and see if it would fit?'
Seems like SoR may be able to settle on a chip that is 'overpowered' for most modules but then go for bulk purchase to keep the cost down. By settling on a std chip, ATMega168 for example, then you could share libraries. ie portability vs saving a few cents.
Hope that helps - but may just make you go 'aaaaaargh'.