livebox:hah_arduino

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
livebox:hah_arduino [2011/10/10 17:49] – external edit 127.0.0.1livebox:hah_arduino [2012/05/14 21:31] (current) – [LED control with a BSC schema] minerva9
Line 9: Line 9:
   * Arduino Ethernet (with a shield)   * Arduino Ethernet (with a shield)
  
-All can be interfaced with the HAH unit.+All can be interfaced with the HAH unit. Depending on your existing knowledge of things like FTP/the vi editor/unix style operating systems/the Lua scripting language, it might take you a little time to read up on these topics. However, the examples and support library code have been designed to help you along. 
 + 
 +Once a USB Arduino is connected it will be presented as a /dev/ttyUSBx or /dev/ttyACMx device to the [[HAH]] system.  At this point it can be interfaced to the xAP bus via the [[xap serial]] adapter software.
  
-Once a USB Arduino is connected it will be presented as a /dev/ttyUSBxxx device to the [[HAH]] system.  At this point it can be interfaced to the xAP bus via the [[xap serial]] adapter software. 
 <code> <code>
-# dmesg | tail+/var/log/messages
 usbserial.c: FTDI 8U232AM converter detected usbserial.c: FTDI 8U232AM converter detected
 usbserial.c: FTDI 8U232AM converter now attached to ttyUSB0 (or usb/tts/0 for devfs) usbserial.c: FTDI 8U232AM converter now attached to ttyUSB0 (or usb/tts/0 for devfs)
 +ttyACM0: USB ACM device
 +</code>
 +
 +
 +====== Programming the Arduino from the HAH ======
 +
 +Arduino: Duemilanove 
 +<code>
 +# stty -F /dev/ttyUSB0 hupcl
 +#  avrdude -v -c arduino -p m328p -P /dev/ttyUSB0 -b 57600 -Uflash:w:FILE.hex
 +</code>
 +
 +Arduino: UNO
 +<code>
 +# stty -F /dev/ttyACM0 hupcl
 +#  avrdude -v -c arduino -p m328p -P /dev/ttyACM0 -b 115200 -Uflash:w:FILE.hex
 </code> </code>
  
Line 36: Line 53:
 {{:livebox:arduino-svn-checkout-files.png|}} {{:livebox:arduino-svn-checkout-files.png|}}
  
-<note important>Don't move any of the libraries from their checkout location.  YES, YES every other arduino site talks about shifting them into the Libraries folder of the IDE, but seriously you don't need to anymore!  In fact if you don't they correctly appears as "Contributed Library" under the "import library..." IDE menu option.   Also it makes upgrading your IDE so much easier if you don't pollute it.</note>+<note important>Don't move any of the libraries from their checkout location.  YES, YES every other Arduino site talks about shifting them into the Libraries folder of the IDE, but seriously you don't need to anymore!  In fact if you don't they correctly appears as "Contributed Library" under the "import library..." IDE menu option.   Also it makes upgrading your IDE so much easier if you don't pollute it.</note>
  
 Tested with v18 of the IDE Tested with v18 of the IDE
Line 42: Line 59:
 ====== Ethernet xAP Arduino Library ====== ====== Ethernet xAP Arduino Library ======
  
-To aid writing xAP compliant applications for the Arduino an xAP processing library has been written.  This allows Arduino to be connected to your LAN and will transmit xAP messages without any HAH involvement. See http://wiki.london.hackspace.org.uk/view/Project:Ethernet_Arduino+To aid writing xAP compliant applications for the Arduinoan xAP processing library has been written.  This allows Arduino to be connected to your LAN and will transmit xAP messages without any HAH involvement. See http://wiki.london.hackspace.org.uk/view/Project:Ethernet_Arduino
  
 These are the classes exposed by the library.  Grab the source and browse to see the inner working. These are the classes exposed by the library.  Grab the source and browse to see the inner working.
Line 171: Line 188:
 </code> </code>
  
-Step 2. Plug your arduino into your HAH.  Identify the correct USB serial port and adjust the sample below.+Step 2. Plug your Arduino into your HAH.  Identify the correct USB serial port and adjust the sample below.
 <code> <code>
 # dmesg # dmesg
Line 179: Line 196:
 In this case we are using /dev/ttyUSB0 In this case we are using /dev/ttyUSB0
  
-Step 3. Now we will create a LUA [[hah_plugboard_v2|plugboard]] applet and a BSC endpoint so this LED can be easily controlled.  This will take care of converting the xAPBSC.cmd message into a xap-serial message for us, along with providing xAPBSC.query capabilities, and regular xAPBSC.info reporting about the status of our led.+Step 3. Now we will create a Lua [[hah_plugboard_v2|plugboard]] applet and a BSC endpoint so this LED can be easily controlled.  This will take care of converting the xAPBSC.cmd message into a xap-serial message for us, along with providing xAPBSC.query capabilities, and regular xAPBSC.info reporting about the status of our LED. 
 + 
 +Like all Plugboard scripts, this must be placed in the /etc/plugboard directory on the HAH. The vi editor is included in the HAH Busybox operating system build, so you can create/edit the script directly from a Telnet session onto the HAH (default username/password is root/admin). Remember that your script filename must end in 'Applet.lua' (case sensitive). Also check that you have enabled the plugboard scripting engine and the serial schema services via the HAH web UI (Automation/Assists tab).
  
 <code lua> <code lua>
Line 234: Line 253:
 </code> </code>
  
-Step 4. Restart the plugboard daemon make sure the new Applet is loaded+Step 4. Restart the plugboard daemon to make sure the new Applet is loaded. One easy way to do this is to reboot the HAH. 
 + 
 +Step 5. Send a BSC control message to our endpoint and turn the LED on/off. An easy way to send BSC control messages and to view the new LED endpoint itself is to use [[http://www.edjo.pwp.blueyonder.co.uk/edward/xAP/xFx/viewer_main.htm|xFx Viewer]]. 
 + 
 +<note tip>With xFx Viewer you can't send a new message directly. You need to open any arbitrary message, edit it and then press 'send'.</note>
  
-Step 5. Send a BSC control message to our endpoint and turn the LED on/off ! 
 <code> <code>
 xap-header xap-header
Line 253: Line 275:
 } }
 </code> </code>
- 
 ====== Arduino links ====== ====== Arduino links ======
  
  • livebox/hah_arduino.1318268977.txt.gz
  • Last modified: 2012/03/04 00:48
  • (external edit)