Beginners: please read this post and this post before posting to the forum.
0 Members and 1 Guest are viewing this topic.
they added a capacitor between the USB-serial chip’s DTR line (active-low) and the microcontroller’s reset line, so that the host computer can trigger DTR and pull down the reset for a moment, relieving you of pressing the button.
with just a 0.1uF (100 nano-farad) capacitor and a soldering iron.
The retrofitting process consists on soldering a 0.1uF disc capacitor between the DTR pin and the Reset signal. The reset signal is available in several points of the PCB, but the most accesible one is in the ICSP header (pin #5).
I found a description of someone doing it on an arduino board with an atmega8.Quote... so that the host computer can trigger DTR and pull down the reset for a moment, relieving you of pressing the button.but now how do you bring that reset pin low?Can we recompile the fast tiny & mega bootloader to do this for us?
... so that the host computer can trigger DTR and pull down the reset for a moment, relieving you of pressing the button.
The new BlueSmirf modules from Sparkfun have 6 pins (instead of just 4): Vcc, GND, Tx, Rx, RTS, DTR. You may use the DTR pin to reset your atmega to enter the bootloader.
Yeap, turning on the WDT would reset it in software. You'd have to send a command through serial to your ATmega to turn it on, then do your bootloader asap. Hmmmm might have a comport conflict . . .Let me know your progress, I need this to work for my ERP, but don't have time to look into it . . .
//SoR Include#include "SoR_Utils.h" //includes all the technical stuff//global variableschar myReceivedByte;int sharp_IR_reading=0;int sensor_left=0;int sensor_right=0;int photo_thresh=8;int scan_thresh=0;//threshold value of scanning sensorint scan_angle=240;//position of scanner, in units of servo command -> 30 * 8int max_scan_angle=448;//maximum position scanner can rotate to (57) -> 56 * 8//this function causes scanning servo to center on edge of objectvoid scan(void) { //lower (-) goes right //higher (+) goes left //30 far right, 50 straight, 56 far left (until it jams) /*psuedocode object is detected scan right object detected object not detected scan left until object detected*/ sharp_IR_reading=a2dConvert8bit(3); sensor_left=a2dConvert8bit(5); sensor_right=a2dConvert8bit(4); rprintf( "Scanner: %d, \tAngle: %d, \tL Photo: %d, \tR Photo: %d\r\n", sharp_IR_reading, scan_angle, sensor_left, sensor_right ); if (sharp_IR_reading > scan_thresh)//object detected { if (scan_angle>328) //overflow protection -> 41 * 8 scan_angle-=16;//scan right -> 2 * 8? } else //object not detected { if (scan_angle<=max_scan_angle) //maximum servo angle scan_angle+=16; //scan left -> 2* 8? else //if scanned all the way, this forces it to start over scan_angle=240; // 30 * 8 } //servo scan code servo_scan(scan_angle); }//automatically calculates threshold value before runvoid autocalibrate(void) { scan_thresh=a2dConvert8bit(3);//sensor reading }int main(void) { //LED_on(); initialize(); delay_cycles(336000);//two second wait delay -> 42000 * 8 /*********ADD YOUR CODE BELOW THIS LINE **********/ //find thresholds autocalibrate(); //LED_off(); while(1) { scan(); //Object Avoider if (sharp_IR_reading > scan_thresh) robot_turn_right(); //object is centered else robot_go_straight(); /* object chaser //object on left if(scan_angle > 456) // 57 * 8 robot_turn_left(); //object on right else if(scan_angle < 328) // 41 * 8 robot_turn_right(); //object is centered else robot_go_straight(); */if (uartReceiveByte(&myReceivedByte)) { // if there are bytes waiting on the serial port char inByte = uartGetByte(); // read a byte if (inByte == 'r') { //if that byte is the desired character //int len = 5; // expected string is 6 bytes long //char inString[len]; // declare string variable //for (int i = 0; i < len; i++) //{ // inString[i] = uartGetByte(); //} //if ( strstr(inString, "reset") != -1 ) // check to see if the respose is "reset" resetChip(5000); // reset the chip after waiting for the specified # of milliseconds } // end if} // end if delay_cycles(3200);//a small delay to prevent crazy oscillations -> 400 * 8 } // end while loop /*********ADD YOUR CODE ABOVE THIS LINE **********/ return 0; } // end main
//AVR includes#include <avr/io.h> // include I/O definitions (port names, pin names, etc)#include <avr/interrupt.h> // include interrupt support#include <avr/wdt.h> // include watchdog timer//AVRlib includes#include "global.h" // include global settings#include "buffer.h" // include buffer function library#include "uart.h" // include uart function library#include "rprintf.h" // include printf function library//#include "timer.h" // include timer function library (timing, PWM, etc)#include "a2d.h" // include A/D converter function library// For newer AVRs such as ATmega1281// Function Pototypeint MCUSR;void wdt_init(void) __attribute__((naked)) __attribute__((section(".init3")));// Function Implementationvoid wdt_init(void){ MCUSR = 0; wdt_disable(); return;}//define port functions; example: PORT_ON( PORTD, 6);#define PORT_ON( port_letter, number ) port_letter |= (1<<number)#define PORT_OFF( port_letter, number ) port_letter &= ~(1<<number)#define PORT_ALL_ON( port_letter, number ) port_letter |= (number)#define PORT_ALL_OFF( port_letter, number ) port_letter &= ~(number)#define FLIP_PORT( port_letter, number ) port_letter ^= (1<<number)#define PORT_IS_ON( port_letter, number ) ( port_letter & (1<<number) )#define PORT_IS_OFF( port_letter, number ) !( port_letter & (1<<number) )#define soft_reset() \do \{ \ wdt_enable(WDTO_15MS); \ for(;;) \ { \ } \} while(0)//************CONFIGURE PORTS************//configure ports for input or output - specific to ATmega8void configure_ports(void) { DDRC = 0x00; //configure all C ports for input PORTC = 0x00; //make sure pull-up resistors are turned off DDRD = 0xFF; //configure all D ports for output rprintf( "\n\n\t\t\tPorts Configured.\n\n" ); }//***************************************//************DELAY FUNCTIONS************//wait for X amount of cycles (23 cycles is about .992 milliseconds)//to calculate: 23/.992*(time in milliseconds) = number of cycles//or (number of cycles)*.992/23 = time in millisecondsvoid delay_cycles(unsigned long int cycles) { while(cycles > 0) cycles--; }//***************************************//*********SIMPLIFIED FUNCTIONS**********//functions to make coding easier for a beginner//but could cause port mixup confusion for intermediate usersvoid LED_on(void) { PORT_OFF(PORTD, 4);//turn LED on }void LED_off(void) { PORT_ON(PORTD, 4);//turn LED off }void servo_left(signed long int speed) { PORT_ON(PORTD, 2); delay_cycles(speed); PORT_OFF(PORTD, 2);//keep off delay_cycles(1600); // 200 * 8 }void servo_right(signed long int speed) { PORT_ON(PORTD, 3); delay_cycles(speed); PORT_OFF(PORTD, 3);//keep off delay_cycles(1600); // 200 * 8 }void servo_scan(signed long int speed) { PORT_ON(PORTD, 4); delay_cycles(speed); PORT_OFF(PORTD, 4);//keep off delay_cycles(1600); // 200 * 8 }void robot_turn_left(void) { servo_left(200); // 25 * 8 servo_right(200); // 25 * 8 }void robot_turn_right(void) { servo_left(352); // 44 * 8 servo_right(352); // 44 * 8 }void robot_go_straight(void) { servo_left(200); // 25 * 8 servo_right(352); // 44 * 8 }void hold_position(void)//37 { servo_left(312);//39 * 8 servo_right(280);//35 * 8 }//***************************************//*************INITIALIZATIONS***********void initialize(void) { //other stuff Im experimenting with for SoR uartInit(); // initialize the UART (serial port) uartSetBaudRate(57600);// set the baud rate of the UART for our debug/reporting output rprintfInit(uartSendByte);// initialize rprintf system //timerInit(); // initialize the timer system configure_ports(); // configure which ports are analog, digital, etc. a2dInit(); // initialize analog to digital converter (ADC) a2dSetPrescaler(ADC_PRESCALE_DIV32); // configure ADC scaling a2dSetReference(ADC_REFERENCE_AVCC); // configure ADC reference voltage rprintf("\t\t\tInitialization Complete\n\n"); }//****************************************void resetChip(int delayTime) { /* if the project does not typically receive data, and accidental chip resets are tolerable, * this is a simple method that should work just fine. Otherwise it is recommended that the * reset request string be part of a call-response sequence, be transmitted with a * reserved byte or byte string, or be transmitted in some way out of band, so that it is not * accidentally received. */ rprintf("\nMCU will reset in "); rprintf("%d milliseconds...\n\r", (int)((delayTime *.992)/184)); delay_cycles(delayTime); // wait for the specified amount of time, doing nothing rprintf("\nResetting NOW.\n\r"); soft_reset(); // reset macro}
So on the fast tiny & mega bootloader, the bootloader needs to receive the 'keyword' within 0.3 seconds or it starts the application.
Would there be a way to transmit the hex file to some sort of non-volatile memory onboard the robot, and then once the hex file is stored, have the robot reboot the MCU and read the new hex from the memory?
It seems like once the MCU is reset, theres not enough time to re-establish an RF connection in able to push the the new hex file to the bootloader.
I don't have an O-scope, but would that be like your x-ray glasses to be able to see whats going on during this process to find out why the bootloader isnt gettting the data stream
If there was a way to transmit the new hex to the robot prior to a reset and store it on an eeprom.
ZigBee is broadly categorized as a low rate WPAN, and its closest technology is Bluetooth. A good bit of energy has been spent in analyzing whether ZigBee and Bluetooth are complementary or competing technologies, but after a quick look at the two, it can be seen that they fall a lot farther down the complementary side of the spectrum. They are two different technologies with very different areas of application and different means of designing for those applications. While ZigBee is focused on control and automation, Bluetooth is focused on connectivity between laptops, PDA’s, and the like, as well as more general cable replacement. ZigBee uses low data rate, low power consumption, and works with small packet devices; Bluetooth uses a higher data rate, higher power consumption, and works with large packet devices. ZigBee networks can support a larger number of devices and a longer range between devices than Bluetooth. Because of these differences, the technologies are not only geared toward different applications, they don't have the capability to extend out to other applications. As an example, for its applications, Bluetooth must rely on fairly frequent battery recharging, while the whole goal of ZigBee is for a user to be able to put a couple of batteries in the devices and forget about them for months to years. In timing critical applications, ZigBee is designed to respond quickly, while Bluetooth takes much longer and could be detrimental to the application. Thus, a user could easily use both technologies as a wireless solution in a PAN to suit all types of applications within that network.