Author Topic: Any way to share pins 3&4 with digiusb?  (Read 4215 times)

martyn_w

  • Newbie
  • *
  • Posts: 5
Any way to share pins 3&4 with digiusb?
« on: December 08, 2013, 12:42:08 pm »
I'm a digispark newbie but I have a digispark happily sending data via a RF24L01+ radio module to an Arduino.  The RF24L01 needs 5 pins so I simply used pins 0-4.
I did initially have a problem and remarkably was able to use digiusb to send debug info back to to my windows 7 machine and see it using digiusb.exe.
It was rather hit and miss, but I soon twigged that the radio module and digiusb were both using pins 3 & 4.

My aim is to send (Kinect-derived) data from my windows machine through digiusb and over the radio, but I am one pin short on the digispark.

As I partially got away with debugging with digiusb, I was wondering if there was some relatively easy way to time-share pins 3 & 4.  I only need use the radio if I have data from digiusb, so perhaps at that point I could disable digiusb, handle the radio and when done, disable the radio and re-enable digiusb waiting for the next data.

Does anyone have any idea if/how I might do this with digiusb please?

Thanks,
Martyn.

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: Any way to share pins 3&4 with digiusb?
« Reply #1 on: December 11, 2013, 01:48:24 pm »
You'd have to simulate a disconnect for this to work, so after each transmission you'd need to reenumerate the device which on windows can take as long as 2 seconds from memory, and then your program would need to scan the usb bus until the digispark came back online.

Really you'd be better using a teensy, arduino uno, or the fancy digispark with more pins that hasn't been properly announced yet and wont be available for a while.

martyn_w

  • Newbie
  • *
  • Posts: 5
Re: Any way to share pins 3&4 with digiusb?
« Reply #2 on: December 12, 2013, 01:00:04 pm »
Thanks for the reply Bluebie. Yes, I did try simulating a disconnect, but it didn't seem to work first time and I didn't persist as another problem is that Windows gets a bit confused by the chatter to the RF24 when the usb is supposedly disconnected (moans every time theres a transmission about an unknown usb device) .

But I'm not giving up so easily on my first digispark project.  If I need more pins then why not add a second digispark with a stackable header? I could stack the 5v & GND pins and my one spare pin 5.  Then the bottom spark could do the usb stuff on its p3 & 4 and forward data to (& maybe from?) the top spark.  Also pick up the power from its usb and pass it to the top spark (with its usb disconnected or even trimmed).

Even with two sparks it would still be a pleasingly small form factor and relatively cheap.  Or can you see a gotcha to my plan B? I haven't quite worked out how to use pin 5 for this yet mind!

Thanks,
Martyn.

Bluebie

  • Sr. Member
  • ****
  • Posts: 486
Re: Any way to share pins 3&4 with digiusb?
« Reply #3 on: December 14, 2013, 12:48:44 am »
That seems overly complicated. Why not use a teensy?

martyn_w

  • Newbie
  • *
  • Posts: 5
Re: Any way to share pins 3&4 with digiusb?
« Reply #4 on: December 14, 2013, 07:33:11 am »
Hehe, fair comment.  But I have the RF24 and bits all soldered up and working on a proto shield with spark, plus a spare spark and no teensy - so its no turning back now I think.