Skip to content

Commit

Permalink
Added comments to address the use of a fast microcontroller and TS423…
Browse files Browse the repository at this point in the history
…1 timing.
  • Loading branch information
jseibel6900 committed May 9, 2018
1 parent fe58ec0 commit 35c4b75
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Installation instructions:
**** 1) The TS4231 is a 3.3V device and must only be used with a 3.3V Arduino board. Failure to do so will damage the TS4231.
**** 2) DO NOT add pull-up or pull-down resistors to the D and E signals.
**** 3) DO NOT configure the Arduino INPUT ports that connect to the D and E signals with a pull-up or pull-down function. They must be floating.
**** 4) If using a microcontroller than can toggle output pin states faster than approximately 100ns, the TS4231 datasheet must be consulted to verify TS4231 timing parameters are not being violated to assure proper TS4231 operation.

1) First, install the TS4231 Arduino library by following the instructions here:

Expand Down
13 changes: 9 additions & 4 deletions examples/ts4231_config_example/ts4231_config_example.ino
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@

#define light_timeout 500 //500ms is a placeholder as this number will be system dependent

//IMPORTANT NOTE: If porting the TS4231 library code to a non-Arduino architecture,
//be sure that the INPUT ports assigned to the E and D signals are configured as
//floating inputs with NO pull-up or pull-down function. Using a pull-up or
//pull-down function on the inputs will cause the TS4231 to operate incorrectly.
//IMPORTANT NOTES:
//1) If porting the TS4231 library code to a non-Arduino architecture,
// be sure that the INPUT ports assigned to the E and D signals are configured as
// floating inputs with NO pull-up or pull-down function. Using a pull-up or
// pull-down function on the inputs will cause the TS4231 to operate incorrectly.
//2) If a microcontroller is being used that can change states on the E and D
// outputs faster than approximately 100ns, see the IMPORTANT NOTES section
// in file ts4231.cpp for more information.

#define device1_E_pin your_E_pin //User must replace your_E_pin with their pin number (compile error will occur if no number defined)
#define device1_D_pin your_D_pin //User must replace your_D_pin with their pin number (compile error will occur if no number defined)

Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=TS4231 Library
version=1.0.3
version=1.0.4
author=Triad Semiconductor
maintainer=Triad Semiconductor <info@triadsemi.com>
sentence=Triad Semiconductor library for configuring the TS4231 Light to Digital Converter.
Expand Down
23 changes: 19 additions & 4 deletions ts4231.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,21 @@
#include "ts4231.h"
#include <Arduino.h>

//IMPORTANT NOTE: If porting the TS4231 library code to a non-Arduino architecture,
//be sure that the INPUT ports assigned to the E and D signals are configured as
//floating inputs with NO pull-up or pull-down function. Using a pull-up or
//pull-down function on the inputs will cause the TS4231 to operate incorrectly.
//IMPORTANT NOTES:
//1) If porting the TS4231 library code to a non-Arduino architecture,
// be sure that the INPUT ports assigned to the E and D signals are configured as
// floating inputs with NO pull-up or pull-down function. Using a pull-up or
// pull-down function on the inputs will cause the TS4231 to operate incorrectly.
//2) The TS4231 library omits delays between E and D signal transitions when going
// from S3_STATE to WATCH_STATE or SLEEP_STATE to WATCH_STATE in function
// goToWatch() for the purpose of transitioning into WATCH_STATE as quickly as
// possible. If a microcontroller is being used that can change states on
// the E and D outputs faster than approximately 100ns, the TS4231 datasheet
// must be consulted to verify timing parameters are not being violated to
// assure proper TS4231 operation. A suitable solution would be to include
// a short delay in function ts_digitalWrite() to allow enough time between
// output pin signal changes to meet the TS4231 timing parameters as stated
// in the datasheet. See the ts_digitalWrite() function for more information.

TS4231::TS4231(int device_E_pin, int device_D_pin) {
configured = false;
Expand All @@ -39,6 +50,10 @@ uint8_t TS4231::ts_digitalRead(int pin) {

void TS4231::ts_digitalWrite(int pin, uint8_t write_val) {
digitalWrite(pin, write_val);
//A short delay function can be inserted here to extend the time between writes to
//the E and D outputs if TS4231 timing parameters are being violated. Consult
//the TS4231 datasheet for more information on timing parameters. It is recommended
//that any added delay be no longer than approximately 1us.
}

unsigned long TS4231::ts_millis() {
Expand Down

0 comments on commit 35c4b75

Please sign in to comment.