Author
Topic: Errors with delays.h header (Read 9378 times)

I am using the MPLAB IDE to program a PIC24. I am getting an abundance of errors when trying to use a code I found at pyro-electro. The code should just create a pulse to move a servo. Any ideas why this might be happening?

I thought I attached the header files, and linker scripts correctly. I have attached the build failure, please advise.

//Delay100TCYx(5);};}}Last three lines... is that semicolon supposed to be there? (Right before the right bracket?) It looks like it goes to the while loop but I can't think of any reason it'd be there, especially like that.

Usually when I get a bunch of unknown/weird errors it's a missing/extra semicolon somewhere near the start of my program, causing cascading errors the rest of the way through.

Just for a test try putting a copy of delay.h in the same folder as the source file and replace the <> with "" to tell the assembler to look in the local folder.If the errors go away then it is a path issue. Check that the search paths are correctly setup in MPLAB for the PIC24 assembler.

It's something I haven't seen in a long time, I'd doubt many (if any) modern compiler supports it - think it was something to do with allowing 16bit pointers to address data in foreign segments, i.e. to use a 16bit offset from a different base address, though I'd look it up if you wanted to be sure, from the foggy past ...You could try just deleting each occurrence of the word "far" from that header file.

far void Delay10TCY(void);That "void" in the "()" I've never seen before. It's like you're sending the Delay10TCY function "nothing", and it doesn't like that. Maybe post that function if you haven't already?

This is why I don't like to use other people's code. When you don't do it yourself you don't know how it works.

The func(void) is ok, it's just explicitly stating there's no params.However, i dont think you can specify storage class in a parameter list e.g. func(auto int myInt). The params go on the stack i.e. the compiler decides where they're stored. Maybe there was a compiler once that allowed you to hint where you wanted the params stored but I don't know of any now that will let you do this.Slightly worried that if you do get this to compile you'll just run into more and more issues like this, does appear to be very old code!

Disregard the last code insertion, I read richiereynolds suggestion more closely and he instructed me to delete PARAM_SCLASS from only the lines giving me the "type-name" error, so now I did that, but the same "undefined reference" errors... remain.

Corrado33 I do just want to watch it do something, I recently acquired an animatronic hand, Mecha TE, and I'm trying to start somewhere, a finger wiggle would be nice. Once I can get going with driving servos (software) I will learn how to close all the fingers in to a fist. Maybe there is some prewritten code for that? Probably not a good idea though, like someone said its better to write it yourself.

Ultimately, I will use EMG signals from my extensor carpi to drive the animatronic hand to close in parallel with my own hand.

Looks like your header file isn't actually being included i.e. an include path issue, though I'd expect the compiler to report that it can't find the file so not certain.

On second look, the output from the compiler isn't what I'm used to, doesn't look to be very well separated into compilation and linking phases, but I noticed it does say "link step failed" at the end - so the include is probably ok, but where is the actual definition of those DelayXXX prototypes in the header? Were they supplied in another C file that you need to also compile? Or a compiled library that you need to link with?

This is where my inexperience fails me. I didn't realize that delays.h didn't actually define those functions.

My compiler didn't have delays.h in the library, so I found it at a website called Koders. I could try to find the missing piece, but I'm not sure what the file name would be for any compiled library, or C file that I need. In that case I'm not sure that we can keep going with this code.

Can you direct me to a sample code to arbitrarily move a servo motor, that doesn't require any obscure header files? I don't know how to code a delay precise enough to create an accurate pulse. Up until now if I needed to create a delay in C I would just make some counter for loops. But to implement PWM I dont think that will work...?

From my understanding the delay function takes into account processing cycles. If I know my processor speed and instructions per second is it possible to use for loops to create pulses or is that just silly?

Coding delay functions are rather basic and a necessary learning experience when working with micro-controllers.

MPLAB has a simulator that can be used to test and measure the delay time so it isn't hard to get the dealy function working. Here is a good tutorial that uses software delays:http://www.gooligum.com.au/tutorials.html

For accurate software delays assembler is common. Accurate delays can be done in C but just beware of any optimizing done by the compiler. Do use the MPLAB simulator to test, measure and debug you functions. A simple delay function in C goes like this:

I used to do delays like this, but I could never get the EXACT delay I wanted unless I played with it for a long time. If they are trying to control a servo, do you think more precise timing would be required?