Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - lcpalm

Pages: 1
1
Hi,
I have a TinyZero circuit that works as expected when connected using Proto Terminal Blocks shield, or using an Arduino UNO.
But it does not work when connected in the same way with Wirelings....! I'm trying to use GND, 3v3, and INT wires, along with an external pull-up resistor to get analog voltage values off my sensor.

Does Wireling have some internal processing that prohibits using this analog input in this way? can I turn that off? or am I doing something wrong?

My code:
Code: [Select]
//TerminalBlocksVsWireling
// 2022-09-15

#include <Wire.h>
#include <Wireling.h>

// boilerplate code to make serial monitor work with either arduino uno or tinycircuit's tinyzero
#if defined (ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB
#endif

#define irdPin A0        // Corresponds to PORT# of Wireling used; or A0 of TerminalBlocks or Arduino UNO
int readValue = 0;       // the IR sensor value, analog

void setup() {
  SerialMonitorInterface.begin(9600);

  // Start with a 3s delay, lighting external green LED for 3s.
  pinMode(LED_BUILTIN, OUTPUT);     
  digitalWrite(LED_BUILTIN, HIGH);   
  delay(3000);                     
  digitalWrite(LED_BUILTIN, LOW);   

  SerialMonitorInterface.println("");
  SerialMonitorInterface.println("TerminalBlocksVsWireling");

  pinMode(irdPin, INPUT);

}

void loop() {
  readValue = analogRead(irdPin);

  SerialMonitorInterface.print("IRD pin read value: ");
  SerialMonitorInterface.println(readValue);

  delay(500);

}

I took a Wireling cable and stripped the ends of the GND, 3V3, and INT (analog) and soldered them to wires to plug into a breadboard for testing.

On TerminalBlocks: I connect GND, VCC, and A0 to my protoboard.
On Wireling: I connect GND, 3V3, and INT from port 0 to my protoboard (equivalent).

The board has a couple of diodes and resistors as follows:
1. IR-Emitter diode with external current-limiting resistor: Just emits IR light:
VCC --------- 220ohmResist -------(+)anode_IRE_cathode(-)--------- GND


2. IR-Detector diode with external pullup resistor, connected to A0 between the resistor and the IRD:

VCC -----10kResist ---/-----(+)anode_IRD_cathode(-)------------------GND
                                 /
                              A0

So,
When IRD is active (detects IR light), voltage on analog input A0 should be low voltage,
 When IRD is inactive (detects no IR light), voltage on A0 should be a higher voltage.

Results:
Works perfectly with TerminalBlocks shield on TinyZero, or with Arduino UNO:
 Low ~53            when IRD gets IR light
