Author Topic: new to programming PICs, need a little help  (Read 653 times)

0 Members and 1 Guest are viewing this topic.

Offline machinegunmaxTopic starter

  • Beginner
  • *
  • Posts: 2
  • Helpful? 0
new to programming PICs, need a little help
« on: March 06, 2010, 01:42:49 AM »
Basically i have a line following robot.  The inputs are 2 signals coming between an LDR and a resistor acting as a voltage divider as outlined in http://www.societyofrobots.com/schematics_photoresistor.shtml
The output is a servo.  Here is some very rough pseudocode:

A = input1 - input2

servo pulse length = 1.5ms + k*A

here k is a constant.  1.5ms is the pulse length which lines up the servo so that the robot goes straight.  So if one side gets more light the signal will be larger, A will be +ve and therefore the servo will move one direction, if the other LDR gets more light, A will be -ve and the servo will move the opposite direction.  My question is: firstly would this sort of idea work ... and if it would, how would i find the value of K (or could you suggest any good starting values)

Offline little-c

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 1
Re: new to programming PICs, need a little help
« Reply #1 on: March 07, 2010, 03:03:17 PM »
idea works. its simple enough.



as for k, start with a value of 100, and multiply/divide by ten to find when it starts changing from too violent to too slow a reaction, then start splitting it in half.


so if 100 was too slow, and 1000 too fast, go for 500, and if thats too slow, go for 750, blah.

if the value is 750 and it behaves like that, I want a cookie! ;D

 


Get Your Ad Here

data_list