tag:blogger.com,1999:blog-132730202024-03-08T09:15:52.798+01:00MatHertels WebLogMatHertel blogging about current activities.
I am currently focusing on DMX related hardware and software on the Arduino platform.Unknownnoreply@blogger.comBlogger27125tag:blogger.com,1999:blog-13273020.post-84179102532860284022018-10-02T17:52:00.000+02:002018-10-02T17:52:13.679+02:00Robust ESP8266 network connectsWhile building small devices with the ESP8266 chip I made some experiences with the stability of implementations which I would like to share here.<br />
<br />
The examples you can find on the Internet often don't go into these problems in detail, but you can also find tips and tricks on these topics.<br />
<br />
<h3>Connecting to the Network, too simple too bad</h3><br />
To connect to a local network you often find only a very simple implementation of this kind:<br />
<br />
<pre class="code">WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
</pre><br />
Obviously, if the <b>ssid</b> or <b>password </b>is wrong, the device will hang in an infinite loop because you never will connect and status will never return WL_CONNECTED(3) when using wrong settings.<br />
<br />
But WiFi.status() also has more return codes that may give a hint that is never reported to the Serial output and root causes will be undiscovered.<br />
<br />
By looking more into the WiFi library there is a waitForConnectResult() function that is used in the OTA samples (file ESP8266WiFiSTA.cpp).<br />
<br />
<pre class="code">while(status() == WL_DISCONNECTED) {
delay(100);
}
</pre><br />
In the case of no connectable available WiFi the status will return WL_NO_SSID_AVAIL(1) or WL_CONNECT_FAILED(4) so the loop exist. At least no infinitive loop and the samples just restart the chip and the sketch.<br />
<br />
<br />
In case of a miss-configuration this is just another kind of infinitive loop that needs to be avoided.<br />
<br />
<h3>Connect during startup</h3><br />
Here is a more robust implementation using a timeout to start a complete new approach after 30 secs and providing more information on the Serial output and terminating with the last return code of the status call.<br />
<br />
The possible results of status I observed that end the attempt to connect to the network are WL_CONNECTED(3), WL_NO_SSID_AVAIL(1) and WL_CONNECT_FAILED(4). When one of these status codes exist the loop can end as well.<br />
<br />
When you need to connect during startup this sequence can be used.<br />
<br />
<pre class="code">// wait max. 30 seconds for connecting
unsigned long maxTime = millis() + (30 * 1000);
while (1) {
wifi_status = WiFi.status();
Serial.printf("(%d).", wifi_status);
if ((wifi_status == WL_CONNECTED) || (wifi_status == WL_NO_SSID_AVAIL) ||
(wifi_status == WL_CONNECT_FAILED) || (millis() >= maxTime))
break; // exit this loop
delay(100);
} // while
Serial.printf("(%d)\n", wifi_status);
</pre><br />
The delay was reduced to 100 msec. as the implementations inside the SDK also use this timing.<br />
<br />
However, when a connection could not be established something needs to be done. A reset of the whole device is a valid option and in the case of a unreliable WiFi that helps connecting after the network is available again.<br />
<br />
<pre class="code">if (WiFi.status() != WL_CONNECTED) {
ESP.restart();
}
</pre><br />
<p>You can find out by calling the WiFi status function from time-to-time and start a re-connect or restart.</p><br />
<h3>More improvements</h3><br />
<p>This is just a replacement for the usual connect sequence you can find in the setup of a device. But there are more situations to be taken in considerations like setting up a fresh network connection, using the WPS feature of your browser etc.</p><br />
<br />
<h3>Reading Material</h3><ul><li><a href="http://usemodj.com/2016/08/04/esp8266-wifi-smartconfig/">http://usemodj.com/2016/08/04/esp8266-wifi-smartconfig/</a></li>
<li><a href="https://tzapu.com/esp8266-smart-config-esp-touch-arduino-ide/">https://tzapu.com/esp8266-smart-config-esp-touch-arduino-ide/</a></li>
<li><a href="http://bienonline.magix.net/public/esp8266-UrsWiFi.html">http://bienonline.magix.net/public/esp8266-UrsWiFi.html</a></li>
</ul><br />
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-63270337639501559452017-09-03T18:41:00.001+02:002017-09-06T21:57:04.689+02:00Arduino based DMX device for controlling NeoPixel and WS2811<p>In the <a href="http://www.mathertel.de/Arduino/DMXSerial.aspx">DMXSerial library</a> examples folder you now can find a sketch for receiving DMX with an Arduino and send the received data to a series of NeoPixel or WS2811 LEDs. Just load the DMXSerial library version 1.4 using the library manager of the Arduino environment of download <a href="https://github.com/mathertel/DmxSerial">DMXLibrary from Github</a>.</p><br />
<p>The challenge for this sketch was the fact the both protocols, DMX and WS2811, are time critical and that the standard Arduino Uno processor doesn’t have the power to do both protocols at the same time.</p><br />
<p>The solution for this is another DMX mode in the DMXSerial implementation that allows to stop the DMX protocol while sending out the data to the NeoPixels.</p><br />
<h2>DMXProbe mode</h2><br />
<p>This mode is starting the Arduino in DMX receiving state, but doesn’t actively listen for incoming data. No interrupts are enabled and any incoming data packet will stick in the serial receiver.</p><br />
<p>To receive data the receive() function must be called. This function clears all hardware buffers and waits for an incoming data package by using the same mechanism as the DMXReceiver mode. After receiving a package this function returns with true and data can be found in the internal buffer.</p><br />
<p>When no DMX data was received in the specified time the receive function will return false.</p><br />
<br />
<h2>The DmxSerialNeoPixels example</h2><br />
<p>This example contains a sketch for receiving DMX data with an Arduino and send the received values to a series of NeoPixel or WS2811 LEDs.</p><p>The NeoPixel sending routine is based on the work of bigjosh2 from his positing on his web site: <br />
<a href="https://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/">https://wp.josh.com/2014/05/13/ws2812-neopixels-are-not-so-finicky-once-you-get-to-know-them/</a></p><br />
<p>The DMXSerial library is not yet published as a new version to the Arduino community. I just like to push it out to all of you working with time critical implementations as an added value and check for problems during the next days.</p><br />
Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-41516252744683474572015-04-14T18:47:00.001+02:002015-04-14T18:47:25.841+02:00The DMX library DMXSerial for Arduino is now available using the Arduino Library Manager<p>From now on it’s easy to install and update the library by using the Library Manager in the Arduino environment including including 3 sample applications for sending and receiving DMX messages.</p> <p>I used several of the beta versions and also the final to test compatibility of my DMXSerial library. <p>By using the Library Manager you can always download the latest stable version that is tagged with the version number directly in my github repository. <p>You can find that repository directly at: <ul> <li><a href="https://github.com/mathertel/DmxSerial">https://github.com/mathertel/DmxSerial</a></li></ul> <p>If you haven’t already done so, please download the new Arduino environment version 1.6.3 or later from the Arduino web site <a href="http://www.arduino.cc">www.arduino.cc</a>.</p> <p> </p> <p>If you like the latest version including work in progress please use the download from github directly by using a git or subversion client. If you like to contribute I like to see your attributions based on this version.</p> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-39789234002192739752014-10-28T23:32:00.001+01:002014-10-28T23:32:54.371+01:00An Arduino library for FM radio chips<p>My latest project is about controlling an FM radio chip by using an Arduino Board, an LCD display and a rotary encoder all the components I need to build a standalone radio for my needs.</p> <p>There are diverse radio chips available for building radio receivers. Because most of them are made for integration into mobile phones or car radios they normally come on breakout boards, sometimes together with audio amplifiers for headphones.</p> <p>The ones I found and tried are:</p> <li>The SI4703 from Silicon Labs <li>RDA5807 from RDA Microelectronics <li>TEA5767 from NXP</td></tr> <p>They all are capable for receiving FM radio stations in stereo with European and US settings and can be controlled by using the I2C bus. However there are differences in the sensitivity and quality and well on receiving RDS information from the stations.</p> <p>The idea of the project beside implementing a radio for my personal needs is to provide Arduino compatible libraries for these (and possible more) chips that all offer the same functionality and expose the same functions. These radio chip adaptions can be combined with the also available RDS encoder and the radio applications.</p> <p>This is my current hardware setup for the latest project I am working on by using a breakout board for the SI4703 chip including an audio amplifier that I found on eBay:</p> <p><a href="http://lh4.ggpht.com/-cZ5GMi2v37E/VFAZa2dY_gI/AAAAAAAAAX4/ljr7dla2_Ew/s1600-h/SAM_25044.jpg"><img title="SAM_2504" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="SAM_2504" src="http://lh3.ggpht.com/-st0yeJRjyB8/VFAZbeC5mRI/AAAAAAAAAX8/LIWyLU7Rp1c/SAM_2504_thumb1.jpg?imgmax=800" width="604" height="472"></a></p> <h3>The radio library</h3> <p>The libraries for this project can be found on github:</p> <blockquote> <p><a href="https://github.com/mathertel/Radio">https://github.com/mathertel/Radio</a> </p></blockquote> <p>You can download all the files at once by using the provided zip file:</p> <blockquote> <p><a href="https://github.com/mathertel/Radio/archive/master.zip">https://github.com/mathertel/Radio/archive/master.zip</a></p></blockquote> <p>I still work on this and still some features I like to implement are still in development but maybe you already have experiences with audio functionality on the Arduino or other platforms or you also work on a similar project. Let me know (via eMail) and maybe we can share some experiences. </p> <h3>Open Topics</h3> <ul> <li>Implementing all functions for all chips <li>good documentation <li>pictures <li>writing about using LCD displays in the I2C bus <li>writing about interpreting RDS data <li>… let me know</li></ul> </li> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-32794858437671230802014-10-19T19:11:00.000+02:002016-04-16T19:11:49.897+02:00Joystick shields for Arduino<p>I was playing around lately with some standard I/O boards and came across the joystick shields. There are at least 2 versions of joystick shields on the market. There is one from sparkfun (see link below) and another labeled with funduino that is available in many stores and as well on eBay. </p> <p>Both share a kind of Nintendo layout using an analog joystick on the left, 4 buttons on the right and 2 buttons in between. The JoyStick Shield V1.a is the one I like to write bout here but I expect that the sources I share with you can help out on other layouts too.</p> <p><a href="https://lh3.googleusercontent.com/-p2wJqa6r1X8/VxJyVKLg6dI/AAAAAAAAAbo/RcArMCFfUGQ/s1600-h/JoyStickShield6.jpg"><img title="JoyStickShield" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="JoyStickShield" src="https://lh3.googleusercontent.com/-U6a2DJ4snqE/VxJyVUrG9zI/AAAAAAAAAbs/tzXvBbVtVfE/JoyStickShield_thumb4.jpg?imgmax=800" width="604" height="372"></a></p> <p>The Funduino version has more functionality by providing switch for the reference voltage of the analog joystick and a lot of connectors especially for the NRF24L01 transceiver. However samples for the shield are hard to find and most stores don’t provide a schema. So here is my documentation that may help you out of this and some sketches to show the functionality.</p> <p>The JoyStick IO definitions I use are for the Funduino JoyStick Shield V1.A but they can easily be adapted to the sparkfun and other similar joystick shields.</p> <h3>Raw Signal testing</h3> <p>The JoyStick_RawTest.ino sketch that you can find in the library shows how to initialize all the input ports of the Arduino corresponding to the buttons and the joystick of the shield.</p> <p>Here is the list of the Arduino ports used by the shield buttons and joystick:</p> <table cellspacing="0" cellpadding="2" width="315" border="0"> <tbody> <tr> <td valign="top" width="175"><strong>function </strong></td> <td valign="top" width="138"><strong>io port</strong></td></tr> <tr> <td valign="top" width="175">Button A</td> <td valign="top" width="138">digital pin 2</td></tr> <tr> <td valign="top" width="175">Button B</td> <td valign="top" width="138">digital pin 3</td></tr> <tr> <td valign="top" width="175">Button C</td> <td valign="top" width="138">digital pin 4</td></tr> <tr> <td valign="top" width="175">Button D</td> <td valign="top" width="138">digital pin 5</td></tr> <tr> <td valign="top" width="175">Button E</td> <td valign="top" width="138">digital pin 6</td></tr> <tr> <td valign="top" width="175">Button F</td> <td valign="top" width="138">digital pin 7</td></tr> <tr> <td valign="top" width="175">X - Axis</td> <td valign="top" width="138">analog pin A0</td></tr> <tr> <td valign="top" width="175">Y – Axis</td> <td valign="top" width="138">analog pin A1</td></tr> <tr> <td valign="top" width="175">Joystick push, Button K</td> <td valign="top" width="138">digital pin 8</td></tr></tbody></table> <p>In the loop function the real raw signal levels of the IO are printed out to the Serial port so you can inspect the current values. After compiling and uploading the sketch you should open the serial monitor with the 57600 baud settings and watch all the information coming from the shield.<br>You can see the difference for the 3V3 / 5V switch in the possible values of the analog input signals.</p> <p>You should use this sketch just to be sure all the IO definitions are fine.</p> <h3>Signal testing</h3> <p>However, using the raw signals is a kind of pain. 2 simple methods can help you to make this more easy. The JoyStick_Test.ino sketch that you can find in the download files shows how to use the input on a more logical level and in respect of the not so exact analog joystick signals.</p> <p><strong>Buttons</strong></p> <p>The levels of the buttons are on the level 1 when not pressed. The conversion is implemented in the function joyButton(...) and returns a boolean value.</p><pre class="code">boolean joyButton(byte pin) {
int signal = digitalRead(pin);
return (signal == 0);
} // joyButton</pre>
<p><strong>JoyStick position</strong></p>
<p>The levels of the X and Y joystick normally are not very correct. If you leave the stick untouched in the middle position the actual value from the analog port will not be exactly half the reference voltage and it may jump between some values. It is also very hard to get the stick to a specific position and hold it in place. Therefore I use a function that converts to the analog input value to a range of -4 to 4 where 0 is the level in normal position. The conversion is implemented in the function joyStick(...) and returns a signed int. The 3v3 / 5v switch should be in the 5v position.</p><pre class="code">int joyStick(byte pin) {
// read the analog value
int signal = analogRead(pin);
// convert with mathematics:
signal = ((signal+64) / 128) - 4;
return (signal);
} // joyStick</pre>
<p>After compiling and uploading the sketch you should open the serial monitor with the 57600 baud settings and watch all the information coming from the shield.</p>
<p>If you like to use these functions just copy them over to your sketch.</p>
<p>...</p>
<h3>Sketch JoyStick_RawTest.ino </h3><pre class="code">/// \file JoyStick_rawtest.ino
/// \brief A simple sketch showing the binary input values fro the joystick board.
///
/// \author Matthias Hertel, http://www.mathertel.de
/// \copyright Copyright (c) 2014 by Matthias Hertel.\n
/// This work is licensed under a BSD style license.\n
/// See http://www.mathertel.de/License.aspx
///
/// \details
/// This sketch shows how to initialize all the input ports of the Arduino
/// corresponding to the buttons and the joystick of the shield.
/// The real raw singal levels of the IO are printed out to the Serial port
/// so you can inspect the current values.
/// you can see the difference for the 3V3 / 5V switch in the possible values
/// of the analog input signals.
/// The JoyStick IO definitions here are for the Funduino JoyStick Shield V1.A.
/// It can easily be adapted to the sparkfun JoyStick Shield.
///
/// More documentation and source code is available at http://www.mathertel.de/Arduino
///
/// History:
/// --------
/// * 18.10.2014 creation.
/// Port definitions for the buttons on the shield with the printed labels
#define BUTTON_A 2
#define BUTTON_B 3
#define BUTTON_C 4
#define BUTTON_D 5
#define BUTTON_E 8
#define BUTTON_F 7
/// Port definitions for the JoyStick functions
#define ANALOG_PUSH 8
#define ANALOG_X A0
#define ANALOG_Y A1
void setup() {
Serial.begin(57600);
// Setup button inputs with internal pull up high resistor
pinMode(BUTTON_A, INPUT_PULLUP);
pinMode(BUTTON_B, INPUT_PULLUP);
pinMode(BUTTON_C, INPUT_PULLUP);
pinMode(BUTTON_D, INPUT_PULLUP);
// Setup the option buttons
pinMode(BUTTON_E, INPUT_PULLUP);
pinMode(BUTTON_F, INPUT_PULLUP);
// Setup joystick button
pinMode(ANALOG_PUSH, INPUT_PULLUP);
// The analog inputs need no setup.
}
void loop() {
Serial.print(" A:"); Serial.print(digitalRead(BUTTON_A));
Serial.print(" B:"); Serial.print(digitalRead(BUTTON_B));
Serial.print(" C:"); Serial.print(digitalRead(BUTTON_C));
Serial.print(" D:"); Serial.print(digitalRead(BUTTON_D));
Serial.print(" E:"); Serial.print(digitalRead(BUTTON_E));
Serial.print(" F:"); Serial.print(digitalRead(BUTTON_F));
Serial.print(" -- X:"); Serial.print(analogRead(ANALOG_X));
Serial.print(" y:"); Serial.print(analogRead(ANALOG_Y));
Serial.print(" K:"); Serial.print(digitalRead(ANALOG_PUSH));
Serial.println();
delay(250);
}
</pre>
<p> </p>
<h3>Sketch JoyStick_Test.ino </h3><pre class="code">///
/// \file JoyStick_Test.ino
/// \brief A simple sketch showing the binary input values from the joystick board.
///
/// \author Matthias Hertel, http://www.mathertel.de
/// \copyright Copyright (c) 2014 by Matthias Hertel.\n
/// This work is licensed under a BSD style license.\n
/// See http://www.mathertel.de/License.aspx
///
/// \details
/// This sketch shows how to initialize all the input ports of the Arduino
/// corresponding to the buttons and the joystick of the shield.
/// Here the io signal are converted to be interpreted easily:
/// * The levels of the buttons are on the level 1 when not pressed.
/// The conversion is implemented in the function joyButton(...) and returns a boolean value.
/// * The levels of the X and Y joystick normally are not very correct.
/// They are converted to the range -4 to 4 where 0 is the level in normal position.
/// The conversion is implemented in the function joyStick(...) and returns a signed int.
/// The 3v3 / 5v switch should be in the 5v position.
///
/// The JoyStick IO definitions here are for the Funduino JoyStick Shield V1.A.
/// It can easily be adapted to the sparkfun JoyStick Shield.
///
/// More documentation and source code is available at http://www.mathertel.de/Arduino
///
/// History:
/// --------
/// * 18.10.2014 creation.
/// Port definitions for the buttons on the shield with the printed labels
#define BUTTON_A 2
#define BUTTON_B 3
#define BUTTON_C 4
#define BUTTON_D 5
#define BUTTON_E 8
#define BUTTON_F 7
/// Buttons with the names of the classic Nintendo layout
#define BUTTON_SELECT BUTTON_F
#define BUTTON_START BUTTON_E
/// Port definitions for the JoyStick functions
#define ANALOG_PUSH 8
#define ANALOG_X A0
#define ANALOG_Y A1
boolean joyButton(byte pin) {
int signal = digitalRead(pin);
return (signal == 0);
} // joyButton
int joyStick(byte pin) {
// 000....128....256....384....512....640....768....896....1024
// -4 -3 -2 -1 0 1 2 3 4
int signal = analogRead(pin);
/// convert with mathematics
signal = ((signal+64) / 128) - 4;
return (signal);
} // joyStick
void setup() {
Serial.begin(57600);
// Setup button inputs with internal pull up high resistor
pinMode(BUTTON_A, INPUT_PULLUP);
pinMode(BUTTON_B, INPUT_PULLUP);
pinMode(BUTTON_C, INPUT_PULLUP);
pinMode(BUTTON_D, INPUT_PULLUP);
// Setup the option buttons
pinMode(BUTTON_E, INPUT_PULLUP);
pinMode(BUTTON_F, INPUT_PULLUP);
// Setup joystick button
pinMode(ANALOG_PUSH, INPUT_PULLUP);
// The analog inputs need no setup.
}
void loop() {
Serial.print(" A:"); Serial.print(joyButton(BUTTON_A));
Serial.print(" B:"); Serial.print(joyButton(BUTTON_B));
Serial.print(" C:"); Serial.print(joyButton(BUTTON_C));
Serial.print(" D:"); Serial.print(joyButton(BUTTON_D));
Serial.print(" E:"); Serial.print(joyButton(BUTTON_E));
Serial.print(" F:"); Serial.print(joyButton(BUTTON_F));
Serial.print(" -- X:"); Serial.print(joyStick(ANALOG_X));
Serial.print(" y:"); Serial.print(joyStick(ANALOG_Y));
Serial.print(" K:"); Serial.print(joyButton(ANALOG_PUSH));
Serial.println();
delay(250);
}
</pre>
<p> </p>
<h3>Additional Links</h3>
<p><a title="http://arduino.cc/en/Main/ArduinoBoardEsplora" href="http://arduino.cc/en/Main/ArduinoBoardEsplora">http://arduino.cc/en/Main/ArduinoBoardEsplora</a></p><a title=" http://arduino.cc/en/Reference/EsploraReadJoystickSwitch
" href=" http://arduino.cc/en/Reference/EsploraReadJoystickSwitch">http://arduino.cc/en/Reference/EsploraReadJoystickSwitch<br><br></a>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-78192141362579413792014-04-03T19:23:00.001+02:002014-04-04T13:12:00.146+02:00Improved DMX Shield Version for Arduino<p>The last version of the shield with it’s features and internals can be found on <a title="http://www.mathertel.de/Arduino/DMXShield.aspx" href="http://www.mathertel.de/Arduino/DMXShield.aspx">http://www.mathertel.de/Arduino/DMXShield.aspx</a> .</p> <p>This new version of the shield has no functional additions, so it works exactly like the shield in version v03 that is in use in multiple installations. But there are some improvements by adjusting some values and make its use more flexible when using it on top of an Arduino MEGA and other shields.</p> <p>The most obvious features of the new (V04) version of the DMX Shield are the better placements of some of the components and the addition of all the shield connectors from the current Arduino boards.</p> <h3>Fixes to resistor values</h3> <p>The values from the optocoupler OK3 transferring the receiving signal in version v03 are adapted to the other optocouplers.</p> <p>The 3 resistors (R4, R5, R6) are used to limit the current for the internal LEDs of the optocouplers. They had 300 or 470 Ohm in the first layout. These values are now made equal to 470 Ohm which is sufficient.</p> <p>The 3 resistors (R7, R8, R9) are used to pull the output value of the optocoupler to HIGH also had different values of 470 or 4,7k Ohm. These values are now also made equal to 4,7k Ohm which is also sufficient. The downside of it is that the resistors are hard to distinguish.</p> <p>I use both adjustments in some installations and they run fine. </p> <p>The error in the naming of R1 and R2 is fixed.</p> <p>Here is a picture of the shield with some assembly hints:</p> <p><a href="http://lh4.ggpht.com/-fPM_xNpYAjo/Uz2ZFyRLSqI/AAAAAAAAAV4/C-XVkliL2cM/s1600-h/DMXShield.v04.hints%25255B8%25255D.png"><img title="DMXShield.v04.hints" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="DMXShield.v04.hints" src="http://lh6.ggpht.com/-F0sbrtVXYrg/Uz2ZGh52zkI/AAAAAAAAAWA/6VKsARbYGpY/DMXShield.v04.hints_thumb%25255B6%25255D.png?imgmax=800" width="700" height="452"></a></p> <h3>Flexibility for Arduino MEGA</h3> <p>The signals RX, TX and D2 are now brought to the pins d0, d1, d2 via a solder jumper. These 3 jumpers should be closed by dropping a small part of solder upon them for normal operation with Arduino Uno or Leonardo Boards.</p> <p>If you like to use other serial ports or signals like on the Arduino MEGA you can leave these jumpers open and connect the signals the way you like. </p> <p>The ICSP header of the Arduino board can now be brought to the next shield above the DMX shield by soldering a stackable header.</p> <p>All the 4 holes from the Arduino Uno Board are now also available to the shield for building permanent robust stacks.</p> <h3>ICSP header and more pins.</h3> <p>All of these extensions are not needed by the DMX shield but it is a good practice to have connection pads and holes at these positions so the signals can be passed through.</p> <p>Some Arduino shields are using the ICSP header to access the SPI signals from the ATmega chip. The Ethernet shield is a good example for that and there are good reasons to do so.</p> <p>Not the new version of the DMX shield has 6 contacts right where a ICSP connector can be soldered to pass through the signals to a shield above.</p> <p>Also 2 of the Arduino header pins have been expanded since some versions. The POWER connector is now 8 pins long and includes IOREF signal. The upper digital connector is now 10 pins long and include the SDA and SCL signals.</p> <p>Because the DMX shield does not need these signals you can leave these pins without soldering a header or use the (old) shorter headers if you like.</p> <h3>Partlist DMX Shield</h3> <p>Here are the parts you need for a full assembly. It’s also a good order of soldering them.</p> <table style="height: 580px; width: 664px" cellpadding="0" border="1"> <tbody> <tr> <td><b>Part name</b></td> <td><b>Value</b></td> <td><b>Description</b></td></tr> <tr> <td valign="top" colspan="3"><b>Starting with the low parts...</b></td></tr> <tr> <td valign="top"> <p>R4, R5, R6</p></td> <td valign="top"> <p>470 Ω</p></td> <td valign="top"> <p>Bands: (yellow, purple, black, <strong>brown</strong>, brown*) or (yellow, purple, <strong>brown</strong>, silver*)</p></td></tr> <tr> <td valign="top"> <p>R7, R8, R9</p></td> <td valign="top"> <p>4,7 kΩ</p></td> <td valign="top"> <p>Bands: (yellow, purple, black, <strong>black</strong>, brown*) or (yellow, purple, <strong>red</strong>, silver*)</p></td></tr> <tr> <td valign="top" colspan="3"><b>The resistors R1 - R3 should be adjusted for the role of the DMX board in your DMX setup. <br>This configuration is for a DMX / RDM Controller. Don't use them when implementing a DMX or RDM Slave.</b></td></tr> <tr> <td valign="top"> <p>R1, R3</p></td> <td valign="top"> <p>562 Ω</p></td> <td valign="top"> <p>Bands: (green, blue, red, black, brown*)</p></td></tr> <tr> <td valign="top"> <p>R2</p></td> <td valign="top"> <p>133 Ω</p></td> <td valign="top"> <p>Bands: (brown, orange, orange, black, brown*)</p></td></tr> <tr> <td valign="top" colspan="3"> <p><b>Now the capacitators...</b></p></td></tr> <tr> <td valign="top"> <p>C1,C2,C3,C4</p></td> <td valign="top"> <p>100n</p></td> <td valign="top"> <p>Capacitors stabilizing the power. Label: 104</p></td></tr> <tr> <td valign="top" colspan="3"><b>The dc-dc converter...</b></td></tr> <tr> <td valign="top"> <p>DC1</p></td> <td valign="top"> <p>NME 0505</p></td> <td valign="top"> <p>A dc-dc-converter. The chip that provides another 5 v source for the DMX signal converter.</p></td></tr> <tr> <td valign="top" colspan="3"> <p><b>Now you can check if the secondary 5v power is existing. Put it on top of an Arduino and measure the voltage at the capacitor C4. It should be near by 5V.</b></p></td></tr> <tr> <td valign="top" colspan="3"> <p><b>The optocouplers and the driver chips...</b></p></td></tr> <tr> <td valign="top"> <p>IC1</p></td> <td valign="top"> <p>MAX481CPA</p></td> <td valign="top">A MAX481CPA or MAX485 CPA from Maxim or another supplier used to convert the differential DMX signal into a logical signal.<br>The 8 pin chip can be soldered directly or put on a socket. Be sure to place it in the right direction.</td></tr> <tr> <td valign="top"> <p>OK1, OK2, OK3</p></td> <td valign="top"> <p>6N137</p></td> <td valign="top"> <p>The optocouplers.<br>The 8 pin chip can be soldered directly or put on a socket. Be sure to place it in the right direction.</p></td></tr> <tr> <td valign="top" colspan="3"> <p><b>...and the connectors</b></p></td></tr> <tr> <td valign="top"> <p>DMX</p></td> <td valign="top"> </td> <td valign="top"> <p>1X03 pinhead. I cut it from a longer (20 pin) one.</p></td></tr> <tr> <td valign="top"> <p>RGB</p></td> <td valign="top"> </td> <td valign="top"> <p>1X04 pinhead</p></td></tr> <tr> <td valign="top"> <p>stackable headers</p></td> <td valign="top"> </td> <td valign="top"> <p>You can solder the usual stackable headers or if you use the shield at the uppermost shield on the Arduino you can solder simple pinheads too.</p></td></tr> <tr> <td valign="top"> <p>ICSP</p></td> <td valign="top"> </td> <td valign="top"> <p>There is no need caused by this shield to solder a ICSP. You can solder one if you like to use the shield with another shield above that needs these connections.</p></td></tr> <tr> <td valign="top"> <p>solder jumpers</p></td> <td valign="top"> </td> <td valign="top"> <p>Don’t forget to close the jumpers when using a standard Arduino.</p></td></tr></tbody></table> <p>I will update the article on the web during the next days and will attach some pictures too.</p> <p>I ordered more than I need for my projects so if you are interested in the PCB – let me know.</p> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-3457667644074178842014-01-20T22:37:00.001+01:002014-01-20T22:48:08.429+01:00Rotary Encoder Library<p>Here you can find an Arduino compatible library for using rotary encoders.</p> <p>I was searching a library for using a rotary encoder in my latest project and found a lot of information on this topic but none of the existing libraries did immediately match my expectations so I finally built my own.</p> <p>This article likes to explain the software mechanisms used in detail so you can understand the coding and might be able to adjust it to your needs if you like. There are various aspects when writing a library for rotary encoders and you can also find a lot of the sources I analyzed at the bottom of this article.</p> <h3>Download</h3> <p>from <a title="http://www.mathertel.de/Arduino/RotaryEncoderStart.aspx" href="http://www.mathertel.de/Arduino/RotaryEncoderStart.aspx">http://www.mathertel.de/Arduino/RotaryEncoderStart.aspx</a></p> <h3>Rotary Encoder signals</h3> <p>The signals a rotary encoder produces (and what can be handled by this library) are based on a 2-bit gray code available on 2 digital data signal lines. The typical encoders use 3 output pins: 2 for the signals and one for the common signal usually GND.</p> <p>There are 4 possible combinations of on and off on these 2 signal lines that can be seen on this video:</p> <div id="scid:5737277B-5D6D-4f48-ABFC-DD9C333F4C5D:0667452f-03c7-4851-a658-2f443a9cab8f" class="wlWriterEditableSmartContent" style="float: none; padding-bottom: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px"><div><object width="448" height="277"><param name="movie" value="http://www.youtube.com/v/i_5KiK7YQjY?hl=en&hd=1"></param><embed src="http://www.youtube.com/v/i_5KiK7YQjY?hl=en&hd=1" type="application/x-shockwave-flash" width="448" height="277"></embed></object></div><div style="width:448px;clear:both;font-size:.8em">Rotary Encoder signal generation</div></div> <p>The rotary encoder usually has a detent mechanism that holds the knob in place when both contacts are open. when rotating the knob the two contacts will be connected to the common signal one by one. </p> <p>A common cabling is to use the ground as the common signal and use pull-up resistors to have a HIGH signal when the contacts are open. The Arduino processor has internal pull-up resistors on all input pins that can be enabled by software. Have a look at the inline comments of the library.</p> <h3>The bouncing problem</h3> <p>When using contacts there is no exact ON and OFF condition while switching because the contacts never close exactly and especially older contacts or dirty contacts generate a lot of fast ON/OFF sequences (sometimes called noise).</p> <p>Hopefully when you stop turning the knob the contact situation should be fixed. If not, try to clean or throw it away and buy a new one.</p> <p>By using a capacitor it is possible to build a low pass filter that reduce the bouncing effect and eliminates the very small spikes. If you ever have like to use this solution put the capacitor as near as possible to the contacts. 100nF will do here.</p> <p>Another solution is to detect changes of the signal in a very small timeframe and ignore them. You can find a solution using this approach on the Arduino playground article. </p> <p>The solution I found in some of the libraries around is to exactly follow all the 4 possible states of the signals that a switch will pass when being turned from one position to the next and detect the next position only when reaching a detent state. Even when a bouncing will occur it will not change the position counting more than once.</p> <h3>High Frequency</h3> <p>There are library approaches that can handle high frequency rotary encoders. I only use the rotary encoder with my fingers (not by using a motor) and have not found any problems for that speed.</p> <p>However with the library it is important to have a look at the signals every few microseconds or at least when a signal has changed. So give the library often a try to detect the situation or use an interrupt. </p> <p>You can tweak reading the ports by using the bitRead function or a direct read of the Port, but the library looses some of the compatibility with the Arduino style of programming because you have to know the exact hardware definitions.</p> <p>If you need more advanced support for decoding signals from encoders have a look at the optical solutions and processors like the ATXMEGA that includes hardware support for reading position from<br>Quadrature Encoders.</p> <h3>Counting States</h3> <p>Many of the sources use two variables for storing the levels of the 2 signal lines. I found it more practical to use a number between 0 and 3 for a specific state. The first signal line counts for the value 1 and the second counts for the value 2. The addition of both values is used. Because the digitalRead function returns 0 or 1 this can be done by using a bit-shift and addition:</p><pre class="code">thisState = sig1 + 2 * sig2;</pre>
<p>or more effective:</p><pre class="code">thisState = sig1 | (sig2 << 1);</pre>
<h3>Transitions within states</h3>
<p>Detecting a movement of the knob is now identical to detect a transition from one state to the next one. Not all transitions are valid and when both signals change at once there is something wrong with the signals.</p>
<p>Here is a straight forward implementation for calculating the position of the knob from an old (last known) state and the current state:</p><pre class="code">if ((oldState == 3) && (thisState == 1)) {
knobPosition++;
} else if ((oldState == 1) && (thisState == 0)) {
knobPosition++;
} else if ((oldState == 0) && (thisState == 2)) {
knobPosition++;
} else if ((oldState == 2) && (thisState == 3)) {
knobPosition++;
} else if ((oldState == 3) && (thisState == 2)) {
knobPosition--;
} else if ((oldState == 2) && (thisState == 0)) {
knobPosition--;
} else if ((oldState == 0) && (thisState == 1)) {
knobPosition--;
} else if ((oldState == 1) && (thisState == 3)) {
knobPosition--;
} // if</pre>
<p>But this solution uses a lot of programming instructions and also seems to be slow (especially when turning left). A small static array can help reducing time and space. The implementation from brianlow also uses a table and almost the same trick:</p>
<p>calculate an unique index from the oldState and the newState and make a lookup into a array of integers:</p><pre class="code">index = thisState + 4 * oldState;</pre>
<p>or more effective:</p><pre class="code">index = thisState | (oldState<<2);</pre>
<p>The array holds the values –1 for the entries where a position was decremented, a 1 for the entries where the position was incremented and 0 in all the other (no change or not valid) cases:</p><pre class="code">const int8_t KNOBDIR[] = {
0, -1, 1, 0,
1, 0, 0, -1,
-1, 0, 0, 1,
0, 1, -1, 0 };</pre>
<p>Updating the position counter of the rotary encoder now is an simple formula: </p><pre class="code">knobPosition += KNOBDIR[thisState | (oldPos<<2)];</pre>
<p>Every time the current state is equal to 3 the rotary encoder is in the next valid position and a new official position can be made available by dividing the internal counter by 4 (or shifting right by 2):</p><pre class="code">if (thisState == 3)
knobPositionExtern = knobPosition>>2;</pre>
<p>The resulting implementation now is very small and obviously very fast. Also situations where the knob is not turned completely from one official position to another is handled correctly.</p>
<p>The only thing that is critical is that every state change has to be detected and the check routine implementing this functionality has to be called often at minimum once per state change.</p>
<h3>The Return</h3>
<p>Most implementations I found calculate a integer number for the position of the knob others return a “right” or “left”. I found the support for a position value very useful in my projects and therefore stay with this approach.</p>
<p>To read the current position just use the getPosition() function.</p>
<p>However I added the possibility to change the position from a sketch by calling setPosition(newPosition) and you can use that for relative movement detection.</p>
<h3>Using Polling</h3>
<p>The simplest approach of checking the state of the rotary encoder is to poll the signals as often as you can. Just call the tick() function as often as you can and then use the position value for your needs.</p>
<p>The SimplePollRotator example just does this and prints out the current position when changed.</p>
<h3>Using interrupts</h3>
<p>Constantly polling the current state of the rotary encoder is sometimes a void time and resource consumption. Especially when dealing with other topics in your sketch that can take a while you might not have the time for polling.</p>
<p>A good approach is to use the pin change interrupt feature available in the ATMega processors. The Arduino environment has no direct support for this kind of interrupts so programming an Interrupt Service Routine (ISR) is required.</p>
<p>It is important to keep ISR implementations as small and fast as possible. The only thing that has to be done is to call the tick() function. The logic of your sketch should be implemented in the loop function.
<p>All the IO pins on Atmega168 can be used for Pin Change Interrupts
<p>Here is the implementation for the pin change interrupt in the case you have used the A2 and A3 lines for the encoder.
<p>Enable the Pin Change Interrupt 1 in general that covers the Analog input pins or Port C:</p><pre class="code">PCICR |= (1 << PCIE1);</pre>
<p>Now enable the interrupt for pin 2 and 3 of Port C:</p><pre class="code">PCMSK1 |= (1 << PCINT10) | (1 << PCINT11); </pre>
<p>Now the Interrupt Service Routine only has to call the tick function:</p><pre class="code">ISR(PCINT1_vect) {
encoder.tick(); // just call tick() to check the state.
}</pre>
<p>You can also find this in the InterruptRotator example. </p>
<h3>The Examples</h3>
<p><strong>SimplePollRotator</strong></p>
<p>This example checks the state of the rotary encoder in the loop() function. The current position is printed on output when changed.</p>
<p><strong>SimplePollRotatorLCD</strong></p>
<p>The same example as SimplePollRotator but output to an LCD display. You may need to include another LCD library when not using the LiquidCrystal_PCF8574 library. (LCD using SPI)</p>
<p><strong>InterruptRotator</strong></p>
<p>This example checks the state of the rotary encoder by using interrupts as described above.</p>
<p>In this example, when reaching position 66 the output will freeze for 6.6 seconds. The further turned positions will be recognized anyway because the interrupt still works in the background.<br>The output is correct 6.6 seconds later.</p>
<h3>Links</h3>
<p>Some discussions on simple rotary approaches:</p>
<li><a title="http://playground.arduino.cc/Main/RotaryEncoders" href="http://playground.arduino.cc/Main/RotaryEncoders">http://playground.arduino.cc/Main/RotaryEncoders</a>
<p>A datasheet of a typical rotary encoder:</p>
<li><a title="http://www.hobbytronics.co.uk/datasheets/TW-700198.pdf" href="http://www.hobbytronics.co.uk/datasheets/TW-700198.pdf">http://www.hobbytronics.co.uk/datasheets/TW-700198.pdf</a>
<p>The gray code explained:</p>
<li><a title="http://en.wikipedia.org/wiki/Gray_code" href="http://en.wikipedia.org/wiki/Gray_code">http://en.wikipedia.org/wiki/Gray_code</a>.
<p>Some other rotary decoder implementations:</p>
<li><a title="https://github.com/brianlow/Rotary/blob/master/Rotary.cpp" href="https://github.com/brianlow/Rotary/blob/master/Rotary.cpp">https://github.com/brianlow/Rotary/blob/master/Rotary.cpp</a>
<li><a title="http://www.buxtronix.net/2011/10/rotary-encoders-done-properly.html" href="http://www.buxtronix.net/2011/10/rotary-encoders-done-properly.html">http://www.buxtronix.net/2011/10/rotary-encoders-done-properly.html</a>
<p>IO Performance:</p>
<li><a title="http://www.instructables.com/id/Arduino-is-Slow-and-how-to-fix-it/" href="http://www.instructables.com/id/Arduino-is-Slow-and-how-to-fix-it/">http://www.instructables.com/id/Arduino-is-Slow-and-how-to-fix-it/</a>
<li><a title="http://forum.arduino.cc/index.php/topic,68656.0.html" href="http://forum.arduino.cc/index.php/topic,68656.0.html">http://forum.arduino.cc/index.php/topic,68656.0.html</a>
<li><a title="http://jeelabs.org/2010/01/06/pin-io-performance/" href="http://jeelabs.org/2010/01/06/pin-io-performance/">http://jeelabs.org/2010/01/06/pin-io-performance/</a>
<li><a title="http://garretlab.web.fc2.com/en/arduino/inside/arduino/wiring_digital.c/digitalRead.html" href="http://garretlab.web.fc2.com/en/arduino/inside/arduino/wiring_digital.c/digitalRead.html">http://garretlab.web.fc2.com/en/arduino/inside/arduino/wiring_digital.c/digitalRead.html</a>
<p>Interrupts</p>
<li><a title="http://playground.arduino.cc/Main/PcInt" href="http://playground.arduino.cc/Main/PcInt">http://playground.arduino.cc/Main/PcInt</a><pre>More: </pre>
<li><a title="http://www.atmel.com/Images/doc8109.pdf" href="http://www.atmel.com/Images/doc8109.pdf">http://www.atmel.com/Images/doc8109.pdf</a>
</li> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-91414725599295551592013-12-14T14:43:00.001+01:002013-12-14T14:43:14.524+01:00Arduino DMX libraries now also available on Github<p> </p> <p>In the last weeks I got some very valuable feedback and some corrections for the DMXSerial2 library for Arduino from Felicitus and he asked me to put the sources into the GitHub repository.</p> <p>I am used to work with Subversion and never worked with Git before but everything runs perfectly. I love the way how someone can add merge requests to an existing repository without the need to manage users and roles.</p> <p>So you can find the library now on:<br><a href="https://github.com/mathertel/DmxSerial2">https://github.com/mathertel/DmxSerial2</a>.</p> <p>You can download the complete library including the samples by using the “Download ZIP” button on the right-hand side or by using the link<br><a href="https://github.com/mathertel/DmxSerial2/archive/master.zip">https://github.com/mathertel/DmxSerial2/archive/master.zip</a></p> <p>I plan to also leave a copy of the other Arduino libraries there.</p> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-85514668420886917612013-09-18T21:55:00.001+02:002013-09-18T21:55:02.483+02:00Update for DMXSerial2 the DMX RDM library for Arduino<p>IT’s some months ago since I released the first version of DMXSerial2. Now there is an update with some fixes and some more complete functionality.</p> <p>First of all thanks to Simon Newton who shared the link to a copy of the RDM standard E1.20. A download is available at <a href="http://tsp.plasa.org/freestandards">http://tsp.plasa.org/freestandards</a>. “Now there are no more excuses for not complying with the standard” – he writes and I will try to do so.</p> <p>In the update you can the following additions:</p> <ul> <li>The serial port definitions now also support Arduino MEGA 2560 (port 0 and 1) and Arduino Leonardo (port 1) boards. <li>I registered my own manufacurer id, now #0987 for mathertel.de. <li>There is a functionality that creates random device ids in the code. If a board once has started to work the device id will be stored into the eeprom and will remain there even when new software is uploaded. <li>I added the required RDM parameters SOFTWARE_VERSION_LABEL and SUPPORTED_PARAMETERS to comply with the standard. <li>Finally I removed some DMX-only specific code and did some simplifications and memory optimizations. <li>The initialization data for the library is now combined into a new structure.</li></ul> <p>It was an easy job to register a manufacturer id to myself as explained on <a href="http://tsp.plasa.org/tsp/working_groups/CP/mfctrIDs.php">http://tsp.plasa.org/tsp/working_groups/CP/mfctrIDs.php</a>. Feel free to use my manufacturer id yourself if you promise only to use it for experiments and never to put a real device that leaves your hands.<br>If you plan for more please request your own manufacturer id and adjust the _devID definition to use it.</p> <p>You can find the new version of the library now on <a title="http://www.mathertel.de/Arduino/DMXSerial2.aspx" href="http://www.mathertel.de/Arduino/DMXSerial2.aspx">http://www.mathertel.de/Arduino/DMXSerial2.aspx</a>.</p> <p>I will update the text of this site in the next days.</p> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-83533330499404281182013-08-31T20:52:00.001+02:002013-08-31T20:52:49.740+02:00DMXBridge, a wireless DMX sender and receiver<p>There are situations where DMX cables are unwanted or just not practical. This project implements a wireless transfer of a DMX signal in the 2.4 GHz band using the Arduino platform and the popular transceiver module nRF24L01+ from nordic semiconductor.</p> <h3>The DMX protocol</h3> <p>Receiving and sending the DMX protocol from the ATmega chip is done by using the DMXSerial library and the built-in serial port. This implementation is using interrupts and is a good base for implementing a second protocol on the same chip. <p>The DMX Serial library has a built-in 512 byte buffer for a DMX universe that is accessible using the functions provided by the library. After initializing the library and starting the communication the interrupts ensure the communication in the background.</p> <p>You can find a lot of details in the article about the DMXSerial library.</p> <h3>The Wireless protocol</h3> <p>The 2.4GHz RF Transceiver is connected to the Arduino board or ATmega processor by using the SPI interface. The library for driving this chip I used is the library from Greg Copeland that you can find at <a href="https://github.com/gcopeland/RF24">https://github.com/gcopeland/RF24</a>. After initializing the library it is possible to send and receive data by using the provided functions of the library. The library transfers all the commands and data to the nRF24L01+ chip will also handle all the transfer details in the background.</p> <h3>Implementation</h3> <p>Because the libraries handle most of the communication details the implementation of this project only has to close the gap between the 2 protocols. The main differences between them are </p> <p>Frame size: DMX is using a max. 512 byte long frame for sending all the values of all channels at once. The Transceiver uses a much shorter protocol that can transfer up to 32 bytes in one frame. I have seen controllers that do not send all the 512 bytes when only some channels are used in the setup. </p> <p>Transfer speed: DMX is constantly using a 250 kBaud serial transfer speed on the DMX wire. There may be longer gaps between the frames and also between the individual bytes of a frame but it is common to use the maximum possible transfer speed. The Transceiver is supporting 3 different transfer modes </p> <p>The solution I found and implemented here is to break up the 512 channels of the DMX information into smaller packages.</p> <h4>The sender</h4> <p>There are 2 buffers of DMX values. One contains the values I have received lately from the DMX protocol. The DMXSerial library is used to listen to the DMX protocol and fill this buffer.</p> <p>The second buffer contains the values that have been sent over the wireless.</p> <p>The values of both buffers are compared to find the recent changes and to send them with priority. If there is no difference between the 2 buffers no priority data will be sent.</p> <p>To enable the addition of new receivers and to heal dropped packages all the DMX data is sent from time to time regardless whether there are changes on not. </p> <p>The package transferred wirelessly contains a start-address and the actual 8 values starting at this address. The sender just sends the package without requesting any handshake from the receiver. This is called the broadcast mode of the nRF24L01+ modules that enables to use multiple receivers.</p> <h4>The receivers</h4> <p>The receiver only needs a single DMX buffer. All data from the incoming packages is directly taken into this buffer.</p> <p>The DMXSerial library is used to send this information using the DMX protocol.</p> <h3>Setup the hardware </h3> <p>Both, the sender and the receivers need the DMX interface hardware attached to the serial interface and a nRF24L01+ module attached to the SPI bus. A prototype for this setup I used is the <a href="http://www.mathertel.de/Arduino/DMXShield.aspx">DMX Shield</a> I published and a hand-soldered nRF24L01 adapter. The DMX shield is not forwarding the ICSP pins yet so this will only work on the Arduino UNO and older boards. (See discussion in <a title="Arduino Shield for NRF24L01+" href="http://mathertel.blogspot.de/2013/08/arduino-shield-for-nrf24l01.html">Arduino Shield for NRF24L01+</a> post).</p> <p><img src="http://lh4.ggpht.com/-wKnR3zsjvN0/Uhjse0eEVOI/AAAAAAAAAS8/9cequ-Pdk7I/s1600/NRF24L01_Proto2%25255B2%25255D.jpg" width="238" height="160"></p> <p>You need 2 of these at minimum.</p> <h3>Setup the software</h3> <ul> <li>Install Arduino development environment. <li>Add DMXSerial Library from <a title="http://www.mathertel.de/Arduino/DMXSerial.aspx" href="http://www.mathertel.de/Arduino/DMXSerial.aspx">http://www.mathertel.de/Arduino/DMXSerial.aspx</a> <li>Add the RF24 library by Greg Copeland from <a href="https://github.com/gcopeland/RF24">https://github.com/gcopeland/RF24</a>.</li></ul> <p>Now you should be able to open and compile the provided sketches and upload them to the Arduino hardware.</p> <p>The sketches I can provide for now are working in my environment and are not yet optimal for rough environments like stages. There are still some optimizations to do like sending smaller or larger packages and testing different transfer speeds. I like to get feedback from you.</p> <h3>Links </h3> <ul> <li>The sketches can be downloaded from<br><a title="http://www.mathertel.de/Arduino/DMXBridgeStart.aspx" href="http://www.mathertel.de/Arduino/DMXBridgeStart.aspx">http://www.mathertel.de/Arduino/DMXBridgeStart.aspx</a></li> <li>nRF24L01+ specifications<br><a href="http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01P">http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01P</a> </li> <li>DMXSerial Library<br><a title="http://www.mathertel.de/Arduino/DMXSerial.aspx" href="http://www.mathertel.de/Arduino/DMXSerial.aspx">http://www.mathertel.de/Arduino/DMXSerial.aspx</a></li> <li>nRF24 Library by Greg Copeland<br><a href="https://github.com/gcopeland/RF24">https://github.com/gcopeland/RF24</a>.</li></ul> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-13912262300851015032013-08-26T20:04:00.001+02:002013-08-26T20:04:32.175+02:00DMXSerial Update<p>I just updated the <a href="http://www.mathertel.de/Arduino/DMXSerial.aspx">Arduino Library for DMX</a> with some improvements in memory and speed as well as some minor changes.</p> <p>Thanks to Jenny for the hints.</p> <p>If you use this library please download the newest version from: <a title="http://www.mathertel.de/Arduino/DMXSerial.aspx" href="http://www.mathertel.de/Arduino/DMXSerial.aspx">http://www.mathertel.de/Arduino/DMXSerial.aspx</a></p> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-85925774796425552022013-08-24T19:25:00.001+02:002013-08-24T19:25:18.537+02:00Arduino Shield for NRF24L01+<p>Here is the picture of a brand new Arduino Shield for the NRF24L01 on top of an Arduino UNO:</p> <p><a href="http://lh6.ggpht.com/-WJ8eSMpzDfs/UhjsdFiJGfI/AAAAAAAAASc/W8hOXdW79OU/s1600-h/NRF24L01Shield.v01%25255B8%25255D.jpg"><img title="NRF24L01Shield.v01" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="NRF24L01Shield.v01" src="http://lh5.ggpht.com/-UnS2cOIo95g/UhjsdSLjGQI/AAAAAAAAASk/kenGbmm2mJQ/NRF24L01Shield.v01_thumb%25255B6%25255D.jpg?imgmax=800" width="604" height="391"></a></p> <p>It’s the first version and it works :-) so I finally soldered a transceiver directly onto it.</p> <h3>Signal layout</h3> <p>The signals for the SPI bus come from the ICSP connector to make it compatible to Arduino boards that do not have the classic ATmega328 (2009, UNO) but use other processor ICs like Leonardo, Mega. Here the MIIS, MOSI and SCK signals are not D12,D11 and D9. Using the ICSP connector is compatible.</p> <p>The CSN and CE signals can be connected to pin D7 and D8 by using little solder drops on top of the shield that you can see on the right. Using these 2 pins because they do not conflict with other cards I use (Ethernet, SDCard). Initialize the RF24 radio class by using:</p><pre class="code">RF24 radio(7,8);</pre>
<p>If other pins must be used, the 2 solder pads can be kept open and some wires can be used to pass the signals.</p>
<p>The IRQ signal is available on pin D3 the same way, but I don’t use it yet.</p>
<p>The rest of the shield has a permanent breadboard layout for small robust implementations.</p>
<p>In the back you can see another connector for I2C bus that I use to connect other hardware like LCD panels.</p>
<h3>Prototypes:</h3>
<p>Before I had 2 versions in place that I made. The first one was a “flying” transmitter that was perfect for finding the right pins and setup. The second one is sitting on top of an DMX shield.</p>
<p><a href="http://lh3.ggpht.com/-LavRObcVxNA/Uhjsd41HD8I/AAAAAAAAASo/zKD9BAIrxvg/s1600-h/NRF24L01_Proto1%25255B2%25255D.jpg"><img title="NRF24L01_Proto1" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="NRF24L01_Proto1" src="http://lh3.ggpht.com/-iJLuTQfiQlA/UhjseVChFLI/AAAAAAAAASw/B85kk8S4c5w/NRF24L01_Proto1_thumb.jpg?imgmax=800" width="244" height="164"></a><a href="http://lh4.ggpht.com/-wKnR3zsjvN0/Uhjse0eEVOI/AAAAAAAAAS8/9cequ-Pdk7I/s1600-h/NRF24L01_Proto2%25255B2%25255D.jpg"><img title="NRF24L01_Proto2" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; margin: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="NRF24L01_Proto2" src="http://lh6.ggpht.com/-0aV7yyxXqvs/UhjsfDaFkiI/AAAAAAAAATE/vKZQbkqRhCk/NRF24L01_Proto2_thumb.jpg?imgmax=800" width="244" height="164"></a></p>
<h3>See also:</h3>
<p><a href="http://mathertel.blogspot.de/2013/04/hints-on-using-nfr24l01-with-arduino.html">Hints on using NRF24L01+ with Arduino</a></p>
<p>This is a first version of a NRF24L01 shield, especially the breadboard it not perfect. I ordered more than I need so if you are working on a NRF24L01 project and like to have one – let me know. (first come first serve)</p> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-1849540094434465252013-07-01T22:04:00.001+02:002013-08-24T18:14:42.540+02:00Another DMXSerial example<p>The DMXSerial library for the Arduino that you can find at <a title="http://www.mathertel.de/Arduino/DMXSerial.aspx" href="http://www.mathertel.de/Arduino/DMXSerial.aspx">http://www.mathertel.de/Arduino/DMXSerial.aspx</a> has only 2 small examples that show the principle functionality of the DMX library:</p> <ul> <li>DMXSerialRecv implements a 3 channel DMX device on channel 1-3 and sends the data to the PWM output pins 9, 6 and 5.<br>It also shows the usage of the DMXSerial.noDataSince method. <li>DMXSerialSend implements a 3 channel DMX Controller sending a continuously changing color schema to the channels 1 to 3.<br>Here an array of color definition is used and the implementations adjusts the current color smoothly into the next color from the arrays.</li></ul> <p>Now there is a new example available:</p> <p><strong>DMXSerialFlow </strong>implements a 60 (20*3) channel DMX Controller sending a continuously changing colors schema to the channels 1 to 3. </p> <p>The calculation of the colors is done by using a hue to rgb converter.</p> <p>Hue is a number from 0 to 764 that represents one of the colors of a color wheel. With a simple algorithm it is possible to calculate the red,green and blue component of it.</p> <p>There are some hints inside the code that allows you to make some changes for example the speed of the color changing.</p> <p>This example was used for testing a wireless 2.4 GHz DMX transceiver that I am working on right now. Stay tuned :-)</p> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-80021276950082537642013-05-19T22:51:00.001+02:002013-05-20T16:35:53.747+02:00Update for the DMXSerial library<p>There is a significant update for the DMXSerial library on my web site that enables programming DMX devices on ARDUINO MEGA boards and ARDUINO Leonardo boards using the DMXSerial library.</p> <p>The original library was written for Arduino 2009 and Arduino UNO boards that use the ATmega328 or ATmega168 chip. These chips only have a single Universal Synchronous and Asynchronous serial Receiver and Transmitter (USART) a.k.a. the Serial port in the Arduino environment. The DMXSerial library uses this port for sending or receiving DMX signals.</p> <p>This conflicts a little bit with the usage of the programming mode the Arduino offers through then USB ports or serial interfaces but it is possible to build compatible DMX shields that don’t interfere with this usage if done right. The <a title="Arduino DMX Shield for sending and receiving DMX and RDM signals." href="http://www.mathertel.de/Arduino/DMXShield.aspx">DMXShield</a> is an example of this.</p> <h3>Arduino Leonardo</h3> <p>The Arduino Leonardo board uses a chip that has a USB 2.0 port available in addition to the USART. Therefore the “Serial” port is routed through the USB port that behaves like a serial port device and not the built-in USART. If you like to address the real Serial port you have to go with the Serial1.</p> <p>But if you look at the hardware and the registers directly the USART0 still exists but the definitions for addressing the registers have changed (for example USART_RX_vect is now USART0_RX_vect). Therefore some adjustments had to be done.</p> <p>With this board you can write debugging information to the Serial port in your sketch for debugging or data exchange purpose. So maybe a DMX diagnostic sketch can profit from that.</p> <h3>Arduino MEGA 2560</h3> <p>When using the chip on the Arduino MEGA 2560 board you have more than one USART available and maybe you wish to use port 1 instead of port 0. This can be done by enabling the definitions for port1 in the library just uncomment the line </p><pre class="code">#define DMX_USE_PORT1</pre>
<h3>ATmega8 boards</h3>
<p>I added the definitions of boards based on the ATmega8 too for experimental purpose. If you find problems with these boards, leave me a note please.</p>
<p>Thanks to Bob Lynas to support me.</p>
<h3>Available</h3>
<p>The updated version is available on my site at: <a title="http://www.mathertel.de/Arduino/DMXSerial.aspx" href="http://www.mathertel.de/Arduino/DMXSerial.aspx">http://www.mathertel.de/Arduino/DMXSerial.aspx</a>.</p> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-59983673818911603432013-04-30T19:21:00.001+02:002013-04-30T19:21:39.512+02:00RGB pixels from 1998<p>Last year I saw these fluorescent lamps from the Omega company that were used to display huge “bildboard” signs.</p> <p>No, blue LEDs have not been evented yet.</p> <p><a href="http://lh4.ggpht.com/-Wv0wsGNyo6g/UX_9iZ_XWDI/AAAAAAAAAQM/FoIV1kcaTjw/s1600-h/20120609_103008%25255B3%25255D.jpg"><img title="20120609_103008" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="20120609_103008" src="http://lh5.ggpht.com/-HeRlKeoWU14/UX_9j2CuIYI/AAAAAAAAAQU/rujc389aEU8/20120609_103008_thumb.jpg?imgmax=800" width="244" height="184"></a><a href="http://lh5.ggpht.com/-otvncC5Ky6Q/UX_9lJ-9g0I/AAAAAAAAAQc/-3ajzRZg0zw/s1600-h/20120609_103030%25255B3%25255D.jpg"><img title="20120609_103030" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="20120609_103030" src="http://lh5.ggpht.com/-VfzEy7IhfH0/UX_9mL2p51I/AAAAAAAAAQk/Bso_NaJ-XMc/20120609_103030_thumb.jpg?imgmax=800" width="244" height="184"></a><a href="http://lh5.ggpht.com/-aTkcSgFogOc/UX_9mwW-1uI/AAAAAAAAAQs/YZqXJ-dPO7U/s1600-h/20120609_103054%25255B3%25255D.jpg"><img title="20120609_103054" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; display: inline; padding-right: 0px; border-top-width: 0px" border="0" alt="20120609_103054" src="http://lh3.ggpht.com/-1sA2et5iII8/UX_9oNNz4bI/AAAAAAAAAQ0/ajO_iA289ss/20120609_103054_thumb.jpg?imgmax=800" width="184" height="244"></a></p> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-23877150643363847192013-04-14T16:32:00.001+02:002013-10-13T14:59:39.829+02:00Hints on using NRF24L01+ with Arduino<p>I like to share some liks to the ressources on the internet that I found helpful for implementing projects using the Ultra low power 2.4GHz RF Transceiver NRF24L01+ with the Arduino platform.</p> <h3>The chip specifications</h3> <p>The NRF24L01 (no + at the end) was replaced by the NRF24L01+ (or sometimes called NRF24L01P). Be sure to get the new chip when buying an breakout board.</p>The nRF24L01+ is drop-in compatible with nRF24L01 and on-air compatible with nRF2401A, nRF2402, nRF24E1 and nRF24E2. Intermodulation and wideband blocking values in nRF24L01+ are much improved in comparison to the nRF24L01 and the addition of internal filtering to nRF24L01+ has improved the margins for meeting RF regulatory standards.<br> <p>The old chip: http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01</p> <p>The new chip: <a title="nRF24L01+ product page" href="http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01P">http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01P</a><br> <p>You should read the <a title="nRF24L01+DataSheet" href="http://www.nordicsemi.com/eng/content/download/2726/34069/file/nRF24L01P_Product_Specification_1_0.pdf">nRF24L01+DataSheet</a>, even if it is long and with many details – but that’s what you will need: <a href="http://www.nordicsemi.com/eng/content/download/2726/34069/file/nRF24L01P_Product_Specification_1_0.pdf">http://www.nordicsemi.com/eng/content/download/2726/34069/file/nRF24L01P_Product_Specification_1_0.pdf</a></p> <h3>About ShockBurst<sup>TM</sup></h3> <p>This is a nice to read whitepaper with a description of the ShockBurst<sup>TM</sup> transfer features of the chip:</p> <p><a href="http://www.semiconductorstore.com/pdf/NewSite/nordic/WP_nRF240x_ShockBurst.pdf">http://www.semiconductorstore.com/pdf/NewSite/nordic/WP_nRF240x_ShockBurst.pdf</a></p> <h3>Arduino compatible Libraries for NRF24L01</h3> <p>There is no official “Arduino” library that is maintained by the core Arduino team so you have to look for the available libraries on the internet.</p> <p>The web site <a title="http://www.tinkerer.eu/AVRLib/nRF24L01" href="http://www.tinkerer.eu/">http://www.tinkerer.eu/</a> from Stefan Engelke in 2009 provides a native NRF20L01 library, the original MiRF library (not Arduino specific) and a native <a title="SPI library" href="http://www.tinkerer.eu/AVRLib/SPI">SPI library</a> See <a title="http://www.tinkerer.eu/AVRLib/nRF24L01" href="http://www.tinkerer.eu/AVRLib/nRF24L01">http://www.tinkerer.eu/AVRLib/nRF24L01</a>, and <a title="http://www.tinkerer.eu/AVRLib/SPI" href="http://www.tinkerer.eu/AVRLib/SPI">http://www.tinkerer.eu/AVRLib/SPI</a> . I mention this library because it uses interrupts that most Arduino samples don’t.</p> <p>The MiRF library was ported to the Arduino platform and is using the Arduino SPI library and is described on the arduino playground article: See <a href="http://playground.arduino.cc/InterfacingWithHardware/Nrf24L01">http://playground.arduino.cc/InterfacingWithHardware/Nrf24L01</a></p> <p>J. Coliz (a.k.a. maniacbug) implemented a ARDUINO specific library often called the RF24 library. Its available at <a title="https://github.com/maniacbug/RF24/" href="https://github.com/maniacbug/RF24/">https://github.com/maniacbug/RF24/</a> and was used as the base for implementing other libraries (see below) the last commit to this projects was last on 2012/06/23. <p>Greg Copeland forked (copied over) the library from maniacbug and added some useful stuff including a scanner sample application. He is currently (2013.04.09) supporting his work. See <a href="https://github.com/gcopeland/RF24">https://github.com/gcopeland/RF24</a>. <p>Arco van Geest (a.k.a. gnulnulf) also forked the library from maniacbug is currently adding support for the <a href="https://github.com/gnulnulf/RF24/tree/master/librf24-rpi#raspberry-pi-rf24-libraries" name="raspberry-pi-rf24-libraries"></a>Raspberry Pi. See <a href="https://github.com/gnulnulf/RF24">https://github.com/gnulnulf/RF24</a> </p><!--EndFragment--> <p>Stanley Seow forked the version gnulnulf <a title="https://github.com/stanleyseow/RF24" href="https://github.com/stanleyseow/RF24">https://github.com/stanleyseow/RF24</a> also working on upport for the <a href="https://github.com/gnulnulf/RF24/tree/master/librf24-rpi#raspberry-pi-rf24-libraries" name="raspberry-pi-rf24-libraries"></a>Raspberry Pi.</p> <h3>Critics</h3> <p>There are too much libraries out there for my opinion and those starting from J. Coliz are using the GNU General Public License (not LGPL) and therefore are not compatible with the Arduino license policy.</p> <p>J. Coliz also used the stdio.h printf() functionality ??? causing more usage of the program memory</p> <p>For my personal projects I used the library from Greg Copeland for my first steps to discover the functionality of the chip.</p> <p> </p> <p> <p> <h3>Samples and Projects</h3> <p>Poor Man's 2.4 GHz Scanner:<br><a title="http://arduino.cc/forum/index.php/topic,54795.0.html" href="http://arduino.cc/forum/index.php/topic,54795.0.html">http://arduino.cc/forum/index.php/topic,54795.0.html</a></p> <p>Home Automation – Designing a remote module:<br><a title="http://geekboy.it/projects/home_automation/home-automation-design" href="http://geekboy.it/projects/home_automation/home-automation-design">http://geekboy.it/projects/home_automation/home-automation-design</a></p> <p>Sample without using a library:<br><a title="http://blog.iteadstudio.com/nrf24l01-wireless-module-with-arduino/" href="http://blog.iteadstudio.com/nrf24l01-wireless-module-with-arduino/">http://blog.iteadstudio.com/nrf24l01-wireless-module-with-arduino/</a></p> <p>A sample using the MiRF library:<br><a href="http://www.bajdi.com/playing-with-nrf24l01-modules/">http://www.bajdi.com/playing-with-nrf24l01-modules/</a></p> <p>Step-by-Step introduction using the RF24 library:<br><a href="http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo">http://arduino-info.wikispaces.com/Nrf24L01-2.4GHz-HowTo</a></p> <p>Network Layer for RF24 Radios:<br><a title="http://maniacbug.github.io/RF24Network/index.html" href="http://maniacbug.github.io/RF24Network/index.html">http://maniacbug.github.io/RF24Network/index.html</a></p> <p>A very detailed tutorial in German:<br><a href="http://www.mikrocontroller.net/articles/NRF24L01_Tutorial">http://www.mikrocontroller.net/articles/NRF24L01_Tutorial</a></p> <h3>Other Stuff</h3> <p>These links are not related to Arduino itself but when reading you may also find some interesting information.</p> <ul> <li>This web site contains several tutorials from 2011 that still apply: <a title="http://blog.diyembedded.com/" href="http://blog.diyembedded.com/">http://blog.diyembedded.com/</a> <li><a href="http://nrqm.ca/nrf24l01/">http://nrqm.ca/nrf24l01/</a> <li><a href="http://wiibrew.org/wiki/Logitech_USB_steering_wheel">http://wiibrew.org/wiki/Logitech_USB_steering_wheel</a> </li></ul> <p>...</p> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-87891389885958340622013-04-07T19:57:00.001+02:002013-04-07T19:57:42.870+02:00Update to the OneButton Arduino library<blockquote></blockquote> <p>I wrote <a title="OneButton Arduino Library" href="http://www.mathertel.de/Arduino/OneButtonLibrary.aspx">this small Arduino library</a> more than 2 years ago for some of my projects to use a single input button for multiple purposes. This library detects clicks, doubleclicks and long press situations without a lot of coding on the sketch side.</p> <p>This enables you to reuse the same hardware button and input pin for several functions and lowers the hardware invests.</p> <p>I just updated it including a new sample that shows how to setup the library and bind a "machine" that can blink the LED slow or fast.</p> <p>See <a title="Arduino OneButton Library" href="http://www.mathertel.de/Arduino/OneButtonLibrary.aspx">Arduino OneButton Library</a> on my side.</p> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-47915535203815786332013-04-06T13:05:00.001+02:002013-04-14T16:29:57.311+02:00Using the SPI bus with Ethernet, SD-card and NRF24L01 and other slave devices together<p>I currently work on an project using the popular NRF24L01 module where I came across the question how to avoid conflicts of new designs and existing Arduino boards.<br>The problem when using the W5100 based Ethernet shield including the SD Card adapter and the NRF24L01 Modules together with a Arduino UNO board is that all of them are using the same SPI bus for the data transfer to the chips. Here is an overview of how to make them work all together.<br>Here the master is always the same ATMEGA328 chip on the Arduino board and the 3 chips are slave devices.</p> <h3>The SPI bus concept</h3> <p>A brief explanation of the SPI bus can be found on wikipedia. See <a title="http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus" href="http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus">http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus</a><br>The SPI bus needs 4 signals to work: <br><strong>SCK or SCLK (serial clock) </strong>The clock signal that sets the tempo for any data transfer. This signal is generated by the master chip.<br>On the Arduino Uno this signal is available on pin 13 and ICSP 3.<br><strong>MISO (master input, slave output) </strong>This signal line transfers the data from a slave device to the master chip.<br>On the Arduino Uno this signal is available on pin 12 and ICSP 1.<br><strong>MOSI (master output, slave input) </strong>This signal line transfers the data from the master to the slave devices.<br>On the Arduino Uno this signal is available on pin 11 and ICSP 4.<br><strong>SS or CSN (Slave Select) </strong>This signal makes a slave active by selecting it with a low signal.<br>On the Arduino Uno this signal has to be discussed…<br>Remark: The signal lines SCK, MOSI and MISO are also available on the ICSP header, see below.<br>The signal lines SCK, MOSI and MISO can permanently remain connected to all participating chips. However the Slave Select signal has to be different for every device.</p> <h3>Advantages in using the ICSP header</h3> <p>The SPI signals on an Arduino Mega board are not available on the pins 10, 11, 12 and 13 because this board uses another processor. But because programming an ATMEGA chip through the ICSP is internally also using the SPI interface, the signals are available on the ICSP header too. With the Arduino Ethernet Shield Version 06 the design has changed so that the SPI signals are not taken from the pins 11, 12 and 13 but from the pins ISP 4, 1 and 3. If you use an Arduino UNO or 2009 however these pins are connected on the main board. When designing new shields for Standard and MEGA boards with SPI usage I recommended using the ICSP header like the Ethernet Shield does.</p> <h3>Pin 10</h3>The Arduino pin 10, also labeled SS, also known as PB2 for ATMEGA328, is used by ATMEL to indicate whether the processor is used as an SPI master or slaver device. That pin 10 must remain an output or the SPI hardware will go into 'slave' mode.<br>Using this pin 10 for example on the Ethernet Shield is fine, but if you use other SPI slave devices, keep in mind to no use this pin for input purpose – better don’t use it to avoid conflicts. <h3>Using multiple SPI bus slave devices </h3> <p>When using multiple slave devices on the same SPI bus there is no principle problem with the lines SCK, MOSI and MISO. Because every slave device needs its own slave select signal there are conflicts using the available Arduino pins. When you stack multiple ARDUINO shields on a single Arduino board you may also have conflicts with other pins the shield uses so you have to take care of other conflicts too. Here are some common pin usages:</p> <table style="width: 601px" cellspacing="0" cellpadding="2" border="0"> <tbody> <tr> <td valign="top" width="233"><strong>Arduino Shield</strong></td> <td valign="top" width="232"><strong>Salve device</strong></td> <td valign="top" width="134"><strong>Arduino Pin</strong></td></tr> <tr> <td valign="top" width="232">Ethernet version 01</td> <td valign="top" width="231">W5100 chip Slave Select</td> <td valign="top" width="136">10</td></tr> <tr> <td valign="top" width="231">Ethernet version 06</td> <td valign="top" width="230">W5100 chip Slave Select</td> <td valign="top" width="138">10</td></tr> <tr> <td valign="top" width="231">Ethernet version 06</td> <td valign="top" width="230">SD card Slave Select</td> <td valign="top" width="139">4</td></tr></tbody></table><br> <h3>Using a NRF24L01 radio module </h3> <p>In different samples where the NRF24L01 radio is using the Arduino pin 9 for SS and using pin 8 for the Chip Enable signal but also 8 and 7 is used in same samples. There is no standard definition right now and therefore you have to tell the NRF24L01 library what signals to use for Slave Select and Chip Enable.<br>I personally recommend using 7 for Chip Enable and 8 for Slave Select because the pin 9 is one of the possible PWM output pins. When designing new Shields these pins assignments should be changeable in any way, just to be friendly to other shields… and having the chance to settle conflicts.</p> <h3>More Readings: </h3> <p>Design of the Arduino Ethernet Shield: <a href="http://arduino.cc/en/Main/ArduinoEthernetShield">http://arduino.cc/en/Main/ArduinoEthernetShield</a></p>Using the SD-Slot on the EthernetShield with Hardware SPI: <a title="http://playground.arduino.cc//Main/EthernetShieldSDHardwareSPIMod" href="http://playground.arduino.cc//Main/EthernetShieldSDHardwareSPIMod">http://playground.arduino.cc//Main/EthernetShieldSDHardwareSPIMod</a> General tutorial: <a title="http://tronixstuff.wordpress.com/" href="http://tronixstuff.wordpress.com/">http://tronixstuff.wordpress.com/</a> About the NRF24L01: <a title="http://playground.arduino.cc/InterfacingWithHardware/Nrf24L01" href="http://playground.arduino.cc/InterfacingWithHardware/Nrf24L01">http://playground.arduino.cc/InterfacingWithHardware/Nrf24L01</a> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-10019722151154996912013-03-08T19:30:00.000+01:002013-03-08T20:04:52.563+01:00DMX RDM library DMXSerial2 Version 1.0 released<p><img style="float: left; display: inline" align="left" src="http://www.mathertel.de/Arduino/DMXSerial2.jpg">I just published the version 1.0 of the DMX RDM library as an Arduino library with sample code.</p> <p>Download the file from <a title="DMX Library for Arduino (DMXSerial)" href="http://www.mathertel.de/Arduino/DMXSerial.aspx">http://www.mathertel.de/Arduino/DMXSerial.aspx</a>, unzip the file to your Sketches\libraries and try the example in libraries\DMXSerial2\examples\RDMSerialRecv.</p> <p>The hardware requirements for that sample is a DMX line attached to the serial port, the data direction switch at pin 2 and some led to the ports 5, 6 and 9.</p> <p>The schema of the DMX shield documented in <a title="DMX Shield" href="http://www.mathertel.de/Arduino/DMXShield.aspx">http://www.mathertel.de/Arduino/DMXShield.aspx</a> can be used as well.</p> <p>Any feedback is welcome.</p> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-28185307771326394632013-03-01T19:23:00.001+01:002013-03-01T19:26:03.484+01:00DMXSerial2 Update<p>The first versions (up to version from 22.01.2013) of DMXSerial2 was not stable during several tests I did and often a response package did not reach the controller as expected.</p><p>After some testing with inserted delayMicroseconds() functions and time probes in several places I found that the implementation with the Arduino processor and the DMX Shield was sometimes too fast for the used controllers and the DMX line.</p><p>In several publications for example in <a title="http://www.soundlight.de/techtips/dmx512/dmx_rdm.htm" href="http://www.soundlight.de/techtips/dmx512/dmx_rdm.htm">http://www.soundlight.de/techtips/dmx512/dmx_rdm.htm</a> you can find the timing requirements defined by the RDM standard and it seems that it is very important to follow them strictly.</p><p>The one timing condition that is indeed implemented by the RDM client is the time between the end of a RDM command that is sent by the controller and the start of the RDM response that is sent by the client.</p><p>Because the answer to a command is created asynchronously in the tick() function this time was varying and was often shorter than the expected minimal 176 µsec . </p><p>The version from 01.03.2013 and later now saves the time when the last byte of a command was sent into a global variable and delays the start of the answer when appropriate. After implementing this delay mechanism the RDM communication was much more stable then before.</p><p>And there is the RDM-BREAK that is longer than the DMX-BREAK: min. 176 µsec instead of 88 µsec.</p><p>I published the updated Arduino project today. It’s still work in progress and a library format will be available soon.</p><p>See <a title="http://www.mathertel.de/Arduino/DMXSerial2.aspx" href="http://www.mathertel.de/Arduino/DMXSerial2.aspx">http://www.mathertel.de/Arduino/DMXSerial2.aspx</a></p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-13273020.post-56761025716692538722013-01-22T19:57:00.001+01:002013-03-01T19:27:09.699+01:00New DMX RDM Library for Arduino available<p>I just published an new Arduino project on my web site that implements an DMX RDM Device using the DMXShield.</p><p>From the beginning the DMXSerial library was designed to send and receive DMX data packets. Now it is extended to support RDM packets as well. I had to overcome several pitfalls and stumbling blocks while extending the DMXSerial implementation and I will keep the current version because it needs only a very small amount of program data. The RDM extended version will be DMXSerial2. <p>What you can find in the attached zip file right now is an ARDUINO project including all the files you need to compile. Because it is still in WIP (work in progress) I did not extract the DMXSerial2 files into a library format yet. <p><img src="http://www.mathertel.de/Arduino/DMXShield/RMXShield.jpg" width="300" height="221"></p><p>see: <a href="http://www.mathertel.de/Arduino/DMXSerial2.aspx">RDM Library for Arduino (DMXSerial2)</a></p>Unknownnoreply@blogger.com1tag:blogger.com,1999:blog-13273020.post-18510171613819468292013-01-10T20:01:00.000+01:002013-01-22T19:58:32.137+01:00DMX Shield for Arduino is also working with RDM<p><img title="DMX Shield for Arduino" alt="DMX Shield for Arduino" src="http://www.mathertel.de/Arduino/DMXShield/DMXShieldFull.v03.jpg" width="300" height="236"></p> <p>The last weeks I spent some time in extending the DMXSerial library for Arduino to support the DMX - RDM protocol by using the DMX Shield for Arduino.</p> <p>A prototype version (proof of concept state) is already working. So now I know that the layout of the shield is RDM compatible.</p> <p>But there is still some work to do for the library. I’ll try to publish a new version of the DMX library in some weeks.</p> <p>If you are interested in co-working please let me know.</p> Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-20174063568725887682012-12-20T20:51:00.001+01:002013-03-01T19:27:23.283+01:00New DMX Shields available<p><img src="http://www.mathertel.de/Arduino/DMXShield/DMXShields.v03.jpg"></p><p>Some new DMXShields arrived, tested and running fine. <p>I already updated the article <a title="DMX Shield for Arduino with isolation" href="http://www.mathertel.de/Arduino/DMXShield.aspx" target="_blank">www.mathertel.de/Arduino/DMXShield.aspx</a> and updated the eagle files in the zip file too even if the text is still related to an older version. <p>If you have interest in buying one of the PCBs – just let me know.</p>Unknownnoreply@blogger.com0tag:blogger.com,1999:blog-13273020.post-40270386646751213542012-09-01T14:36:00.000+02:002012-09-01T14:37:25.912+02:00DMX Receiver version 03 is running<p><img style="display: inline; float: left" align="left" src="http://www.mathertel.de/Arduino/DMXSpot/dmxrec.v03.assembled.JPG" width="200" height="145">I just updated <a href="http://www.mathertel.de/Arduino/DMXSpot.aspx">the article</a> on my DMXSpot project. </p>This picture shows the fist good version of the PCB for building simple LED projects with DMX control. It<br />
contains only the parts needed to receive a DMX signal including the isolation parts known from the <a href="http://www.mathertel.de/Arduino/DMXShield.aspx">DMXShield</a> and 3 MosFets that can drive some amperes of load. That should be enough to control a huge amount of LEDs or some power LEDs. <p> </p><p> The schema and the PCB eagle files are available in the download from <a href="http://www.mathertel.de/Arduino/DMXSpot.aspx">the article</a>.</p>Unknownnoreply@blogger.comtag:blogger.com,1999:blog-13273020.post-6998565196090121862012-08-11T20:26:00.000+02:002013-01-22T17:17:53.151+01:00Important DMXSerial Library update<p>Thank to Jonathan L for this brilliant work on fixing some timing conditions with the sending side of the DMXSerial library. </p> <p>From his comment: <blockquote> <p>I'm sure the existing timings (81us break) are pretty much fine with almost all DMX inputs, even though the spec says that the transmitted break time needs to be >= 92 us with MAB >= 12 us. Nonetheless I was motivated to fix it to be as close to 100 us/12us as I could, as this is what is transmitted by most of the commercial DMX units I've seen. <p>The real issue would be if you ran this on a faster processor, in which case the timings would break when the interrupt service routine became faster than the byte time. I was running this on 16 MHz Atmega 328. Most of the ISR is spent doing the long division inside DMXSerialBaud(): I replaced it with a compile-time calculation of the prescaler value, and this results in trashing the last data byte and the break. You can see the results in attached timing23.png. <p>Happily all is fixed by the changes, although the code is a bit more complex.</p></blockquote> <p><img src="http://www.mathertel.de/arduino/DMXSerial/DMXSerialTiming.png" width="600" height="450"></p> <p>I studied the changes to the routines and I understand h did everything. It's all well commented and I like his programming style too. I loaded it into a project I have done some months ago and it works fine.</p> <p>I personally haven't used much the sending part of the library. The last projects were lighting systems that are controlled by DMX used the receiving part only and I found it reliable but he fixed a buffer bug in this too.</p> Unknownnoreply@blogger.com