Author Topic: New to programming  (Read 2607 times)

0 Members and 1 Guest are viewing this topic.

Offline jessman275Topic starter

  • Jr. Member
  • **
  • Posts: 8
  • Helpful? 0
New to programming
« on: September 28, 2009, 06:56:07 PM »
So I purchased a Axon controller and started messing around with it. So far its works great.  I have looked around on the forums and have yet to find a topic about IR sensors and how they could control a motor or Solenoid. I have tried to program the controller by modifying some existing code and needless to say it didn't work.  I have purchased a IR sensors listed below

http://www.acroname.com/robotics/parts/R185-SINGLE-LINE-IR.html

I have used this type of sensor for data logging on cars before and had a great experience with it.

I would like to have the IR sensor pick up off a rotating object and activate a solenoid every time the white line comes around. I am very new to programming and have read many tutorials, but still haven't gotten the hang of it.

My Pseudo code looks like this
"
read IR sensor PORT,F1

if IR sensor detects line
   then activate relay on PORT E2 for 30ms

"
Can someone lead me in the right direction on how to solve this problem. If there is a tutorial out there that is similar to this that would help tremendously.

Thanks

Jesse




Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,704
  • Helpful? 173
    • Society of Robots
Re: New to programming
« Reply #1 on: September 29, 2009, 09:20:16 AM »
Your pseudocode gets you 90% there.

Quote
read IR sensor PORT,F1
becomes:
value=a2dConvert8bit(0);
read this:
http://www.societyofrobots.com/axon/axon_function_list.shtml#adc

Quote
if IR sensor detects line
if(value > 128)

Quote
then activate relay on PORT E2 for 30ms
read this:
http://www.societyofrobots.com/axon/axon_function_list.shtml#digital_output
you'll also need a MOSFET to drive your relay

you'll also need this to turn off the relay:
else
   PORT_OFF(PORTA,6);


so summing it up:
Code: [Select]
while(1)
{
value=a2dConvert8bit(0);
if(value > 128)//depends on values you expect
    PORT_ON(PORTA,6);
else
    PORT_OFF(PORTA,6);
delay_ms(10);//prevent crazy fast oscillation
}

 

SMF spam blocked by CleanTalk