Author Topic: ATMEGA @ 20mhz  (Read 1944 times)

0 Members and 1 Guest are viewing this topic.

Offline alphaomegaTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
ATMEGA @ 20mhz
« on: March 18, 2014, 06:56:55 PM »
Hi
i am building a sumobot for a school project, i plan on using PID on the robot.
i wont be using motor encoders, all my readings will be done through the 4 sharp ir sensors which have a response time of 38ms, +- 10ms attached to the ADC of the atmega 328

my question is does the mcu freq make any difference on the pid calculation? or in fact is there any advantages to run the mcu at 20mhz?
i tried looking for this in google but couldnt find an answer
thanks

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: ATMEGA @ 20mhz
« Reply #1 on: March 19, 2014, 02:59:20 PM »
From my experience it will not matter if you run the processor at 20MHz or 4MHz. You will need to TUNE the PID loops anyway and this will take care of the sampling period in the PID loop.
Do not try to do any of this with floating point math, keep all the math as integers.

Offline alphaomegaTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: ATMEGA @ 20mhz
« Reply #2 on: March 19, 2014, 06:22:49 PM »
thanks for the info, after u tuned the pid, did u have any issues with the behavior vs battery level? i wanted to do a switching buck boost regulator with the ltc3112 so i get a constant voltage to the motors for that specific reason, if you didn't have any issues it would save me the trouble to go that route

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: ATMEGA @ 20mhz
« Reply #3 on: March 20, 2014, 06:49:18 AM »
I just run the motor controller (H-bridge) directly from the battery. The feed-back control loop adjusts the motor PWM duty cycle to maintain motor speed even with a variation of battery Voltage. That is a good reason to use feed-back speed control on the motors.
Since motors tend to draw a lot of current (usually more than anything else in a Bot) any type of Voltage converter will have losses that increase with increased current draw. For this reason it is usually best to run the motors directly from the battery. The other reason is that a Voltage converter can get quite large if the motor current is high.

Offline alphaomegaTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: ATMEGA @ 20mhz
« Reply #4 on: March 20, 2014, 10:55:32 AM »
yeah i did look into feed back loop motor controller, the main reason i didn't go with them was the limited budget,since for my application the cheapest one i could find was the pololu at 50$ a piece and i would need two. in term of size they come down to almost the same when compared to an ltc3112 buck boost converter. in the end its really the price that pushed me towards the second choice. any other advice on pid tuning and control?
btw i am using 2x tb6612fng motor controllers and kf-050 motors
« Last Edit: March 20, 2014, 12:11:10 PM by alphaomega »

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,345
  • Helpful? 82
Re: ATMEGA @ 20mhz
« Reply #5 on: March 20, 2014, 03:10:13 PM »
Yes, the cycle time of your PID loop does affect the constants. This is a very well known phenomenon. Compare, for example, the s-domain to z-domain transform in filters, or the step-size-dependency on the linear (first order) integrator.

Offline alphaomegaTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: ATMEGA @ 20mhz
« Reply #6 on: March 21, 2014, 06:46:43 PM »
btw which motor controller were you using?

 


Get Your Ad Here