Author Topic: need advices how to configure I/O  (Read 1694 times)

0 Members and 1 Guest are viewing this topic.

Offline DRUNISTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
need advices how to configure I/O
« on: January 08, 2012, 08:07:56 AM »
Hello,

i'm building a stair climbing robot, and now i started to write program for it.

i allready have algorithm for my robot, but i cant find any similar source code examples, that i could use

my algorithm have few cycles, for example:

if (sensor1 pin) == 1 ,sensor2 pin) == 0;
than (motor1pin)==1, motor2 pin) ==0;

if (sensor1 pin) == 1 ,sensor2 pin) == 1;
than (motor1pin)==0, motor2 pin) ==0; go to step2;


i still cant decide which c or cbasic would be best for me, and i'm still trying to find any examples wrom which i could use and learn something.


pls give any examples or advices


Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: need advices how to configure I/O
« Reply #1 on: January 09, 2012, 07:09:26 AM »
i'm building a stair climbing robot, and now i started to write program for it.
[...]
i still cant decide which c or cbasic would be best for me, and i'm still trying to find any examples wrom which i could use and learn something.
Something does not add up. Did You start writing code or are You still deciding which programming language to use (which implies that You don't yet have microcontroller)?
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline DRUNISTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: need advices how to configure I/O
« Reply #2 on: January 09, 2012, 12:37:15 PM »
well i have algorithm, how my robot should work (i gave some sample of it)
i allready built my robot, and now i need to program microcontroller and place it to the circut.

i've been reading about compilers and languages for a few days.  i've tried to program wiht C and with PicBasic programming codes, but still cant get results.

i'm a newbie in programming microcontrollers, so i came here to learn from people who already have this knowledge.


P.s. i need this for my final project in school.

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: need advices how to configure I/O
« Reply #3 on: January 10, 2012, 01:28:28 AM »
What microcontroller do You have? Is it one of the PICs?

If You are new to programing microcontrollers then You should look for tutorials related to Your project. You will not find exact code to be copied and pasted into Your project, so better and probably only approach is to find code (with explanations) that pretty much does what You want (in one area, say ADC, or PWM, or etc.) and adapt it for Your needs (or write Your own code based on the example).

What sensors do You have? What do You use to drive motors?
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline DRUNISTopic starter

  • Beginner
  • *
  • Posts: 3
  • Helpful? 0
Re: need advices how to configure I/O
« Reply #4 on: January 11, 2012, 07:28:37 AM »
i'm programming Pic18F2550 with picbasic pro. yesterday i made PCB for my circut . i'm using IRD sensors and L293dne motor drivers to drive few DC motors.
last step i need is programming.
i found few examples with picbasicpro, but non of them had program whic controlls outputs with inputs , like controllling with thermoresistors simple DC motor

this is sample what i'm tryoing to do. pls comment or give any advices about it

  INPUT RA0
  INPUT RA1
  INPUT RA2

  TRISB = $80         
  TRISC = $80         
  mainloop:
    loop 1
  If RA0 = 0  RA1 = 0
  then RB0 = 1 RB1 = 1
 
  If RA0 = 0   RA1 = 1
  then RB0 = 1 RB1 = 0

 if RA=0  RA= 1
then goto loop2
 etc.

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: need advices how to configure I/O
« Reply #5 on: January 11, 2012, 08:32:49 AM »
I've never had anything to do with ASM, however in C reading pins involves bit manipulations, for some reason I think that is the case with ASM as well.

Get some tutorials how to read input pin, then how to use if statement and finally how to output to pin. That should cover Your requirements.
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W