go_away

Author Topic: Cannot get UART to work using WebBot Lib  (Read 1442 times)

0 Members and 1 Guest are viewing this topic.

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Cannot get UART to work using WebBot Lib
« on: July 20, 2012, 02:27:09 PM »
So I downloaded everything using the downloader, used the project designer, trying to do the hello world project.

I got everything to build using the tutorial, I flashed successfully.

I flashed over my successfully running photovore_v1 program, which was upgraded to the 328P successfully. So I know at least my board is good to go.

When I connect to hyperterminal, and turn on my mcu, nothing is happening.

I am using the spark fun 2103 breakout board, drivers installed successfully.

USB connected to the port, I am getting a red power light.

Anyone have any ideas, I am stuck and not sure what to do now.

I really want to tryout the WebBot Lib, it looks incredible, but not sure what to do now.

I suspect I have a hardware issue, but not exactly sure, related to my 2103 breakout board. I am not drawing power from my mcu, only from my USB, and I am connecting rx, tx and ground.

Thx.

Offline Gertlex

  • Supreme Robot
  • *****
  • Posts: 742
  • Helpful? 23
  • Nuclear Engineer Roboticist
Re: Cannot get UART to work using WebBot Lib
« Reply #1 on: July 21, 2012, 09:50:55 AM »
I sympathize... Getting started with this sort of thing is tricky when all of the hardware/software is new, and anything could be an issue... I'll throw a couple ideas out there for you.

I've not used the breakout board that you mentioned.  What I have used for what you're trying to do are this and this (separately of course).  As best I can tell, for what you're doing, these three boards should be interchangeable. *shrug*

Are you setting up the same baud rate between your atmega 328p and hyperterminal?

What about a loopback test? Connect RX to TX on the USB/serial adapter and you should then see what you type echoed back at you in Hyperterminal.
I

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Cannot get UART to work using WebBot Lib
« Reply #2 on: July 22, 2012, 05:38:36 AM »
I sympathize... Getting started with this sort of thing is tricky when all of the hardware/software is new, and anything could be an issue... I'll throw a couple ideas out there for you.

I've not used the breakout board that you mentioned.  What I have used for what you're trying to do are this and this (separately of course).  As best I can tell, for what you're doing, these three boards should be interchangeable. *shrug*

Are you setting up the same baud rate between your atmega 328p and hyperterminal?

What about a loopback test? Connect RX to TX on the USB/serial adapter and you should then see what you type echoed back at you in Hyperterminal.


Thx Gertlex, I may end up trying that board, I am racking my brains right now.

I now tried my ATmega8 and still nothing working, and there is just so little documentation out there.

I want to try a loopback test, here is my understanding, can someone confirm:

physically connect tx and rx on my board.

sudo code:
printf("something")

if(pin(1) =='something"){
     LED_on();
}

Would this be the idea of a loopback test, or is there something more to it?


Offline Gertlex

  • Supreme Robot
  • *****
  • Posts: 742
  • Helpful? 23
  • Nuclear Engineer Roboticist
Re: Cannot get UART to work using WebBot Lib
« Reply #3 on: July 22, 2012, 08:22:31 AM »
the loopback test is just using that sparkfun board plugged into your computer. you then connect tx to rx on it.  In hyperterminal, you can send stuff just by typing. If you're doing a loopback test, the stuff you type on the keyboard will show up in hyperterminal.
I

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Cannot get UART to work using WebBot Lib
« Reply #4 on: July 22, 2012, 08:03:58 PM »
OK, so, I did a loopback test and at first it was not working at all.

Then, I changed from control hardware to control None, and my loopback test worked, what I typed appeared on the screen.

So, I went back to my mcu which was programmed with the webBot Lib example and low and behold I got something!

It was not the Hello World! that was in my printf statement : PRINTF(stdout,"Hello World\n");

But it was a character that looked like a C with a small line coming out of the bottom of the C, and it just kept repeating until I disconnect.

I feel better that I got SOMETHING, but still frustrated as to why I got a funny looking C and not Hello World!

Anyone have any ideas?

Thx!

Offline Gertlex

  • Supreme Robot
  • *****
  • Posts: 742
  • Helpful? 23
  • Nuclear Engineer Roboticist
Re: Cannot get UART to work using WebBot Lib
« Reply #5 on: July 22, 2012, 10:28:17 PM »
Funky characters are usually due to differing baud rates.  Hyperterminal and your code for your MCU's UART need to have the same baud rate.
I

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Cannot get UART to work using WebBot Lib
« Reply #6 on: July 23, 2012, 04:25:03 AM »
Funky characters are usually due to differing baud rates.  Hyperterminal and your code for your MCU's UART need to have the same baud rate.

