Software > Software

McUber failing to upload code. Im missing something.

<< < (2/2)

jwatte:
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.

bukowski:
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.

bukowski:
"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: ---if (leftticks < rampdownticks)
leftspeed = interpolate(leftticks, rampdownticks, backtotaldistanceticks, -40, DRIVE_SPEED_MIN);

--- End code ---

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.

bukowski:
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.

Webbot:
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).

Navigation

[0] Message Index

[*] Previous page

Go to full version