ebterew.blogg.se

Robotc arduino
Robotc arduino




  1. ROBOTC ARDUINO HOW TO
  2. ROBOTC ARDUINO CODE

This adds the error to slavePower, divided by kp. out as a positive number, meaning the right motor has to speed up.Įrror = SensorValue - SensorValue For example, if the left motor is moving faster than the right, then this will come The error value is set as a scaled value representing the amount the slave Set the motor powers to their respective variables. the difference in encoder values effects the final power change to the motor. error is multiplied by, but we cannot use floating point numbers. Usually this is a number between 1 and 0 the 'Constant of proportionality' which the error is divided by. If the motors moved at exactly the same speed, this to slow down, positive if it has to speed up. Essentially the difference between the master encoder and the slave encoder. the right wheel keeps the same speed as the left wheel. masterPower will remain constant while slavePower will change so that In Arduino C it would look something like this: ////task main() Thank you for any advice or direction you may provide.

ROBOTC ARDUINO CODE

It seems to me the concepts set out by the RobotC code offers the perfect solution. I have spent many hours on trying to come up with a way to get the bot to travel in a straight line using some aspect of PID that is not overly complex for this relatively simple task. It uses integers only and math that does not result in floats. If the motors moved at exactly the same speed, this value would be 0.Īnother important aspect of the RobotC straight line code is it does not use floats or other data types that consume large amounts of microprocessor resources. Negative if slave has to slow down, positive if it has to speed up. My limited programming experience/skills do not allow me to simply translate RobotC to an Arduino sketch C which I am currently learning.Īs explained at the above web page the difference between the master encoder and the slave encoder ticks can be used to determine error. This concept was presented at the web page below which uses RobotC for programming. In this situation Error = speed_Master - speed_Slave However, as expected, the bot cannot travel in straight line.Ĭoncept: Keep it simple by having one motor serve as the speed master and the other as a speed slave, where the master motor speed is held constant and the slave motor speed is varied so as to match the master motor speed. Great precision is not needed for this challenge therefore, limited tracking (drift) back and forth across the straight line path is acceptable.Ĭurrent situation: The bot has been tested and it goes forward, backwards, turns etc.

ROBOTC ARDUINO HOW TO

Hobbyist Situation: Good hardware/electronics skills, just learning how to program.Ĭhallenge: Creating a sketch that will allow the bot to travel in a straight line for some distance, turnaround and travel back to the start point. Project: Arduino robot with motors equipped with hall effect quadrature encoders.






Robotc arduino