Gertlex, thx for all your help.

I checked over and over again the Baud rate and I tried doing this with 3 different baud rates, all which are supposedly fine with my adaptor and my mcu.

I also played with the different flow control settings, trying all 3 and making sure they matched.

I still keep getting funky characters.

I played with this for over an hour this am and nothing is working.

Any other ideas?

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Cannot get UART to work using WebBot Lib
« Reply #7 on: July 23, 2012, 04:27:52 AM »
Only other thing I will throw out is that Soren suggested I may need level converters.

I looked into this, and from what I can tell my breakout board does not need them, but I am a complete noob with this stuff and I cannot be sure.

Could that be the problem?

If so, I just cannot figure out what I need, and how to implement it.


Offline Gertlex

  • Supreme Robot
  • *****
  • Posts: 742
  • Helpful? 23
  • Nuclear Engineer Roboticist
Re: Cannot get UART to work using WebBot Lib
« Reply #8 on: July 23, 2012, 08:08:59 AM »
Regarding level converters, I'm pretty sure the sparkfun board can handled 5V... but the 3.3V terminal on it made me wonder, too...

I've not built an MCU starting from the actual Atmega chip. Is it possible you have the timing wrong with a crystal or something?  That would mess up the baud rate...  Perhaps do a test where the LED goes on for 1 second, off for 1 second, over and over.  Then see if it's actually timing correctly?

Also, what's the code (just the print statement, probably) you're using to send Hello World out the UART?
I

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Cannot get UART to work using WebBot Lib
« Reply #9 on: July 23, 2012, 11:21:13 AM »
Regarding level converters, I'm pretty sure the sparkfun board can handled 5V... but the 3.3V terminal on it made me wonder, too...

I've not built an MCU starting from the actual Atmega chip. Is it possible you have the timing wrong with a crystal or something?  That would mess up the baud rate...  Perhaps do a test where the LED goes on for 1 second, off for 1 second, over and over.  Then see if it's actually timing correctly?

Also, what's the code (just the print statement, probably) you're using to send Hello World out the UART?

I suppose that is possible but I would not even know how to change that since I am using webBot Lib.

I think it is using the 8 mHz for my mcu.

I will see if I can figure out the LED on and off, still trying to learn how to use webBot.

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Cannot get UART to work using WebBot Lib
« Reply #10 on: July 25, 2012, 04:33:40 AM »
Gertlex, as I posted in Rmore's thread, I finally got this working.

I had to go back to my original photovore_v1 project that I modified for the 328P.

I still cannot get it to work in Webbot Library, and I am not sure why, but at least I have UART going now.

Thx for all your help!

Offline Gertlex

  • Supreme Robot
  • *****
  • Posts: 742
  • Helpful? 23
  • Nuclear Engineer Roboticist
Re: Cannot get UART to work using WebBot Lib
« Reply #11 on: July 25, 2012, 09:10:28 AM »
Are you using Webbot's Project Designer? (might be tricky if you're not using one of the boards it supports, though...)
I

Offline ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Cannot get UART to work using WebBot Lib
« Reply #12 on: July 25, 2012, 11:55:23 AM »
Yes, I am using the project designer.

The board I am using is one of the choices, the 328P, is that what you mean by supports?

I am struggling in general to get anything working with the Webbotlib in c++


Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 108
Re: Cannot get UART to work using WebBot Lib
« Reply #13 on: July 25, 2012, 04:52:12 PM »
The board I am using is one of the choices, the 328P,

There isn't a board called the 328P. There are many that use that chip: Roboduino, various $50 robots, Orangutans etc. Which are you 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 ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Cannot get UART to work using WebBot Lib
« Reply #14 on: July 25, 2012, 05:12:51 PM »
The board I am using is one of the choices, the 328P,

There isn't a board called the 328P. There are many that use that chip: Roboduino, various $50 robots, Orangutans etc. Which are you using?

Sorry for the confusion, I am using my $50 robot board that I built, which I upgraded to the 328p.


Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 108
Re: Cannot get UART to work using WebBot Lib
« Reply #15 on: July 25, 2012, 05:44:49 PM »
I am using my $50 robot board that I built, which I upgraded to the 328p.

Still not clear. Are you using a board design that came with Project Designer (maybe '$50 ATMega328P 1MHz' or '$50 ATMega328P 8Mhz' I guess?). Or have you 'built' one in Board Designer? Please state the exact name of the board you are using in Project Designer or whether you have create your own Board Design.
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 ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Cannot get UART to work using WebBot Lib
« Reply #16 on: July 25, 2012, 05:54:29 PM »
I am using my $50 robot board that I built, which I upgraded to the 328p.

