Namespaces

Variants
Actions

BayleAdvancedProject-p4

From Cycling '74 Wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "The library has to be put in your Arduino library folder in order to be used. Be careful, if you do that while the Arduino IDE is running, you have to restart the IDE in order...")
 
 
Line 1: Line 1:
 
The library has to be put in your Arduino library folder in order to be used. Be careful, if you do that while the Arduino IDE is running, you have to restart the IDE in order to see the library available in your IDE.
 
The library has to be put in your Arduino library folder in order to be used. Be careful, if you do that while the Arduino IDE is running, you have to restart the IDE in order to see the library available in your IDE.
 
  
 
You can find your library folder :
 
You can find your library folder :
Line 9: Line 8:
 
After having put the library in this folder, you can see it in Sketch > Import Library...
 
After having put the library in this folder, you can see it in Sketch > Import Library...
  
'''<image here>
+
[[File:jb-arduino-library.png]]
ADXL345 library is now available'''
+
 
 +
'''ADXL345 library is now available'''
 +
 
  
 
'''BE CAREFUL: You have to upload your code without any XBee module connected!'''
 
'''BE CAREFUL: You have to upload your code without any XBee module connected!'''
Line 16: Line 17:
 
So, I uploaded the test code by bilder at [http://bildr.org/2011/03/adxl345-arduino/ http://bildr.org/2011/03/adxl345-arduino/] using the FTDI board connected to Arduino Fio. I wanted firstly to validate the accelerometer part first.
 
So, I uploaded the test code by bilder at [http://bildr.org/2011/03/adxl345-arduino/ http://bildr.org/2011/03/adxl345-arduino/] using the FTDI board connected to Arduino Fio. I wanted firstly to validate the accelerometer part first.
  
Here is the patch I used for this purpose
+
Here is the patch I used for this purpose:
 +
 
 +
[[File:jb-arduino-patch.PNG]]
  
'''<image here>'''
 
  
 
By banging at the left top corner or loading the patch making loadbang banging that for you, you have the umenu fed by serial object (and put in good format by the small subpatcher portHandler)
 
By banging at the left top corner or loading the patch making loadbang banging that for you, you have the umenu fed by serial object (and put in good format by the small subpatcher portHandler)
Line 24: Line 26:
 
You can choose the right port. Here I chose the one related to the FTDI board, still connected to the Arduino Fio.
 
You can choose the right port. Here I chose the one related to the FTDI board, still connected to the Arduino Fio.
  
Here is portHandler
+
Here is portHandler:
 +
 
 +
 
 +
[[File:jb-arduino-porthandler.PNG]]
  
'''<image here>'''
 
  
It takes care of the umeny building.
+
This takes care of the umeny building.
  
 
The subpatcher dataHandler takes care of data coming from serial port.
 
The subpatcher dataHandler takes care of data coming from serial port.
  
'''<image here>'''
 
  
The object sel (abbreviation of select) selects incoming messages and fires a bang to specific output if the message equals the argument corresponding to the specific place of that output.
+
[[File:jb-arduino-dataHandler.PNG]]
  
Basically, here, we select 10 or 13. The last output pops out the incoming message if that one doesn’t equal any argument.
 
  
Here, we don’t want to consider new line feed (ASCII code 10). This is why we put it as an argument, but we don’t do anything if that one is selected. It is a nice trick to avoid having this message to trigger anything and even to not have it from the right output of [select]
+
The object sel (abbreviation of select) selects incoming messages and fires a bang to specific output if the message equals the argument corresponding to the specific place of that output. Here, we select 10 or 13. The last output pops out the incoming message if that one doesn’t equal any argument. We also don’t want to consider new line feed (ASCII code 10). This is why we put it as an argument, but we don’t do anything if that one is selected. It is a nice trick to avoid having this message to trigger anything and even to not have it from the right output of [select]
  
 
Here, we send all message received from the Arduino, except 10 or 13 to the [zl group 78] object. This latter is a powerful list processing with many features. group argument makes it grouping messages received in a list. The last argument is here to be sure we don’t have too much elements in the list. As soon as [zl group] is triggered by a bang OR the list length reaches the length argument value, it pops out the whole list by its left outlet.
 
Here, we send all message received from the Arduino, except 10 or 13 to the [zl group 78] object. This latter is a powerful list processing with many features. group argument makes it grouping messages received in a list. The last argument is here to be sure we don’t have too much elements in the list. As soon as [zl group] is triggered by a bang OR the list length reaches the length argument value, it pops out the whole list by its left outlet.
Line 114: Line 116:
  
 
I decided to not go further and calibrate anything for now because I wanted to put it in its box to really test in real conditions.
 
I decided to not go further and calibrate anything for now because I wanted to put it in its box to really test in real conditions.
 +
 +
[[BayleAdvancedProject-p3|Previous: Building and debugging]] [[BayleAdvancedProject-p5|Next: Xbee Setup]]
  
 
[[Category: Bayle Advanced Project]]
 
[[Category: Bayle Advanced Project]]

Latest revision as of 02:22, 11 June 2013

The library has to be put in your Arduino library folder in order to be used. Be careful, if you do that while the Arduino IDE is running, you have to restart the IDE in order to see the library available in your IDE.

You can find your library folder :

  • on Windows it is likely in “My Documents\Arduino\libraries”
  • on OSX, it is likely in your user “Documents/Arduino/libraries” and similarly on Linux

After having put the library in this folder, you can see it in Sketch > Import Library...

jb-arduino-library.png

ADXL345 library is now available


BE CAREFUL: You have to upload your code without any XBee module connected!

So, I uploaded the test code by bilder at http://bildr.org/2011/03/adxl345-arduino/ using the FTDI board connected to Arduino Fio. I wanted firstly to validate the accelerometer part first.

Here is the patch I used for this purpose:

jb-arduino-patch.PNG


By banging at the left top corner or loading the patch making loadbang banging that for you, you have the umenu fed by serial object (and put in good format by the small subpatcher portHandler)

You can choose the right port. Here I chose the one related to the FTDI board, still connected to the Arduino Fio.

Here is portHandler:


jb-arduino-porthandler.PNG


This takes care of the umeny building.

The subpatcher dataHandler takes care of data coming from serial port.


jb-arduino-dataHandler.PNG


The object sel (abbreviation of select) selects incoming messages and fires a bang to specific output if the message equals the argument corresponding to the specific place of that output. Here, we select 10 or 13. The last output pops out the incoming message if that one doesn’t equal any argument. We also don’t want to consider new line feed (ASCII code 10). This is why we put it as an argument, but we don’t do anything if that one is selected. It is a nice trick to avoid having this message to trigger anything and even to not have it from the right output of [select]

Here, we send all message received from the Arduino, except 10 or 13 to the [zl group 78] object. This latter is a powerful list processing with many features. group argument makes it grouping messages received in a list. The last argument is here to be sure we don’t have too much elements in the list. As soon as [zl group] is triggered by a bang OR the list length reaches the length argument value, it pops out the whole list by its left outlet.

Here, we “accumulate” all messages received from the Arduino, and as soon as a carriage return is sent, a bang is sent and all data are passed to the next object.

We currently have a big list, with all data inside, each value being separated from the other one by a space character (the famous ASCII code 32 we added in the last function of the firmware)

This list is passed to [itoa] object. itoa stands for integer to ASCII. This object converts integer to ASCII characters.

The [fromsymbol] object converts a symbol to list of messages.

At last, after this [fromsymbol] we have our big list of values separated by spaces and totally readable.

Here is the compressed code you can copy-paste into a patcher to see & use this patch

-- Pasted Max Patch, click to expand. --

I used this patch to check if everything was fine.

The previous Arduino test code worked fine and as soon as I tap the accelerometer, double tap it, or let it without movement, the Arduino Fio informs me via Serial connection via Max6 and let me know his current state.

I decided to not go further and calibrate anything for now because I wanted to put it in its box to really test in real conditions.

Previous: Building and debugging Next: Xbee Setup