Author Topic: [Solved] Code problem, UART okay (edit: dirt problem)  (Read 4667 times)

0 Members and 1 Guest are viewing this topic.

Offline StephanieTopic starter

  • Jr. Member
  • **
  • Posts: 46
  • Helpful? 0
[Solved] Code problem, UART okay (edit: dirt problem)
« on: July 22, 2009, 10:36:58 AM »
Okay. So I just got my Axon microcontroller and a Sharp IR rangefinder GP2D12 and I want to test them out.

I followed the Getting Started tutorial and it's all okay.

Then I wanted to code a simple program to read data from the sensor on port 9 and output it to UART1 (USB).

I downloaded the Axon source code and edited control.c to the following:

Code: [Select]
void control(void) {
rprintfInit(uart1SendByte);
int reading;
while(1) {
delay_ms(50);
reading = sharp_IR_interpret_GP2D12(a2dConvert8bit(9));
rprintf("Reading: %d", reading);
}
}
...but it doesn't work. What did I do wrong? Do I have to include header files or something? My whole control.c is described above.

Solved. Read my last post. Don't laugh.
« Last Edit: July 24, 2009, 08:50:33 PM by Stephanie »
--- Stephanie

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: [Axon] Noob Programming Question
« Reply #1 on: July 22, 2009, 12:37:34 PM »
Does it just give a constant value. If so - then it looks like you've commented out the line that reads the sensor by using //
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 StephanieTopic starter

  • Jr. Member
  • **
  • Posts: 46
  • Helpful? 0
Re: [Axon] Noob Programming Question
« Reply #2 on: July 22, 2009, 01:07:27 PM »
Ah, sorry, it's not that. I commented it to test "Hello World" and forgot to remove when posting. Still didn't see anything.

It prints absolutely nothing. I think I'm editing the wrong file or forgetting something.
« Last Edit: July 22, 2009, 01:12:50 PM by Stephanie »
--- Stephanie

Offline Canabots

  • Contest Winner
  • Robot Overlord
  • ****
  • Posts: 245
  • Helpful? 6
  • It's not a bug, it's a feature!
    • Salmigondis Tech
Re: [Axon] Noob Programming Question
« Reply #3 on: July 22, 2009, 03:04:18 PM »
Try changing the int to unsigned int.

Also, you don't have to initialize the UART 1 rprintf. I've done it many times without having to use that.

And just a quick note, you don't neccessarily have to use the sharp_ir_interpret_GP2D12. Just simply using reading=a2dConvert8bit(9); works completely fine.

Hope this helps. :)
« Last Edit: July 22, 2009, 03:06:16 PM by Canabots »
My robotics, electronics, software, or other stuff blog:
www.saltech.wordpress.com

Offline StephanieTopic starter

  • Jr. Member
  • **
  • Posts: 46
  • Helpful? 0
Re: [Axon] Noob Programming Question
« Reply #4 on: July 22, 2009, 03:26:30 PM »
Hmm. I did everything, but it still doesn't print anything! I think I'm using wrong files.

Could someone make a ZIP/RAR with the files I need to use (already with the code to print the Sharp reading from port 9) or tell me what to write on control.c to get the desired result? Thanks in advance!
« Last Edit: July 22, 2009, 03:47:55 PM by Stephanie »
--- Stephanie

Offline Canabots

  • Contest Winner
  • Robot Overlord
  • ****
  • Posts: 245
  • Helpful? 6
  • It's not a bug, it's a feature!
    • Salmigondis Tech
Re: [Axon] Noob Programming Question
« Reply #5 on: July 22, 2009, 03:53:57 PM »
Try this (code goes in control.c):

Code: [Select]
unsigned int GP2D12=128;



void GP2D12_refresh(void);



void control(void)  //Run Hyperterminal Program

{

while(1)

{
delay_ms(50);

rprintf("Sensor_Value=%d\r\n", GP2D12);
 //Print in Hyperterm.
}

}



void GP2D15_refresh(void) //Sensor Refresh Subroutine

{

GP2D12=a2dConvert8bit(9);

}

The required files are the hardware, SoR_Utils, control, and Axon.

Let me know if this works.
« Last Edit: July 22, 2009, 03:55:39 PM by Canabots »
My robotics, electronics, software, or other stuff blog:
www.saltech.wordpress.com

Offline StephanieTopic starter

  • Jr. Member
  • **
  • Posts: 46
  • Helpful? 0
