Page 4 of 6

Re: EV3 C-code for third party devices (I2C)

Posted: 11 Nov 2013, 07:55
by HaWe
thank you Lauro for your efforts!

if(ButtonWaitForAnyPress(TITLE_DELAY) == BUTTON_ID_ESCAPE)

is actually not what I intended to do, I wanted to check if any button has been hit incidentally without any delay for the rest of the program loop, and just return if it happened or not.
I hope that maybe someone will find out some day what's wrong with my use of checkButtons().


I now again altered your program and attached the gyro to S4.

Code: Select all

#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/ioctl.h>

#include "lms2012.h"
#include "ev3_button.h"
#include "ev3_lcd.h"

//Runtime constants
const int MAX_SAMPLES = 1000;

//Global variables and constants used by the sensor handling functions

#define TITLE_DELAY 1000

IIC *pXgl;

//***************************************************************************************
// Microinfinity XG1300L IMU settings

const char XGL_PORT = 0x3;       // The ports are designated as XGL_PORT_NUMBER-1

const int  XGL_PACKET_SIZE = 10; // 2(gyyro angle)+2(gyro rate)+2(acc x)+2(acc y)+2(acc z)
int        xgl_device_file;
//***************************************************************************************



int init_xg1300l_gyro()
{
//...
If I want to attach 3 NXT_US-sensors at S1,S2,and S3 and want to show the values on the screen as well, how would the program look like?
(I know there might be an issue concerning sonic reflection noise, but that can be possibly handled by one or two steps after^^)

Re: EV3 C-code for third party devices (I2C)

Posted: 11 Nov 2013, 15:25
by lvoc
I don't know why the checkButtons function does not work. However, I looked at the kernel modules that handle the buttons and LEDs, and noticed that using this hardware is not very complex. It is possible to have an operation as the one you need . I wrote some code that you could use as reference for your program.
http://www.robotnav.com/buttons-and-leds/

Re: EV3 C-code for third party devices (I2C)

Posted: 11 Nov 2013, 16:47
by HaWe
thank you,
that would mean one wouldn't have to both #include ev3_buttons.h and don't have to add ev3_button.c to the .prj any more, correct?

now back to my last/next question:
If I want to attach 3 NXT_US-sensors at S1,S2,and S3 and want to show the values on the screen as well, how would the program look like?
they are IIC devices/files too, so that's why I'm asking in this thread about 3rd party devices

Re: EV3 C-code for third party devices (I2C)

Posted: 11 Nov 2013, 18:24
by HaWe
and I still get this effing error if I try to compile your program:

make: *** No rule to make target `lms2012.o', needed by `all'. Stop.


instead, if I compile a file without #including lms2012.h like, e.g. http://sourceforge.net/apps/phpbb/mindb ... 562#p17550 everything is ok.

I already resetted the makefile template to default, but always the same "lms2012.o rule error" !

Re: EV3 C-code for third party devices (I2C)

Posted: 12 Nov 2013, 13:25
by lvoc
I have limited experience with Bricxcc, and I am not quite sure why you get the 'lms2012.o' error. A couple of days ago, I used Bricxcc to compiled a program that uses several program files (.cpp or .c) and include files (.h). When you specify the project files, you should only add the include files (.h). I wrote a short explanation (with screenshots) showing the steps I followed at:
http://www.robotnav.com/position_and_control/ (see Windows section)

About your question on using several IIC devices at the time. The program that you have, should be ready to read from the other ports. When you open a IIC device, you have access to any sensor that uses this interface. Since the other ports (sonar) don't need any special configuration you only need to read them. As far as I can tell, you should be getting ranges from the sonars using something like:

sonar_range_on_port_number_1 = pXgl->Raw[0][pXgl->Actual[0][0];
sonar_range_on_port_number_2 = pXgl->Raw[1][pXgl->Actual[1][0];
sonar_range_on_port_number_3 = pXgl->Raw[2][pXgl->Actual[2][0];
gyroscope_angle_on_port_number_4 = pXgl->Raw[3][pXgl->Actual[3]][0]*256+pXgl->Raw[3][pXgl->Actual[3]][1];

Re: EV3 C-code for third party devices (I2C)

Posted: 12 Nov 2013, 13:41
by HaWe
thank you Lauro, but I'm using just your original code which you provided and of course there is no other #include than those you have written.
Nevertheless there's this stupid makefile error.
I am totally appalled because I can't go on and try anything and have no idea at all about how this issue could be cleared.

Re: EV3 C-code for third party devices (I2C)

Posted: 12 Nov 2013, 14:48
by HaWe
I think the thing which has to be done to work with BCC is
- completely drop the lms2012.h plus the 2 appending files
- use JH's original lcd and button lib and anything
- write a basic library ( just "ev3_sensors.h", no additional .c files and all that ) providing sensor API functions which work with your low level code as a substitute for the lms2012 stuff.

Having this I would be glad to contribute by writing some wraps for a convenient medium-level user-interface
like, e.g.

Code: Select all

SetSensor(port, PinType) // UART, IIC, ADC1, ADC6 (, ...)

ReadSensor (port, int32 &values[] (, numberofvalues) (,SensorTypeMode) ) // 
But first of all this makefile crap has to be fixed.

Re: EV3 C-code for third party devices (I2C)

Posted: 14 Nov 2013, 10:13
by HaWe
no idea anybody how to fix this error
make: *** No rule to make target `lms2012.o', needed by `all'. Stop.


I would not like to abandon this C thing completely just because the f***ing makefile or linker or whatever makes muck.

Re: EV3 C-code for third party devices (I2C)

Posted: 15 Nov 2013, 02:16
by lvoc
Could you write a list of the files that you are including in your project?

Re: EV3 C-code for third party devices (I2C)

Posted: 15 Nov 2013, 07:35
by HaWe
do you mean: the .c files added by the project manager?