Still not clear. Are you using a board design that came with Project Designer (maybe '$50 ATMega328P 1MHz' or '$50 ATMega328P 8Mhz' I guess?). Or have you 'built' one in Board Designer? Please state the exact name of the board you are using in Project Designer or whether you have create your own Board Design.

I am sorry, I am using the $50 ATMega328P 8Mhz board.

sorry for the confusion.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 108
Re: Cannot get UART to work using WebBot Lib
« Reply #17 on: July 25, 2012, 06:06:35 PM »
Ok - so next step is to see your code and Project. May sound strange - but by default stdout etc are just thrown away unless you have specified where they go to (ie a UART, an LCD, or anything else that can be written to). Bear with me. By sending me your Project file (.prj) then I can see what options you choose during codegen.

ZIP up your entire project folder (ie your Project Designer project which ends in .prj and your code) and send it to me
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 ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Cannot get UART to work using WebBot Lib
« Reply #18 on: July 25, 2012, 06:24:05 PM »
Ok - so next step is to see your code and Project. May sound strange - but by default stdout etc are just thrown away unless you have specified where they go to (ie a UART, an LCD, or anything else that can be written to). Bear with me. By sending me your Project file (.prj) then I can see what options you choose during codegen.

ZIP up your entire project folder (ie your Project Designer project which ends in .prj and your code) and send it to me

I just emailed you the entire project, zipped.

Thanks much for taking a look!

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 108
Re: Cannot get UART to work using WebBot Lib
« Reply #19 on: July 25, 2012, 07:57:15 PM »
edit - hit some button before I meant to...

After a quick look (so I could be wrong) - when you do the codegen (ie Tools | Generate) in Project Designer then it looks like the first 2 drop downs are blank.....

'Send rprintf output to'  is where your rprintf goes to (as used in your code). Since its blank then your output gets binned.
'Send error output to' is worth setting to a uart to a Pc if one exists. WebbotLib can then report errors rathe than trying to flash the status LED.
« Last Edit: July 25, 2012, 08:00:19 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 Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 108
Re: Cannot get UART to work using WebBot Lib
« Reply #20 on: July 25, 2012, 08:01:49 PM »
If you are using C++ then you can also use:
cout << "Hello World"
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 ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Cannot get UART to work using WebBot Lib
« Reply #21 on: July 26, 2012, 07:32:14 AM »
edit - hit some button before I meant to...

After a quick look (so I could be wrong) - when you do the codegen (ie Tools | Generate) in Project Designer then it looks like the first 2 drop downs are blank.....

'Send rprintf output to'  is where your rprintf goes to (as used in your code). Since its blank then your output gets binned.
'Send error output to' is worth setting to a uart to a Pc if one exists. WebbotLib can then report errors rathe than trying to flash the status LED.

Webbot, thanks for taking a look.

I am really not sure why the settings were like that, I originally had done it so that both printf and error were going to myUart, as your tutorial suggested.

So, I reset those settings as you described, and I was able to generate.

I went back int o AVRstudio, opened the project, recompiled, connected, and I tried to flash my ATmega328P, got a weird error message, and then got an orrange blinking light on my AVRRISP mkII, which indicates the ISP is not connecting properly to my ATmega328P.

After spending an hour re-checking everything, I decided that my ATmega328P got screwed up somehow, and decided to go back to my ATmega8.

So, I re-did the entire project exactly as your tutorial suggested, and connected to hyperterminal, and I get a C with a line coming out the bottom of it, for several charactors, every second instead of the Hello World.

Same problem I was having before.

I was able to get it to work in my original project, not using Webbot lib, but for some reason I just cannot get it to work.

One thing I was thinking is when I look at the fuses in the Webbot created project, they don't look the same as the $50 robot.

For example, the $50 robot mentions unchecking CKDiv8, I don't even see that fuse when connected in the Webbot lib, nor the other fuse that is referenced in the UART tutorial, I am starting to wonder if that has something to do with this.

Either way, I still cannot connect.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 108
Re: Cannot get UART to work using WebBot Lib
« Reply #22 on: July 26, 2012, 11:52:03 AM »
Changing the CKDiv8 fuse via say, your AVRISP mkii+AVRStudio, changes the chip from working at 1MHz or at 8MHz - thats part of 'hardware setup'.

WebbotLib is just a software library - it doesn't do anything with fuses or other hardware settings. But you do need to tell it if your chip is configured to run at 1MHz or 8MHz and you do that by choosing the appropriate Board for your project.