Re: [Axon] Noob Programming Question
« Reply #6 on: July 22, 2009, 04:02:52 PM »
Same thing, Canabots. I think the error isn't in the programming part, I think I'm doing something wrong. What I did was:

1. Download Axon source code.
2. Replace control.c wih your code.
3. Connect UART1 to my PC through USB.
4. Open cmd.
5. cd C:\Documents and Settings\Stephanie\Desktop\Axon
6. FBOOT17.EXE -b115200 -c3 -pAxon.hex -vAxon.hex
7. Transfered successfully to my Axon.
8. Turn Axon off.
9. Turn Axon on and check HyperTerminal (COM3).

But nothing happened, again.

Did I do something wrong?
--- Stephanie

Offline Canabots

  • Contest Winner
  • Robot Overlord
  • ****
  • Posts: 245
  • Helpful? 6
  • It's not a bug, it's a feature!
    • Salmigondis Tech
Re: [Axon] Noob Programming Question
« Reply #7 on: July 22, 2009, 04:23:48 PM »
Well, a couple possible issues...

1.
Quote
Make sure there are NO spaces in the file name.

For example, do not do 'C:\Documents and Settings\User\Desktop . . .'

From part 1 installing software on the getting started guide  :P
This may or may not be your problem. Perhaps something to look into though.

2. Have you successfully programmed the Axon before? Has a program worked? Have you managed to get something up in HyperTerm?

3. Is the "Call" button pushed?

4. Is command prompt closed when using hyperterminal? I've had some issues with it not working in the past...
My robotics, electronics, software, or other stuff blog:
www.saltech.wordpress.com

Offline StephanieTopic starter

  • Jr. Member
  • **
  • Posts: 46
  • Helpful? 0
Re: [Axon] Noob Programming Question
« Reply #8 on: July 22, 2009, 05:13:36 PM »
1. Moved it, still not working.
2. I've never done it, actually it's my first attempt. "System Warmed Up... Initialization Complete" appears, but nothing else.
3. Yes.
4. Yes.

It's definitely on my program. I'm doing something wrong, because the pre-compiled .hex files work.

Any more ideas?
« Last Edit: July 23, 2009, 10:14:17 AM by Stephanie »
--- Stephanie

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: [Axon] Code problem, UART okay
« Reply #9 on: July 24, 2009, 12:01:09 PM »
Program the LED to flash. And then program it to turn on the LED only when you push the button.

If that works, that means your code is fine, but you're messing up the UART.

Then, get a multimeter and put it on the frequency setting. Tell the Axon to repeatedly transmit data to UART1, and see if you get a frequency reading on any of the USB header pins (only one should be doing something).

Let us know what happens, and we can go from there.

Offline airman00

  • Contest Winner
  • Supreme Robot
  • ****
  • Posts: 3,650
  • Helpful? 21
  • narobo.com
    • Narobo.com - Mechatronics and related
Re: [Axon] Code problem, UART okay
« Reply #10 on: July 24, 2009, 05:14:41 PM »
I've had a similar problem. The culprit was the push button - it was faulty, and therefore would never actually be "pushed-down".
Try commenting out the pushbutton code at the beginning.
Check out the Roboduino, Arduino-compatible board!


Link: http://curiousinventor.com/kits/roboduino

www.Narobo.com

Offline StephanieTopic starter

  • Jr. Member
  • **
  • Posts: 46
  • Helpful? 0
Re: [Axon] Code problem, UART okay
« Reply #11 on: July 24, 2009, 08:45:05 PM »
Solved. It was so simple that I'm embarrassed: my desk is dirty (I eat here sometimes), and something got into the button in such a way that I couldn't activate anything but would feel like I was pushing it.

The dirt was easily removed and, well, now it works like a charm! Thanks (and sorry) for everything!

I'm really happy with the Axon --- it's an amazing product. I'm very impressed with its incredible customer support: look, a dirt-in-the-button problem moved a lot of great people! I would never imagine that my first attempt at robotics would be successful - and it's going great.
--- Stephanie

Offline Admin

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: [Solved] Code problem, UART okay (edit: dirt problem)
« Reply #12 on: July 24, 2009, 09:59:04 PM »
If anyone wants a new button to fix a misbehaving one, I'll mail you one for free. But you'll have to solder it :P

 


Get Your Ad Here