We would appreciate if you could answer the following questions.
- Could you please tell us which sensor you are using?
- Which image are you using on your Galileo?
- How are you connecting the IR sensor to the board?
- Which version of MRAA are you using?
I would also suggest you to check this guide which uses a similar proximity sensor, it can be helpful as a reference document (The Arduino board in the image should be interpreted as Galileo board).
I am using Sharp 2Y0A02 F distance senosr and mraa 0.8.1 devkit 2015.0.010 version. I connected sensor to analog pin 3( a3). Since the the Galileo runs slower than the arduino. I want to measure the exact time at each instant to get the accurate speed. right now I am not getting the exact time.
1 of 1 people found this helpful
take care of some of your assumptions. The Galileo does not run slower than the Arduino. It runs much, much faster, but in a complete different way.
Arduino Uno or Mega : 8 bits processor running at 16MHz without operating system
Galileo : 32 bits processor running at 400MHz with Linux
You have to understand that the Galileo does not read the ADC in the same manner as the Arduino (it looks the same from programmer point of view, because of the library, but under the hood, it's completely different)
On the Arduino, the ADC output is a simple register that is read directly by your program without any external access by the CPU core using the internal databus. It takes one or two CPU cycles and it's done.
On the Galileo, the ADC is read over the SPI. So it takes time to retrieve the data, since it's a serial communication scheme. Moreover, the SPI communication interface can not be accessed directly from your code, because Linux is in the game, and it takes care of possible concurrent access (Linux is multitasking, do not forget it). The Linux kernel makes the SPI interface appear as a file for the library. That means that any attempt to read an analog input is in fact : opening a "file" (every device is a file with Linux), send a command, wait for the answer, close the file. This is extremely fast even if it appears as heavy to do. The problem is that you do not control when the Linux kernel will really read the analog value.
That's probably where you have a problem (I do not know the sensor you use, so I can not guarantee that it is the explanation). If you need to measure precisely the time difference between two analog inputs, the Linux kernel will add some uncontrolled jitter and you will get false readouts. If it's the case with this sensor, then you will need to use a AVR based Arduino, on which there is no operating system and on which you can control very tightly the timing
Just as BenKissBox said, the conditions working with an Arduino board and an embedded platform running Linux or any other OS are quite different. However, among the things that you can try to improve your results would be to update mraa, update 0.9.0 is already available.