go away spammer

Author Topic: Programming for POTS  (Read 2236 times)

0 Members and 1 Guest are viewing this topic.

Offline NaitoukTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Programming for POTS
« on: February 24, 2013, 04:53:21 PM »
Hello everyone!

I am using an Axon Mote and all of the standard software suggested by SoR.com.  Although i'm no stranger to writing software, I am somewhat new to coding for hardware interaction.  I've attached a basic pot to my Axon and used the basic code that is generated for AVR.  Now, i'm at the point of trying to understand the output.

The code generates the following one line (with the exception of the output):

uint16_t val = a2dConvert10bit(my_pot);

When I view the output in Hyperterminal, most of the time I get a continuous scroll of zeros, then as I rotate the pot the numbers jump around with no distinguishable pattern. 

Please correct me if i'm wrong ... As my understanding goes, the pot is a variable resistor.  So as I turn the knob (in this case), the voltage changes.  So the generated code converts the analog voltage reading to a digital unsigned int.  I'm cool with this thus far.  Now, since those values reported seem to jump around wildly from zero to, for example, 98, how can I determine the actual value of the pot?

Thanks very much for your help!

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: Programming for POTS
« Reply #1 on: February 24, 2013, 07:13:02 PM »
What value pot?
Is the pot good? Sometimes they have intermittent contact.
Measure the pot from the wiper to each end with an Ohmmeter to ensure it changes resistance smoothly.

That function looks to return a 16bit value (of which 10bits are valid). The serial connection sends a byte (8bits) at a time. Hyper-terminal only receives and displays bytes values.

Are you sure you have the pot wired to the ADC input correctly?
The pot's wiper to the ADC pin, one end to Vdd and the other to Vss.
Use your Voltmeter to check the Voltage at the ADC input pin to verify the pot is wired correctly and working.

Offline Gertlex

  • Supreme Robot
  • *****
  • Posts: 763
  • Helpful? 24
  • Nuclear Engineer ยท Roboticist
    • Index of Oddities
Re: Programming for POTS
« Reply #2 on: February 25, 2013, 10:37:38 PM »
Just a random note, your capitalization had be expecting this.

When I view the output in Hyperterminal, most of the time I get a continuous scroll of zeros, then as I rotate the pot the numbers jump around with no distinguishable pattern. 

Just to clarify for us: When you're not moving the pot, does the value return to zero?

Waltr's advice insights are good.  In particular, it would be useful to know the wiring, as he mentions.
I

Offline Jon_Thompson

  • Jr. Member
  • **
  • Posts: 37
  • Helpful? 1
Re: Programming for POTS
« Reply #3 on: February 26, 2013, 06:38:45 AM »
Long time reader, first time poster here :)

Connect one end of the pot's track to +5v and the other to gnd, with the wiper pin obviously going to the ADC.

I don't know the Axom hardware, but other versions of a2dConvert10bit() tend to return an unsigned short, which is equivalent to a uint16_t, so the code is probably fine.

Make sure you're using the right type for the output to Hyperterminal. It may take 8-bit codes, but you need to tell the output function to interpret the values you give it to send the text equivalent, i.e. if the value you want to send is 123, the output function should send the characters "1", "2", and "3".

Hope that helps.
You can still do a lot with a small brain.

Offline NaitoukTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: Programming for POTS
« Reply #4 on: February 26, 2013, 09:15:22 AM »
I'm wondering if my problem is related to the physical wiring.

When I used Webbot to map out all of my hardware to the Axon, the wiring diagram only shows two pins being used.  So I've got one of the pots tracks to one of the pins on the "ADC" row, and the other connected to the ground.  The specific pot I'm testing (its re purposed from another system, a gaming controller) has the wiper jumped to the ground.

Offline Azraels

  • Full Member
  • ***
  • Posts: 57
  • Helpful? 1
Re: Programming for POTS
« Reply #5 on: February 26, 2013, 11:03:24 AM »
yep, that would be why its not working, you need that middle wiper connected to your adc pin. Just like they have all been saying.
If your first post is, "I want to build a super complex robot with object recognition, etc..but I have never done programming or electronics...etc." 
Your doing it wrong. Start Simple and Work Up.

Offline NaitoukTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: Programming for POTS
« Reply #6 on: February 26, 2013, 11:30:33 AM »
Excellent.  So help me understand the hardware aspect of the problem, if you will.

When I use an "Analogue Input" via the WebBot Project Designer, it shows the wiring using the ground pin and the supply pin on the ADC row.  Should I be wiring this differently?

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,345
  • Helpful? 82
Re: Programming for POTS
« Reply #7 on: February 26, 2013, 02:41:49 PM »
You should wire one end of the pot to vcc/supply. The other end of the pot to ground. And the wiper (middle end) to the ADC input pin.

Second, it's not clear to me that your program is doing the right thing, if you see "lots of zeros." Try a program that does something like:

(pseudocode)
Code: [Select]
char buf[20];
forever {
  val = read_adc();
  sprintf(buf, "%d\r\n", val);
  serial_port_write(buf, strlen(buf));
  delay(500);
}

This should output the converted value about twice a second, on a new line per value, in proper ASCII format, so you can read it.

Offline NaitoukTopic starter

  • Beginner
  • *
  • Posts: 4
  • Helpful? 0
Re: Programming for POTS
« Reply #8 on: February 26, 2013, 03:11:30 PM »
Just to clarify ...

I am using default code and configuration as generated by AVR Studio and Webbot.  I am thinking the problem is with the wiring displayed by Webbot.  I will re-write with the configuration you guys have provided and see if that makes a different.

Thank you everyone for the help!

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: Programming for POTS
« Reply #9 on: February 26, 2013, 03:12:19 PM »
The advice above is all good.

Using a multi-meter, and without anything connected to the Mote ADC pin, verify the output voltage of the pot varies from 0V to 1.8V properly when rotating it.

The ADC of the Mote is from 0V to 1.8V only. If you have your pot wired from 0V to 3.3V you could damage your ADC. You can create 1.8V by using a simply voltage divider circuit (two high value resistors):

3.3V input - 2kohm resistor - 1.8V output - 2kohm resistor - ground

See here for more info:
http://www.societyofrobots.com/axon_mote/axon_mote_datasheet.shtml#voltage

 


Get Your Ad Here

data_list