Not sure what the
Quote
other fuse that is referenced in the UART tutorial
is. Are you referring to something in Admins tutorial? Send me a link and I'll have a look.

Believe me - WebbotLib can control UARTs - otherwise I would have zero users! So just hang in there
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 ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Cannot get UART to work using WebBot Lib
« Reply #23 on: July 26, 2012, 12:05:56 PM »
Changing the CKDiv8 fuse via say, your AVRISP mkii+AVRStudio, changes the chip from working at 1MHz or at 8MHz - thats part of 'hardware setup'.

WebbotLib is just a software library - it doesn't do anything with fuses or other hardware settings. But you do need to tell it if your chip is configured to run at 1MHz or 8MHz and you do that by choosing the appropriate Board for your project.

Not sure what the
Quote
other fuse that is referenced in the UART tutorial
is. Are you referring to something in Admins tutorial? Send me a link and I'll have a look.

Believe me - WebbotLib can control UARTs - otherwise I would have zero users! So just hang in there


This is the UART tutorial that I followed, the 2 fuses are unchecking the CKDIV8, and selecting:Int. RC Osc. 8Mhz

as mentioned in this tutorial

http://www.societyofrobots.com/microcontroller_uart_50_robot.shtml

I know that it works, I just have to get the hang of it. I am hoping once I get started I can really start taking advantage of it.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 108
Re: Cannot get UART to work using WebBot Lib
« Reply #24 on: July 26, 2012, 01:32:33 PM »
Ok, thanks, the two fuses are purely to do with what speed the processor runs at - ie nothing 'uart' orientated.

So if you set the fuses to whatever you want - say to 8Mhz as per the tutorial then just use the $50 8 MHz board.

That tutorial also talks about setting F_CPU
Quote
#define F_CPU        8000000   // 8MHz processor
- DO NOT DO THIS WITH WEBBOTLIB. The board design sets the processor speed so NEVER try to change it in your own code.

I think part of the confusion is that you MAY be combining tutorials from societyofrobots (ie Admins own library) with stuff from webbot (my completely different library).
We are different people/websites/etc - and our code is different and completely unrelated!

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 ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Cannot get UART to work using WebBot Lib
« Reply #25 on: July 26, 2012, 01:42:05 PM »
Ok, thanks, the two fuses are purely to do with what speed the processor runs at - ie nothing 'uart' orientated.

So if you set the fuses to whatever you want - say to 8Mhz as per the tutorial then just use the $50 8 MHz board.

That tutorial also talks about setting F_CPU
Quote
#define F_CPU        8000000   // 8MHz processor
- DO NOT DO THIS WITH WEBBOTLIB. The board design sets the processor speed so NEVER try to change it in your own code.

I think part of the confusion is that you MAY be combining tutorials from societyofrobots (ie Admins own library) with stuff from webbot (my completely different library).
We are different people/websites/etc - and our code is different and completely unrelated!

Yeah, I did not change that at all, I assumed that picking the $50 board with the 8MHz processor took care of that in your code.

I don't think I am confusing, I went through your My First Program Hello World tutorial after I did Admin's tutorial.

I was only referencing Admin's because I was suspecting that the fuses MAY have something to do with it, but what you say makes sense that it should not.

I do see what you mean though, I am throwing out the word tutorial to loosely.

Everything in my project is based on your My First Program in the C++ documentation, nothing is based on Admin's.

So, all that being said, I am still getting a weird c character, and I am quite sure that since I programmed the fuse to be 8MHz, and I selected the board with the 8MHz, I should be OK, any other ideas on why I cannot get UART to work?

I know I am probably being stubborn with the UART, but a lot of my work will come off of sensors, and I really need the UART to debug and understand the sensors, so I really need to make sure I can get the UART working with your library before I continue.

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,132
  • Helpful? 108
Re: Cannot get UART to work using WebBot Lib
« Reply #26 on: July 26, 2012, 01:50:14 PM »
Ok - next step - just to help me recreate - what version of WebbotLib are you using? don't say 'latest' - look in the 'version.h' file in WebblotLib folder - scroll to end of file and you will see something like
'Version 2.09 21 April 2012'
Is that what you got or something different?
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 ErikYTopic starter

  • Robot Overlord
  • ****
  • Posts: 186
  • Helpful? 0
Re: Cannot get UART to work using WebBot Lib
« Reply #27 on: July 29, 2012, 05:35:57 AM »
I got this working.

As I suspected, it was on my end.

I somehow did not have my fuses programmed properly. I was sure I did, but when I went back to look at the fuses, I noticed the problem.

I progammed the fuses properly, and got everything working.

Thanks to Webbot for all his help and for this great library!

 


Get Your Ad Here

data_list