Author Topic: 50 robot, code change for 168  (Read 1789 times)

0 Members and 1 Guest are viewing this topic.

Offline javilaTopic starter

  • Jr. Member
  • **
  • Posts: 31
  • Helpful? 0
50 robot, code change for 168
« on: May 29, 2010, 07:11:01 PM »
I skipped the atmel8 and went for the 168 instead, also i bought continuous rotation servos.
the admin says:
'The global.h file should also be modified since it contains a F_CPU define, depending on if you use the makefile to overwrite that value or not.'
I have made all the other modifications for the 168 but I am not sure what value I am suppose to change the F_CPU to.
Also  for the delay function:
//************DELAY FUNCTIONS************
//wait for X amount of cycles (23 cycles is about .992 milliseconds)
//to calculate: 23/.992*(time in milliseconds) = number of cycles
void delay_cycles(unsigned long int cycles)
   {
   while(cycles > 0)
      cycles--;
   }
//***************************************

how does that change with the 168? and, can somebody explain to me how do you come up with the formula. I have check many posts but I do not seem to get it. I have finish building the board for the 50$ robot and connected the servos and they work fine with the code without the modification to the global.g  but I'd like to understand better the delay.
Also, what is the difference between delay_cycles and the delay_ms that the admin uses here:
Code:
while(1)
   {
   wheel_left(30);
   delay_ms(20);
   }
Can somebody help me please???
 

Offline javilaTopic starter

  • Jr. Member
  • **
  • Posts: 31
  • Helpful? 0
Re: 50 robot, code change for 168
« Reply #1 on: May 29, 2010, 07:20:29 PM »
Ok, I already found what to do with the F_CPU. But anybody knows why it was set to 4MHz and not 1 for the atmel8?

 


data_list