Author Topic: McUber failing to upload code. Im missing something.  (Read 3050 times)

0 Members and 1 Guest are viewing this topic.

Offline bukowskiTopic starter

  • Robot Overlord
  • ****
  • Posts: 219
  • Helpful? 0
McUber failing to upload code. Im missing something.
« on: April 16, 2013, 08:08:15 PM »
Hello all!

I am writing a dead reckoning program using the latest Webbotlib Project Designer on the Axon II microcontroller. The program compiles fine using AVR studio 4.19. When I go to upload the hex file to the Axon, the bar goes to max then I get an error message saying that the file failed to flash. I removed bits of code and uploaded it again and again until I found the culprit.

It is during the "reverse" cycle of driving. The forward version of the same code works fine.

Code: [Select]
if (leftticks < rampdownticks){
int difference = -180 - (leftticks - rampdownticks);
leftspeed = interpolate(difference, 0, -180, -40, DRIVE_SPEED_MIN);
}

leftticks is the number of encoder ticks. Rampdownticks is one full rotation (180 ticks) away from the final distance.

The goal is for the motor to ramp down at during the last full wheel rotation to help eliminate some of the slop I was getting.

The "forward" version of the same code that works like a charm:
Code: [Select]
if (leftticks > rampdownticks){
int difference = 180 - (leftticks - rampdownticks);
leftspeed = interpolate(difference, 0, 180, 40, DRIVE_SPEED_MAX);
}

Im sure there is something going on that Im not aware of, or my logic failed somewhere along the way, but I would like another set of eyes on this.

Thank you!
« Last Edit: April 16, 2013, 08:22:18 PM by bukowski »

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: McUber failing to upload code. Im missing something.
« Reply #1 on: April 17, 2013, 01:02:44 AM »
Any code errors would come up at compile time or run time and definitely not at flash time. The only reason I can think of is that Your HEX file is too big, hence does not fit flash memory in microcontroller. Do You use code optimisation?
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline bukowskiTopic starter

  • Robot Overlord
  • ****
  • Posts: 219
  • Helpful? 0
Re: McUber failing to upload code. Im missing something.
« Reply #2 on: April 17, 2013, 09:45:18 AM »
I really cant imagine that the file is too big. I think something may be a little wonky with McUber on my PC. I may have to try to use my old programmer for it.

Offline newInRobotics

  • Supreme Robot
  • *****
  • Posts: 1,015
  • Helpful? 48
  • N.I.R.
Re: McUber failing to upload code. Im missing something.
« Reply #3 on: April 17, 2013, 10:23:56 AM »
Can You post size of Your HEX file?
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian W

Offline bukowskiTopic starter

  • Robot Overlord
  • ****
  • Posts: 219
  • Helpful? 0
Re: McUber failing to upload code. Im missing something.
« Reply #4 on: April 17, 2013, 11:56:38 AM »
39.4k. If everything that can be compiled can be uploaded no problem, there is definitely something fishy going on. I've had the same issue with a simple "cout << variable" line that it wouldn't upload unless I deleted that line.

Offline jwatte

  • Supreme Robot
  • *****
  • Posts: 1,345
  • Helpful? 82
Re: McUber failing to upload code. Im missing something.
« Reply #5 on: April 17, 2013, 12:14:07 PM »
The standard C++ library for I/O is basically unusable in embedded microcontrollers. It includes facets and support for locales and time and other things which use way too much resources to work in a tiny amount of program space and RAM.

Offline bukowskiTopic starter

  • Robot Overlord
  • ****
  • Posts: 219
  • Helpful? 0
Re: McUber failing to upload code. Im missing something.
« Reply #6 on: April 17, 2013, 12:44:12 PM »
Hm, good to know. To say I am weak at programming is an overstatement, haha. The strange thing for me is that it usually works fine. Until it doesnt.

I will rebuild it in Webbot Program Designer for C programming and rewrite it and see how it goes.

Offline bukowskiTopic starter

  • Robot Overlord
  • ****
  • Posts: 219
  • Helpful? 0
Re: McUber failing to upload code. Im missing something.
« Reply #7 on: April 19, 2013, 02:42:05 PM »
"I am already looking at the C++ stuff - and have been for a year or two. The avr-g++ compiler does have some issues and hence I abandoned a pure C++ version of the library - but I may start by wrapping the C code with a thin C++ layer (like Arduino and others do). This would allow existing user code to continue to function in C only mode as well as allowing C++ notation."

Im assuming this is what Webbot did, and what is being uploaded to the Axon is a hex file compiled from C "wraped in a thin C++ layer" for ease of use.

Oddly enough, making a minor change eliminated that problems, and neatened up my code  abit.

Code: [Select]
if (leftticks < rampdownticks)
leftspeed = interpolate(leftticks, rampdownticks, backtotaldistanceticks, -40, DRIVE_SPEED_MIN);

This does exactly the same thing, but it uploads fine. I went to mirror the code for the right wheel, and ran into the same problem, with the identical line of code. It doesnt matter what I put in the if statement, it fails to upload. Anything from declaring a variable, making leftspeed a specific number, anything at all and the program wont load.

I was going to do this all by hand as a coding exercise, and then was going to implement PID as I believe that would be a better solution in the long run anyway.

Offline bukowskiTopic starter

  • Robot Overlord
  • ****
  • Posts: 219
  • Helpful? 0
Re: McUber failing to upload code. Im missing something.
« Reply #8 on: April 20, 2013, 07:53:17 PM »
Update for future people encountering similar problems: Programming with the AVRISP Mk II works fine. Im not sure what wasnt being friendly, but Im glad there was a pretty easy fix.
« Last Edit: April 22, 2013, 03:06:46 PM by bukowski »

Offline Webbot

  • Expert Roboticist
  • Supreme Robot
  • *****
  • Posts: 2,165
  • Helpful? 111
    • Webbot stuff
Re: McUber failing to upload code. Im missing something.
« Reply #9 on: April 27, 2013, 02:08:46 PM »
Programmers like AVRISP and McUber etc are exactly that -they copy a file on your computer to the flash memory of your computer. They have no idea about the content of the file - other than that it conforms to the hex format which is incredibly basic. It would be quite easy to take a jpeg photograph and write it out in hex format and a programmer would upload it - of course it would be jibberish but the programmer doesn't know that.
ie if it compiles to a hex then it is uploadable (else blame the programmer software), if it compiles but doesn't run as expected then it is most likely your code but could also be the optimizer in the compiler (compilers are never 100% bug free and errors will change with the compiler version number, whether you are using C or C++, optimization command line settings etc) in which case try again with optimization turned off (see the codegen dialog box in Project Designer).
Webbot Home: http://webbot.org.uk/
WebbotLib online docs: http://webbot.org.uk/WebbotLibDocs
If your in the neighbourhood: http://www.hovinghamspa.co.uk

 


Get Your Ad Here

data_list