WHAT?!! Circuit Playground Library & Crickit Seesaw library don't work together!!!

Play with it! Please tell us which board you're using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
OdorDecoder
 
Posts: 16
Joined: Sat Mar 19, 2016 11:32 pm

WHAT?!! Circuit Playground Library & Crickit Seesaw library don't work together!!!

Post by OdorDecoder »

I've been writing in Arduino/C++ code for the Circuit Playground Express (CPE) that is attached to an Adafruit Crickit board meant for it. I am more familiar with Arduino code than Circuitpython, and want to use many of the CPE features as well as the Crickit motor drivers. I am attempting to build a 2 wheel rover that can use the CPE's infrared (IR) transceiver to interact with an Adafruit IR remote control (part number 389).
I have figured out why my code stopped working, and tried my theory on an off-the-shelf program example. It also stopped working.
Here's the code that works only if you "un-comment out" line 18, the line with "//CircuitPlayground.begin();"
Below is a copy of the Adafruit_seesaw_Library/Examples/Crickit/motor/dual_motor.ino that has two extra lines:
#include <Adafruit_CircuitPlayground.h>
CircuitPlayground.begin(); //in void setup()

Code: Select all

#include "Adafruit_Crickit.h"
#include "seesaw_motor.h"
#include <Adafruit_CircuitPlayground.h>
Adafruit_Crickit crickit;

seesaw_Motor motor_a(&crickit);
seesaw_Motor motor_b(&crickit);

void setup() {
  Serial.begin(115200);
  Serial.println("Dual motor demo!");
  
  if(!crickit.begin()){
    Serial.println("ERROR!");
    while(1) delay(1);
  }
  else Serial.println("Crickit started");
  //CircuitPlayground.begin();
  //attach motor a
  motor_a.attach(CRICKIT_MOTOR_A1, CRICKIT_MOTOR_A2);

  //attach motor b
  motor_b.attach(CRICKIT_MOTOR_B1, CRICKIT_MOTOR_B2);
}

