Can Teensy 3.0 replace Teensy 2.0 for this Project?

Status
Not open for further replies.

wal

New member
Hi,

I attached a schematic image of a project here. I hope you can see it. It involves two led boards connected to a Teensy 2.0. I want to reproduce this project using the Teensy 3.0.

Would the Teensy 3.0 be compatible enough to replace the Teensy 2.0 for this project? Thank you. :confused::)
 

Attachments

  • LED Matrix Canvas Schematic.png
    LED Matrix Canvas Schematic.png
    13.9 KB · Views: 199
I can see your schematic, but it does not indicate the type of LEDs nor the resistors or other current limiting circuitry.

If the LEDs are red, green, orange or yellow (the types that are well under 3.3 volts), you can probably drive them with Teensy 3.0, but you will need to reduce the resistors. Of course, that's assuming you're using resistors instead of some other type of current limiting.

Can you understand how this lack of information makes it impossible to give you good advice?
 
I looked at this project in some detail, but only briefly, so I can't promise this opinion covers every detail.

It would take some significant work to make this project run with Teensy 3.0. It's not impossible, but you'll almost certainly have to edit the code. It was designed with the avr-gcc compiler running from a Makefile, not Arduino, so it will not build as-is for Teensy 3.0 which uses ARM instead of AVR.

However, the code is pretty straightforward. For example, nearly all the hardware access uses only these 2 functions:

Code:
/*
 * CLK goes low and data is set. CLK goes high and data is tx-ed.
 * MSB is transferred first. Goes from MSB -> LSB
 */
void ht1632_writebits(byte bits, byte firstbit)
{
  while (firstbit)
  {
    PIN_SET_LOW( WR_PORT, WR_PIN );
    if (bits & firstbit) {
      PIN_SET_HIGH( DAT_PORT, DAT_PIN );
    }
    else {
      PIN_SET_LOW( DAT_PORT, DAT_PIN );
    }
    PIN_SET_HIGH( WR_PORT, WR_PIN );
    firstbit >>= 1;
  }
}

/*
 * CLK goes low and data is set. CLK goes high and data is tx-ed.
 * MSB is transferred first. Goes from MSB -> LSB
 * Read 4 bit nybbles from chip. May be called repeatedly for
 * multiple sequential addresses.
 */
byte ht1632_readbits()
{
  byte bitIndex;
  byte retval = 0;
  PIN_MODE(DAT_REG, DAT_PIN, INPUT); // input mode
  for (bitIndex=4; bitIndex>=1; bitIndex--)
  {
    PIN_SET_LOW( RD_PORT, RD_PIN );
    PIN_SET_HIGH( RD_PORT, RD_PIN );
    if (PIN_GET( DAT_PORT_RD, DAT_PIN ) & 0xff)
      retval |= (1<<(bitIndex-1));
  }
  PIN_MODE(DAT_REG, DAT_PIN, OUTPUT); // back to output
  return retval;
}

You could probably bring this code into Arduino and replace those PIN_SET_LOW() with digitalWrite(pin, LOW) or digitalWriteFast(pin, LOW), and likewise for the other macros. The code does not appear to use any of the AVR peripherals directly, so odds are good most of the other code will compile and probably work with little or no modification.

It is based on the older usb_serial.c code I published years ago. Teensy 3.0 tries to provide these functions in Arduino, but how well older code can simply be dropped into Arduino and run on Teensy 3.0 is not well tested. It might work, but odds are you will need to edit some places. There are about 14lines in that project which call the usb functions, all in ledmatric_term.c. You might need to replace things like usb_serial_getchar() with Serial.read() if the code doesn't work as-is.

If you simply want to duplicate that project with minimal effort, using Teensy 2.0 is definitely the best choice.
 
Status
Not open for further replies.
Back
Top