chipKIT® Development Platform

Inspired by Arduino™

4-pin Ultrasonic library works?

Created Tue, 12 Jun 2012 07:55:05 +0000 by RosHardware


RosHardware

Tue, 12 Jun 2012 07:55:05 +0000

Hey.

Sorry for my bad English, I used a translator.

I'm thinking of improving my robot using a UNO32 Chipkit, and for that use this library:

[url]http://www.entremaqueros.com/bitacoras/roshardware/wp-content/uploads/2012/06/Ultrasonic_rev3.zip[/url]

[url]http://www.entremaqueros.com/bitacoras/roshardware/archives/vehiculo-autonomo-con-arduino/[/url]

The ultrasonic sensor used is 4 pin. Can you tell me if the library would work well with a plate UNO32?

Thanks!


nik999389

Tue, 12 Jun 2012 16:27:42 +0000

This library looks like it works, It doesn't have any low level calls or anything. It might not be the fastest library but it would probably work.

The library itself wouldn't be too hard to debug or even remake for that matter, I just glimpsed at it and it looks like it creates a soft serial line between the rangefinder and the Arduino. Try it out, and let us know hoe it goes!


nik999389

Tue, 12 Jun 2012 16:32:00 +0000

Actually There's a correction needed to be made in the code for it to work. At the top of the code theres an include that reads:

#include "Arduino.h"

This should be changed to:

/* For AVR */
#if defined(__AVR__)
    #include <avr/io.h>
#endif

/* For PIC32 */
#if defined(__PIC32MX__)
    #include <p32xxxx.h>    /* this gives all the CPU/hardware definitions */
    #include <plib.h>       /* this gives the i/o definitions */
#endif

RosHardware

Tue, 12 Jun 2012 16:49:29 +0000

Thank you very much!

I'll make the correction Indicate to me and as soon as I get the board will prove it. I'll tell you if it works.

See you soon!


RosHardware

Fri, 13 Jul 2012 17:13:53 +0000

Hello again.

I added the modified library and told me, but Mpide not shown. Not in the list.

[url]http://www.entremaqueros.com/bitacoras/roshardware/wp-content/uploads/2012/07/Ultrasonic-Rev4-for-ChipKit.zip[/url]

I do something wrong?

Thank you very much!


RosHardware

Fri, 13 Jul 2012 17:37:51 +0000

I add the library on .../hardware/pic32/libraries/ and after the library is listed in MPide, but when i add #include <Ultrasonic.h> then appears this error message when i verify:

/Applications/Mpide.app/Contents/Resources/Java/./hardware/pic32/libraries/Ultrasonic/Ultrasonic.cpp: In constructor 'Ultrasonic::Ultrasonic(int, int)': /Applications/Mpide.app/Contents/Resources/Java/./hardware/pic32/libraries/Ultrasonic/Ultrasonic.cpp:20:15: error: 'OUTPUT' was not declared in this scope /Applications/Mpide.app/Contents/Resources/Java/./hardware/pic32/libraries/Ultrasonic/Ultrasonic.cpp:20:21: error: 'pinMode' was not declared in this scope /Applications/Mpide.app/Contents/Resources/Java/./hardware/pic32/libraries/Ultrasonic/Ultrasonic.cpp:21:15: error: 'INPUT' was not declared in this scope /Applications/Mpide.app/Contents/Resources/Java/./hardware/pic32/libraries/Ultrasonic/Ultrasonic.cpp: In member function 'long int Ultrasonic::Timing()': /Applications/Mpide.app/Contents/Resources/Java/./hardware/pic32/libraries/Ultrasonic/Ultrasonic.cpp:28:26: error: 'LOW' was not declared in this scope /Applications/Mpide.app/Contents/Resources/Java/./hardware/pic32/libraries/Ultrasonic/Ultrasonic.cpp:28:29: error: 'digitalWrite' was not declared in this scope /Applications/Mpide.app/Contents/Resources/Java/./hardware/pic32/libraries/Ultrasonic/Ultrasonic.cpp:29:22: error: 'delayMicroseconds' was not declared in this scope /Applications/Mpide.app/Contents/Resources/Java/./hardware/pic32/libraries/Ultrasonic/Ultrasonic.cpp:30:26: error: 'HIGH' was not declared in this scope /Applications/Mpide.app/Contents/Resources/Java/./hardware/pic32/libraries/Ultrasonic/Ultrasonic.cpp:33:41: error: 'pulseIn' was not declared in this scope

HELP!!!


nik999389

Mon, 16 Jul 2012 14:31:28 +0000

Looks Like you also need to add this include at the top of your Ultrasonic.cpp file:

#include "WProgram.h"

Of course, I am no where near my development computer so I have no way of checking this, but It seems like what is wrong. Let me know how it goes!


RosHardware

Mon, 16 Jul 2012 16:11:37 +0000

Thanks!

Now compiles correctly. I just have to do some assembly. When I do it and verify that it works, I would say to you.

Thank you!