High ~700-800  when IR light blocked (using UNO 3.3V, High is ~500; that's fine)

But with Wireling shield, same connections: Not working!
Output is  ~1 or 2, or 3   when IRD gets IR light
and is also  ~1 or 2, or 3   when IR light blocked

I know that I can set an *internal* pull-up resistor on the analog input A0, but we don't want this -- we want to get an analog voltage value.
I found this earlier forum post about analog wireling use but it did not help here.  http://forum.tinycircuits.com/index.php?topic=2419.msg5307#msg5307

Datasheets for the  IRE and IRD diodes: https://www.sparkfun.com/products/retired/241

Thank you for any help!!

2
Hello,
The Wireling IR Emitter and IR Detector Example scripts come as two separate scripts; I've tried to combine them into one, by putting the Receiver code into a function,
and calling it after the Emitter sends in the main loop.
But it looks like it never reads the sent IR-code, ie  if (irrecv.decode(&results))  is never true... Not sure what I am doing wrong, can you help?
thank you!!!

 /************************************************************************
   IR Emitter Wireling Example
   IR Receiver Wireling Example
   Copied from: https://learn.tinycircuits.com/Wirelings/IR-Emitter_Wireling_Tutorial/
               https://learn.tinycircuits.com/Wirelings/IR-Receiver_Wireling_Tutorial/
/// Combined to transmit and receive on same device 5/13/2022 - Never reads?
 ************************************************************************/

#include <IRremote.h>
#include <Wire.h>
#include <Wireling.h>

#if defined (ARDUINO_ARCH_AVR)
#define SerialMonitorInterface Serial
#elif defined(ARDUINO_ARCH_SAMD)
#define SerialMonitorInterface SerialUSB
#endif

// Define codes as 32 bit unsigned integers [///Edit: fewer codes, for simplicity]
uint32_t powerCode = 0x10AF8877;
uint32_t muteCode = 0x10AFF00F;

// Receive and transmit can be done on any IO pin. Pick A0-A3 for Wireling ports 0-3.
int TX_PIN = A0;
int RECV_PIN = A3; /// added from WirelingIRReceiverExample

IRsend irsend(TX_PIN);
IRrecv irrecv(RECV_PIN);

void setup(void) {
  SerialMonitorInterface.begin(9600);
  Wire.begin();
  Wireling.begin();
  while (!SerialMonitorInterface && millis() < 5000); //This will block for 5 seconds or until the Serial Monitor is opened on TinyScreen+/TinyZero platform!

  irrecv.enableIRIn(); // Start receiving data  /// added from WirelingIRReceiverExample
}

void loop() {
  SerialMonitorInterface.println("Sending powerCode!");
  noInterrupts();                                               /// [from example code; I don't know what the interrupt code does]
  irsend.sendNEC(powerCode, 32);
  /// try adding receive code here ///
  receiverExampleCode();
  ///
  interrupts();                                                    /// [from example code; I don't know what the interrupt code does]
  /// try adding receive code here ///
  receiverExampleCode();
  ///
  delay(1000);
  SerialMonitorInterface.println("Sending muteCode!");
  noInterrupts();
  irsend.sendNEC(muteCode, 32);
  /// try adding receive code here ///
  receiverExampleCode();
  ///
  interrupts();
  /// try adding receive code here ///
  receiverExampleCode();
  ///
  delay(1000);
}

/// void loop() {} from WirelingIRReceiverExample code put into below function:
void receiverExampleCode() {
  /// add println
  SerialMonitorInterface.println("into Receiver function");
  decode_results results;
  if (irrecv.decode(&results)) {
    irrecv.resume(); // Receive the next value
    if (results.decode_type = NEC && results.bits == 32) { //Check if there's a match for our expected protocol and bitcount
      if (results.value == powerCode) {
        SerialMonitorInterface.println("powerCode received!");
      } else if (results.value == muteCode) {
        SerialMonitorInterface.println("muteCode received!");
      } else {
        SerialMonitorInterface.print("Unrecognized code! ");
        SerialMonitorInterface.println(results.value, HEX);
      }
    } else {
      SerialMonitorInterface.print(results.decode_type);
      SerialMonitorInterface.print(" ");
      SerialMonitorInterface.print(results.bits);
      SerialMonitorInterface.print(" ");
      SerialMonitorInterface.println(results.value, HEX);
    }
  }
}


3
Hi TinyCircuits,

Question: Is it possible to use the Wireling IR-Emitter and Wireling IR-Receiver to detect simple beam breaks using a TinyZero?

I'm trying to convert a circuit I built using a TinyZero, to Wirelings. This had used a simple non-wireling IR-emitter LED and IR-detector pair  (https://www.sparkfun.com/products/retired/241), soldered in to a tiny shield with appropriate resistors; the IRD required a 10kOhm  pull-up resistor. (It reports a beam break when you block a porthole with an IR illuminator-detector pair on either side, at a sample rate of about 20ms, and writes to microSD.)

I was able to get this working with the same resistors by cutting a Wireling cable and soldering the old IR-emitter and detector up with their same appropriate resistors inline (including the 10k Ohm pullup for the IRD and a 220ohm resistor for the IRE) to the Wireling cable. This uses the Wireling library, but doesn't use the IRremote library.

But it would be much nicer to use the actual Wireling IR Emitter and Wireling IR Receiver and avoid the need to solder in resistors!

I've gotten the Wireling IRE and IRD to send and receive "IR codes" from your tutorial examples on my TinyZero (although the interrupts were a bit of a mystery),  but can't seem to get the IRD to recognize the mere presence or absence of a signal from the IRE  - and am not even sure if have managed to send the signal in that mode.

 I'm attempting to adapt this code :
http://www.righto.com/2010/03/detecting-ir-beam-break-with-arduino-ir.html

One problem : The Wireling IRD TSOP572 datasheet says it suppresses "Continuous signals at any frequency", which that page says will prevent the code from working -- There's some workarounds for this in some comments on that page but I have not been able to get them to work. I don't have a good enough understanding of how the IRremote library and Wirelings work together to adapt them to get the IR-emitter to simply send a continuous signal and the IR-detector to simply detect its presence or absence.

I'd be grateful for any suggestions!

(edit: had another question about pull-up resistor use, posted that separately).



4
Hi,
I'm having trouble and not sure why: Have a circuit set up with a sensor attached to A0, and it reads fine; but if I attach the sensor to A5, it does not report the input.

Here is my code:

---------------------------------

#include <SPI.h>

int readValue1 = 0;
int readValue2 = 0;

// setup for TinyZero
#if defined(ARDUINO_ARCH_SAMD)
  #define SerialInterface SerialUSB
#else
  #define SerialInterface Serial
#endif

void setup() {
  SerialInterface.begin(9600);
  delay(3000);

}

void loop() {

  String dataString = "";

  readValue1 = analogRead(A0);
  readValue2 = analogRead(A5);

  dataString += String(readValue1);
  dataString += ",";
  dataString += String(readValue2);

  SerialInterface.println(dataString);

  delay(1000);

}

----------------------

My circuit is:
 VCC ---> 220ohm ---> IR-emitter ---> GND
VCC ---> 10k ohm ---> A0 [or A5]
                                |--> IR-detector ---> GND

This works as expected when connected to A0: it reports low values when there is IR light striking the IR-detector, and reports high values when the light is blocked. That is, in serial monitor, we get sensor value in A0, and nothing meaningful in A5, as expected:
A0, A5
42,332
43,370
43,367
43,357
361,382 <-- when light blocked
349,373 <-- blocked
340,354 <-- blocked

But when connected to A5, it doesn't report sensor value in A5:
A0, A5
361,382
349,373
340,354
321,372
305,368
that is, here the second column should be low; but it never is.

I'm not sure what is wrong here?

Thank you!

5
Hello,

I have a TinyZero project and would like to attach an external power switch (have wires running to a power switch attached on the enclosure of my project).  I bought a little switch, but am not sure how to wire it up to the TinyZero, or if this is even possible?

Thank you!

6
TinyDuino Processors & TinyShields / Tinyzero won't run off battery?
« on: March 23, 2021, 06:11:44 PM »
Hi, I have a TinyZero circuit built, which runs fine off USB but won't seem to run off battery power.

The battery charges (amber light), but when the USB is removed the system doesn't seem to turn on. It's the 3.7V 150mA Li-Ion battery from TinyCircuits.

The circuit is: TinyZero hooked up to micro SD shield and to protoboard leading to an IR sensor pair, which logs beam-breaks.  It works as expected under USB, incrementing the file name on startup (ie every time it's turned on with the power switch on the TinyZero, or the USB is re-plugged in, it starts a new data log on the SD.) But on removing the USB and trying to run off battery power alone, it doesn't turn on and doesn't write any files.

Not sure how to troubleshoot this.... am new to TinyDuino. Thanks in advance for any help!







Pages: 1
SMF spam blocked by CleanTalk