2

Author Topic: How to turn off a port on Axon  (Read 1095 times)

0 Members and 1 Guest are viewing this topic.

Offline An3Topic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
How to turn off a port on Axon
« on: March 19, 2010, 03:42:34 AM »
Hi. From the Axon source code there was a code to turn on/off a LED on the Axon.
Code: [Select]
void LED_off(void)
{PORT_ON(PORTB,6);}
I was wondering if it was possible to turn a different port on/off? ??? I've connected a basic status LED circuit directly to an I/O port, and i would like to be able to turn it on/off in the program. Thanx for all replies :)

Offline SmAsH

  • Supreme Robot
  • *****
  • Posts: 3,959
  • Helpful? 75
  • SoR's Locale Electronics Nut.
Re: How to turn off a port on Axon
« Reply #1 on: March 19, 2010, 05:14:01 AM »
Yup, just change the "PORTB, 6" to the port letter and number you want to control.
So, instead it could be "PORTB, 3" or something similar.
Howdy

Offline An3Topic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: How to turn off a port on Axon
« Reply #2 on: March 21, 2010, 05:30:47 AM »
Hmm. I think there's some sort of problems with the code then. I've tried running the axon_test.c program witch turns on/off all ports and still  the LED wont turn off... I'm also having problems changing the reference voltage to the ADC to 2.56V. I think i make a new post on how to troubleshoot my code  :-\ Anyway, thanx for the reply man  :)

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 109
Re: How to turn off a port on Axon
« Reply #3 on: March 21, 2010, 08:25:38 AM »
The Axon libraries tend to make most IO pins into output pins. So if your LED is like this
--------- +5v
      |
    ___
    \   /
    ----
      |
     R
      |
    I/O Pin

Then you will need to make sure the pin is made into an input by changing the Data Direction Register (DDR) for the Port and Pin you are connecting to. You light the LED by making the input pin go low.

Whereas if your LED is like this
 
    I/O Pin
      |
    ___
    \   /
    ----
      |
     R
      |
    Ground

The port need to be an output port and you light the LED by setting the pin high

  
« Last Edit: April 18, 2010, 06:30:18 PM by Webbot »
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,658
  • Helpful? 169
    • Society of Robots
Re: How to turn off a port on Axon
« Reply #4 on: March 22, 2010, 05:20:45 AM »
Search the source code example page for how to configure a port.

As Webbot said, it'll need to be configured as an output first.

Also, which port are you trying to use?

Offline An3Topic starter

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: How to turn off a port on Axon
« Reply #5 on: April 08, 2010, 04:29:02 AM »
Thanx for all replies  :) When i saw Webbot's illustration i noticed what i had done wrong. I had connected the three-pin connector from the LED to Axon the wrong way. The result was that the LED wasn't connected to the I/O-pin on Axon at all, only between ground and source  ::)
« Last Edit: April 08, 2010, 04:30:20 AM by An3 »

 


Get Your Ad Here