void loop() {
  motor_a.throttle(1);
  motor_b.throttle(-1);
  delay(1000);

  motor_a.throttle(.5);
  motor_b.throttle(-.5);
  delay(1000);

  motor_a.throttle(0);
  motor_b.throttle(0);
  delay(1000);

  motor_a.throttle(-.5);
  motor_b.throttle(.5);
  delay(1000);

  motor_a.throttle(-1);
  motor_b.throttle(1);
  delay(1000);

  motor_a.throttle(0);
  motor_b.throttle(0);
  delay(500);
}
I have a rover, with a Crickit for Circuit Playground Express with TT DC motors that have speed encoders attached (aka T-slot photo interrupters, Ada part# 3985). I want it to move straight and know its speed and distance, hence why I'm using the encoder reader. I'd like to keep that capability. The code I wrote uses interrupts to report and adjust the speed. It works, until I "begin" the Circuit Playground library. I also want to use the CPE's IR transceiver for controlling the rover. Maybe I also want to use the light sensor and sound sensor and also use Neopixels and a speaker on the Crickit.

What should I do to make this work? I can include my code, but this code displayed here clarifies that it's not my code that is the problem, it's the incompatible libraries, Crickit and Playground, which is hard to believe - given that Crickit is meant to work with Playground.

Thanks for your help!

User avatar
dastels
 
Posts: 15667
Joined: Tue Oct 20, 2015 3:22 pm

Re: WHAT?!! Circuit Playground Library & Crickit Seesaw library don't work together!!!

Post by dastels »

So if you remove the comment so as to have CircuitPlayground.begin() execute, it freezes/crashes/fails. Is it that line that it fails at, or does it get past it?

Are all the board support packages and libraries up to date?

Dave

User avatar
OdorDecoder
 
Posts: 16
Joined: Sat Mar 19, 2016 11:32 pm

Re: WHAT?!! Circuit Playground Library & Crickit Seesaw library don't work together!!!

Post by OdorDecoder »

Here is the output:
Dual motor demo!
Crickit started
in the loop 1

And here's the code, now with debugging prints and a delay on Serial starting.

Code: Select all

#include "Adafruit_Crickit.h"
#include "seesaw_motor.h"
#include <Adafruit_CircuitPlayground.h>
Adafruit_Crickit crickit;

seesaw_Motor motor_a(&crickit);
seesaw_Motor motor_b(&crickit);

void setup() {
  Serial.begin(115200);
  while (!Serial) delay(10);
  Serial.println("Dual motor demo!");
  
  if(!crickit.begin()){
    Serial.println("ERROR!");
    while(1) delay(1);
  }
  else Serial.println("Crickit started");
  CircuitPlayground.begin();
  //attach motor a
  motor_a.attach(CRICKIT_MOTOR_A1, CRICKIT_MOTOR_A2);

  //attach motor b
  motor_b.attach(CRICKIT_MOTOR_B1, CRICKIT_MOTOR_B2);
}

void loop() {
  Serial.println("in the loop 1");
  motor_a.throttle(1);
  Serial.println("in the loop 2");
  motor_b.throttle(-1);
  Serial.println("in the loop 3");
  delay(1000);

  motor_a.throttle(.5);
  motor_b.throttle(-.5);
  delay(1000);

  motor_a.throttle(0);
  motor_b.throttle(0);
  delay(1000);

  motor_a.throttle(-.5);
  motor_b.throttle(.5);
  delay(1000);

  motor_a.throttle(-1);
  motor_b.throttle(1);
  delay(1000);

  motor_a.throttle(0);
  motor_b.throttle(0);
  delay(500);
}[/color]
It stop executing at the first
motor_a.throttle(1)
The seesaw library on the Crickit is updated (2019 was the last update, see link to .UF2 here https://learn.adafruit.com/adafruit-cri ... ur-crickit
The CPE is using Seesaw library 1.6.2, and the circuit playground library 1.11.4, Arduino IDE 1.8.19
Here are all the warnings when compiling:
In file included from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibHardware.h:83,
from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibHardware.cpp:33:
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:71: warning: "IR_SEND_PWM_PIN" redefined
71 | #define IR_SEND_PWM_PIN 25
|
In file included from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibHardware.h:83,
from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.cpp:14:
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:71: warning: "IR_SEND_PWM_PIN" redefined
71 | #define IR_SEND_PWM_PIN 25
|
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:67: note: this is the location of the previous definition
67 | #define IR_SEND_PWM_PIN 12
|
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:234: warning: "IR_CLEAR_INTERRUPT" redefined
234 | #define IR_CLEAR_INTERRUPT IR_TCx->COUNT16.INTFLAG.bit.MC0 = 1;
|
In file included from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.cpp:14:
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibHardware.h:24: note: this is the location of the previous definition
24 | #define IR_CLEAR_INTERRUPT {} //clear interrupt flag
|
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:67: note: this is the location of the previous definition
67 | #define IR_SEND_PWM_PIN 12
|
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:234: warning: "IR_CLEAR_INTERRUPT" redefined
234 | #define IR_CLEAR_INTERRUPT IR_TCx->COUNT16.INTFLAG.bit.MC0 = 1;
|
In file included from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibHardware.cpp:33:
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibHardware.h:24: note: this is the location of the previous definition
24 | #define IR_CLEAR_INTERRUPT {} //clear interrupt flag
|
In file included from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibHardware.h:83,
from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibDecodeBase.cpp:14:
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:71: warning: "IR_SEND_PWM_PIN" redefined
71 | #define IR_SEND_PWM_PIN 25
|
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:67: note: this is the location of the previous definition
67 | #define IR_SEND_PWM_PIN 12
|
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:234: warning: "IR_CLEAR_INTERRUPT" redefined
234 | #define IR_CLEAR_INTERRUPT IR_TCx->COUNT16.INTFLAG.bit.MC0 = 1;
|
In file included from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibDecodeBase.cpp:14:
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibHardware.h:24: note: this is the location of the previous definition
24 | #define IR_CLEAR_INTERRUPT {} //clear interrupt flag
|
In file included from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibHardware.h:83,
from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSendBase.cpp:17:
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:71: warning: "IR_SEND_PWM_PIN" redefined
71 | #define IR_SEND_PWM_PIN 25
|
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:67: note: this is the location of the previous definition
67 | #define IR_SEND_PWM_PIN 12
|
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:234: warning: "IR_CLEAR_INTERRUPT" redefined
234 | #define IR_CLEAR_INTERRUPT IR_TCx->COUNT16.INTFLAG.bit.MC0 = 1;
|
In file included from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSendBase.cpp:17:
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibHardware.h:24: note: this is the location of the previous definition
24 | #define IR_CLEAR_INTERRUPT {} //clear interrupt flag
|
In file included from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibHardware.h:83,
from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibRecvBase.cpp:21:
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:71: warning: "IR_SEND_PWM_PIN" redefined
71 | #define IR_SEND_PWM_PIN 25
|
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:67: note: this is the location of the previous definition
67 | #define IR_SEND_PWM_PIN 12
|
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:234: warning: "IR_CLEAR_INTERRUPT" redefined
234 | #define IR_CLEAR_INTERRUPT IR_TCx->COUNT16.INTFLAG.bit.MC0 = 1;
|
In file included from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibRecvBase.cpp:21:
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibHardware.h:24: note: this is the location of the previous definition
24 | #define IR_CLEAR_INTERRUPT {} //clear interrupt flag
|
In file included from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibHardware.h:83,
from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibRecvPCI.cpp:19:
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:71: warning: "IR_SEND_PWM_PIN" redefined
71 | #define IR_SEND_PWM_PIN 25
|
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:67: note: this is the location of the previous definition
67 | #define IR_SEND_PWM_PIN 12
|
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibSAMD21.h:234: warning: "IR_CLEAR_INTERRUPT" redefined
234 | #define IR_CLEAR_INTERRUPT IR_TCx->COUNT16.INTFLAG.bit.MC0 = 1;
|
In file included from ~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibRecvPCI.cpp:19:
~/Arduino/Sketchbook/libraries/Adafruit_Circuit_Playground/utility/IRLibHardware.h:24: note: this is the location of the previous definition
24 | #define IR_CLEAR_INTERRUPT {} //clear interrupt flag

|

User avatar
dastels
 
Posts: 15667
Joined: Tue Oct 20, 2015 3:22 pm

Re: WHAT?!! Circuit Playground Library & Crickit Seesaw library don't work together!!!

Post by dastels »

I've asked to see if anyone has information on this.

Dave

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: WHAT?!! Circuit Playground Library & Crickit Seesaw library don't work together!!!

Post by adafruit_support_carter »

Try calling

Code: Select all

CircuitPlayground.begin();
before calling

Code: Select all

crickit.begin();
The cap touch initialization done (for CPX) on the pins in CircuitPlayground.begin(); is probably breaking the use of I2C on the SCL/SDA pins. So they were initially working for the call to crickit.begin();, but then after calling CircuitPlayground.begin();, they get reconfigured to cap touch, which causes subsequent I2C comms to hang.

Cap touch init lines for ref:
https://github.com/adafruit/Adafruit_Ci ... pp#L93-L98

User avatar
OdorDecoder
 
Posts: 16
Joined: Sat Mar 19, 2016 11:32 pm

Re: WHAT?!! Circuit Playground Library & Crickit Seesaw library don't work together!!!

Post by OdorDecoder »

Carter,
your suggestion worked! Thanks for the explanation.
Much appreciated!

Locked
Please be positive and constructive with your questions and comments.

Return to “Circuit Playground Classic, Circuit Playground Express, Circuit Playground Bluefruit”